auraphp / Aura.SqlQuery

Independent query builders for MySQL, PostgreSQL, SQLite, and Microsoft SQL Server.
MIT License
452 stars 86 forks source link

[BUG] Fix bad use of strripos #206

Closed auroraeosrose closed 1 year ago

auroraeosrose commented 1 year ago

It is 100% valid for strripos to return 0 and still be considered a match 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

harikt commented 1 year ago

Hey @auroraeosrose ,

Thank you for the PR.

Can I add you to one of the maintainers. So you can also merge and release soon. I didn't find this earlier or missed for some reason. So don't want PR to wait so long.

harikt commented 1 year ago

@koriym I guess I made a mistake. We never released 4.x . So merging to 4.x was something I did wrong. I guess it should go to 3.x.

auroraeosrose commented 1 year ago

Should probably go to both if the issue exists in both branches I'd have to look at the code :)

harikt commented 1 year ago

I have pushed to 3.x, 2.x . 4.x seems not released yet.

Bug fixes are released in 2.8.1 and 3.0.0 .

Thank you.

koriym commented 1 year ago

@harikt Yes. The 3.x test covers PHP 5.6 through PHP 8.2. (We don't need the 4.x branch now, right?)

harikt commented 1 year ago

Cool. Thank you.