Open mgmeier opened 8 years ago
Are you sure this is correct? There are no tests, your code is quite complex, and I see several uses of B.map toLower
that raise yellow flags for me. Because the code is difficult to follow, I worry that parts of the query are being lowercased, which was not the pre-existing behaviour.
Thanks for looking into it. B.map toLower just lowercases the template to case-insensitively search for the "values" substring (as did the regex). The original template is never affected by that; you can see that the lowercased version doesn't even get bound to a variable. Anyway I'm sorry if it seems quite complex, maybe I should have commented more.
The approach is:
(6+) <$>
)INSERT INTO test VALUES (?, ?, SUBSTRING(?, 2, 2))
becomes
Just ("INSERT INTO test VALUES", "(?, ?, SUBSTRING(?, 2, 2))", "")
I'm sorry I didn't write any test; since I didn't know if you wanted to change the substitution group logic at all, my implementation was meant more as a proposal on how I'd thought to do it, so you could see what I meant.
If the code is less expressive than I hoped it to be (aka yellow flags), please don't hesitate to ask again.
... also I haven't had much time... leaving for a 3 week vacation today :)
Take actual parsing or regex matching out of the equation for extracting substitution groups from query templates. Makes substitution groups more permissive wrt. to MySQL functions and removes pcre-light dependency.