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

Use quoted identifiers in generated SQL #311

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

robert-werner
Copy link

I've tried to deploy a T-Rex server from OSM data.
I've generated a config with genconfig command with PostgreSQL.
I started to get PostgreSQL's syntax errors, so I've investigated through the code, and I discovered that replacing the braces with nothing is creating these errors, so I've decided to delete that code.

Tests are passed.

robert-werner and others added 3 commits February 6, 2024 03:44
Deleting the double quotes creates unpleasant bugs
@pka
Copy link
Member

pka commented Feb 9, 2024

Thanks for your PR!
I really like the feature of having readable SQL in the generated configuration. A better solution would probably be checking that no problematic characters are included before removing the quotes.

@pka pka changed the title Fixing the syntax error Don't remove quotes in generated SQL Feb 9, 2024
@robert-werner
Copy link
Author

'problematic characters' are the reserved words of Postgre, so the 'better solution' is not the solution at all,

Just try to generate .toml from OSM2PGSQL imported database.

@pka
Copy link
Member

pka commented Feb 9, 2024

Which problematic table or column names does osm2pgsql create?

I'm still in favor of letting basic names unquoted. Rule proposal (subset of https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS): "SQL identifiers must begin with a letter a-z or an underscore (_). Subsequent characters in an identifier can be a-z, underscores or digits (0-9)"

@joto
Copy link

joto commented Feb 9, 2024

Which problematic table or column names does osm2pgsql create?

Of course it depends on the configuration, but typical osm2pgsql configs generate column names such as addr:housenumber from the tags of the same name. Not a great idea, but we are pretty much stuck with that.

@robert-werner
Copy link
Author

Which problematic table or column names does osm2pgsql create?

Of course it depends on the configuration, but typical osm2pgsql configs generate column names such as addr:housenumber from the tags of the same name. Not a great idea, but we are pretty much stuck with that.

That's why T-Rex doesn't need the readability instead of functionality.
If anyone wants to get readable SQL's, he may be pleased with dedicated option.

@pka pka changed the title Don't remove quotes in generated SQL Use quoted identifiers in generated SQL Feb 9, 2024
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

Successfully merging this pull request may close these issues.

3 participants