Skip to content
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

Support primary key specified after the fields #333

Closed
paralin opened this issue Dec 4, 2020 · 3 comments · Fixed by #382
Closed

Support primary key specified after the fields #333

paralin opened this issue Dec 4, 2020 · 3 comments · Fixed by #382
Labels
enhancement New feature or request
Milestone

Comments

@paralin
Copy link

paralin commented Dec 4, 2020

The following new test should probably pass (PRIMARY KEY after the fields):

ldiff --git a/sql/query/create_test.go b/sql/query/create_test.go
index 54c09e2..55520a2 100644
--- a/sql/query/create_test.go
+++ b/sql/query/create_test.go
@@ -28,6 +28,7 @@ func TestCreateTable(t *testing.T) {
 		{"If not exists, twice", "CREATE TABLE IF NOT EXISTS test;CREATE TABLE IF NOT EXISTS test", false},
 		{"With primary key", "CREATE TABLE test(foo TEXT PRIMARY KEY)", false},
 		{"With field constraints", "CREATE TABLE test(foo.a[1][2] TEXT primary key, bar[4][0].bat INTEGER not null, baz not null)", false},
+		{"With primary key after", "CREATE TABLE test(a TEXT, PRIMARY KEY(`id`));", false},
 		{"With no constraints", "CREATE TABLE test(a, b)", false},
 		{"With coherent constraint(common)", "CREATE TABLE test(a DOCUMENT, a.b ARRAY, a.b[0] TEXT);", false},
 		{"With coherent constraint(any)", "CREATE TABLE test(a, a.b[0] TEXT);", false},

@paralin paralin added the enhancement New feature or request label Dec 4, 2020
@paralin
Copy link
Author

paralin commented Dec 7, 2020

For reference the default SQL library will generate this query

@asdine
Copy link
Collaborator

asdine commented Dec 8, 2020

Thanks @paralin ! Indeed, we don't support yet this syntax but we definitely want to.

@paralin
Copy link
Author

paralin commented Dec 16, 2020

Looking forward to it. I am making a proof of concept / demo of running gogs (Git service) - which uses Go-Orm - on top of GenjiDB. This was the current blocker. If solved, I will be able to move onto the next blocker ;)

@asdine asdine added this to the v0.12.0 milestone Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants