CREATE TABLE with primary keys
Closed this issue · 2 comments
danrzeppa commented
It appears that when defining a column I can use the primaryKey
boolean to indicate if the column is a primary key. However, when create()
is used to create the table no SQL is generated for the primary key. For example (in a PostgreSQL DB):
var users = sql.define({
name: 'users',
columns: [
{
name: "pkid",
dataType: "int",
primaryKey: true
},
{
name: "name",
dataType: "varchar(100)"
}
]
})
var text=users.create().toQuery().text
generates:
CREATE TABLE "users" ("pkid" int, "name" varchar(100))
instead of
CREATE TABLE "users" ("pkid" int PRIMARY KEY, "name" varchar(100))
Is there a reason that this isn't supported? Or is it something that just hasn't been implemented?
I suppose the same question applies to foreign keys as well.
Thanks
diwu1989 commented
I think this may just be an overlooked bug.