Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fixed SQL placeholder parsing #113
I reworked DoctrineSQLParser to fix these problems:
Named placeholder patterns
The parser used a pattern that would match multiple colons, so junk like
The parser neglected the underscore so
This is cleaned up so placeholder names are consistent with PHP variable names: "starts with a letter or underscore, followed by any number of letters, numbers, or underscores".
Quote characters in strings
The parser had a simplistic way of matching quote pairs, ignoring that a quote character could be escaped by a backslash inside a string.
It now recognizes
The original algorithm looped a regular expression over each character position in the whole statement. The new algorithm handles matching in two steps:
I measured the result to be over 100% faster given the simple strings from the test case (even with 2 new runs added to the test data). The improvement would be greater on longer statements: