Skip to content

Conversation

staabm
Copy link
Owner

@staabm staabm commented Feb 13, 2023

just a ugly prototype to do the first steps and learn how sqlftw works.

the PR as narrows the return type of count() expressions to 0|positive-int in combination with the native type range

function countInference(\Dibi\Connection $conn): void
{
    $conn->fetch('SELECT count(email) as myemail, count(email) from ada');
}

relevant upstream issues

see mysql functions list at https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html

Closes #460
Closes #248

Comment on lines 120 to 121
$parserInference = new ParserInference($this->getSchemaReflection());
$resultType = $parserInference->narrowResultType($queryString, $resultType);
Copy link
Owner Author

@staabm staabm Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should make this inference disabled by default and allow to enable it via RuntimeConfiguration for now.

reasons

  • stabilize
  • sqlftw is pretty recent and therefore it should be able to disable it, to make sure we don't run into dead-ends
  • sqlftw atm requires php 7.4, so this feature does not work for all versions supported by phpstan-dba

@staabm staabm marked this pull request as ready for review February 16, 2023 21:19
@staabm staabm merged commit 7f5fc7e into main Feb 16, 2023
@staabm staabm deleted the sqlftw branch February 16, 2023 21:20
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

Successfully merging this pull request may close these issues.

COALESCE: returns int|null even if one argument is not nullable count() Should be inferred as a 0|positive-int
1 participant