Merge pull request #270 from niphlod/fix/dal_reference
fix for references, DAL tests pass also on MSSQL now
This commit is contained in:
@@ -1261,7 +1261,7 @@ class BaseAdapter(ConnectionPool):
|
||||
return dict([(k[0].name, k[1]) for k in fields \
|
||||
if k[0].name in table._primarykey])
|
||||
id = self.lastrowid(table)
|
||||
if not isinstance(id,int):
|
||||
if not isinstance(id, (int, long)):
|
||||
return id
|
||||
rid = Reference(id)
|
||||
(rid._table, rid._record) = (table, None)
|
||||
|
||||
@@ -559,8 +559,13 @@ class TestMigrations(unittest.TestCase):
|
||||
|
||||
class TestReference(unittest.TestCase):
|
||||
|
||||
def testRun(self):
|
||||
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')
|
||||
@@ -836,7 +841,7 @@ class TestValidateAndInsert(unittest.TestCase):
|
||||
db.val_and_insert.drop()
|
||||
|
||||
|
||||
class TestZRName(unittest.TestCase):
|
||||
class TestRName(unittest.TestCase):
|
||||
"""
|
||||
tests for highly experimental rname attribute
|
||||
"""
|
||||
@@ -946,6 +951,11 @@ class TestZRName(unittest.TestCase):
|
||||
self.assertEqual(rtn[2].pet.name, 'Gertie')
|
||||
|
||||
#aliases
|
||||
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')
|
||||
rname = db._adapter.QUOTE_TEMPLATE % 'the cubs'
|
||||
db.define_table('pet_farm',
|
||||
Field('name'),
|
||||
|
||||
Reference in New Issue
Block a user