staabm / phpstan-dba

PHPStan based SQL static analysis and type inference for the database access layer
https://staabm.github.io/archive.html#phpstan-dba
MIT License
255 stars 17 forks source link

MysqlTypeMapper: add support for FLOAT types #572

Closed hemberger closed 1 year ago

hemberger commented 1 year ago

Note that, unlike DOUBLE, the FLOAT type can be either single-precision or double-precision, depending on the precision specification. See: https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html.

Since PHP floats are double precision, you could technically run into issues when passing a PHP float into a MySQL FLOAT. However, since we only have a single FloatType in PHPStan, I don't think we have the ability to account for this.

staabm commented 1 year ago

thank you

staabm commented 1 year ago

the mysqli mapper also utilizes the mysql mapper. please add another test-case for the mysqli case https://github.com/staabm/phpstan-dba/blob/90473e78a3ae303a3e5832474c8c0ede1b4ae1f4/src/TypeMapping/MysqliTypeMapper.php#L51

do you have experience with pgsql? do we need a similar change in PgsqlTypeMapper?

hemberger commented 1 year ago

do you have experience with pgsql? do we need a similar change in PgsqlTypeMapper?

The PgsqlTypeMapper already has float8 (here). I don't know if that's the same as float or float(p) though. And the documentation isn't entirely clear to me. Unfortunately I don't have any personal experience with postgresql.

staabm commented 1 year ago

thanks for looking into it. I have no personal experience either :).

@p4veI since you implemened pgsql support.. do you think we need something similar?

p4veI commented 1 year ago

@staabm hmm, it might be missing a few things, but would have to look into this. I'll try to get back up to speed with recent changes and finish what I started here..