55//! rename hints into [`DiffCase::renames`], and the asserted statement output into
66//! [`DiffCase::expected_sql`].
77//!
8- //! Some scenarios in this file assert only a structured statement encoding (never
9- //! the rendered SQL), so they are recorded as [`Status::Skip`] with reason
10- //! `"statements-only encoding"` — the schemas are still translated faithfully so
11- //! the differ agent can promote them later by supplying the expected SQL.
8+ //! Every scenario in this file asserts the rendered SQL the differ emits for the
9+ //! `from`/`to` pair under normalized comparison.
1210
1311use postgres_kit:: differ:: ir:: {
1412 SchemaSnapshot , SnapColumn , SnapCompositePk , SnapForeignKey , SnapTable ,
@@ -34,8 +32,8 @@ pub fn cases() -> Vec<DiffCase> {
3432 )
3533 . build( ) ,
3634 renames: & [ ] ,
37- expected_sql: & [ ] ,
38- status: Status :: Skip ( "statements-only encoding" ) ,
35+ expected_sql: & [ "ALTER TABLE \" users \" ADD COLUMN \" name \" text;" ] ,
36+ status: Status :: Supported ,
3937 } ,
4038 // ---- add columns #2 ----
4139 // schema1: users { id serial primaryKey }
@@ -54,8 +52,11 @@ pub fn cases() -> Vec<DiffCase> {
5452 )
5553 . build( ) ,
5654 renames: & [ ] ,
57- expected_sql: & [ ] ,
58- status: Status :: Skip ( "statements-only encoding" ) ,
55+ expected_sql: & [
56+ "ALTER TABLE \" users\" ADD COLUMN \" email\" text;" ,
57+ "ALTER TABLE \" users\" ADD COLUMN \" name\" text;" ,
58+ ] ,
59+ status: Status :: Supported ,
5960 } ,
6061 // ---- alter column change name #1 ----
6162 // schema1: users { id serial primaryKey, name text('name') }
@@ -77,8 +78,8 @@ pub fn cases() -> Vec<DiffCase> {
7778 )
7879 . build( ) ,
7980 renames: & [ "public.users.name->public.users.name1" ] ,
80- expected_sql: & [ ] ,
81- status: Status :: Skip ( "statements-only encoding" ) ,
81+ expected_sql: & [ "ALTER TABLE \" users \" RENAME COLUMN \" name \" TO \" name1 \" ;" ] ,
82+ status: Status :: Supported ,
8283 } ,
8384 // ---- alter column change name #2 ----
8485 // schema1: users { id serial primaryKey, name text('name') }
@@ -101,8 +102,11 @@ pub fn cases() -> Vec<DiffCase> {
101102 )
102103 . build( ) ,
103104 renames: & [ "public.users.name->public.users.name1" ] ,
104- expected_sql: & [ ] ,
105- status: Status :: Skip ( "statements-only encoding" ) ,
105+ expected_sql: & [
106+ "ALTER TABLE \" users\" RENAME COLUMN \" name\" TO \" name1\" ;" ,
107+ "ALTER TABLE \" users\" ADD COLUMN \" email\" text;" ,
108+ ] ,
109+ status: Status :: Supported ,
106110 } ,
107111 // ---- alter table add composite pk ----
108112 // schema1: table { id1 integer, id2 integer }
@@ -145,8 +149,11 @@ pub fn cases() -> Vec<DiffCase> {
145149 "public.users->public.users1" ,
146150 "public.users1.id->public.users1.id1" ,
147151 ] ,
148- expected_sql: & [ ] ,
149- status: Status :: Skip ( "statements-only encoding" ) ,
152+ expected_sql: & [
153+ "ALTER TABLE \" users\" RENAME TO \" users1\" ;" ,
154+ "ALTER TABLE \" users1\" RENAME COLUMN \" id\" TO \" id1\" ;" ,
155+ ] ,
156+ status: Status :: Supported ,
150157 } ,
151158 // ---- with composite pks #1 ----
152159 // schema1: users { id1, id2, pk(id1,id2 name=compositePK) }
@@ -171,8 +178,8 @@ pub fn cases() -> Vec<DiffCase> {
171178 )
172179 . build( ) ,
173180 renames: & [ ] ,
174- expected_sql: & [ ] ,
175- status: Status :: Skip ( "statements-only encoding" ) ,
181+ expected_sql: & [ "ALTER TABLE \" users \" ADD COLUMN \" text \" text;" ] ,
182+ status: Status :: Supported ,
176183 } ,
177184 // ---- with composite pks #2 ----
178185 // schema1: users { id1, id2 }
@@ -195,8 +202,10 @@ pub fn cases() -> Vec<DiffCase> {
195202 )
196203 . build( ) ,
197204 renames: & [ ] ,
198- expected_sql: & [ ] ,
199- status: Status :: Skip ( "statements-only encoding" ) ,
205+ expected_sql: & [
206+ "ALTER TABLE \" users\" ADD CONSTRAINT \" compositePK\" PRIMARY KEY(\" id1\" ,\" id2\" );" ,
207+ ] ,
208+ status: Status :: Supported ,
200209 } ,
201210 // ---- with composite pks #3 ----
202211 // schema1: users { id1, id2, pk(id1,id2 name=compositePK) }
@@ -220,8 +229,11 @@ pub fn cases() -> Vec<DiffCase> {
220229 )
221230 . build( ) ,
222231 renames: & [ "public.users.id2->public.users.id3" ] ,
223- expected_sql: & [ ] ,
224- status: Status :: Skip ( "statements-only encoding" ) ,
232+ expected_sql: & [
233+ "ALTER TABLE \" users\" RENAME COLUMN \" id2\" TO \" id3\" ;" ,
234+ "ALTER TABLE \" users\" DROP CONSTRAINT \" compositePK\" ;\n --> statement-breakpoint\n ALTER TABLE \" users\" ADD CONSTRAINT \" compositePK\" PRIMARY KEY(\" id1\" ,\" id3\" );" ,
235+ ] ,
236+ status: Status :: Supported ,
225237 } ,
226238 // ---- add multiple constraints #1 ----
227239 // Adds onDelete actions to three FKs across three referenced tables.
0 commit comments