Skip to content

Commit 3ebcc6b

Browse files
committed
add another failing test
1 parent a2846e4 commit 3ebcc6b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,21 @@ def test_add_column_doesnt_break_anything(self):
339339
one = self.db.one("SELECT foo.*::foo FROM foo WHERE bar='baz'")
340340
assert one.boo is None
341341

342+
def test_replace_column_different_type(self):
343+
self.db.run("CREATE TABLE grok (bar int)")
344+
self.db.run("INSERT INTO grok VALUES (0)")
345+
class EmptyModel(Model): pass
346+
self.db.register_model(EmptyModel, 'grok')
347+
# Add a new column then drop the original one
348+
self.db.run("ALTER TABLE grok ADD COLUMN biz text NOT NULL DEFAULT 'x'")
349+
self.db.run("ALTER TABLE grok DROP COLUMN bar")
350+
# The number of columns hasn't changed but the names and types have
351+
one = self.db.one("SELECT grok.*::grok FROM grok LIMIT 1")
352+
assert one.biz == 'x'
353+
assert not hasattr(one, 'bar')
354+
342355
@mark.xfail
343-
def test_add_and_drop_columns(self):
356+
def test_replace_column_same_type(self):
344357
self.db.run("ALTER TABLE foo ADD COLUMN biz int NOT NULL DEFAULT 0")
345358
self.db.run("ALTER TABLE foo DROP COLUMN bar")
346359
one = self.db.one("SELECT foo.*::foo FROM foo LIMIT 1")

0 commit comments

Comments
 (0)