-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow usage of options on PK in postgreSQL #18
Conversation
@@ -23,19 +23,17 @@ func (p *Postgres) CreateTable(t fizz.Table) (string, error) { | |||
for _, c := range t.Columns { | |||
if c.Primary { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the primary check after adding the column itself? That's the way it's done with MySQL, so it should work the same way. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to avoid having a second if c.Primary bellow but if it's ok for you when i'm doing that!
translators/postgres_test.go
Outdated
@@ -11,7 +11,8 @@ var pgt = translators.NewPostgres() | |||
func (p *PostgreSQLSuite) Test_Postgres_CreateTable() { | |||
r := p.Require() | |||
ddl := `CREATE TABLE "users" ( | |||
"id" SERIAL PRIMARY KEY, | |||
PRIMARY KEY("id"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned previously, the MySQL driver have another output. We should have the same order (column def, then PRIMARY constraint) as in the MySQL driver.
Thanks for your contribution! |
Fix #17
The following example doesn't work as I expected with PostgreSQL
I expected the column to be created as described but no options are taken into account when primary is set to true
This PR tries to fix the issue.
note: It may also work on sqlite and coackroach but I have absolutely no skill with them and don't wanna break anything... feel free to contribute to my fork, i can give you access to it so that you can push freely