Changeset 6354
- Timestamp:
- 09/16/07 05:04:26 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/tests/regressiontests/backends/models.py
r6242 r6354 1 1 from django.db import models 2 from django.db import connection 2 3 3 4 class Square(models.Model): … … 8 9 return "%s ** 2 == %s" % (self.root, self.square) 9 10 11 if connection.features.uses_case_insensitive_names: 12 t_convert = lambda x: x.upper() 13 else: 14 t_convert = lambda x: x 15 qn = connection.ops.quote_name 16 10 17 __test__ = {'API_TESTS': """ 11 18 … … 13 20 >>> from django.db import connection 14 21 >>> cursor = connection.cursor() 15 >>> cursor.executemany('INSERT INTO BACKENDS_SQUARE (ROOT, SQUARE) VALUES (%s, %s)', 16 ... [(i, i**2) for i in range(-5, 6)]) and None or None 22 >>> opts = Square._meta 23 >>> f1, f2 = opts.get_field('root'), opts.get_field('square') 24 >>> query = ('INSERT INTO %s (%s, %s) VALUES (%%s, %%s)' 25 ... % (t_convert(opts.db_table), qn(f1.column), qn(f2.column))) 26 >>> cursor.executemany(query, [(i, i**2) for i in range(-5, 6)]) and None or None 17 27 >>> Square.objects.order_by('root') 18 28 [<Square: -5 ** 2 == 25>, <Square: -4 ** 2 == 16>, <Square: -3 ** 2 == 9>, <Square: -2 ** 2 == 4>, <Square: -1 ** 2 == 1>, <Square: 0 ** 2 == 0>, <Square: 1 ** 2 == 1>, <Square: 2 ** 2 == 4>, <Square: 3 ** 2 == 9>, <Square: 4 ** 2 == 16>, <Square: 5 ** 2 == 25>] 19 29 20 30 #4765: executemany with params=[] does nothing 21 >>> cursor.executemany( 'INSERT INTO BACKENDS_SQUARE (ROOT, SQUARE) VALUES (%s, %s)', []) and None or None31 >>> cursor.executemany(query, []) and None or None 22 32 >>> Square.objects.count() 23 33 11
