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

Query AST analysis? #566

Closed
jakubvojacek opened this issue Mar 14, 2023 · 2 comments
Closed

Query AST analysis? #566

jakubvojacek opened this issue Mar 14, 2023 · 2 comments
Milestone

Comments

@jakubvojacek
Copy link
Contributor

Hello @staabm

how far advanced do you think the analysis is, should we start reporting issues? I get errors thrown on some more non-standard queries, such as CROSS join or queries with subqueries.

But I also tested with simple select count(*) from xx and I didnt get a RangeIntegerType. I tried digging deeper and found that it never got past this condition https://github.com/staabm/phpstan-dba/blob/main/src/SqlAst/ParserInference.php#L102 ($valueType was min: 0, max: null but it was not merged to $resultType due to hasOffsetValueType === false)

I am not sure I understand all the parts of the code to start sending PRs though.

Thanks

@staabm
Copy link
Owner

staabm commented Mar 14, 2023

hey,

thx for asking. for SQL AST to work you need to enable it in your phpstan-dba-bootstrap via RuntimeConfiguration

after thats done and you are using mysql it should work for select count(*) from xx.
I would love someone doing more testing with it.

such as CROSS join or queries with subqueries.

I have open todos regarding joins, which I have expressed here #527
if you have concrete examples and concrete expectations - at best already in form of a unit test - that would be really awesome.

But I also tested with simple select count(*) from xx and I didnt get a RangeIntegerType

please provide a reproducing case.
see https://github.com/staabm/phpstan-dba/blob/main/tests/default/data/sql-ast-narrowing.php for all already existing test-cases

@staabm staabm added this to the SQL AST milestone Mar 14, 2023
@jakubvojacek
Copy link
Contributor Author

you need to enable it in your phpstan-dba-bootstrap

yeah, I did that

please provide a reproducing case.

will try, perhaps I am still missunderstanding some parts of it and coming up with repro case will help me understand.

Thanks 👍

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

2 participants