You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have columns in my database with . characters in them. named-placeholders breaks when I pass it objects that contain non-alphanum chars in their property names.
i.e.
{
"my.funky.col.id": 1234
}
The following is a change I made to the param regex that seems to have addressed my specific issue:
constRE_PARAM=/(?:\?)|(?::(\d+|(?:[a-zA-Z][a-zA-Z0-9_\.]*)))/g,// I added \. to the regex
My question is, how should named-placeholders handle non-alphanum chars in column names, since MySQL allows them as long as they're escaped with backticks? Currently RE_PARAM is private, and it seems that there is no one-size-fits-all regex. Expose it as an option on createCompiler?
I saw you changed the regex in #6 so maybe that is the way you want to go with this. Please advise. I'm ready and willing to submit a PR.
Full repro of issue:
varnamedPlaceholders=require("named-placeholders")varnp=namedPlaceholders();np('select * from test where `my.funky.col.id` = :my.funky.col.id',{"my.funky.col.id": 1234})
Returns
["select * from test where `my.funky.col.id` = ?.funky.col.id",[undefined]]
The text was updated successfully, but these errors were encountered:
julius-e
pushed a commit
to julius-e/named-placeholders
that referenced
this issue
May 14, 2019
In regards to the above issue where @julius-e had '.' in his column, I am facing similar issue where I have '-' in my column , I faced the same issue with error as Bind parameters must not contain undefined. because of RE_PARAM regex could not parse my name place holder having '-'. So I add - to the regex and it worked!,
const RE_PARAM = /(?:\?)|(?::(\d+|(?:[a-zA-Z][a-zA-Z0-9_\.\-]*)))/g, // I added \- to the regex
I think we should build one powerful regex to include/match any random char which might break the lib.
I have columns in my database with
.
characters in them.named-placeholders
breaks when I pass it objects that contain non-alphanum chars in their property names.i.e.
The following is a change I made to the param regex that seems to have addressed my specific issue:
to
My question is, how should
named-placeholders
handle non-alphanum chars in column names, since MySQL allows them as long as they're escaped with backticks? CurrentlyRE_PARAM
is private, and it seems that there is no one-size-fits-all regex. Expose it as an option oncreateCompiler
?I saw you changed the regex in #6 so maybe that is the way you want to go with this. Please advise. I'm ready and willing to submit a PR.
Full repro of issue:
Returns
The text was updated successfully, but these errors were encountered: