File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -339,8 +339,21 @@ def test_add_column_doesnt_break_anything(self):
339
339
one = self .db .one ("SELECT foo.*::foo FROM foo WHERE bar='baz'" )
340
340
assert one .boo is None
341
341
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
+
342
355
@mark .xfail
343
- def test_add_and_drop_columns (self ):
356
+ def test_replace_column_same_type (self ):
344
357
self .db .run ("ALTER TABLE foo ADD COLUMN biz int NOT NULL DEFAULT 0" )
345
358
self .db .run ("ALTER TABLE foo DROP COLUMN bar" )
346
359
one = self .db .one ("SELECT foo.*::foo FROM foo LIMIT 1" )
You can’t perform that action at this time.
0 commit comments