Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

escape.ident should quote identifiers that have capital letters #22

Open
jedwards1211 opened this issue Jun 9, 2021 · 5 comments · Fixed by maybephilipp/pg-escape#2 · May be fixed by #24
Open

escape.ident should quote identifiers that have capital letters #22

jedwards1211 opened this issue Jun 9, 2021 · 5 comments · Fixed by maybephilipp/pg-escape#2 · May be fixed by #24

Comments

@jedwards1211
Copy link

jedwards1211 commented Jun 9, 2021

Expected behavior: escape.ident('Foo') === '"Foo"'
Actual behavior: escape.ident('Foo') === 'Foo'

If we had pool.query(`CREATE DATABASE ${escape.ident(name)}`), and name is 'Foo', the created database would have the name foo instead since Postgres lowercases unquoted identifiers.

I'm not even sure if name.toLowerCase() !== name would be a sufficient to decide whether to quote because who knows if JS lowercases all the same non-Latin characters as Postgres does? I think the safest bet would be to add double quotes if the name doesn't match /^[a-z_][a-z0-9_$]*$/ (case sensitive)

jedwards1211 added a commit to jedwards1211/pg-escape that referenced this issue Jun 9, 2021
@jedwards1211 jedwards1211 linked a pull request Jun 9, 2021 that will close this issue
@sMoKeSz
Copy link

sMoKeSz commented Sep 14, 2021

hi. why is this not merged yet ?

@jedwards1211
Copy link
Author

actually I don't know why I bothered making a PR, the last commit was in 2015 so project is probably dead

@sMoKeSz
Copy link

sMoKeSz commented Sep 14, 2021

something is fishy cause I see allot of weekly downloads 19,017 , that means people is using it.
I made myself a fork so I can use in my project the case sensitive fix
I saw another PR just like yours sitting there from 2015.

#12

@jedwards1211
Copy link
Author

yeah, though people can keep using an abandoned package, it happens

@jedwards1211
Copy link
Author

also that's funny that someone already made a PR, wish I had noticed 😂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants