Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variables with multiple values #206

Open
jasonxu123 opened this issue Jan 22, 2024 · 1 comment
Open

variables with multiple values #206

jasonxu123 opened this issue Jan 22, 2024 · 1 comment

Comments

@jasonxu123
Copy link

jasonxu123 commented Jan 22, 2024

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

@ankane
Copy link
Owner

ankane commented Feb 28, 2024

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}"

@ankane ankane mentioned this issue Feb 28, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants