diff --git a/src/backend/postgres/table.rs b/src/backend/postgres/table.rs index e0a8ed854..a87a9c46c 100644 --- a/src/backend/postgres/table.rs +++ b/src/backend/postgres/table.rs @@ -112,7 +112,15 @@ impl TableBuilder for PostgresQueryBuilder { let f = |column_def: &ColumnDef, sql: &mut dyn SqlWriter| { if let Some(column_type) = &column_def.types { write!(sql, " ").unwrap(); - self.prepare_column_type(column_type, sql); + if column_def + .spec + .iter() + .any(|v| matches!(v, ColumnSpec::AutoIncrement)) + { + self.prepare_column_auto_increment(column_type, sql); + } else { + self.prepare_column_type(column_type, sql); + } } }; self.prepare_column_def_common(column, sql, f); diff --git a/tests/postgres/table.rs b/tests/postgres/table.rs index 6292000bc..ece729c32 100644 --- a/tests/postgres/table.rs +++ b/tests/postgres/table.rs @@ -519,7 +519,7 @@ fn alter_9() { #[test] fn alter_10() { - // https://dbfiddle.uk/PQksflGf + // https://dbfiddle.uk/BeiZPvBe assert_eq!( Table::alter() .table(Glyph::Table) @@ -534,7 +534,7 @@ fn alter_10() { .to_string(PostgresQueryBuilder), [ r#"ALTER TABLE "glyph""#, - r#"ADD COLUMN "aspect" integer NOT NULL UNIQUE PRIMARY KEY"#, + r#"ADD COLUMN "aspect" serial NOT NULL UNIQUE PRIMARY KEY"#, ] .join(" ") );