Recommended workaround for () in a named parameter? #1612
-
Hi there I see from the documentation and recent issues that using In this case I would like to avoid mangling the columns / replacing I'm happy to make a PR to modify the mogrify parser to handle this situation if the reason these characters aren't supported is a matter of bandwidth/prioritization. I'm also interested to know if there are any preferred workarounds for the meanwhile or if there's no intention to ever support parens in column names Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
The fact that you cannot use a Workarounds are pretty trivial: just drop the I don't think that you can write a parser that can decide whether |
Beta Was this translation helpful? Give feedback.
Psycopg doesn't put any constraint in the column names: brackets or any other character in column names is supported. It is true that Postgres doesn't offer limitation in column names, but it does with parameters: should you ever write queries in pure postgres parametric functions you could only use numbers as parameters (
$1
,$2
, etc). Parameters substitution is a language inside the language and has its own limitations which are not related to the outermost one.Query parameters in psycopg2 have their language, which is the one of Python string formatting: the limitation comes from there.