@@ -682,7 +682,9 @@ def test_transform_update_incoming_fks_on_column_rename(fresh_db):
682682
683683 # Verify initial FK
684684 assert fresh_db ["books" ].foreign_keys == [
685- ForeignKey (table = "books" , column = "author_id" , other_table = "authors" , other_column = "id" )
685+ ForeignKey (
686+ table = "books" , column = "author_id" , other_table = "authors" , other_column = "id"
687+ )
686688 ]
687689
688690 # Rename authors.id to authors.author_pk with update_incoming_fks=True
@@ -697,12 +699,19 @@ def test_transform_update_incoming_fks_on_column_rename(fresh_db):
697699
698700 # Verify books FK was updated to point to new column name
699701 assert fresh_db ["books" ].foreign_keys == [
700- ForeignKey (table = "books" , column = "author_id" , other_table = "authors" , other_column = "author_pk" )
702+ ForeignKey (
703+ table = "books" ,
704+ column = "author_id" ,
705+ other_table = "authors" ,
706+ other_column = "author_pk" ,
707+ )
701708 ]
702709
703710 # Verify data integrity
704711 assert list (fresh_db ["authors" ].rows ) == [{"author_pk" : 1 , "name" : "Alice" }]
705- assert list (fresh_db ["books" ].rows ) == [{"id" : 1 , "title" : "Book A" , "author_id" : 1 }]
712+ assert list (fresh_db ["books" ].rows ) == [
713+ {"id" : 1 , "title" : "Book A" , "author_id" : 1 }
714+ ]
706715
707716 # Verify FK enforcement still works
708717 assert fresh_db .execute ("PRAGMA foreign_keys" ).fetchone ()[0 ] == 1
@@ -749,13 +758,28 @@ def test_transform_update_incoming_fks_multiple_tables(fresh_db):
749758
750759 # Verify all FKs were updated
751760 assert fresh_db ["books" ].foreign_keys == [
752- ForeignKey (table = "books" , column = "author_id" , other_table = "authors" , other_column = "author_pk" )
761+ ForeignKey (
762+ table = "books" ,
763+ column = "author_id" ,
764+ other_table = "authors" ,
765+ other_column = "author_pk" ,
766+ )
753767 ]
754768 assert fresh_db ["articles" ].foreign_keys == [
755- ForeignKey (table = "articles" , column = "writer_id" , other_table = "authors" , other_column = "author_pk" )
769+ ForeignKey (
770+ table = "articles" ,
771+ column = "writer_id" ,
772+ other_table = "authors" ,
773+ other_column = "author_pk" ,
774+ )
756775 ]
757776 assert fresh_db ["quotes" ].foreign_keys == [
758- ForeignKey (table = "quotes" , column = "speaker_id" , other_table = "authors" , other_column = "author_pk" )
777+ ForeignKey (
778+ table = "quotes" ,
779+ column = "speaker_id" ,
780+ other_table = "authors" ,
781+ other_column = "author_pk" ,
782+ )
759783 ]
760784
761785 # Verify FK enforcement still works
@@ -770,22 +794,31 @@ def test_transform_update_incoming_fks_self_referential(fresh_db):
770794 fresh_db .execute ("PRAGMA foreign_keys=ON" )
771795
772796 # Create employees table with self-referential FK (manager_id -> id)
773- fresh_db .execute ("""
797+ fresh_db .execute (
798+ """
774799 CREATE TABLE employees (
775800 id INTEGER PRIMARY KEY,
776801 name TEXT,
777802 manager_id INTEGER REFERENCES employees(id)
778803 )
779- """ )
780- fresh_db ["employees" ].insert_all ([
781- {"id" : 1 , "name" : "CEO" , "manager_id" : None },
782- {"id" : 2 , "name" : "VP" , "manager_id" : 1 },
783- {"id" : 3 , "name" : "Dev" , "manager_id" : 2 },
784- ])
804+ """
805+ )
806+ fresh_db ["employees" ].insert_all (
807+ [
808+ {"id" : 1 , "name" : "CEO" , "manager_id" : None },
809+ {"id" : 2 , "name" : "VP" , "manager_id" : 1 },
810+ {"id" : 3 , "name" : "Dev" , "manager_id" : 2 },
811+ ]
812+ )
785813
786814 # Verify initial FK
787815 assert fresh_db ["employees" ].foreign_keys == [
788- ForeignKey (table = "employees" , column = "manager_id" , other_table = "employees" , other_column = "id" )
816+ ForeignKey (
817+ table = "employees" ,
818+ column = "manager_id" ,
819+ other_table = "employees" ,
820+ other_column = "id" ,
821+ )
789822 ]
790823
791824 # Rename employees.id to employees.emp_id with update_incoming_fks=True
@@ -800,7 +833,12 @@ def test_transform_update_incoming_fks_self_referential(fresh_db):
800833
801834 # Verify self-referential FK was updated
802835 assert fresh_db ["employees" ].foreign_keys == [
803- ForeignKey (table = "employees" , column = "manager_id" , other_table = "employees" , other_column = "emp_id" )
836+ ForeignKey (
837+ table = "employees" ,
838+ column = "manager_id" ,
839+ other_table = "employees" ,
840+ other_column = "emp_id" ,
841+ )
804842 ]
805843
806844 # Verify data integrity
0 commit comments