Changeset 6335
- Timestamp:
- 09/15/07 16:35:33 (1 year ago)
- Files:
-
- django/branches/queryset-refactor/AUTHORS (modified) (1 diff)
- django/branches/queryset-refactor/django/contrib/admin/media/css/null.css (copied) (copied from django/trunk/django/contrib/admin/media/css/null.css)
- django/branches/queryset-refactor/django/core/management/sql.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/db/backends/creation.py (copied) (copied from django/trunk/django/db/backends/creation.py)
- django/branches/queryset-refactor/django/db/backends/__init__.py (modified) (1 diff)
- django/branches/queryset-refactor/django/db/backends/oracle/base.py (modified) (1 diff)
- django/branches/queryset-refactor/django/db/models/fields/__init__.py (modified) (2 diffs)
- django/branches/queryset-refactor/django/db/models/options.py (modified) (1 diff)
- django/branches/queryset-refactor/django/test/_doctest.py (modified) (2 diffs)
- django/branches/queryset-refactor/docs/newforms.txt (modified) (1 diff)
- django/branches/queryset-refactor/docs/settings.txt (modified) (7 diffs)
- django/branches/queryset-refactor/tests/regressiontests/model_regress/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/queryset-refactor/AUTHORS
r6334 r6335 279 279 thebjorn <bp@datakortet.no> 280 280 Zach Thompson <zthompson47@gmail.com> 281 Deepak Thukral <deep.thukral@gmail.com> 281 282 tibimicu@gmax.net 282 283 tobias@neuyork.de django/branches/queryset-refactor/django/core/management/sql.py
r6013 r6335 303 303 if opts.has_auto_field: 304 304 # Add any extra SQL needed to support auto-incrementing primary keys. 305 autoinc_sql = connection.ops.autoinc_sql(opts.db_table) 305 auto_column = opts.auto_field.db_column or opts.auto_field.name 306 autoinc_sql = connection.ops.autoinc_sql(opts.db_table, auto_column) 306 307 if autoinc_sql: 307 308 for stmt in autoinc_sql: … … 386 387 387 388 # Add any extra SQL needed to support auto-incrementing PKs 388 autoinc_sql = connection.ops.autoinc_sql(f.m2m_db_table() )389 autoinc_sql = connection.ops.autoinc_sql(f.m2m_db_table(), 'id') 389 390 if autoinc_sql: 390 391 for stmt in autoinc_sql: django/branches/queryset-refactor/django/db/backends/__init__.py
r5978 r6335 57 57 row. 58 58 """ 59 def autoinc_sql(self, table ):59 def autoinc_sql(self, table, column): 60 60 """ 61 61 Returns any SQL needed to support auto-incrementing primary keys, or django/branches/queryset-refactor/django/db/backends/oracle/base.py
r5992 r6335 32 32 33 33 class DatabaseOperations(BaseDatabaseOperations): 34 def autoinc_sql(self, table ):34 def autoinc_sql(self, table, column): 35 35 # To simulate auto-incrementing primary keys in Oracle, we have to 36 36 # create a sequence and a trigger. 37 37 sq_name = get_sequence_name(table) 38 38 tr_name = get_trigger_name(table) 39 tbl_name = self.quote_name(table) 40 col_name = self.quote_name(column) 39 41 sequence_sql = 'CREATE SEQUENCE %s;' % sq_name 40 42 trigger_sql = """ 41 CREATE OR REPLACE TRIGGER % s42 BEFORE INSERT ON % s43 CREATE OR REPLACE TRIGGER %(tr_name)s 44 BEFORE INSERT ON %(tbl_name)s 43 45 FOR EACH ROW 44 WHEN (new. idIS NULL)46 WHEN (new.%(col_name)s IS NULL) 45 47 BEGIN 46 SELECT %s.nextval INTO :new.id FROM dual; 47 END;/""" % (tr_name, self.quote_name(table), sq_name) 48 SELECT %(sq_name)s.nextval 49 INTO :new.%(col_name)s FROM dual; 50 END;/""" % locals() 48 51 return sequence_sql, trigger_sql 49 52 django/branches/queryset-refactor/django/db/models/fields/__init__.py
r6332 r6335 441 441 super(AutoField, self).contribute_to_class(cls, name) 442 442 cls._meta.has_auto_field = True 443 cls._meta.auto_field = self 443 444 444 445 def formfield(self, **kwargs): … … 546 547 # Casts dates into string format for entry into database. 547 548 if value is not None: 548 value = value.strftime('%Y-%m-%d') 549 try: 550 value = value.strftime('%Y-%m-%d') 551 except AttributeError: 552 # If value is already a string it won't have a strftime method, 553 # so we'll just let it pass through. 554 pass 549 555 return Field.get_db_prep_save(self, value) 550 556 django/branches/queryset-refactor/django/db/models/options.py
r5960 r6335 34 34 self.meta = meta 35 35 self.pk = None 36 self.has_auto_field = False36 self.has_auto_field, self.auto_field = False, None 37 37 self.one_to_one_field = None 38 38 self.parents = [] django/branches/queryset-refactor/django/test/_doctest.py
r5391 r6335 1 1 # This is a slightly modified version of the doctest.py that shipped with Python 2.4 2 # It incorporates changes that have been submitted the the Python ticket tracker 2 # It incorporates changes that have been submitted the the Python ticket tracker 3 3 # as ticket #1521051. These changes allow for a DoctestRunner and Doctest base 4 4 # class to be specified when constructing a DoctestSuite. … … 106 106 from StringIO import StringIO 107 107 108 if sys.platform.startswith('java'): 109 # On Jython, isclass() reports some modules as classes. Patch it. 110 def patch_isclass(isclass): 111 def patched_isclass(obj): 112 return isclass(obj) and hasattr(obj, '__module__') 113 return patched_isclass 114 inspect.isclass = patch_isclass(inspect.isclass) 115 108 116 # Don't whine about the deprecated is_private function in this 109 117 # module's tests. django/branches/queryset-refactor/docs/newforms.txt
r6332 r6335 986 986 987 987 The ``widget`` argument lets you specify a ``Widget`` class to use when 988 rendering this ``Field``. See "Widgets"_ below for more information.988 rendering this ``Field``. See `Widgets`_ below for more information. 989 989 990 990 ``help_text`` django/branches/queryset-refactor/docs/settings.txt
r6008 r6335 326 326 `allowed date format strings`_. 327 327 328 See also DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT. 328 See also ``DATETIME_FORMAT``, ``TIME_FORMAT``, ``YEAR_MONTH_FORMAT`` 329 and ``MONTH_DAY_FORMAT``. 329 330 330 331 .. _allowed date format strings: ../templates/#now … … 339 340 `allowed date format strings`_. 340 341 341 See also DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT. 342 See also ``DATE_FORMAT``, ``DATETIME_FORMAT``, ``TIME_FORMAT``, 343 ``YEAR_MONTH_FORMAT`` and ``MONTH_DAY_FORMAT``. 342 344 343 345 .. _allowed date format strings: ../templates/#now … … 351 353 352 354 If you define custom settings, django/views/debug.py has a ``HIDDEN_SETTINGS`` 353 regular expression which will hide from the DEBUG view anything that cont ins354 ``'SECRET ``, ``PASSWORD``, or ``PROFANITIES'``. This allows untrusted users to355 regular expression which will hide from the DEBUG view anything that contains 356 ``'SECRET'``, ``'PASSWORD'``, or ``'PROFANITIES'``. This allows untrusted users to 355 357 be able to give backtraces without seeing sensitive (or offensive) settings. 356 358 … … 657 659 "January 1," whereas Spanish might say "1 Enero." 658 660 659 See `allowed date format strings`_. See also DATE_FORMAT, DATETIME_FORMAT,660 TIME_FORMAT and YEAR_MONTH_FORMAT.661 See `allowed date format strings`_. See also ``DATE_FORMAT``, 662 ``DATETIME_FORMAT``, ``TIME_FORMAT`` and ``YEAR_MONTH_FORMAT``. 661 663 662 664 PREPEND_WWW … … 816 818 you'll want to set that to take advantage of this setting. 817 819 818 See also DEBUG.820 See also ``DEBUG``. 819 821 820 822 TEMPLATE_DIRS … … 906 908 `allowed date format strings`_. 907 909 908 See also DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and909 MONTH_DAY_FORMAT.910 See also ``DATE_FORMAT``, ``DATETIME_FORMAT``, ``TIME_FORMAT``, 911 ``YEAR_MONTH_FORMAT`` and ``MONTH_DAY_FORMAT``. 910 912 911 913 .. _allowed date format strings: ../templates/#now … … 981 983 "January 2006," whereas another locale might say "2006/January." 982 984 983 See `allowed date format strings`_. See also DATE_FORMAT, DATETIME_FORMAT,984 TIME_FORMAT and MONTH_DAY_FORMAT.985 See `allowed date format strings`_. See also ``DATE_FORMAT``, 986 ``DATETIME_FORMAT``, ``TIME_FORMAT`` and ``MONTH_DAY_FORMAT``. 985 987 986 988 .. _cache docs: ../cache/ django/branches/queryset-refactor/tests/regressiontests/model_regress/models.py
r5876 r6335 21 21 return self.headline 22 22 23 class Movie(models.Model): 24 #5218: Test models with non-default primary keys / AutoFields 25 movie_id = models.AutoField(primary_key=True) 26 name = models.CharField(max_length=60) 27 23 28 __test__ = {'API_TESTS': """ 24 29 (NOTE: Part of the regression test here is merely parsing the model
