Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(5)

Side by Side Diff: trytond/backend/sqlite/table.py

Issue 1864045: Remove cursor, user and context instead use a Transaction (Closed)
Patch Set: Better Report.parse signature Created 14 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « trytond/backend/postgresql/table.py ('k') | trytond/ir/action.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #This file is part of Tryton. The COPYRIGHT file at the top level of 1 #This file is part of Tryton. The COPYRIGHT file at the top level of
2 #this repository contains the full copyright notices and license terms. 2 #this repository contains the full copyright notices and license terms.
3 3
4 from trytond.backend.table import TableHandlerInterface 4 from trytond.backend.table import TableHandlerInterface
5 import logging 5 import logging
6 import re 6 import re
7 7
8 8
9 class TableHandler(TableHandlerInterface): 9 class TableHandler(TableHandlerInterface):
10 def __init__(self, cursor, model, module_name=None, history=False): 10 def __init__(self, cursor, model, module_name=None, history=False):
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 self.cursor.execute(('ALTER TABLE "%s" ADD COLUMN "%s" %s' + default) % 184 self.cursor.execute(('ALTER TABLE "%s" ADD COLUMN "%s" %s' + default) %
185 (self.table_name, column_name, column_type)) 185 (self.table_name, column_name, column_type))
186 186
187 if column_format: 187 if column_format:
188 # check if table is non-empty: 188 # check if table is non-empty:
189 self.cursor.execute('SELECT 1 FROM "%s" limit 1' % self.table_name) 189 self.cursor.execute('SELECT 1 FROM "%s" limit 1' % self.table_name)
190 if self.cursor.fetchone(): 190 if self.cursor.fetchone():
191 # Populate column with default values: 191 # Populate column with default values:
192 default = None 192 default = None
193 if default_fun is not None: 193 if default_fun is not None:
194 default = default_fun(self.cursor, 0, {}) 194 default = default_fun()
195 self.cursor.execute('UPDATE "' + self.table_name + '" '\ 195 self.cursor.execute('UPDATE "' + self.table_name + '" '\
196 'SET "' + column_name + '" = %s', 196 'SET "' + column_name + '" = %s',
197 (column_format(default),)) 197 (column_format(default),))
198 198
199 self._update_definitions() 199 self._update_definitions()
200 200
201 def add_fk(self, column_name, reference, on_delete=None): 201 def add_fk(self, column_name, reference, on_delete=None):
202 logging.getLogger('init').warning( 202 logging.getLogger('init').warning(
203 'Unable to add foreign key on table %s!' % \ 203 'Unable to add foreign key on table %s!' % \
204 (self.table_name,)) 204 (self.table_name,))
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 267
268 @staticmethod 268 @staticmethod
269 def drop_table(cursor, model, table, cascade=False): 269 def drop_table(cursor, model, table, cascade=False):
270 cursor.execute('DELETE from ir_model_data where '\ 270 cursor.execute('DELETE from ir_model_data where '\
271 'model = \'%s\'' % model) 271 'model = \'%s\'' % model)
272 272
273 query = 'DROP TABLE "%s"' % table 273 query = 'DROP TABLE "%s"' % table
274 if cascade: 274 if cascade:
275 query = query + ' CASCADE' 275 query = query + ' CASCADE'
276 cursor.execute(query) 276 cursor.execute(query)
OLDNEW
« no previous file with comments | « trytond/backend/postgresql/table.py ('k') | trytond/ir/action.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b