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

View File

@@ -105,8 +105,8 @@ class BaseAdapter(ConnectionPool):
'list:string': 'TEXT',
'list:reference': 'TEXT',
# the two below are only used when DAL(...bigint_id=True) and replace 'id','reference'
'big-id': 'BIGINT PRIMARY KEY AUTOINCREMENT',
'big-reference': 'BIGINT REFERENCES %(foreign_key)s ON DELETE %(on_delete_action)s',
'big-id': 'INTEGER PRIMARY KEY AUTOINCREMENT',
'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',
}

View File

@@ -42,6 +42,7 @@ ALLOWED_DATATYPES = [
'upload',
'password',
'json',
'bigint'
]
IS_POSTGRESQL = 'postgres' in DEFAULT_URI
@@ -622,27 +623,28 @@ class TestMigrations(unittest.TestCase):
class TestReference(unittest.TestCase):
def testRun(self):
db = DAL(DEFAULT_URI, check_reserved=['all'])
if DEFAULT_URI.startswith('mssql'):
#multiple cascade gotcha
for key in ['reference','reference FK']:
db._adapter.types[key]=db._adapter.types[key].replace(
'%(on_delete_action)s','NO ACTION')
db.define_table('tt', Field('name'), Field('aa','reference tt'))
db.commit()
x = db.tt.insert(name='max')
assert x.id == 1
assert x['id'] == 1
x.aa = x
assert x.aa == 1
x.update_record()
y = db.tt[1]
assert y.aa == 1
assert y.aa.aa.aa.aa.aa.aa.name == 'max'
z=db.tt.insert(name='xxx', aa = y)
assert z.aa == y.id
db.tt.drop()
db.commit()
for b in [True, False]:
db = DAL(DEFAULT_URI, check_reserved=['all'], bigint_id=b)
if DEFAULT_URI.startswith('mssql'):
#multiple cascade gotcha
for key in ['reference','reference FK']:
db._adapter.types[key]=db._adapter.types[key].replace(
'%(on_delete_action)s','NO ACTION')
db.define_table('tt', Field('name'), Field('aa','reference tt'))
db.commit()
x = db.tt.insert(name='max')
assert x.id == 1
assert x['id'] == 1
x.aa = x
assert x.aa == 1
x.update_record()
y = db.tt[1]
assert y.aa == 1
assert y.aa.aa.aa.aa.aa.aa.name == 'max'
z=db.tt.insert(name='xxx', aa = y)
assert z.aa == y.id
db.tt.drop()
db.commit()
class TestClientLevelOps(unittest.TestCase):