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
the driver 'mssqlnative' fails on Insert_ID() if the insert statement contains a semicolon in a value string.
A possible solution is to replace the regular expression in ADODB_mssqlnative::_query($sql, $inputarr=false) (adodb-mssqlnative.inc.php line: 567 )
// original pattern
$pattern = "/^\W*(insert [^;]+);?$/i";
//suggested pattern which allows semicolons in value strings
$pattern = "/^\W*insert((('')*'([^'])+'('')*)|[^;'])*;?$/i";
In mssql a tick mark (') in a value string is escaped via a second one. Therefore the number of tick marks before the semicolon must be odd (since the string starts with a tick mark). In my opinion semicolons should be allowed after an odd number of tick marks.
any particular reason for removing the space after insert in your revised pattern ?
Since we don't use the matches, I don't think there's any need to capture all of the subpatterns, performance would be improved by using non-capturing ones (i.e. (?:xxx))
Would you mind submitting a pull request for this ? This way I can give you proper credit (and reduce effort to merge the change) too.
Note: I can't test because I don't have mssql.
stekule
added a commit
to stekule/ADOdb
that referenced
this issue
May 4, 2015
In mssql a tick mark (') in a value string is escaped via a second one. Therefore the number of tick marks before the semicolon must be odd (since the string starts with a tick mark). In my opinion semicolons should be allowed after an odd number of tick marks.
See also ADOdb#96
In mssql a tick mark (') in a value string is escaped via a second one.
Therefore the number of tick marks before the semicolon must be odd
(since the string starts with a tick mark).
Semicolons should be allowed after an odd number of tick marks.
There must be a character between the odd tick mark groups.
Fixes#97, see also #96
Hello,
the driver 'mssqlnative' fails on Insert_ID() if the insert statement contains a semicolon in a value string.
A possible solution is to replace the regular expression in ADODB_mssqlnative::_query($sql, $inputarr=false) (adodb-mssqlnative.inc.php line: 567 )
In mssql a tick mark (') in a value string is escaped via a second one. Therefore the number of tick marks before the semicolon must be odd (since the string starts with a tick mark). In my opinion semicolons should be allowed after an odd number of tick marks.
Best regards
Stephan
sample code:
The text was updated successfully, but these errors were encountered: