nette/database

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

forgie1 opened this issue · 5 comments

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.

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

Which database and PHP version?

The same results while tested on:

DB:

  • 10.3.31-MariaDB
  • 10.5.8-MariaDB

PHP:

  • PHP 8.0.2 (windows 10)
  • PHP 8.0.2 (Debian GNU/Linux 10)
dg commented

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

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.