Problem/Motivation

Currently depending upon how a database connection is configured the following scenarios may occur:

  • Only strings will be returned
  • Integer like strings will be returned as integers, all other results returned as strings

Neither of these methods is guaranteed to match the intended use of the result.

Steps to reproduce

N/A

Proposed resolution

All new uses of the database must explicitly cast to expected type when the record is retrieved/used

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

Comments

cmlara created an issue. See original summary.

cmlara’s picture

Never linked the related issue that describes the underlying database issue.
#3224245: Open MySQL connection using \PDO::ATTR_STRINGIFY_FETCHES can (last I looked) be overridden by supplying custom connection option.

solideogloria’s picture

Issue summary: View changes

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

donquixote’s picture

Disabling the \PDO::ATTR_STRINGIFY_FETCHES setting seems preferable over manually casting values.
But from what I understand, different database engines might return differently typed values.