Unverified Commit 4d172813 authored by Sergei Morozov's avatar Sergei Morozov Committed by GitHub

Merge pull request #4167 from morozov/remove-wrapper-query-exec

Remove deprecated methods from the wrapper Connection
parents 5ceeed8c ea020aa5
# Upgrade to 3.0
## BC BREAK: removed wrapper `Connection` methods
The following methods of the `Connection` class have been removed:
1. `query()`.
2. `exec()`.
3. `executeUpdate()`.
## BC BREAK: Changes in the wrapper-level API ancestry
The wrapper-level `Connection` and `Statement` classes no longer implement the corresponding driver-level interfaces.
......@@ -50,8 +58,6 @@ The following classes have been renamed:
The following driver-level methods are allowed to throw a Driver\Exception:
- `Connection::prepare()`
- `Connection::query()`
- `Connection::exec()`
- `Connection::lastInsertId()`
- `Connection::beginTransaction()`
- `Connection::commit()`
......
......@@ -12,5 +12,5 @@ use Doctrine\DBAL\DriverManager;
'user' => 'ORACLE',
'password' => 'ORACLE',
'dbname' => 'XE',
])->query('ALTER USER ORACLE IDENTIFIED BY ORACLE');
])->executeStatement('ALTER USER ORACLE IDENTIFIED BY ORACLE');
})();
......@@ -12,7 +12,6 @@ use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\Exception as DriverException;
use Doctrine\DBAL\Driver\Result as DriverResult;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement as DriverStatement;
use Doctrine\DBAL\Exception\ConnectionLost;
......@@ -1028,48 +1027,6 @@ class Connection
return new Result($result, $this);
}
/**
* @deprecated Use {@link executeQuery()} instead.
*
* @throws DBALException
*/
public function query(string $sql): DriverResult
{
$connection = $this->getWrappedConnection();
$logger = $this->_config->getSQLLogger();
if ($logger !== null) {
$logger->startQuery($sql);
}
try {
return $connection->query($sql);
} catch (DriverException $e) {
throw $this->convertExceptionDuringQuery($e, $sql);
} finally {
if ($logger !== null) {
$logger->stopQuery();
}
}
}
/**
* Executes an SQL INSERT/UPDATE/DELETE query with the given parameters
* and returns the number of affected rows.
*
* @deprecated Use {@link executeStatement()} instead.
*
* @param string $query The SQL query.
* @param array<mixed> $params The query parameters.
* @param array<int|string|null> $types The parameter types.
*
* @throws DBALException
*/
public function executeUpdate(string $query, array $params = [], array $types = []): int
{
return $this->executeStatement($query, $params, $types);
}
/**
* Executes an SQL statement with the given parameters and returns the number of affected rows.
*
......@@ -1126,31 +1083,6 @@ class Connection
}
}
/**
* @deprecated Use {@link executeStatement()} instead.
*
* @throws DBALException
*/
public function exec(string $statement): int
{
$connection = $this->getWrappedConnection();
$logger = $this->_config->getSQLLogger();
if ($logger !== null) {
$logger->startQuery($statement);
}
try {
return $connection->exec($statement);
} catch (DriverException $e) {
throw $this->convertExceptionDuringQuery($e, $statement);
} finally {
if ($logger !== null) {
$logger->stopQuery();
}
}
}
/**
* Returns the current transaction nesting level.
*
......@@ -1436,7 +1368,7 @@ class Connection
throw ConnectionException::savepointsNotSupported();
}
$this->executeUpdate($this->platform->createSavePoint($savepoint));
$this->executeStatement($this->platform->createSavePoint($savepoint));
}
/**
......@@ -1458,7 +1390,7 @@ class Connection
return;
}
$this->executeUpdate($this->platform->releaseSavePoint($savepoint));
$this->executeStatement($this->platform->releaseSavePoint($savepoint));
}
/**
......@@ -1476,7 +1408,7 @@ class Connection
throw ConnectionException::savepointsNotSupported();
}
$this->executeUpdate($this->platform->rollbackSavePoint($savepoint));
$this->executeStatement($this->platform->rollbackSavePoint($savepoint));
}
/**
......
......@@ -9,16 +9,13 @@ use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\Exception as DriverException;
use Doctrine\DBAL\Driver\Result;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Statement;
use InvalidArgumentException;
use function array_rand;
use function assert;
use function count;
use function func_get_args;
/**
* Primary-Replica Connection
......@@ -30,9 +27,8 @@ use function func_get_args;
*
* 1. Replica if primary was never picked before and ONLY if 'getWrappedConnection'
* or 'executeQuery' is used.
* 2. Primary picked when 'exec', 'executeUpdate', 'executeStatement', 'insert', 'delete', 'update', 'createSavepoint',
* 'releaseSavepoint', 'beginTransaction', 'rollback', 'commit', 'query' or
* 'prepare' is called.
* 2. Primary picked when 'executeStatement', 'insert', 'delete', 'update', 'createSavepoint',
* 'releaseSavepoint', 'beginTransaction', 'rollback', 'commit' or 'prepare' is called.
* 3. If Primary was picked once during the lifetime of the connection it will always get picked afterwards.
* 4. One replica connection is randomly picked ONCE during a request.
*
......@@ -260,18 +256,6 @@ class PrimaryReadReplicaConnection extends Connection
return $config;
}
/**
* {@inheritDoc}
*
* @deprecated Use {@link executeStatement()} instead.
*/
public function executeUpdate(string $query, array $params = [], array $types = []): int
{
$this->ensureConnectedToPrimary();
return parent::executeUpdate($query, $params, $types);
}
/**
* {@inheritDoc}
*/
......@@ -312,16 +296,6 @@ class PrimaryReadReplicaConnection extends Connection
return parent::rollBack();
}
/**
* {@inheritDoc}
*/
public function delete($tableName, array $identifier, array $types = [])
{
$this->ensureConnectedToPrimary();
return parent::delete($tableName, $identifier, $types);
}
/**
* {@inheritDoc}
*/
......@@ -335,33 +309,6 @@ class PrimaryReadReplicaConnection extends Connection
$this->connections = ['primary' => null, 'replica' => null];
}
/**
* {@inheritDoc}
*/
public function update($tableName, array $data, array $identifier, array $types = [])
{
$this->ensureConnectedToPrimary();
return parent::update($tableName, $data, $identifier, $types);
}
/**
* {@inheritDoc}
*/
public function insert($tableName, array $data, array $types = [])
{
$this->ensureConnectedToPrimary();
return parent::insert($tableName, $data, $types);
}
public function exec(string $statement): int
{
$this->ensureConnectedToPrimary();
return parent::exec($statement);
}
/**
* {@inheritDoc}
*/
......@@ -392,27 +339,6 @@ class PrimaryReadReplicaConnection extends Connection
parent::rollbackSavepoint($savepoint);
}
public function query(string $sql): Result
{
$this->ensureConnectedToPrimary();
assert($this->_conn instanceof DriverConnection);
$args = func_get_args();
$logger = $this->getConfiguration()->getSQLLogger();
if ($logger !== null) {
$logger->startQuery($sql);
}
$statement = $this->_conn->query($sql);
if ($logger !== null) {
$logger->stopQuery();
}
return $statement;
}
public function prepare(string $sql): Statement
{
$this->ensureConnectedToPrimary();
......
......@@ -30,7 +30,7 @@ class SQLSessionInit implements EventSubscriber
*/
public function postConnect(ConnectionEventArgs $args)
{
$args->getConnection()->executeUpdate($this->sql);
$args->getConnection()->executeStatement($this->sql);
}
/**
......
......@@ -278,7 +278,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
foreach ($tableDiff->removedColumns as $col) {
$columnConstraintSql = $this->getColumnConstraintSQL($tableDiff->name, $col->getName());
foreach ($this->_conn->fetchAllAssociative($columnConstraintSql) as $constraint) {
$this->_conn->exec(
$this->_conn->executeStatement(
sprintf(
'ALTER TABLE %s DROP CONSTRAINT %s',
$tableDiff->name,
......
......@@ -28,7 +28,7 @@ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
{
foreach ($sql as $s) {
try {
$this->conn->exec($s);
$this->conn->executeStatement($s);
} catch (Throwable $e) {
}
}
......@@ -44,7 +44,7 @@ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
protected function processSql(array $sql)
{
foreach ($sql as $s) {
$this->conn->exec($s);
$this->conn->executeStatement($s);
}
}
}
......@@ -174,18 +174,6 @@ class ConnectionTest extends TestCase
*/
public static function getQueryMethods(): iterable
{
yield 'exec' => [
static function (Connection $connection, string $statement): void {
$connection->exec($statement);
},
];
yield 'query' => [
static function (Connection $connection, string $statement): void {
$connection->query($statement);
},
];
yield 'executeQuery' => [
static function (Connection $connection, string $statement): void {
$connection->executeQuery($statement);
......
......@@ -17,7 +17,7 @@ class SQLSessionInitTest extends TestCase
{
$connectionMock = $this->createMock(Connection::class);
$connectionMock->expects(self::once())
->method('executeUpdate')
->method('executeStatement')
->with(self::equalTo("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"));
$eventArgs = new ConnectionEventArgs($connectionMock);
......
......@@ -158,7 +158,7 @@ class BlobTest extends FunctionalTestCase
private function assertBlobContains(string $text): void
{
$rows = $this->connection->query('SELECT blobfield FROM blob_table')->fetchFirstColumn();
$rows = $this->connection->fetchFirstColumn('SELECT blobfield FROM blob_table');
self::assertCount(1, $rows);
......
......@@ -30,7 +30,7 @@ class ConnectionLostTest extends FunctionalTestCase
public function testConnectionLost(): void
{
$this->connection->query('SET SESSION wait_timeout=1');
$this->connection->executeStatement('SET SESSION wait_timeout=1');
sleep(2);
......
......@@ -546,7 +546,7 @@ class DataAccessTest extends FunctionalTestCase
*/
public function testBitComparisonExpressionSupport(): void
{
$this->connection->exec('DELETE FROM fetch_table');
$this->connection->executeStatement('DELETE FROM fetch_table');
$platform = $this->connection->getDatabasePlatform();
$bitmap = [];
......@@ -601,7 +601,7 @@ class DataAccessTest extends FunctionalTestCase
$this->connection->insert('fetch_table', ['test_int' => 10, 'test_string' => 'foo']);
$sql = 'SELECT test_int FROM fetch_table';
$values = $this->connection->query($sql)->fetchFirstColumn();
$values = $this->connection->fetchFirstColumn($sql);
self::assertEquals([1, 10], $values);
}
......@@ -612,9 +612,8 @@ class DataAccessTest extends FunctionalTestCase
public function testEmptyFetchOneReturnsFalse(): void
{
$this->connection->beginTransaction();
$this->connection->exec('DELETE FROM fetch_table');
$this->connection->executeStatement('DELETE FROM fetch_table');
self::assertFalse($this->connection->fetchOne('SELECT test_int FROM fetch_table'));
self::assertFalse($this->connection->query('SELECT test_int FROM fetch_table')->fetchOne());
$this->connection->rollBack();
}
......
......@@ -40,8 +40,7 @@ class ConnectionTest extends FunctionalTestCase
self::assertEquals(
$charset,
$connection->query('SHOW client_encoding')
->fetchOne()
$connection->fetchOne('SHOW client_encoding')
);
}
......
......@@ -86,7 +86,7 @@ class ExceptionTest extends FunctionalTestCase
public function testForeignKeyConstraintViolationExceptionOnInsert(): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'sqlite') {
$this->connection->exec('PRAGMA foreign_keys=ON');
$this->connection->executeStatement('PRAGMA foreign_keys=ON');
}
$this->setUpForeignKeyConstraintViolationExceptionTest();
......@@ -231,7 +231,7 @@ class ExceptionTest extends FunctionalTestCase
$table->setPrimaryKey(['id']);
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$this->expectException(Exception\NotNullConstraintViolationException::class);
......@@ -246,7 +246,7 @@ class ExceptionTest extends FunctionalTestCase
$table->addColumn('id', 'integer', []);
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$this->expectException(Exception\InvalidFieldNameException::class);
......@@ -264,7 +264,7 @@ class ExceptionTest extends FunctionalTestCase
$table2->addColumn('id', 'integer');
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$sql = 'SELECT id FROM ambiguous_list_table, ambiguous_list_table_2';
......@@ -281,7 +281,7 @@ class ExceptionTest extends FunctionalTestCase
$table->addUniqueIndex(['id']);
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$this->connection->insert('unique_field_table', ['id' => 5]);
......@@ -345,7 +345,7 @@ EOT
try {
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
$conn->exec($sql);
$conn->executeStatement($sql);
}
} finally {
$this->cleanupReadOnlyFile($filename);
......@@ -390,7 +390,7 @@ EOT
$this->expectException(Exception\ConnectionException::class);
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
$conn->exec($sql);
$conn->executeStatement($sql);
}
}
......
......@@ -35,8 +35,15 @@ class ModifyLimitQueryTest extends FunctionalTestCase
self::$tableCreated = true;
}
$this->connection->exec($this->connection->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table'));
$this->connection->exec($this->connection->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2'));
$platform = $this->connection->getDatabasePlatform();
$this->connection->executeStatement(
$platform->getTruncateTableSQL('modify_limit_table')
);
$this->connection->executeStatement(
$platform->getTruncateTableSQL('modify_limit_table2')
);
}
public function testModifyLimitQuerySimpleQuery(): void
......
......@@ -27,7 +27,7 @@ class DateExpressionTest extends FunctionalTestCase
$platform = $this->connection->getDatabasePlatform();
$sql = sprintf('SELECT %s FROM date_expr_test', $platform->getDateDiffExpression('date1', 'date2'));
$diff = $this->connection->query($sql)->fetchOne();
$diff = $this->connection->fetchOne($sql);
self::assertEquals($expected, $diff);
}
......
......@@ -62,16 +62,16 @@ class DefaultExpressionTest extends FunctionalTestCase
$table->addColumn('default_value', $type, ['default' => $defaultSql]);
$this->connection->getSchemaManager()->dropAndCreateTable($table);
$this->connection->exec(
$this->connection->executeStatement(
sprintf(
'INSERT INTO default_expr_test (actual_value) VALUES (%s)',
$defaultSql
)
);
[$actualValue, $defaultValue] = $this->connection->query(
[$actualValue, $defaultValue] = $this->connection->fetchNumeric(
'SELECT default_value, actual_value FROM default_expr_test'
)->fetchNumeric();
);
self::assertEquals($actualValue, $defaultValue);
}
......
......@@ -48,7 +48,7 @@ final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends FunctionalTestCa
$diff = (new Comparator())->compare($schema, $newSchema);
foreach ($diff->toSql($this->getPlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$validationSchema = $schemaManager->createSchema();
......
......@@ -53,7 +53,7 @@ class PortabilityTest extends FunctionalTestCase
$rows = $this->connection->fetchAllAssociative('SELECT * FROM portability_table');
$this->assertFetchResultRows($rows);
$result = $this->connection->query('SELECT * FROM portability_table');
$result = $this->connection->executeQuery('SELECT * FROM portability_table');
while (($row = $result->fetchAssociative())) {
$this->assertFetchResultRow($row);
......@@ -73,7 +73,7 @@ class PortabilityTest extends FunctionalTestCase
$rows = $this->connection->fetchAllAssociative('SELECT * FROM portability_table');
$this->assertFetchResultRows($rows);
$result = $this->connection->query('SELECT * FROM portability_table');
$result = $this->connection->executeQuery('SELECT * FROM portability_table');
while (($row = $result->fetchAssociative())) {
$this->assertFetchResultRow($row);
}
......@@ -120,7 +120,7 @@ class PortabilityTest extends FunctionalTestCase
*/
public function testFetchColumn(string $field, array $expected): void
{
$result = $this->connection->query('SELECT ' . $field . ' FROM portability_table');
$result = $this->connection->executeQuery('SELECT ' . $field . ' FROM portability_table');
$column = $result->fetchFirstColumn();
self::assertEquals($expected, $column);
......@@ -145,9 +145,8 @@ class PortabilityTest extends FunctionalTestCase
public function testFetchAllNullColumn(): void
{
$result = $this->connection->query('SELECT Test_Null FROM portability_table');
$column = $this->connection->fetchFirstColumn('SELECT Test_Null FROM portability_table');
$column = $result->fetchFirstColumn();
self::assertSame([null, null], $column);
}
}
......@@ -189,48 +189,4 @@ class PrimaryReadReplicaConnectionTest extends FunctionalTestCase
$conn->ensureConnectedToPrimary();
self::assertTrue($conn->isConnectedToPrimary());
}
public function testQueryOnPrimary(): void
{
$conn = $this->createPrimaryReadReplicaConnection();
$query = 'SELECT count(*) as num FROM primary_replica_table';
$result = $conn->query($query);
//Query must be executed only on Primary
self::assertTrue($conn->isConnectedToPrimary());
$data = $result->fetchAllAssociative();
self::assertArrayHasKey(0, $data);
self::assertArrayHasKey('num', $data[0]);
//Could be set in other fetchmodes
self::assertArrayNotHasKey(0, $data[0]);
self::assertEquals(1, $data[0]['num']);
}
public function testQueryOnReplica(): void
{
$conn = $this->createPrimaryReadReplicaConnection();
$conn->ensureConnectedToReplica();
$query = 'SELECT count(*) as num FROM primary_replica_table';
$result = $conn->query($query);
//Query must be executed only on Primary, even when we connect to the replica
self::assertTrue($conn->isConnectedToPrimary());
$data = $result->fetchAllAssociative();
self::assertArrayHasKey(0, $data);
self::assertArrayHasKey('num', $data[0]);
//Could be set in other fetchmodes
self::assertArrayNotHasKey(0, $data[0]);
self::assertEquals(1, $data[0]['num']);
}
}
......@@ -26,7 +26,7 @@ class ForeignKeyTest extends FunctionalTestCase
);
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
self::assertCount(
......
......@@ -520,7 +520,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
public function testEnsureTableOptionsAreReflectedInMetadata(): void
{
$this->connection->query('DROP TABLE IF EXISTS test_table_metadata');
$this->connection->executeStatement('DROP TABLE IF EXISTS test_table_metadata');
$sql = <<<'SQL'
CREATE TABLE test_table_metadata(
......@@ -534,7 +534,7 @@ AUTO_INCREMENT=42
PARTITION BY HASH (col1)
SQL;
$this->connection->query($sql);
$this->connection->executeStatement($sql);
$onlineTable = $this->schemaManager->listTableDetails('test_table_metadata');
self::assertEquals('InnoDB', $onlineTable->getOption('engine'));
......@@ -549,9 +549,9 @@ SQL;
public function testEnsureTableWithoutOptionsAreReflectedInMetadata(): void
{
$this->connection->query('DROP TABLE IF EXISTS test_table_empty_metadata');
$this->connection->executeStatement('DROP TABLE IF EXISTS test_table_empty_metadata');
$this->connection->query('CREATE TABLE test_table_empty_metadata(col1 INT NOT NULL)');
$this->connection->executeStatement('CREATE TABLE test_table_empty_metadata(col1 INT NOT NULL)');
$onlineTable = $this->schemaManager->listTableDetails('test_table_empty_metadata');
self::assertNotEmpty($onlineTable->getOption('engine'));
......
......@@ -28,7 +28,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
}
TestUtil::getPrivilegedConnection()
->exec('GRANT ALL PRIVILEGES TO ' . $GLOBALS['db_user']);
->executeStatement('GRANT ALL PRIVILEGES TO ' . $GLOBALS['db_user']);
self::$privilegesGranted = true;
}
......
......@@ -66,10 +66,10 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
public function testSupportDomainTypeFallback(): void
{
$createDomainTypeSQL = 'CREATE DOMAIN MyMoney AS DECIMAL(18,2)';
$this->connection->exec($createDomainTypeSQL);
$this->connection->executeStatement($createDomainTypeSQL);
$createTableSQL = 'CREATE TABLE domain_type_test (id INT PRIMARY KEY, value MyMoney)';
$this->connection->exec($createTableSQL);
$this->connection->executeStatement($createTableSQL);
$table = $this->connection->getSchemaManager()->listTableDetails('domain_type_test');
self::assertInstanceOf(DecimalType::class, $table->getColumn('value')->getType());
......@@ -154,7 +154,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
*/
public function testTableWithSchema(): void
{
$this->connection->exec('CREATE SCHEMA nested');
$this->connection->executeStatement('CREATE SCHEMA nested');
$nestedRelatedTable = new Table('nested.schemarelated');
$column = $nestedRelatedTable->addColumn('id', 'integer');
......@@ -190,10 +190,10 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
public function testReturnQuotedAssets(): void
{
$sql = 'create table dbal91_something ( id integer CONSTRAINT id_something PRIMARY KEY NOT NULL ,"table" integer );';
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
$sql = 'ALTER TABLE dbal91_something ADD CONSTRAINT something_input FOREIGN KEY( "table" ) REFERENCES dbal91_something ON UPDATE CASCADE;';
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
$table = $this->schemaManager->listTableDetails('dbal91_something');
......@@ -349,8 +349,8 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
public function testListTableDetailsWhenCurrentSchemaNameQuoted(): void
{
$this->connection->exec('CREATE SCHEMA "001_test"');
$this->connection->exec('SET search_path TO "001_test"');
$this->connection->executeStatement('CREATE SCHEMA "001_test"');
$this->connection->executeStatement('SET search_path TO "001_test"');
try {
$this->testListQuotedTable();
......
......@@ -86,7 +86,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
//TODO: SchemaDiff does not drop removed namespaces?
try {
//sql server versions below 2016 do not support 'IF EXISTS' so we have to catch the exception here
$this->connection->exec('DROP SCHEMA testschema');
$this->connection->executeStatement('DROP SCHEMA testschema');
} catch (DBALException $e) {
return;
}
......@@ -643,7 +643,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$diff->newNamespaces[] = 'testschema';
foreach ($diff->toSql($this->schemaManager->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
//test if table is create in namespace
......@@ -1440,17 +1440,17 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$this->connection->insert('test_pk_auto_increment', ['text' => '1']);
$result = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = \'1\'');
$lastUsedIdBeforeDelete = (int) $result->fetchOne();
$lastUsedIdBeforeDelete = (int) $this->connection->fetchOne(
"SELECT id FROM test_pk_auto_increment WHERE text = '1'"
);
$this->connection->query('DELETE FROM test_pk_auto_increment');
$this->connection->executeStatement('DELETE FROM test_pk_auto_increment');
$this->connection->insert('test_pk_auto_increment', ['text' => '2']);
$result = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = \'2\'');
$lastUsedIdAfterDelete = (int) $result->fetchOne();
$lastUsedIdAfterDelete = (int) $this->connection->fetchOne(
"SELECT id FROM test_pk_auto_increment WHERE text = '2'"
);
self::assertGreaterThan($lastUsedIdBeforeDelete, $lastUsedIdAfterDelete);
}
......@@ -1505,7 +1505,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$sqls = $diff->toSql($platform);
foreach ($sqls as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$schema = new Schema([
......
......@@ -77,7 +77,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
public function testListForeignKeysFromExistingDatabase(): void
{
$this->connection->exec(<<<EOS
$this->connection->executeStatement(<<<EOS
CREATE TABLE user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
page INTEGER CONSTRAINT FK_1 REFERENCES page (key) DEFERRABLE INITIALLY DEFERRED,
......@@ -165,7 +165,7 @@ CREATE TABLE dbal_1779 (
)
SQL;
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
$columns = $this->schemaManager->listTableColumns('dbal_1779');
......@@ -234,13 +234,13 @@ SQL;
$this->connection->insert('test_pk_auto_increment', ['text' => '1']);
$this->connection->query('DELETE FROM test_pk_auto_increment');
$this->connection->executeStatement('DELETE FROM test_pk_auto_increment');
$this->connection->insert('test_pk_auto_increment', ['text' => '2']);
$result = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = "2"');
$lastUsedIdAfterDelete = (int) $result->fetchOne();
$lastUsedIdAfterDelete = (int) $this->connection->fetchOne(
'SELECT id FROM test_pk_auto_increment WHERE text = "2"'
);
// with an empty table, non autoincrement rowid is always 1
self::assertEquals(1, $lastUsedIdAfterDelete);
......
......@@ -31,7 +31,7 @@ class TableGeneratorTest extends FunctionalTestCase
$schema->visit($visitor);
foreach ($schema->toSql($platform) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
} catch (Throwable $e) {
}
......
......@@ -13,7 +13,9 @@ class TemporaryTableTest extends FunctionalTestCase
{
parent::setUp();
try {
$this->connection->exec($this->connection->getDatabasePlatform()->getDropTableSQL('nontemporary'));
$this->connection->executeStatement(
$this->connection->getDatabasePlatform()->getDropTableSQL('nontemporary')
);
} catch (Throwable $e) {
}
}
......@@ -23,7 +25,9 @@ class TemporaryTableTest extends FunctionalTestCase
if ($this->connection) {
try {
$tempTable = $this->connection->getDatabasePlatform()->getTemporaryTableName('my_temporary');
$this->connection->exec($this->connection->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable));
$this->connection->executeStatement(
$this->connection->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable)
);
} catch (Throwable $e) {
}
}
......@@ -56,7 +60,9 @@ class TemporaryTableTest extends FunctionalTestCase
$this->connection->beginTransaction();
$this->connection->insert('nontemporary', ['id' => 1]);
$this->connection->exec($platform->getDropTemporaryTableSQL($tempTable));
$this->connection->executeStatement(
$platform->getDropTemporaryTableSQL($tempTable)
);
$this->connection->insert('nontemporary', ['id' => 2]);
$this->connection->rollBack();
......@@ -90,13 +96,15 @@ class TemporaryTableTest extends FunctionalTestCase
$this->connection->beginTransaction();
$this->connection->insert('nontemporary', ['id' => 1]);
$this->connection->exec($createTempTableSQL);
$this->connection->executeStatement($createTempTableSQL);
$this->connection->insert('nontemporary', ['id' => 2]);
$this->connection->rollBack();
try {
$this->connection->exec($platform->getDropTemporaryTableSQL($tempTable));
$this->connection->executeStatement(
$platform->getDropTemporaryTableSQL($tempTable)
);
} catch (Throwable $e) {
}
......
......@@ -19,7 +19,7 @@ class DBAL202Test extends FunctionalTestCase
}
if ($this->connection->getSchemaManager()->tablesExist('DBAL202')) {
$this->connection->exec('DELETE FROM DBAL202');
$this->connection->executeStatement('DELETE FROM DBAL202');
} else {
$table = new Table('DBAL202');
$table->addColumn('id', 'integer');
......@@ -36,7 +36,7 @@ class DBAL202Test extends FunctionalTestCase
$stmt->execute();
$this->connection->rollBack();
self::assertEquals(0, $this->connection->query('SELECT COUNT(1) FROM DBAL202')->fetchOne());
self::assertEquals(0, $this->connection->fetchOne('SELECT COUNT(1) FROM DBAL202'));
}
public function testStatementCommit(): void
......@@ -46,6 +46,6 @@ class DBAL202Test extends FunctionalTestCase
$stmt->execute();
$this->connection->commit();
self::assertEquals(1, $this->connection->query('SELECT COUNT(1) FROM DBAL202')->fetchOne());
self::assertEquals(1, $this->connection->fetchOne('SELECT COUNT(1) FROM DBAL202'));
}
}
......@@ -26,8 +26,8 @@ class DBAL630Test extends FunctionalTestCase
}
try {
$this->connection->exec('CREATE TABLE dbal630 (id SERIAL, bool_col BOOLEAN NOT NULL);');
$this->connection->exec('CREATE TABLE dbal630_allow_nulls (id SERIAL, bool_col BOOLEAN);');
$this->connection->executeStatement('CREATE TABLE dbal630 (id SERIAL, bool_col BOOLEAN NOT NULL);');
$this->connection->executeStatement('CREATE TABLE dbal630_allow_nulls (id SERIAL, bool_col BOOLEAN);');
} catch (DBALException $e) {
}
......
......@@ -23,7 +23,7 @@ class DBAL752Test extends FunctionalTestCase
public function testUnsignedIntegerDetection(): void
{
$this->connection->exec(<<<SQL
$this->connection->executeStatement(<<<SQL
CREATE TABLE dbal752_unsigneds (
small SMALLINT,
small_unsigned SMALLINT UNSIGNED,
......
......@@ -29,7 +29,7 @@ class TransactionTest extends FunctionalTestCase
public function testCommitFalse(): void
{
$this->connection->query('SET SESSION wait_timeout=1');
$this->connection->executeStatement('SET SESSION wait_timeout=1');
self::assertTrue($this->connection->beginTransaction());
......
......@@ -174,8 +174,9 @@ class WriteTest extends FunctionalTestCase
return strtolower($sequence->getName()) === 'write_table_id_seq';
}));
$result = $this->connection->query($this->connection->getDatabasePlatform()->getSequenceNextValSQL('write_table_id_seq'));
$nextSequenceVal = $result->fetchOne();
$nextSequenceVal = $this->connection->fetchOne(
$this->connection->getDatabasePlatform()->getSequenceNextValSQL('write_table_id_seq')
);
$lastInsertId = $this->lastInsertId('write_table_id_seq');
......@@ -276,7 +277,7 @@ class WriteTest extends FunctionalTestCase
}
foreach ($platform->getCreateTableSQL($table) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$seqName = $platform->usesSequenceEmulatedIdentityColumns()
......@@ -285,11 +286,11 @@ class WriteTest extends FunctionalTestCase
$sql = $platform->getEmptyIdentityInsertSQL('test_empty_identity', 'id');
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
$firstId = $this->lastInsertId($seqName);
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
$secondId = $this->lastInsertId($seqName);
......
......@@ -106,7 +106,7 @@ class TestUtil
$stmts = $schema->toDropSql($testConn->getDatabasePlatform());
foreach ($stmts as $stmt) {
$testConn->exec($stmt);
$testConn->executeStatement($stmt);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment