Skip to content

Commit

Permalink
- make even more tables
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzeek committed Feb 7, 2015
1 parent 68900c2 commit a147292
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions test/dialect/mysql/test_reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,36 +293,39 @@ def test_nullable_reflection(self):

# this is ideally one table, but older MySQL versions choke
# on the multiple TIMESTAMP columns
Table('nn_t1', meta) # to allow DROP
Table('nn_t2', meta)
Table('nn_t3', meta)

testing.db.execute("""
CREATE TABLE nn_t1 (
x INTEGER NULL,
y INTEGER NOT NULL,
z INTEGER,
q TIMESTAMP NULL,
p TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP)""")

testing.db.execute("""
CREATE TABLE nn_t2 (
r TIMESTAMP NOT NULL,
s TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)""")

testing.db.execute("""
CREATE TABLE nn_t3 (
t TIMESTAMP,
u TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)""")

eq_(
reflected = []
for idx, cols in enumerate([
[
{"name": d['name'], "nullable": d['nullable'],
"default": d['default']}
for d in sum([inspect(testing.db).get_columns(t)
for t in ('nn_t1', 'nn_t2', 'nn_t3')], [])
"x INTEGER NULL",
"y INTEGER NOT NULL",
"z INTEGER",
"q TIMESTAMP NULL"
],

["p TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP"],
["r TIMESTAMP NOT NULL"],
["s TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"],
["t TIMESTAMP"],
["u TIMESTAMP DEFAULT CURRENT_TIMESTAMP"]
]):
Table("nn_t%d" % idx, meta) # to allow DROP

testing.db.execute("""
CREATE TABLE nn_t%d (
%s
)
""" % (idx, ", \n".join(cols)))

reflected.extend(
{
"name": d['name'], "nullable": d['nullable'],
"default": d['default']}
for d in inspect(testing.db).get_columns("nn_t%d" % idx)
)

eq_(
reflected,
[
{'name': 'x', 'nullable': True, 'default': None},
{'name': 'y', 'nullable': False, 'default': None},
Expand Down

0 comments on commit a147292

Please sign in to comment.