Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-06 Thread Saki Takamachi
As Ayesh says, I'm starting to feel like I need to provide a completely new feature separately tbh… The following issues are completely bugs and should at least be fixed. https://github.com/php/php-src/issues/12581 Saki -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visi

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-06 Thread Saki Takamachi
Hi, I think this is probably the same problem that Matteo ran into, but when using emulate mode, pgsql errors out with code like this: ``` true, ], ); $db->exec('CREATE TABLE test2 (val BOOLEAN)'); $stmt = $db->prepare('INSERT INTO test2 VALUES(:val)'); $stmt->bindValue(':val', 1, PDO::PA

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-06 Thread Saki Takamachi
Hi Hans, > I think it'd be a good idea if they used FILTER_VALIDATE_BOOLEAN and > FILTER_VALIDATE_INTEGER type logic, with an error if conversion fails.. This can be difficult. Forcing an error is highly likely to destroy the existing user environment. > I wonder if PDO::PARAM_BOOL_OR_NULL wou

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-05 Thread Kentaro Takeda via internals
Hi, Matteo > 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). I'm sorry, this was my mistake. select 1::boolean ; -- returns `t` select 1 = true ; -- `ERR

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-05 Thread Saki Takamachi
I couldn't express myself well in English, I'm sure my words were bad. sorry. Saki -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-05 Thread Kentaro Takeda via internals
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 n

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-05 Thread Saki Takamachi
I should have said that the spec was broken, not the code. By that logic, my PR is probably broken as well. I did additional research on each DB to see if the specs were broken. Saki -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-05 Thread Saki Takamachi
Hi Matteo, > I'm sure there are several bugs w/ types in PDO. > > Perhaps some can be fixed, but I would be very careful touching that part. > > The last time I tried to fix the PDO_PARAM_INT behaviour on pdo_pgsql I broke > Laravel and surely many other projects. > > I'm afraid that most libr

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-05 Thread Hans Henrik Bergan
I think it'd be a good idea if they used FILTER_VALIDATE_BOOLEAN and FILTER_VALIDATE_INTEGER type logic, with an error if conversion fails.. I wonder if PDO::PARAM_BOOL_OR_NULL would be worthwhile On Sun, Nov 5, 2023, 10:10 Saki Takamachi wrote: > Hi, > > To think more deeply about this issue,

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-05 Thread Matteo Beccati
Hi Saki, Il 04/11/2023 07:59, Saki Takamachi ha scritto: Hi internals, As shown in the following issue, the behavior of `PDO::PARAM_` is inconsistent and I would like to fix this. https://github.com/php/php-src/issues/12603 First, I tried fixed pdo_pgsql. https://github.com/php/php-src/pu

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-05 Thread Saki Takamachi
Hi, To think more deeply about this issue, I investigated various cases in major databases. It's too big to write in an email, so I posted it in the comments of the issue. https://github.com/php/php-src/issues/12603#issuecomment-1793679776 Regards. Saki -- PHP Internals - PHP Runtime Developm

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-04 Thread Saki Takamachi
Hi Kentaro, The case you presented certainly confuses us very much. Although it is outside the scope of this discussion, it certainly seems like it would be better to improve it from a safety perspective. BOOL probably has the most problems; for example, when you pass str, the boolean value wi

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-04 Thread Kentaro Takeda via internals
Hi, internals. > As shown in the following issue, the behavior of `PDO::PARAM_` is > inconsistent and I would like to fix this. > https://github.com/php/php-src/issues/12603 I consider the current behavior a bug. And some of them contain behaviors that are very confusing to users. > It may b

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-04 Thread Saki Takamachi
Hi Hans, Thank you, I will discuss it and improve it in a way that everyone is satisfied with. Saki -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-04 Thread Hans Henrik Bergan
I had no idea PDO's PARAM_INT and PARAM_BOOL was so buggy, good catch! On Sat, Nov 4, 2023, 07:59 Saki Takamachi wrote: > Hi internals, > > As shown in the following issue, the behavior of `PDO::PARAM_` is > inconsistent and I would like to fix this. > https://github.com/php/php-src/issues/1

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-04 Thread Saki Takamachi
Hi, Ayesh, I forgot to tell you one important thing. Binding of parameters is not actually done in the `bind`method, but in the `execute()` method. Therefore, when preparing a new method, a slightly larger mechanism is required to determine which method the parameter was set through. Regar

Re: [PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-04 Thread Ayesh Karunaratne
> > Hi internals, > > As shown in the following issue, the behavior of `PDO::PARAM_` is > inconsistent and I would like to fix this. > https://github.com/php/php-src/issues/12603 > > First, I tried fixed pdo_pgsql. > https://github.com/php/php-src/pull/12605 > > Eventually I plan to make simil

[PHP-DEV] Fix the inconsistent behavior of PDO::PARAM_XXX

2023-11-04 Thread Saki Takamachi
Hi internals, As shown in the following issue, the behavior of `PDO::PARAM_` is inconsistent and I would like to fix this. https://github.com/php/php-src/issues/12603 First, I tried fixed pdo_pgsql. https://github.com/php/php-src/pull/12605 Eventually I plan to make similar changes to all b