diff --git a/gluon/dal.py b/gluon/dal.py index 152ebe2f..abca02e9 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -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) diff --git a/gluon/tests/test_dal.py b/gluon/tests/test_dal.py index bea336e1..d9bbbad0 100644 --- a/gluon/tests/test_dal.py +++ b/gluon/tests/test_dal.py @@ -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'),