Re: Fix the inconsistent behavior of PDO::PARAM_XXX
| From: | Kentaro Takeda via internals | Date: | Sun, 05 Nov 2023 15:36:55 +0000 |
| Subject: | Re: Fix the inconsistent behavior of PDO::PARAM_XXX | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-121592@lists.php.net to get a copy of this message | ||
Hi, Matteo,
> The last time I tried to fix the PDO_PARAM_INT behavior on pdo_pgsql I broke Laravel and surely
> many other projects.
> https://github.com/php/php-src/pull/6801
Thank you for providing an important example.
Regarding this past issue with PostgreSQL, it can be solved by
treating numbers larger than
int4 as unknown (as is the case now)
rather than as int8 (as in previous attempts).
This approach aligns with PostgreSQL's capability to cast integer to
boolean but not smallint or bigint. This consideration is
crucial for ensuring interoperability.
````
postgres=# select 1::integer::boolean ; -- returns t
postgres=# select 1::smallint::boolean ; -- `ERROR: cannot cast type
smallint to boolean`
postgres=# select 1::bigint::boolean ; -- `ERROR: cannot cast type
bigint to boolean`
````
It is certainly not realistic to unify behavior across all databases.
Also, as in the example above, there are certainly places where each
database requires individual support.
I think it would be good if a solution could be found that would allow
for more correct behavior without breaking the behavior of existing
applications.
Your insights and contributions are interesting and invaluable. They
are much appreciated.
Best regards