-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
Description
I have following table:
let create_table = [%sqlf
{|
CREATE TABLE users (
id INTEGER NOT NULL PRIMARY KEY,
email VARCHAR NOT NULL,
name VARCHAR NOT NULL
)
|}
];And I want to insert all columns at once, possible adding multiple rows.
This query adds two rows with all columns:
let insert = [%sqlf {|
INSERT INTO users
VALUES (1, 'John', 'email1'), (2, 'Mary', 'email2')
RETURNING id
|}];but replacing (1, 'John', 'email1') with $user or $@user fails during compilation:
Error: [%sqlf]: ERROR: 42601: syntax error at or near "$1"
Would be amazing to have support for something like this:
let insert = [%sqlf {|
INSERT INTO users
VALUES $user
RETURNING id
|}];
let insert = (~user: (int32, string, string)) => ...it would be just a shortcut for
let insert = [%sqlf {|
INSERT INTO users
VALUES ($id, $email, $name)
RETURNING id
|}];