Merge branch 'master' of github.com:web2py/web2py
This commit is contained in:
@@ -3291,8 +3291,8 @@ class OracleAdapter(BaseAdapter):
|
||||
class MSSQLAdapter(BaseAdapter):
|
||||
drivers = ('pyodbc',)
|
||||
T_SEP = 'T'
|
||||
|
||||
QUOTE_TEMPLATE = "[%s]"
|
||||
|
||||
QUOTE_TEMPLATE = '"%s"'
|
||||
|
||||
types = {
|
||||
'boolean': 'BIT',
|
||||
|
||||
@@ -1396,24 +1396,26 @@ class TestRNameFields(unittest.TestCase):
|
||||
self.assertEqual(len(db.person._referenced_by),0)
|
||||
db.person.drop()
|
||||
|
||||
|
||||
class TestQuoting(unittest.TestCase):
|
||||
# tests for complex table names
|
||||
def testRun(self):
|
||||
return
|
||||
db = DAL(DEFAULT_URI, check_reserved=['all'])
|
||||
|
||||
t0 = db.define_table('A.table.with.dots and spaces',
|
||||
Field('f', 'string'))
|
||||
t1 = db.define_table('A.table',
|
||||
Field('f.other', t0),
|
||||
Field('f_other', t0),
|
||||
Field('words', 'text'))
|
||||
|
||||
blather = 'blah blah and so'
|
||||
t0[0] = {'f': 'content'}
|
||||
t1[0] = {'f.other': int(t0[1]['id']),
|
||||
t1[0] = {'f_other': int(t0[1]['id']),
|
||||
'words': blather}
|
||||
|
||||
|
||||
r = db(t1['f.other']==t0.id).select()
|
||||
r = db(t1['f_other']==t0.id).select()
|
||||
self.assertEqual(r[0][db['A.table']].words, blather)
|
||||
|
||||
db.define_table('t0', Field('f0'))
|
||||
@@ -1423,17 +1425,26 @@ class TestQuoting(unittest.TestCase):
|
||||
|
||||
rows=db(db.t0.id==db.t1.t0).select()
|
||||
self.assertEqual(rows[0].t1.t0, rows[0].t0.id)
|
||||
|
||||
t0.drop('cascade')
|
||||
t1.drop()
|
||||
if DEFAULT_URI.startswith('mssql'):
|
||||
#there's no drop cascade in mssql
|
||||
t1.drop()
|
||||
t0.drop()
|
||||
else:
|
||||
t0.drop('cascade')
|
||||
t1.drop()
|
||||
|
||||
db.t1.drop()
|
||||
db.t0.drop()
|
||||
|
||||
# tests for case sensitivity
|
||||
def testCase(self):
|
||||
return
|
||||
db = DAL(DEFAULT_URI, check_reserved=['all'], ignore_field_case=False)
|
||||
|
||||
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')
|
||||
|
||||
# test table case
|
||||
t0 = db.define_table('B',
|
||||
@@ -1482,16 +1493,21 @@ class TestQuoting(unittest.TestCase):
|
||||
t0.drop()
|
||||
|
||||
def testPKFK(self):
|
||||
|
||||
# test primary keys
|
||||
|
||||
db = DAL(DEFAULT_URI, check_reserved=['all'], ignore_field_case=False)
|
||||
|
||||
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')
|
||||
# test table without surrogate key. Length must is limited to
|
||||
# 100 because of MySQL limitations: it cannot handle more than
|
||||
# 767 bytes in unique keys.
|
||||
|
||||
t0 = db.define_table('t0', Field('Code', length=100), primarykey=['Code'])
|
||||
t22 = db.define_table('t22', Field('f'), Field('t0_Code', 'reference t0'))
|
||||
t2 = db.define_table('t2', Field('f'), Field('t0_Code', 'reference t0'))
|
||||
t3 = db.define_table('t3', Field('f', length=100), Field('t0_Code', t0.Code), primarykey=['f'])
|
||||
t4 = db.define_table('t4', Field('f', length=100), Field('t0', t0), primarykey=['f'])
|
||||
|
||||
@@ -1500,11 +1516,18 @@ class TestQuoting(unittest.TestCase):
|
||||
except Exception, e:
|
||||
self.assertTrue(isinstance(e, KeyError))
|
||||
|
||||
if DEFAULT_URI.startswith('mssql'):
|
||||
#there's no drop cascade in mssql
|
||||
t3.drop()
|
||||
t4.drop()
|
||||
t2.drop()
|
||||
t0.drop()
|
||||
else:
|
||||
t0.drop('cascade')
|
||||
t2.drop()
|
||||
t3.drop()
|
||||
t4.drop()
|
||||
|
||||
t0.drop('cascade')
|
||||
t22.drop()
|
||||
t3.drop()
|
||||
t4.drop()
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
tearDownModule()
|
||||
|
||||
Reference in New Issue
Block a user