Problem/Motivation

The way I understand it, StatementWrapperLegacyTest::testClientStatementMethod()
is written to ensure that PDOStatement methods can run against $this->statement regardless of what the actual object is. The choice of the query that is executed, the choice of the method, and the actual result is arbitrary and not important, just that there is no exception thrown. The SQL Server driver will occasionally add extra columns to a database table, for example, if a column is labeled unique but is too many bytes in size for SQLServer to index against. Using Select * From {test} returns a different number of columns because of this, but the method does exist and does not error, which is what the test is trying to actually assert.

Steps to reproduce

Run the test using the Sqlsrv driver.

Proposed resolution

The query could be changed to anything. The choice of method could be changed as well. I propose changing the query to `SELECT id from {test}` and asserting that the column count is 1.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

Issue fork drupal-3213644

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Beakerboy created an issue. See original summary.

beakerboy’s picture

sqlite failures appear to be unrelated.

mondrake’s picture

Status: Active » Reviewed & tested by the community

I see the same sqlite failure on php 8.1 at #3217699: Convert select query extenders to backend-overrideable services, good to know it’s unrelated

beakerboy’s picture

daffie’s picture

+1 for RTBC. I have run the test with the MR on my local machine with SQL Server and it passes all but the test StatementWrapperLegacyTest::testMissingMethod(). To pass that test we need to change the code for the method Drupal\Core\Database\StatementWrapper::__call() to:

  public function __call($method, $arguments) {
    try {
      if (is_callable([$this->getClientStatement(), $method])) {
        @trigger_error("StatementWrapper::{$method} should not be called in drupal:9.1.0 and will error in drupal:10.0.0. Access the client-level statement object via ::getClientStatement(). See https://www.drupal.org/node/3177488", E_USER_DEPRECATED);
        return call_user_func_array([$this->getClientStatement(), $method], $arguments);
      }
    }
    catch (\PDOException $e) {
      // Do nothing.
    }
    throw new \BadMethodCallException($method);
  }

This is needed because the code is_callable([$this->getClientStatement(), $method]) will trigger a PDOException on the SQL Server.

beakerboy’s picture

@daffie Microsoft PDO throwing an exception is a bug, and is fixed in pdo_sqlsrv_5.10beta1.

daffie’s picture

@Beakerboy: Thank you for the info!

alexpott’s picture

Version: 9.1.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 8512e0e93c to 9.4.x and 9d6d526458 to 9.3.x. Thanks!

Backported to 9.3.x as a test only fix.

  • alexpott committed 8512e0e on 9.4.x
    Issue #3213644 by Beakerboy, daffie: StatementWrapperLegacyTest::...

  • alexpott committed 9d6d526 on 9.3.x
    Issue #3213644 by Beakerboy, daffie: StatementWrapperLegacyTest::...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.