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

genconfig doesn't quote column/table names #283

Open
joto opened this issue Feb 27, 2022 · 3 comments
Open

genconfig doesn't quote column/table names #283

joto opened this issue Feb 27, 2022 · 3 comments

Comments

@joto
Copy link

joto commented Feb 27, 2022

When using the genconfig command, the SQL queries generated do not quote the column/table names. This is necessary if they contain "strange" characters. So either all column/table names should be double quoted or at least those containing non-identifier characters.

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

@pka
Copy link
Member

pka commented Mar 13, 2022

genconfig tries to generate a human readable configuration and lets quoting to be done by the user:

// Remove quotes from column names for better readability
.replace('"', "");

Maybe there should be an option for generating a template with quoted column/table names, for cases when there a a log of ugly names.

@joto
Copy link
Author

joto commented Mar 14, 2022

At the moment the query it generates doesn't work and I would consider this a bug. There is also a security consideration here, although minor, because the user should hopefully know what they are doing.

It should be possible to figure out which column names need quoting and which don't and only quote those that need it. This way you get the best of both worlds: A working query and minimal quoting for readability and security.

@pka
Copy link
Member

pka commented Apr 22, 2022

A good compromise would be removing double quotes only if select_list doesn't contain special characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants