Fails to add commas between 'ADD' statements
YorkFieldX opened this issue · 5 comments
Application crashes due to incorrect syntax of SQL statement generated from a migration
ALTER TABLE "entity" ADD "create_user_id" BIGINT REFERENCES "user" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION ADD "modify_user_id" BIGINT REFERENCES "user" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION ADD "create_date" TIMESTAMPTZ ADD "modify_date" TIMESTAMPTZ ADD "delete_date" TIMESTAMPTZ ADD "attributes" JSONB ADD "notes" TEXT
[] ["database-id": psql] (PostgresNIO/Connection/PostgresClient+Query.swift:39)`
PostgreSQL and MySQL require a comma before subsequent ADD
statements.
SQLite seems to require multiple ALTER TABLE
commands entirely, you can't join them.
Those lines need to change to something more like this
for (idx, column) in self.addColumns.enumerated() {
if idx > 0 {
$0.append("<")
}
$0.append("ADD")
$0.append(column)
}
But the true fix requires using the SqlDialect stuff, and I see there's some implementation of an alter table element started, but it's not in all the respective -kit packages, so I didn't wanna muck with this one.
@mattpolzin Looks like you are referenced on the 'git blame' for that area. Maybe it's something you worked on that you can quickly fix?
@grosch your assessment sounds about right. I can take a crack at this tomorrow after work. @tanner0101 let me know if you tear this off first so I don't dupe your efforts (or you could assign this ticket to me if you want to let me have it).
@mattpolzin that would be great, thank you.