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

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

Issue 275044: Add decimal digits validation on fields and fix precision errors (Closed)
Patch Set: Add unittest for precision of Float and Numeric fields, fix precision on MySQL and SQLite Created 15 years, 1 month 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/mysql/fields.py ('k') | trytond/backend/postgresql/database.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 6
7 7
8 class TableHandler(TableHandlerInterface): 8 class TableHandler(TableHandlerInterface):
9 9
10 def __init__(self, cursor, model, module_name=None, history=False): 10 def __init__(self, cursor, model, module_name=None, history=False):
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if size is None: 390 if size is None:
391 size = self._columns[column_name]['size'] 391 size = self._columns[column_name]['size']
392 if default is None: 392 if default is None:
393 default = self._columns[column_name]['default'] 393 default = self._columns[column_name]['default']
394 res = '' 394 res = ''
395 if typname == 'varchar': 395 if typname == 'varchar':
396 if int(size) > 255: 396 if int(size) > 255:
397 size = 255 397 size = 255
398 res = 'varchar(%s)' % str(size) 398 res = 'varchar(%s)' % str(size)
399 elif typname == 'decimal': 399 elif typname == 'decimal':
400 res = 'decimal(16, 8)' 400 res = 'decimal(65, 30)'
401 elif typname == 'double':
402 res = 'double(255, 30)'
401 else: 403 else:
402 res = typname 404 res = typname
403 # Default value for timestamp doesn't work 405 # Default value for timestamp doesn't work
404 if typname == 'timestamp' and not nullable: 406 if typname == 'timestamp' and not nullable:
405 nullable = True 407 nullable = True
406 if nullable: 408 if nullable:
407 res += ' NULL' 409 res += ' NULL'
408 else: 410 else:
409 res += ' NOT NULL' 411 res += ' NOT NULL'
410 if default is not None: 412 if default is not None:
411 res += ' DEFAULT %s' % default 413 res += ' DEFAULT %s' % default
412 return res 414 return res
OLDNEW
« no previous file with comments | « trytond/backend/mysql/fields.py ('k') | trytond/backend/postgresql/database.py » ('j') | no next file with comments »

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