diff --git a/lapis/db/postgres/schema.lua b/lapis/db/postgres/schema.lua index e0abf73c..e5ccb5be 100644 --- a/lapis/db/postgres/schema.lua +++ b/lapis/db/postgres/schema.lua @@ -84,7 +84,7 @@ create_table = function(name, columns, opts) if #columns > 0 then add("\n") end - add(");") + add(")") return db.query(concat(buffer)) end local create_index @@ -129,7 +129,6 @@ create_index = function(tname, ...) if options.when then error("did you mean create_index `where`?") end - append_all(buffer, ";") return db.query(concat(buffer)) end local drop_index @@ -148,7 +147,7 @@ drop_index = function(...) end local drop_table drop_table = function(tname) - return db.query("DROP TABLE IF EXISTS " .. tostring(escape_identifier(tname)) .. ";") + return db.query("DROP TABLE IF EXISTS " .. tostring(escape_identifier(tname))) end local add_column add_column = function(tname, col_name, col_type) diff --git a/lapis/db/postgres/schema.moon b/lapis/db/postgres/schema.moon index b1645a8a..07eb66d1 100644 --- a/lapis/db/postgres/schema.moon +++ b/lapis/db/postgres/schema.moon @@ -46,7 +46,7 @@ create_table = (name, columns, opts={}) -> add "\n" if #columns > 0 - add ");" + add ")" db.query concat buffer create_index = (tname, ...) -> @@ -86,7 +86,6 @@ create_index = (tname, ...) -> if options.when error "did you mean create_index `where`?" - append_all buffer, ";" db.query concat buffer drop_index = (...) -> @@ -101,7 +100,7 @@ drop_index = (...) -> db.query concat buffer drop_table = (tname) -> - db.query "DROP TABLE IF EXISTS #{escape_identifier tname};" + db.query "DROP TABLE IF EXISTS #{escape_identifier tname}" add_column = (tname, col_name, col_type) -> tname = escape_identifier tname diff --git a/spec/postgres_spec.moon b/spec/postgres_spec.moon index 4051ecab..a88f2d6a 100644 --- a/spec/postgres_spec.moon +++ b/spec/postgres_spec.moon @@ -287,7 +287,7 @@ tests = { "password_reset_token" character varying(255), "data" text NOT NULL, PRIMARY KEY (user_id) -);]] +)]] } { @@ -301,53 +301,53 @@ tests = { [[CREATE TABLE IF NOT EXISTS "join_stuff" ( "hello_id" integer NOT NULL, "world_id" integer NOT NULL -);]] +)]] } { -> schema.drop_table "user_data" - [[DROP TABLE IF EXISTS "user_data";]] + [[DROP TABLE IF EXISTS "user_data"]] } { -> schema.create_index "user_data", "thing" - [[CREATE INDEX "user_data_thing_idx" ON "user_data" ("thing");]] + [[CREATE INDEX "user_data_thing_idx" ON "user_data" ("thing")]] } { -> schema.create_index "user_data", "thing", unique: true - [[CREATE UNIQUE INDEX "user_data_thing_idx" ON "user_data" ("thing");]] + [[CREATE UNIQUE INDEX "user_data_thing_idx" ON "user_data" ("thing")]] } { -> schema.create_index "user_data", "thing", unique: true, index_name: "good_idx" - [[CREATE UNIQUE INDEX "good_idx" ON "user_data" ("thing");]] + [[CREATE UNIQUE INDEX "good_idx" ON "user_data" ("thing")]] } { -> schema.create_index "user_data", "thing", if_not_exists: true - [[CREATE INDEX IF NOT EXISTS "user_data_thing_idx" ON "user_data" ("thing");]] + [[CREATE INDEX IF NOT EXISTS "user_data_thing_idx" ON "user_data" ("thing")]] } { -> schema.create_index "user_data", "thing", unique: true, where: "age > 100" - [[CREATE UNIQUE INDEX "user_data_thing_idx" ON "user_data" ("thing") WHERE age > 100;]] + [[CREATE UNIQUE INDEX "user_data_thing_idx" ON "user_data" ("thing") WHERE age > 100]] } { -> schema.create_index "users", "friend_id", tablespace: "farket" - [[CREATE INDEX "users_friend_id_idx" ON "users" ("friend_id") TABLESPACE "farket";]] + [[CREATE INDEX "users_friend_id_idx" ON "users" ("friend_id") TABLESPACE "farket"]] } { -> schema.create_index "user_data", "one", "two" - [[CREATE INDEX "user_data_one_two_idx" ON "user_data" ("one", "two");]] + [[CREATE INDEX "user_data_one_two_idx" ON "user_data" ("one", "two")]] } { -> schema.create_index "user_data", db.raw("lower(name)"), "height" - [[CREATE INDEX "user_data_lower_name_height_idx" ON "user_data" (lower(name), "height");]] + [[CREATE INDEX "user_data_lower_name_height_idx" ON "user_data" (lower(name), "height")]] } {