Using postgres variables in sqlx fixtures? #3450
-
I'm trying to setup a fixture for sqlx::test, but I get a syntax error with my fixture, even thought it runs correctly with I think its because of the postgres variables I'm using. Any idea what the issue is? \set alice_email '[email protected]'
\set bob_email '[email protected]'
\set charlie_email '[email protected]'
\set daniel_email '[email protected]'
INSERT INTO users
(email)
VALUES
(:'alice_email'),
(:'bob_email'),
(:'charlie_email'),
(:'daniel_email')
; failed to apply test fixture "./fixtures/001/data.sql": Database(PgDatabaseError { severity: Error, code: "42601", message: "syntax error at or near \"\\\"", detail: None, hint: None, position: Some(Original(1)), where: None, schema: None, table: None, column: None, data_type: None, constraint: None, file: Some("scan.l"), line: Some(1241), routine: Some("scanner_yyerror") }) Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Please see https://stackoverflow.com/questions/29593908/difference-between-set-set-and-pset-in-psql TL;DR: I think https://www.postgresql.org/docs/current/plpgsql-declarations.html might solve what you are trying to achieve, but have never needed that part |
Beta Was this translation helpful? Give feedback.
Please see https://stackoverflow.com/questions/29593908/difference-between-set-set-and-pset-in-psql
TL;DR:
\set
is a psql meta-command => given that we are not psql, that won't work..I think https://www.postgresql.org/docs/current/plpgsql-declarations.html might solve what you are trying to achieve, but have never needed that part