Skip to content

Instantly share code, notes, and snippets.

@w1ck3dg0ph3r
Created May 7, 2021 10:46
Show Gist options
  • Save w1ck3dg0ph3r/cfbce1590fdce1ce54a179b6cb74f6a4 to your computer and use it in GitHub Desktop.
Save w1ck3dg0ph3r/cfbce1590fdce1ce54a179b6cb74f6a4 to your computer and use it in GitHub Desktop.
Additional test cases for sqlx
{
name: `multiline indented query`,
query: `INSERT INTO foo (
a,
b,
c,
d
) VALUES (
:name,
:age,
:first,
:last
)`,
expect: `INSERT INTO foo (
a,
b,
c,
d
) VALUES (
:name,
:age,
:first,
:last
),(
:name,
:age,
:first,
:last
)`,
loop: 2,
},
{
name: `on duplicate key update`,
query: `INSERT INTO foo (a,b,c,d) VALUES (:name, :age, :first, :last) ON DUPLICATE KEY UPDATE b = VALUES(b), c = VALUES(c)`,
expect: `INSERT INTO foo (a,b,c,d) VALUES (:name, :age, :first, :last),(:name, :age, :first, :last) ON DUPLICATE KEY UPDATE b = VALUES(b), c = VALUES(c)`,
loop: 2,
},
{
name: `functions inside values`,
query: `INSERT INTO foo (a,b,c,d) VALUES (:name, cast(:age as int), :first, :last)`,
expect: `INSERT INTO foo (a,b,c,d) VALUES (:name, cast(:age as int), :first, :last),(:name, cast(:age as int), :first, :last)`,
loop: 2,
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment