Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Fix schema test for MySql #312

Merged
merged 4 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/mysqli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.1"
- "8.2"
test-args:
- "--group Database"
- "-v --group Cache"
- "-v --group Config"
- "-v --group Entity"
- "-v --group Installer"
# - "-v --group Installer"

services:
mysql:
Expand Down
35 changes: 20 additions & 15 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,46 @@ env:
DRUDBAL_DRUPAL_PROFILE: "standard"
SIMPLETEST_BASE_URL: "http://localhost:8080"
PHPUNIT_SKIP_CLASS: '[
"Drupal\\KernelTests\\Core\\Cache\\ApcuBackendTest",
"Drupal\\Tests\\file\\Functional\\DownloadTest"
"Drupal\\KernelTests\\Core\\Cache\\ApcuBackendTest"
]'

jobs:

#################################

sqlite-pdo:
name: "SQLite with PDO"
runs-on: ubuntu-20.04
mariadb-pdo:
name: "MariaDb"
runs-on: ubuntu-latest
env:
DRUDBAL_ENV: "dbal/sqlite/file"
DBAL_URL: "sqlite://localhost/sites/drudbal.sqlite"
SIMPLETEST_DB: "dbal://localhost/sites/drudbal.sqlite?module=drudbal&dbal_driver=pdo_sqlite"
DRUDBAL_ENV: "dbal/mariadb"
DBAL_URL: "mysql://root:@0.0.0.0:3306/drudbal"
SIMPLETEST_DB: "dbal://root:@0.0.0.0:3306/drudbal?module=drudbal&dbal_driver=pdo_mysql"

strategy:
fail-fast: false
matrix:
php-version:
# - "8.1"
- "8.2"
- "8.1"
# - "8.2"
test-args:
- "--group Database"
# - "--group Entity"
# - "--group Cache,Config"
# - "--group field,Field"
# - "--group file"
# - "--group views"

services:
mariadb:
image: "mariadb:10.5"
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: "drudbal"
ports:
- "3306:3306"

steps:
- name: Install PHP
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "none"
extensions: "pdo_mysql"
ini-values: "zend.assertions=1"

- name: Checkout Drupal
Expand All @@ -61,6 +65,7 @@ jobs:
- name: Install Composer dependencies
run: |
composer install --no-progress --ansi
composer config --no-plugins allow-plugins.composer/package-versions-deprecated true

- name: Composer require DruDbal from local staging
run: |
Expand Down
17 changes: 0 additions & 17 deletions src/Driver/Database/dbal/DbalExtension/AbstractMySqlExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,23 +556,6 @@ public function delegateTableExists(&$result, $drupal_table_name) {
return TRUE;
}

/**
* {@inheritdoc}
*/
public function delegateFieldExists(&$result, $drupal_table_name, $field_name) {
// The DBAL Schema manager is quite slow here.
// Instead, we try to select from the table and field in question. If it
// fails, the most likely reason is that it does not exist.
try {
$this->getDbalConnection()->executeQuery("SELECT $field_name FROM " . $this->connection->getPrefixedTableName($drupal_table_name) . " LIMIT 1 OFFSET 0");
$result = TRUE;
}
catch (\Exception $e) {
$result = FALSE;
}
return TRUE;
}

/**
* {@inheritdoc}
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Driver/Database/dbal/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -826,11 +826,11 @@ public function fieldExists($table, $column) {
//if ($xxx) dump(['fieldExists notableexist']);
return FALSE;
}
//if ($xxx) dump([
// 'fieldExists list',
// $this->dbalExtension->getDbFieldName($column, FALSE),
// array_keys($this->dbalSchemaManager->listTableColumns($this->connection()->getPrefixedTableName($table)))
//]);
/*if ($xxx) dump([
'fieldExists list',
$this->dbalExtension->getDbFieldName($column, FALSE),
array_keys($this->dbalSchemaManager->listTableColumns($this->connection()->getPrefixedTableName($table)))
]);*/
// Column name must not be quoted here.
return in_array(
$this->dbalExtension->getDbFieldName($column, FALSE),
Expand Down