Reduce complexity of __getitem__ API
If you need to specify more, call get_table method
This commit is contained in:
parent
7a6b16931c
commit
0e39190062
@ -223,9 +223,6 @@ class Database(object):
|
|||||||
self._release()
|
self._release()
|
||||||
|
|
||||||
def __getitem__(self, table_name):
|
def __getitem__(self, table_name):
|
||||||
if type(table_name) is tuple:
|
|
||||||
return self.get_table(*table_name[:3])
|
|
||||||
else:
|
|
||||||
return self.get_table(table_name)
|
return self.get_table(table_name)
|
||||||
|
|
||||||
def query(self, query, **kw):
|
def query(self, query, **kw):
|
||||||
|
|||||||
@ -76,7 +76,7 @@ class DatabaseTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def test_create_table_shorthand1(self):
|
def test_create_table_shorthand1(self):
|
||||||
pid = "int_id"
|
pid = "int_id"
|
||||||
table = self.db['foo5', pid]
|
table = self.db.get_table('foo5', pid)
|
||||||
assert table.table.exists
|
assert table.table.exists
|
||||||
assert len(table.table.columns) == 1, table.table.columns
|
assert len(table.table.columns) == 1, table.table.columns
|
||||||
assert pid in table.table.c, table.table.c
|
assert pid in table.table.c, table.table.c
|
||||||
@ -89,7 +89,7 @@ class DatabaseTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def test_create_table_shorthand2(self):
|
def test_create_table_shorthand2(self):
|
||||||
pid = "string_id"
|
pid = "string_id"
|
||||||
table = self.db['foo6', pid, 'String']
|
table = self.db.get_table('foo6', primary_id=pid, primary_type='String')
|
||||||
assert table.table.exists
|
assert table.table.exists
|
||||||
assert len(table.table.columns) == 1, table.table.columns
|
assert len(table.table.columns) == 1, table.table.columns
|
||||||
assert pid in table.table.c, table.table.c
|
assert pid in table.table.c, table.table.c
|
||||||
@ -100,7 +100,7 @@ class DatabaseTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def test_create_table_shorthand3(self):
|
def test_create_table_shorthand3(self):
|
||||||
pid = "string_id"
|
pid = "string_id"
|
||||||
table = self.db['foo7', pid, 'String(20)']
|
table = self.db.get_table('foo7', primary_id=pid, primary_type='String(20)')
|
||||||
assert table.table.exists
|
assert table.table.exists
|
||||||
assert len(table.table.columns) == 1, table.table.columns
|
assert len(table.table.columns) == 1, table.table.columns
|
||||||
assert pid in table.table.c, table.table.c
|
assert pid in table.table.c, table.table.c
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user