Put quotes around sequence names
Identifiers are quoted in trytond/backend/postgresql/table.py, sequence names must be quoted too (see http://www.postgresql.org/docs/8.4/static/functions-sequence.html) issue2176 review141002
This commit is contained in:
1 parent
80fd323cae
commit
f35f3ec546
1 file changed
+4
-4
@@ -32,7 +32,7 @@ class TableHandler(TableHandlerInterface):
|
||||
if not self.history:
|
||||
self.cursor.execute('ALTER TABLE "%s" ' \
|
||||
'ADD COLUMN id INTEGER ' \
|
||||
'DEFAULT nextval(\'%s\') NOT NULL' % \
|
||||
'DEFAULT nextval(\'"%s"\') NOT NULL' % \
|
||||
(self.table_name, self.sequence_name))
|
||||
self.cursor.execute('ALTER TABLE "%s" ' \
|
||||
'ADD PRIMARY KEY(id)' % self.table_name)
|
||||
@@ -43,17 +43,17 @@ class TableHandler(TableHandlerInterface):
|
||||
if self.history and not '__id' in self._columns:
|
||||
self.cursor.execute('ALTER TABLE "%s" ' \
|
||||
'ADD COLUMN __id INTEGER ' \
|
||||
'DEFAULT nextval(\'%s\') NOT NULL' % \
|
||||
'DEFAULT nextval(\'"%s"\') NOT NULL' % \
|
||||
(self.table_name, self.sequence_name))
|
||||
self.cursor.execute('ALTER TABLE "%s" ' \
|
||||
'ADD PRIMARY KEY(__id)' % self.table_name)
|
||||
if self.history:
|
||||
self.cursor.execute('ALTER TABLE "%s" ' \
|
||||
'ALTER __id SET DEFAULT nextval(\'%s\')' % (self.table_name,
|
||||
'ALTER __id SET DEFAULT nextval(\'"%s"\')' % (self.table_name,
|
||||
self.sequence_name))
|
||||
else:
|
||||
self.cursor.execute('ALTER TABLE "%s" ' \
|
||||
'ALTER id SET DEFAULT nextval(\'%s\')' % (self.table_name,
|
||||
'ALTER id SET DEFAULT nextval(\'"%s"\')' % (self.table_name,
|
||||
self.sequence_name))
|
||||
self._update_definitions()
|
||||
|
||||
|
||||
Reference in new issue
Block a user