Skip to content

Commit

Permalink
tweak: double single quote for proper escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Aug 17, 2023
1 parent 094856d commit 180df86
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Query/SqlQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private function injectDynamicIn(string $sql, array &$data):string {

foreach($data["__dynamicIn"] as $i => $value) {
if(is_string($value)) {
$value = str_replace("'", "\'", $value);
$value = str_replace("'", "''", $value);
$data["__dynamicIn"][$i] = "'$value'";
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/phpunit/Query/SqlQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public function testDynamicBindingsWhereInStrings(

self::assertStringNotContainsString("dynamicIn", $injectedSql);

self::assertStringContainsString("where `createdAt` > :startDate and `name` in ( 'one', 'two', 'three\'s the last' ) limit 10", $injectedSql);
self::assertStringContainsString("where `createdAt` > :startDate and `name` in ( 'one', 'two', 'three''s the last' ) limit 10", $injectedSql);
self::assertArrayNotHasKey("__dynamicIn", $data);
self::assertSame("2020-01-01", $data["startDate"]);
}
Expand Down

0 comments on commit 180df86

Please sign in to comment.