new bigint type, DAL(...bigint_id=True) works better
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 1.99.7 (2012-05-04 10:47:21) dev
|
Version 1.99.7 (2012-05-04 14:01:49) dev
|
||||||
|
|||||||
+31
-11
@@ -539,6 +539,7 @@ class BaseAdapter(ConnectionPool):
|
|||||||
'blob': 'BLOB',
|
'blob': 'BLOB',
|
||||||
'upload': 'CHAR(%(length)s)',
|
'upload': 'CHAR(%(length)s)',
|
||||||
'integer': 'INTEGER',
|
'integer': 'INTEGER',
|
||||||
|
'bigint': 'INTEGER',
|
||||||
'float':'DOUBLE',
|
'float':'DOUBLE',
|
||||||
'double': 'DOUBLE',
|
'double': 'DOUBLE',
|
||||||
'decimal': 'DOUBLE',
|
'decimal': 'DOUBLE',
|
||||||
@@ -1454,10 +1455,6 @@ class BaseAdapter(ConnectionPool):
|
|||||||
|
|
||||||
def log_execute(self, *a, **b):
|
def log_execute(self, *a, **b):
|
||||||
command = a[0]
|
command = a[0]
|
||||||
if not self.db._bigint_id:
|
|
||||||
if command.startswith('CREATE') or command.startswith('ALTER'):
|
|
||||||
command = command.replace('BIGINT','INT').replace('BIGSERIAL','SERIAL')
|
|
||||||
a = [command]+a[1:]
|
|
||||||
self.db._lastsql = command
|
self.db._lastsql = command
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
ret = self.cursor.execute(*a, **b)
|
ret = self.cursor.execute(*a, **b)
|
||||||
@@ -1650,6 +1647,7 @@ class BaseAdapter(ConnectionPool):
|
|||||||
self.parsemap = {
|
self.parsemap = {
|
||||||
'id':self.parse_id,
|
'id':self.parse_id,
|
||||||
'integer':self.parse_integer,
|
'integer':self.parse_integer,
|
||||||
|
'bigint':self.parse_integer,
|
||||||
'float':self.parse_double,
|
'float':self.parse_double,
|
||||||
'double':self.parse_double,
|
'double':self.parse_double,
|
||||||
'reference':self.parse_reference,
|
'reference':self.parse_reference,
|
||||||
@@ -1990,6 +1988,7 @@ class MySQLAdapter(BaseAdapter):
|
|||||||
'blob': 'LONGBLOB',
|
'blob': 'LONGBLOB',
|
||||||
'upload': 'VARCHAR(%(length)s)',
|
'upload': 'VARCHAR(%(length)s)',
|
||||||
'integer': 'INT',
|
'integer': 'INT',
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'FLOAT',
|
'float': 'FLOAT',
|
||||||
'double': 'DOUBLE',
|
'double': 'DOUBLE',
|
||||||
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
||||||
@@ -2094,6 +2093,7 @@ class PostgreSQLAdapter(BaseAdapter):
|
|||||||
'blob': 'BYTEA',
|
'blob': 'BYTEA',
|
||||||
'upload': 'VARCHAR(%(length)s)',
|
'upload': 'VARCHAR(%(length)s)',
|
||||||
'integer': 'INTEGER',
|
'integer': 'INTEGER',
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'FLOAT',
|
'float': 'FLOAT',
|
||||||
'double': 'FLOAT8',
|
'double': 'FLOAT8',
|
||||||
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
||||||
@@ -2383,6 +2383,7 @@ class OracleAdapter(BaseAdapter):
|
|||||||
'blob': 'CLOB',
|
'blob': 'CLOB',
|
||||||
'upload': 'VARCHAR2(%(length)s)',
|
'upload': 'VARCHAR2(%(length)s)',
|
||||||
'integer': 'INT',
|
'integer': 'INT',
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'FLOAT',
|
'float': 'FLOAT',
|
||||||
'double': 'DOUBLE',
|
'double': 'DOUBLE',
|
||||||
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
||||||
@@ -2518,6 +2519,7 @@ class MSSQLAdapter(BaseAdapter):
|
|||||||
'blob': 'IMAGE',
|
'blob': 'IMAGE',
|
||||||
'upload': 'VARCHAR(%(length)s)',
|
'upload': 'VARCHAR(%(length)s)',
|
||||||
'integer': 'INT',
|
'integer': 'INT',
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'FLOAT',
|
'float': 'FLOAT',
|
||||||
'double': 'FLOAT',
|
'double': 'FLOAT',
|
||||||
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
||||||
@@ -2707,6 +2709,7 @@ class MSSQL2Adapter(MSSQLAdapter):
|
|||||||
'blob': 'IMAGE',
|
'blob': 'IMAGE',
|
||||||
'upload': 'NVARCHAR(%(length)s)',
|
'upload': 'NVARCHAR(%(length)s)',
|
||||||
'integer': 'INT',
|
'integer': 'INT',
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'FLOAT',
|
'float': 'FLOAT',
|
||||||
'double': 'FLOAT',
|
'double': 'FLOAT',
|
||||||
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
||||||
@@ -2746,6 +2749,7 @@ class FireBirdAdapter(BaseAdapter):
|
|||||||
'blob': 'BLOB SUB_TYPE 0',
|
'blob': 'BLOB SUB_TYPE 0',
|
||||||
'upload': 'VARCHAR(%(length)s)',
|
'upload': 'VARCHAR(%(length)s)',
|
||||||
'integer': 'INTEGER',
|
'integer': 'INTEGER',
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'FLOAT',
|
'float': 'FLOAT',
|
||||||
'double': 'DOUBLE PRECISION',
|
'double': 'DOUBLE PRECISION',
|
||||||
'decimal': 'DECIMAL(%(precision)s,%(scale)s)',
|
'decimal': 'DECIMAL(%(precision)s,%(scale)s)',
|
||||||
@@ -2918,6 +2922,7 @@ class InformixAdapter(BaseAdapter):
|
|||||||
'blob': 'BLOB SUB_TYPE 0',
|
'blob': 'BLOB SUB_TYPE 0',
|
||||||
'upload': 'VARCHAR(%(length)s)',
|
'upload': 'VARCHAR(%(length)s)',
|
||||||
'integer': 'INTEGER',
|
'integer': 'INTEGER',
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'FLOAT',
|
'float': 'FLOAT',
|
||||||
'double': 'DOUBLE PRECISION',
|
'double': 'DOUBLE PRECISION',
|
||||||
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
||||||
@@ -3031,6 +3036,7 @@ class DB2Adapter(BaseAdapter):
|
|||||||
'blob': 'BLOB',
|
'blob': 'BLOB',
|
||||||
'upload': 'VARCHAR(%(length)s)',
|
'upload': 'VARCHAR(%(length)s)',
|
||||||
'integer': 'INT',
|
'integer': 'INT',
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'REAL',
|
'float': 'REAL',
|
||||||
'double': 'DOUBLE',
|
'double': 'DOUBLE',
|
||||||
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
||||||
@@ -3115,6 +3121,7 @@ class TeradataAdapter(BaseAdapter):
|
|||||||
'blob': 'BLOB',
|
'blob': 'BLOB',
|
||||||
'upload': 'VARCHAR(%(length)s)',
|
'upload': 'VARCHAR(%(length)s)',
|
||||||
'integer': 'INT',
|
'integer': 'INT',
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'REAL',
|
'float': 'REAL',
|
||||||
'double': 'DOUBLE',
|
'double': 'DOUBLE',
|
||||||
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
||||||
@@ -3335,6 +3342,7 @@ class IngresAdapter(BaseAdapter):
|
|||||||
'blob': 'BLOB',
|
'blob': 'BLOB',
|
||||||
'upload': 'VARCHAR(%(length)s)', ## FIXME utf8 or nvarchar... or blob? what is this type?
|
'upload': 'VARCHAR(%(length)s)', ## FIXME utf8 or nvarchar... or blob? what is this type?
|
||||||
'integer': 'INTEGER4', # or int8...
|
'integer': 'INTEGER4', # or int8...
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'FLOAT',
|
'float': 'FLOAT',
|
||||||
'double': 'FLOAT8',
|
'double': 'FLOAT8',
|
||||||
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
||||||
@@ -3432,6 +3440,7 @@ class IngresUnicodeAdapter(IngresAdapter):
|
|||||||
'blob': 'BLOB',
|
'blob': 'BLOB',
|
||||||
'upload': 'VARCHAR(%(length)s)', ## FIXME utf8 or nvarchar... or blob? what is this type?
|
'upload': 'VARCHAR(%(length)s)', ## FIXME utf8 or nvarchar... or blob? what is this type?
|
||||||
'integer': 'INTEGER4', # or int8...
|
'integer': 'INTEGER4', # or int8...
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'FLOAT',
|
'float': 'FLOAT',
|
||||||
'double': 'FLOAT8',
|
'double': 'FLOAT8',
|
||||||
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
'decimal': 'NUMERIC(%(precision)s,%(scale)s)',
|
||||||
@@ -3459,6 +3468,7 @@ class SAPDBAdapter(BaseAdapter):
|
|||||||
'blob': 'LONG',
|
'blob': 'LONG',
|
||||||
'upload': 'VARCHAR(%(length)s)',
|
'upload': 'VARCHAR(%(length)s)',
|
||||||
'integer': 'INT',
|
'integer': 'INT',
|
||||||
|
'bigint': 'BIGINT',
|
||||||
'float': 'FLOAT',
|
'float': 'FLOAT',
|
||||||
'double': 'DOUBLE PRECISION',
|
'double': 'DOUBLE PRECISION',
|
||||||
'decimal': 'FIXED(%(precision)s,%(scale)s)',
|
'decimal': 'FIXED(%(precision)s,%(scale)s)',
|
||||||
@@ -3736,7 +3746,7 @@ class NoSQLAdapter(BaseAdapter):
|
|||||||
if not obj is None:
|
if not obj is None:
|
||||||
if isinstance(obj, list) and not is_list:
|
if isinstance(obj, list) and not is_list:
|
||||||
obj = [self.represent(o, fieldtype) for o in obj]
|
obj = [self.represent(o, fieldtype) for o in obj]
|
||||||
elif fieldtype in ('integer','id'):
|
elif fieldtype in ('integer','bigint','id'):
|
||||||
obj = long(obj)
|
obj = long(obj)
|
||||||
elif fieldtype == 'double':
|
elif fieldtype == 'double':
|
||||||
obj = float(obj)
|
obj = float(obj)
|
||||||
@@ -3883,6 +3893,7 @@ class GoogleDatastoreAdapter(NoSQLAdapter):
|
|||||||
'blob': gae.BlobProperty,
|
'blob': gae.BlobProperty,
|
||||||
'upload': gae.StringProperty,
|
'upload': gae.StringProperty,
|
||||||
'integer': gae.IntegerProperty,
|
'integer': gae.IntegerProperty,
|
||||||
|
'bigint': gae.IntegerProperty,
|
||||||
'float': gae.FloatProperty,
|
'float': gae.FloatProperty,
|
||||||
'double': gae.FloatProperty,
|
'double': gae.FloatProperty,
|
||||||
'decimal': GAEDecimalProperty,
|
'decimal': GAEDecimalProperty,
|
||||||
@@ -4210,6 +4221,7 @@ class CouchDBAdapter(NoSQLAdapter):
|
|||||||
'blob': str,
|
'blob': str,
|
||||||
'upload': str,
|
'upload': str,
|
||||||
'integer': long,
|
'integer': long,
|
||||||
|
'bigint': long,
|
||||||
'float': float,
|
'float': float,
|
||||||
'double': float,
|
'double': float,
|
||||||
'date': datetime.date,
|
'date': datetime.date,
|
||||||
@@ -4410,6 +4422,7 @@ class MongoDBAdapter(NoSQLAdapter):
|
|||||||
'blob': str,
|
'blob': str,
|
||||||
'upload': str,
|
'upload': str,
|
||||||
'integer': long,
|
'integer': long,
|
||||||
|
'bigint': long,
|
||||||
'float': float,
|
'float': float,
|
||||||
'double': float,
|
'double': float,
|
||||||
'date': datetime.date,
|
'date': datetime.date,
|
||||||
@@ -5113,6 +5126,7 @@ class IMAPAdapter(NoSQLAdapter):
|
|||||||
'id': long,
|
'id': long,
|
||||||
'boolean': bool,
|
'boolean': bool,
|
||||||
'integer': int,
|
'integer': int,
|
||||||
|
'bigint': long,
|
||||||
'blob': str,
|
'blob': str,
|
||||||
'list:string': str,
|
'list:string': str,
|
||||||
}
|
}
|
||||||
@@ -5944,7 +5958,7 @@ def sqlhtml_validators(field):
|
|||||||
requires.append(validators.IS_LENGTH(field_length))
|
requires.append(validators.IS_LENGTH(field_length))
|
||||||
elif field_type == 'double' or field_type == 'float':
|
elif field_type == 'double' or field_type == 'float':
|
||||||
requires.append(validators.IS_FLOAT_IN_RANGE(-1e100, 1e100))
|
requires.append(validators.IS_FLOAT_IN_RANGE(-1e100, 1e100))
|
||||||
elif field_type == 'integer':
|
elif field_type in ('integer','bigint'):
|
||||||
requires.append(validators.IS_INT_IN_RANGE(-1e100, 1e100))
|
requires.append(validators.IS_INT_IN_RANGE(-1e100, 1e100))
|
||||||
elif field_type.startswith('decimal'):
|
elif field_type.startswith('decimal'):
|
||||||
requires.append(validators.IS_DECIMAL_IN_RANGE(-10**10, 10**10))
|
requires.append(validators.IS_DECIMAL_IN_RANGE(-10**10, 10**10))
|
||||||
@@ -6342,6 +6356,13 @@ class DAL(dict):
|
|||||||
db_codec, credential_decoder,
|
db_codec, credential_decoder,
|
||||||
driver_args or {}, adapter_args or {})
|
driver_args or {}, adapter_args or {})
|
||||||
self._adapter = ADAPTERS[self._dbname](*args)
|
self._adapter = ADAPTERS[self._dbname](*args)
|
||||||
|
if not bigint_id:
|
||||||
|
types = ADAPTERS[self._dbname].types
|
||||||
|
self._adapter.types = copy.copy(types)
|
||||||
|
for key in ('id','reference'):
|
||||||
|
self._adapters.types[key] = types[key]\
|
||||||
|
.replace('BIGINT','INT')\
|
||||||
|
.replace('BIGSERIAL','SERIAL')
|
||||||
connected = True
|
connected = True
|
||||||
break
|
break
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
@@ -6466,8 +6487,7 @@ def index():
|
|||||||
tag += '/{%s.%s}' % (table,field)
|
tag += '/{%s.%s}' % (table,field)
|
||||||
patterns.append(tag)
|
patterns.append(tag)
|
||||||
patterns.append(tag+'/:field')
|
patterns.append(tag+'/:field')
|
||||||
elif f.type.startswith('float') or \
|
elif f.type in ('float','double','integer','bigint'):
|
||||||
f.type.startswith('double') or f.type.startswith('integer'):
|
|
||||||
tag += '/{%s.%s.ge}/{%s.%s.lt}' % (table,field,table,field)
|
tag += '/{%s.%s.ge}/{%s.%s.lt}' % (table,field,table,field)
|
||||||
patterns.append(tag)
|
patterns.append(tag)
|
||||||
patterns.append(tag+'/:field')
|
patterns.append(tag+'/:field')
|
||||||
@@ -7050,7 +7070,7 @@ class Table(dict):
|
|||||||
archive_db = archive_db or self._db
|
archive_db = archive_db or self._db
|
||||||
fieldnames = self.fields()
|
fieldnames = self.fields()
|
||||||
archive_name = archive_name % dict(tablename=self._tablename)
|
archive_name = archive_name % dict(tablename=self._tablename)
|
||||||
field_type = self if archive_db is self._db else 'integer'
|
field_type = self if archive_db is self._db else 'bigint'
|
||||||
archive_table = archive_db.define_table(
|
archive_table = archive_db.define_table(
|
||||||
archive_name,
|
archive_name,
|
||||||
Field(current_record,field_type),
|
Field(current_record,field_type),
|
||||||
@@ -7353,7 +7373,7 @@ class Table(dict):
|
|||||||
value = None
|
value = None
|
||||||
else:
|
else:
|
||||||
value = float(value)
|
value = float(value)
|
||||||
elif field.type=='integer':
|
elif field.type in ('integer','bigint'):
|
||||||
if not value.strip():
|
if not value.strip():
|
||||||
value = None
|
value = None
|
||||||
else:
|
else:
|
||||||
@@ -7525,7 +7545,7 @@ class Expression(object):
|
|||||||
return Expression(self.db,self.db._adapter.ADD,self,other,self.type)
|
return Expression(self.db,self.db._adapter.ADD,self,other,self.type)
|
||||||
|
|
||||||
def __sub__(self, other):
|
def __sub__(self, other):
|
||||||
if self.type == 'integer':
|
if self.type in ('integer','bigint'):
|
||||||
result_type = 'integer'
|
result_type = 'integer'
|
||||||
elif self.type in ['date','time','datetime','double','float']:
|
elif self.type in ['date','time','datetime','double','float']:
|
||||||
result_type = 'double'
|
result_type = 'double'
|
||||||
|
|||||||
Reference in New Issue
Block a user