-
Notifications
You must be signed in to change notification settings - Fork 25
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
sql()
overeagerly converts dollar characters into parameter placeholders
#96
Comments
I've since realized that a proper way to achieve the above could be to do It could help to have the features implemented by #61 and #74 explicitly described in the doc pages though... would it be worth updating them? I don't mind writing a PR with documentation updates, but the |
You're right, the gh-pages branch wasn't updated in 2016, but there were doc fixes in 2016. I just now updated it to the latest (2.0.2).
That would be much appreciated. |
@sneakertack: As mentioned above, there were missing docs added in 2016 (180314b) that needed to be pushed to Today I added some more documentation in 46e5c7b and 45eef1c, so I think this can be closed. Regarding the request for a way to escape the '$' character... I suppose we could make '\$' and '\?' be an escape, via adding |
@prust the usual thing to use is double char like |
Actually But yes I no longer have that strong a need for the escaping originally raised, especially not if it makes things more difficult - after all the "workaround" of parametrizing your query and moving |
@Suor (as the issue was discovered in the process of using PostgreSQL/sql-bricks-postgres - not sure where a fix if any ought to be applied)
sql()
, recommended as a fallback for additional Postgres operations not covered bysql-bricks-postgres
, will mangle values where an actual dollar character is desired.In my case, I wanted to construct queries that do POSIX regular expression matching. The Postgres syntax looks something like:
SELECT * FROM table1 WHERE col1 ~* '.*someregex\d+$'
(note the use of$
as an end-of-line anchor in the regex)In such a case, doing
sql.select().from('table1').where(sql("col1 ~* '.*someregex\d+$'"))
will replace$
with$1
(in bothtoString()
andtoParams()
).Is there any way to escape the $-character to prevent it from being treated as a parameter placeholder? I looked at https://github.com/CSNW/sql-bricks/blob/master/sql-bricks.js#L69 and that line suggests that there isn't one at the moment.
The text was updated successfully, but these errors were encountered: