nette / database

💾 A database layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.
https://doc.nette.org/database
Other
502 stars 107 forks source link

ActiveRow::accessColumn() returns INT value of column as a string #285

Closed forgie1 closed 2 years ago

forgie1 commented 2 years ago

Version: 3.1.3|3.1.4

Bug Description

ActiveRow::accessColumn() returns value of column of type INT as a string.

Table, for example:

CREATE TABLE `some_table` (
    `id`      INT(11)      NOT NULL AUTO_INCREMENT,
    PRIMARY KEY (`id`),
....

Expected Behavior

Value of DB column with type of integer should be returned as integer not string.

forgie1 commented 2 years ago

Version 3.1.2 if database column was datetime , than the value we have got from Nette DB was Nette\Utils\DateTime in version 3.1.4 it is plain string.

Is this new feature, or bug?

dg commented 2 years ago

Which database and PHP version?

forgie1 commented 2 years ago

The same results while tested on:

DB:

PHP:

dg commented 2 years ago

I don't know where the problem might be, because it works fine for me. There's a test for that: https://github.com/nette/database/blob/master/tests/Database/ResultSet.normalizeRow.mysql.phpt

forgie1 commented 2 years ago

Thank you, I found the problem we were overriding \Nette\Database\Connection::query() but without $rowNormalizer being set.

Since the Connection::class is not final, but many of its the properties are private, overriding it leads to a lot of code copied to the new class.