Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quoting problem with cast() on postgres #157

Open
inghamn opened this issue Feb 1, 2018 · 2 comments
Open

Quoting problem with cast() on postgres #157

inghamn opened this issue Feb 1, 2018 · 2 comments

Comments

@inghamn
Copy link

inghamn commented Feb 1, 2018

I'm on postgres and am writing a select that converts an integer field to varchar, so I can compare using "like". The 2.x branch misquotes the cast structure's datatype.

<?php
$select = $this->queryFactory->newSelect();
$select->cols(['street_number'])
        ->from('addresses')
        ->where('cast(street_number as varchar) like ?', '10%');
return $select->getStatement();
SELECT
    street_number
FROM
    "addresses"
WHERE
    cast(street_number AS "varchar) like :_1_"
@auroraeosrose
Copy link
Contributor

3.x does this as well - the issue is with naive quoting on the AS statement - see

https://github.com/auraphp/Aura.SqlQuery/blob/3.x/src/Common/Quoter.php#L88

I'm doing a getStatement and regexing the fix out of the final query for now, as fixing this is not a small thing
Probably need to change the strripos check to be smarter( regex?) or change the CAST to be a pgsql specific builder

@harikt
Copy link
Member

harikt commented May 21, 2022

@auroraeosrose as you mentioned this recently, does this have the same problem for the PR #142 . Or does this resolve the issue ? If possible could you do a test on that branch ? There were some requests for releasing 3.x and I was just looking into the issues and PR's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants