Merge pull request #555 from ilvalle/bigint

Fix and initial tests for bigint
This commit is contained in:
mdipierro
2014-12-12 05:10:20 -06:00
2 changed files with 25 additions and 23 deletions
+2 -2
View File
@@ -105,8 +105,8 @@ class BaseAdapter(ConnectionPool):
'list:string': 'TEXT', 'list:string': 'TEXT',
'list:reference': 'TEXT', 'list:reference': 'TEXT',
# the two below are only used when DAL(...bigint_id=True) and replace 'id','reference' # the two below are only used when DAL(...bigint_id=True) and replace 'id','reference'
'big-id': 'BIGINT PRIMARY KEY AUTOINCREMENT', 'big-id': 'INTEGER PRIMARY KEY AUTOINCREMENT',
'big-reference': 'BIGINT REFERENCES %(foreign_key)s ON DELETE %(on_delete_action)s', 'big-reference': 'INTEGER REFERENCES %(foreign_key)s ON DELETE %(on_delete_action)s',
'reference FK': ', CONSTRAINT "FK_%(constraint_name)s" FOREIGN KEY (%(field_name)s) REFERENCES %(foreign_key)s ON DELETE %(on_delete_action)s', 'reference FK': ', CONSTRAINT "FK_%(constraint_name)s" FOREIGN KEY (%(field_name)s) REFERENCES %(foreign_key)s ON DELETE %(on_delete_action)s',
} }
+23 -21
View File
@@ -42,6 +42,7 @@ ALLOWED_DATATYPES = [
'upload', 'upload',
'password', 'password',
'json', 'json',
'bigint'
] ]
IS_POSTGRESQL = 'postgres' in DEFAULT_URI IS_POSTGRESQL = 'postgres' in DEFAULT_URI
@@ -622,27 +623,28 @@ class TestMigrations(unittest.TestCase):
class TestReference(unittest.TestCase): class TestReference(unittest.TestCase):
def testRun(self): def testRun(self):
db = DAL(DEFAULT_URI, check_reserved=['all']) for b in [True, False]:
if DEFAULT_URI.startswith('mssql'): db = DAL(DEFAULT_URI, check_reserved=['all'], bigint_id=b)
#multiple cascade gotcha if DEFAULT_URI.startswith('mssql'):
for key in ['reference','reference FK']: #multiple cascade gotcha
db._adapter.types[key]=db._adapter.types[key].replace( for key in ['reference','reference FK']:
'%(on_delete_action)s','NO ACTION') db._adapter.types[key]=db._adapter.types[key].replace(
db.define_table('tt', Field('name'), Field('aa','reference tt')) '%(on_delete_action)s','NO ACTION')
db.commit() db.define_table('tt', Field('name'), Field('aa','reference tt'))
x = db.tt.insert(name='max') db.commit()
assert x.id == 1 x = db.tt.insert(name='max')
assert x['id'] == 1 assert x.id == 1
x.aa = x assert x['id'] == 1
assert x.aa == 1 x.aa = x
x.update_record() assert x.aa == 1
y = db.tt[1] x.update_record()
assert y.aa == 1 y = db.tt[1]
assert y.aa.aa.aa.aa.aa.aa.name == 'max' assert y.aa == 1
z=db.tt.insert(name='xxx', aa = y) assert y.aa.aa.aa.aa.aa.aa.name == 'max'
assert z.aa == y.id z=db.tt.insert(name='xxx', aa = y)
db.tt.drop() assert z.aa == y.id
db.commit() db.tt.drop()
db.commit()
class TestClientLevelOps(unittest.TestCase): class TestClientLevelOps(unittest.TestCase):