I am testing the MYSQL tinyint data type on Peachpie.NET.Sdk/1.1.5 via Peachpie.Library.PDO.MySQL/1.1.5 and find out the operattor == return error results. To reproduce it, please follow the steps listed below:
Create a table with tinyint data type in MySQL db, and insert value 5 to the field address_type:
However, on Peachpie .NET, it produces incorrect results, the address_type int value is 1:
DB connected
stdClass Object ( [address_type] => System\SByte Object ( [m_value:System\SByte:private] => 5 ) [address] => Testing Road )
address_type:5
address_type intval:1
address_type is not 5
It is because the MySQL TinyInt is loaded as System\SByte in Peachpie PDO, however the conversion from SByte to int is not supported in Peachpie runtime (Peachpie.Runtime/Conversions.cs line 542):
public static long ToLong(object obj)
{
if (obj is IPhpConvertible convertible)
{
return convertible.ToLong();
}
else if (obj is decimal d)
{
// boxed System.Decimal
return (long)d;
}
else
{
PhpException.Throw(PhpError.Notice, string.Format(Resources.ErrResources.object_could_not_be_converted, PhpVariable.GetClassName(obj), PhpVariable.TypeNameInt));
return ReferenceEquals(obj, null) ? 0 : 1;
}
}
It causes lots of trouble for converting history PHP codes to Peachpie, could you please help to fix the errors in the coming version, or provide a way to bypass the issues?
I am testing the MYSQL
tinyint
data type onPeachpie.NET.Sdk/1.1.5
viaPeachpie.Library.PDO.MySQL/1.1.5
and find out the operattor==
return error results. To reproduce it, please follow the steps listed below:tinyint
data type in MySQL db, and insert value5
to the fieldaddress_type
:On PHP environment, it produces the correct result as expected, the
address_type
value is5
:However, on Peachpie .NET, it produces incorrect results, the
address_type
int value is1
:It is because the MySQL
TinyInt
is loaded asSystem\SByte
in Peachpie PDO, however the conversion fromSByte
toint
is not supported in Peachpie runtime (Peachpie.Runtime/Conversions.cs line 542):It causes lots of trouble for converting history PHP codes to Peachpie, could you please help to fix the errors in the coming version, or provide a way to bypass the issues?