pgsync
pgsync copied to clipboard
variables with multiple values
Hi,
Is it possible to run pgsync with a variable that is a list? e.g.
groups:
product:
products: "where id in {1}"
and
pgsync product:\(123,456\)
This syntax works if only 1 value is passed in to the variable, since the SQL evaluates to where id in (123), which is valid. But it looks like if there's a comma anywhere, it gets treated as a delimiter for a table name, so I get the error
Table not found in source: 456)
(Trying to escape the comma like \, or putting quotes " around the whole string does not make a difference.)
Thank you!
https://github.com/ankane/pgsync?tab=readme-ov-file#variables
Hi @jasonxu123, thanks for reporting! Will think about how to address this for 1.0, but for now, you can hack around it with something like:
groups:
product:
products: "where id = ANY(REPLACE('{1}', '|', ',')::int[])"
and
pgsync "product:{123|456}"