-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
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:
const RE_PARAM = /(?:\?)|(?::(\d+|(?:[a-zA-Z][a-zA-Z0-9_]*)))/gto
const RE_PARAM = /(?:\?)|(?::(\d+|(?:[a-zA-Z][a-zA-Z0-9_\.]*)))/g, // I added \. to the regexMy 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:
var namedPlaceholders = require("named-placeholders")
var np = 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]]Metadata
Metadata
Assignees
Labels
No labels