Skip to content

Commit

Permalink
[BUG] Fix bad use of strripos
Browse files Browse the repository at this point in the history
It is 100% valid for strripos to return 0
we want quotes in that case for the AS blah
NEVER EVER if a strripos, always explicitly check for false!!

This was breaking jsonb text returns with mixed case aliases

Select "pt"."name"->>'en_US' AS "myDescription" from mytable pt is what we want to end up with
The replaceNamesAndAliasIn was getting ' AS myDescription' and not properly escaping it because the strripos was returning 0
  • Loading branch information
auroraeosrose authored and harikt committed Apr 25, 2023
1 parent 265abd3 commit 6f71a3b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Common/Quoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected function replaceNamesAndAliasIn($val)
{
$quoted = $this->replaceNamesIn($val);
$pos = strripos($quoted, ' AS ');
if ($pos) {
if ($pos !== false) {
$alias = $this->replaceName(substr($quoted, $pos + 4));
$quoted = substr($quoted, 0, $pos) . " AS $alias";
}
Expand Down

0 comments on commit 6f71a3b

Please sign in to comment.