Skip to content

Commit

Permalink
feature: improve error handling of special binding including infiles
Browse files Browse the repository at this point in the history
closes #364
  • Loading branch information
g105b committed Feb 10, 2024
1 parent 3c27070 commit f04807a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Query/SqlQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ public function injectSpecialBindings(
}

if($type === "field") {
$replacement = "`" . $bindings[$special] . "`";
$words = explode(" ", $bindings[$special]);
$words[0] = "`" . $words[0] . "`";
$replacement = implode(" ", $words);
}
elseif($type === "string") {
$replacement = "'" . $bindings[$special] . "'";
Expand Down
4 changes: 2 additions & 2 deletions test/phpunit/Query/SqlQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function testSpecialBindingsNoAscDesc(
self::assertStringNotContainsString(":limit", $injectedSql);
self::assertStringNotContainsString(":offset", $injectedSql);

self::assertStringContainsString("order by sortColumn", $injectedSql);
self::assertStringContainsString("order by `sortColumn`", $injectedSql);
self::assertStringContainsString("limit 100", $injectedSql);
self::assertStringContainsString("offset 25", $injectedSql);
}
Expand All @@ -260,7 +260,7 @@ public function testSpecialBindingsAscDesc(
"offset" => 25,
]);

self::assertStringContainsString("order by sortColumn desc", $injectedSql);
self::assertStringContainsString("order by `sortColumn` desc", $injectedSql);
}

/**
Expand Down

0 comments on commit f04807a

Please sign in to comment.