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

unsigned int recognized as type of int<-2147483648, 2147483647> #737

Open
danrot opened this issue Jan 29, 2025 · 5 comments
Open

unsigned int recognized as type of int<-2147483648, 2147483647> #737

danrot opened this issue Jan 29, 2025 · 5 comments

Comments

@danrot
Copy link

danrot commented Jan 29, 2025

I have the following table structure (output from a SHOW CREATE TABLE statement in MySQL and omitted fields that do not matter for the issue):

CREATE TABLE `t_documents` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`),
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC

When I query that table in my code, then phpstan-dba will result in the following type:

array{id: int<-2147483648, 2147483647>}

Which I think is wrong, since the minimum value should be 0, because the id column is defined as unsigned.

I wanted to update the tests in a way that show that issue, but it took me too long... I am still willing to contribute a test and maybe even the fix, but I wanted to make sure I am not making any stupid mistakes 😅

@staabm
Copy link
Owner

staabm commented Jan 29, 2025

thanks for reporting. which database driver are you using? I guess the problem only happens for certain drivers (pdo, mysqli, doctrine/dbal,..?)

@danrot
Copy link
Author

danrot commented Jan 29, 2025

In this project we are using Doctrine DBAL, cannot tell if it also happens with other drivers as well right now.

@staabm
Copy link
Owner

staabm commented Jan 29, 2025

dbal tests are here: https://github.com/staabm/phpstan-dba/blob/main/tests/default/data/doctrine-dbal.php
the used db schema for the tests is here: https://github.com/staabm/phpstan-dba/blob/main/tests/schema.sql

I think it should be reproducible there

@uuf6429
Copy link
Contributor

uuf6429 commented Jan 29, 2025

Just thinking out loud, could it make sense to have a TypemixDoctrineDbal test? Essentially a TypemixMysql test for DoctrineDbal. Or is a case-by-case test preferred?

@staabm
Copy link
Owner

staabm commented Jan 29, 2025

sounds like a good idea

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