Ticket #13295: postgresql_name_seq.2.diff

File postgresql_name_seq.2.diff, 2.5 KB (added by Max Shabalihin, 15 years ago)
  • django/db/models/sql/compiler.

    old new  
    785785            return
    786786        if self.connection.features.can_return_id_from_insert:
    787787            return self.connection.ops.fetch_returned_insert_id(cursor)
    788         return self.connection.ops.last_insert_id(cursor,
     788        if 'db_seq' in self.query.model._meta.__dict__:
     789            return self.connection.ops.last_insert_id(cursor,
     790                self.query.model._meta.db_seq, '')
     791        else:
     792            return self.connection.ops.last_insert_id(cursor,
    789793                self.query.model._meta.db_table, self.query.model._meta.pk.column)
    790794
    791795
  • django/db/models/options.

    old new  
    1818# Calculate the verbose_name by converting from InitialCaps to "lowercase with spaces".
    1919get_verbose_name = lambda class_name: re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', ' \\1', class_name).lower().strip()
    2020
    21 DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering',
     21DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering', 'db_seq',
    2222                 'unique_together', 'permissions', 'get_latest_by',
    2323                 'order_with_respect_to', 'app_label', 'db_tablespace',
    2424                 'abstract', 'managed', 'proxy', 'auto_created')
     
    3030        self.module_name, self.verbose_name = None, None
    3131        self.verbose_name_plural = None
    3232        self.db_table = ''
     33        self.db_seq = ''
    3334        self.ordering = []
    3435        self.unique_together =  []
    3536        self.permissions =  []
  • django/db/backends/postgresql/operations.

    old new  
    5454        return '%s'
    5555
    5656    def last_insert_id(self, cursor, table_name, pk_name):
    57         cursor.execute("SELECT CURRVAL('\"%s_%s_seq\"')" % (table_name, pk_name))
     57        if pk_name:
     58            cursor.execute("SELECT CURRVAL('\"%s_%s_seq\"')" % (table_name, pk_name))
     59        else:
     60            cursor.execute("SELECT CURRVAL('\"%s_seq\"')" % table_name)
    5861        return cursor.fetchone()[0]
    5962
    6063    def no_limit_value(self):
Back to Top