Django

Code

Changeset 6335

Show
Ignore:
Timestamp:
09/15/07 16:35:33 (1 year ago)
Author:
adrian
Message:

queryset-refactor: Merged to [6197]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/queryset-refactor/AUTHORS

    r6334 r6335  
    279279    thebjorn <bp@datakortet.no> 
    280280    Zach Thompson <zthompson47@gmail.com> 
     281    Deepak Thukral <deep.thukral@gmail.com> 
    281282    tibimicu@gmax.net 
    282283    tobias@neuyork.de 
  • django/branches/queryset-refactor/django/core/management/sql.py

    r6013 r6335  
    303303    if opts.has_auto_field: 
    304304        # 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) 
    306307        if autoinc_sql: 
    307308            for stmt in autoinc_sql: 
     
    386387 
    387388            # 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'
    389390            if autoinc_sql: 
    390391                for stmt in autoinc_sql: 
  • django/branches/queryset-refactor/django/db/backends/__init__.py

    r5978 r6335  
    5757    row. 
    5858    """ 
    59     def autoinc_sql(self, table): 
     59    def autoinc_sql(self, table, column): 
    6060        """ 
    6161        Returns any SQL needed to support auto-incrementing primary keys, or 
  • django/branches/queryset-refactor/django/db/backends/oracle/base.py

    r5992 r6335  
    3232 
    3333class DatabaseOperations(BaseDatabaseOperations): 
    34     def autoinc_sql(self, table): 
     34    def autoinc_sql(self, table, column): 
    3535        # To simulate auto-incrementing primary keys in Oracle, we have to 
    3636        # create a sequence and a trigger. 
    3737        sq_name = get_sequence_name(table) 
    3838        tr_name = get_trigger_name(table) 
     39        tbl_name = self.quote_name(table) 
     40        col_name = self.quote_name(column) 
    3941        sequence_sql = 'CREATE SEQUENCE %s;' % sq_name 
    4042        trigger_sql = """ 
    41             CREATE OR REPLACE TRIGGER %
    42             BEFORE INSERT ON %
     43            CREATE OR REPLACE TRIGGER %(tr_name)
     44            BEFORE INSERT ON %(tbl_name)
    4345            FOR EACH ROW 
    44             WHEN (new.id IS NULL) 
     46            WHEN (new.%(col_name)s IS NULL) 
    4547                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() 
    4851        return sequence_sql, trigger_sql 
    4952 
  • django/branches/queryset-refactor/django/db/models/fields/__init__.py

    r6332 r6335  
    441441        super(AutoField, self).contribute_to_class(cls, name) 
    442442        cls._meta.has_auto_field = True 
     443        cls._meta.auto_field = self 
    443444 
    444445    def formfield(self, **kwargs): 
     
    546547        # Casts dates into string format for entry into database. 
    547548        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 
    549555        return Field.get_db_prep_save(self, value) 
    550556 
  • django/branches/queryset-refactor/django/db/models/options.py

    r5960 r6335  
    3434        self.meta = meta 
    3535        self.pk = None 
    36         self.has_auto_field = Fals
     36        self.has_auto_field, self.auto_field = False, Non
    3737        self.one_to_one_field = None 
    3838        self.parents = [] 
  • django/branches/queryset-refactor/django/test/_doctest.py

    r5391 r6335  
    11# 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 
    33# as ticket #1521051. These changes allow for a DoctestRunner and Doctest base 
    44# class to be specified when constructing a DoctestSuite. 
     
    106106from StringIO import StringIO 
    107107 
     108if 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 
    108116# Don't whine about the deprecated is_private function in this 
    109117# module's tests. 
  • django/branches/queryset-refactor/docs/newforms.txt

    r6332 r6335  
    986986 
    987987The ``widget`` argument lets you specify a ``Widget`` class to use when 
    988 rendering this ``Field``. See "Widgets"_ below for more information. 
     988rendering this ``Field``. See `Widgets`_ below for more information. 
    989989 
    990990``help_text`` 
  • django/branches/queryset-refactor/docs/settings.txt

    r6008 r6335  
    326326`allowed date format strings`_. 
    327327 
    328 See also DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT. 
     328See also ``DATETIME_FORMAT``, ``TIME_FORMAT``, ``YEAR_MONTH_FORMAT`` 
     329and ``MONTH_DAY_FORMAT``. 
    329330 
    330331.. _allowed date format strings: ../templates/#now 
     
    339340`allowed date format strings`_. 
    340341 
    341 See also DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT. 
     342See also ``DATE_FORMAT``, ``DATETIME_FORMAT``, ``TIME_FORMAT``, 
     343``YEAR_MONTH_FORMAT`` and ``MONTH_DAY_FORMAT``. 
    342344 
    343345.. _allowed date format strings: ../templates/#now 
     
    351353 
    352354If you define custom settings, django/views/debug.py has a ``HIDDEN_SETTINGS`` 
    353 regular expression which will hide from the DEBUG view anything that contins 
    354 ``'SECRET``, ``PASSWORD``, or ``PROFANITIES'``. This allows untrusted users to 
     355regular expression which will hide from the DEBUG view anything that contains 
     356``'SECRET'``, ``'PASSWORD'``, or ``'PROFANITIES'``. This allows untrusted users to 
    355357be able to give backtraces without seeing sensitive (or offensive) settings. 
    356358 
     
    657659"January 1," whereas Spanish might say "1 Enero." 
    658660 
    659 See `allowed date format strings`_. See also DATE_FORMAT, DATETIME_FORMAT
    660 TIME_FORMAT and YEAR_MONTH_FORMAT
     661See `allowed date format strings`_. See also ``DATE_FORMAT``
     662``DATETIME_FORMAT``, ``TIME_FORMAT`` and ``YEAR_MONTH_FORMAT``
    661663 
    662664PREPEND_WWW 
     
    816818you'll want to set that to take advantage of this setting. 
    817819 
    818 See also DEBUG
     820See also ``DEBUG``
    819821 
    820822TEMPLATE_DIRS 
     
    906908`allowed date format strings`_. 
    907909 
    908 See also DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT, YEAR_MONTH_FORMAT and 
    909 MONTH_DAY_FORMAT
     910See also ``DATE_FORMAT``, ``DATETIME_FORMAT``, ``TIME_FORMAT``, 
     911``YEAR_MONTH_FORMAT`` and ``MONTH_DAY_FORMAT``
    910912 
    911913.. _allowed date format strings: ../templates/#now 
     
    981983"January 2006," whereas another locale might say "2006/January." 
    982984 
    983 See `allowed date format strings`_. See also DATE_FORMAT, DATETIME_FORMAT
    984 TIME_FORMAT and MONTH_DAY_FORMAT
     985See `allowed date format strings`_. See also ``DATE_FORMAT``
     986``DATETIME_FORMAT``, ``TIME_FORMAT`` and ``MONTH_DAY_FORMAT``
    985987 
    986988.. _cache docs: ../cache/ 
  • django/branches/queryset-refactor/tests/regressiontests/model_regress/models.py

    r5876 r6335  
    2121        return self.headline 
    2222 
     23class 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 
    2328__test__ = {'API_TESTS': """ 
    2429(NOTE: Part of the regression test here is merely parsing the model