Skip to content

Commit 826c7f3

Browse files
committed
Fix for test
1 parent 4a3cf57 commit 826c7f3

File tree

5 files changed

+75
-65
lines changed

5 files changed

+75
-65
lines changed

src/Platform/MySQLPlatform.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,13 @@ public function listColumns(string $table, ?string $schema = null): array
209209
$erratas['permitted_values'] = $permittedValues;
210210
}
211211

212-
[, $scale, $precision] = $this->getDataType()::extract($row['COLUMN_TYPE']);
212+
[$type, $scale, $precision] = $this->getDataType()::extract($row['COLUMN_TYPE']);
213213

214-
if ($scale !== '') {
214+
if (
215+
$scale !== ''
216+
// MSQL 8.0 remove length expr from int type
217+
&& $type !== 'int'
218+
) {
215219
$erratas['custom_length'] = rtrim($scale . ',' . $precision, ',');
216220
}
217221

src/Test/AbstractDatabaseDriverTestCase.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ protected static function importIterator(iterable $queries): void
159159
public function __destruct()
160160
{
161161
// static::$baseConn->exec('DROP DATABASE ' . static::qn(static::$dbname));
162-
163-
static::$baseConn = null;
162+
// static::$baseConn = null;
164163
}
165164

166165
/**

test/Manager/MySQLTableManagerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function testGetConstraints(): void
105105
$constraints = $this->instance->getConstraints();
106106
$constraints = array_filter($constraints, fn(Constraint $item) => $item->constraintType !== 'CHECK');
107107

108-
self::assertEquals(
108+
self::assertArraySimilar(
109109
['PRIMARY', 'idx_enterprise_alias'],
110110
array_keys($constraints)
111111
);
@@ -257,7 +257,7 @@ function () {
257257

258258
$this->instance->reset();
259259

260-
self::assertEquals(
260+
self::assertArraySimilar(
261261
[
262262
'PRIMARY',
263263
'idx_enterprise_alias',
@@ -559,7 +559,7 @@ public function testGetIndexes(): void
559559
{
560560
$indexes = array_keys($this->instance->getIndexes());
561561

562-
self::assertEquals(
562+
self::assertArraySimilar(
563563
[
564564
'PRIMARY',
565565
'idx_enterprise_alias',

test/Platform/MySQLPlatformTest.php

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function testListColumns(): void
128128
array_keys($columns[array_key_first($columns)])
129129
);
130130

131-
self::assertEquals(
131+
self::assertArraySimilar(
132132
[
133133
'id' => [
134134
'column_name' => 'id',
@@ -147,7 +147,6 @@ public function testListColumns(): void
147147
'auto_increment' => true,
148148
'erratas' => [
149149
'is_json' => false,
150-
'custom_length' => '11'
151150
],
152151
],
153152
'category_id' => [
@@ -167,7 +166,6 @@ public function testListColumns(): void
167166
'auto_increment' => false,
168167
'erratas' => [
169168
'is_json' => false,
170-
'custom_length' => '11'
171169
],
172170
],
173171
'page_id' => [
@@ -187,7 +185,6 @@ public function testListColumns(): void
187185
'auto_increment' => false,
188186
'erratas' => [
189187
'is_json' => false,
190-
'custom_length' => '11'
191188
],
192189
],
193190
'type' => [
@@ -330,7 +327,6 @@ public function testListColumns(): void
330327
'auto_increment' => false,
331328
'erratas' => [
332329
'is_json' => false,
333-
'custom_length' => '11'
334330
],
335331
],
336332
'created' => [
@@ -369,7 +365,6 @@ public function testListColumns(): void
369365
'auto_increment' => false,
370366
'erratas' => [
371367
'is_json' => false,
372-
'custom_length' => '11'
373368
],
374369
],
375370
'language' => [
@@ -423,7 +418,7 @@ public function testListConstraints(): void
423418
{
424419
$constraints = $this->instance->listConstraints('#__articles', static::$schema);
425420

426-
self::assertEquals(
421+
self::assertArraySimilar(
427422
[
428423
'PRIMARY' => [
429424
'constraint_name' => 'PRIMARY',
@@ -457,24 +452,24 @@ public function testListConstraints(): void
457452
'update_rule' => 'RESTRICT',
458453
'delete_rule' => 'RESTRICT',
459454
],
460-
'fk_articles_category_more' => [
461-
'constraint_name' => 'fk_articles_category_more',
462-
'constraint_type' => 'FOREIGN KEY',
463-
'table_name' => 'ww_articles',
464-
'columns' => [
465-
'page_id',
466-
'created_by',
467-
],
468-
'referenced_table_schema' => 'windwalker_test',
469-
'referenced_table_name' => 'ww_categories',
470-
'referenced_columns' => [
471-
'parent_id',
472-
'level',
473-
],
474-
'match_option' => 'NONE',
475-
'update_rule' => 'RESTRICT',
476-
'delete_rule' => 'RESTRICT',
477-
],
455+
// 'fk_articles_category_more' => [
456+
// 'constraint_name' => 'fk_articles_category_more',
457+
// 'constraint_type' => 'FOREIGN KEY',
458+
// 'table_name' => 'ww_articles',
459+
// 'columns' => [
460+
// 'page_id',
461+
// 'created_by',
462+
// ],
463+
// 'referenced_table_schema' => 'windwalker_test',
464+
// 'referenced_table_name' => 'ww_categories',
465+
// 'referenced_columns' => [
466+
// 'parent_id',
467+
// 'level',
468+
// ],
469+
// 'match_option' => 'NONE',
470+
// 'update_rule' => 'RESTRICT',
471+
// 'delete_rule' => 'RESTRICT',
472+
// ],
478473
],
479474
$constraints
480475
);
@@ -487,7 +482,7 @@ public function testListIndexes(): void
487482
{
488483
$indexes = $this->instance->listIndexes('#__articles', static::$schema);
489484

490-
self::assertEquals(
485+
self::assertArraySimilar(
491486
[
492487
'PRIMARY' => [
493488
'table_schema' => 'windwalker_test',
@@ -499,7 +494,9 @@ public function testListIndexes(): void
499494
'columns' => [
500495
'id' => [
501496
'column_name' => 'id',
502-
'sub_part' => null,
497+
'erratas' => [
498+
'sub_parts' => null,
499+
]
503500
],
504501
],
505502
],
@@ -513,28 +510,30 @@ public function testListIndexes(): void
513510
'columns' => [
514511
'alias' => [
515512
'column_name' => 'alias',
516-
'sub_part' => 150,
517-
],
518-
],
519-
],
520-
'fk_articles_category_more' => [
521-
'table_schema' => 'windwalker_test',
522-
'table_name' => 'ww_articles',
523-
'is_unique' => false,
524-
'is_primary' => false,
525-
'index_name' => 'fk_articles_category_more',
526-
'index_comment' => '',
527-
'columns' => [
528-
'page_id' => [
529-
'column_name' => 'page_id',
530-
'sub_part' => null,
531-
],
532-
'created_by' => [
533-
'column_name' => 'created_by',
534-
'sub_part' => null,
513+
'erratas' => [
514+
'sub_parts' => 150,
515+
]
535516
],
536517
],
537518
],
519+
// 'fk_articles_category_more' => [
520+
// 'table_schema' => 'windwalker_test',
521+
// 'table_name' => 'ww_articles',
522+
// 'is_unique' => false,
523+
// 'is_primary' => false,
524+
// 'index_name' => 'fk_articles_category_more',
525+
// 'index_comment' => '',
526+
// 'columns' => [
527+
// 'page_id' => [
528+
// 'column_name' => 'page_id',
529+
// 'sub_parts' => null,
530+
// ],
531+
// 'created_by' => [
532+
// 'column_name' => 'created_by',
533+
// 'sub_parts' => null,
534+
// ],
535+
// ],
536+
// ],
538537
'idx_articles_category_id' => [
539538
'table_schema' => 'windwalker_test',
540539
'table_name' => 'ww_articles',
@@ -545,7 +544,9 @@ public function testListIndexes(): void
545544
'columns' => [
546545
'category_id' => [
547546
'column_name' => 'category_id',
548-
'sub_part' => null,
547+
'erratas' => [
548+
'sub_parts' => null,
549+
]
549550
],
550551
],
551552
],
@@ -559,7 +560,9 @@ public function testListIndexes(): void
559560
'columns' => [
560561
'created_by' => [
561562
'column_name' => 'created_by',
562-
'sub_part' => null,
563+
'erratas' => [
564+
'sub_parts' => null,
565+
]
563566
],
564567
],
565568
],
@@ -573,7 +576,9 @@ public function testListIndexes(): void
573576
'columns' => [
574577
'language' => [
575578
'column_name' => 'language',
576-
'sub_part' => null,
579+
'erratas' => [
580+
'sub_parts' => null,
581+
]
577582
],
578583
],
579584
],
@@ -587,7 +592,9 @@ public function testListIndexes(): void
587592
'columns' => [
588593
'page_id' => [
589594
'column_name' => 'page_id',
590-
'sub_part' => null,
595+
'erratas' => [
596+
'sub_parts' => null,
597+
]
591598
],
592599
],
593600
],

test/stub/metadata/MySQL.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
DROP TABLE IF EXISTS ww_categories;
22
CREATE TABLE ww_categories
33
(
4-
id int(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
5-
parent_id int(11) UNSIGNED DEFAULT 0 NOT NULL COMMENT 'Parent ID',
4+
id int(8) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
5+
parent_id int(8) UNSIGNED DEFAULT 0 NOT NULL COMMENT 'Parent ID',
66
lft int DEFAULT 0 NOT NULL COMMENT 'Left Index',
77
rgt int DEFAULT 0 NOT NULL COMMENT 'Right key',
8-
level int(11) UNSIGNED DEFAULT 0 NOT NULL COMMENT 'Nested Level',
8+
level int(8) UNSIGNED DEFAULT 0 NOT NULL COMMENT 'Nested Level',
99
path varchar(1024) DEFAULT '' NOT NULL COMMENT 'Alias Path',
1010
type varchar(50) DEFAULT '' NOT NULL COMMENT 'Content Type',
1111
title varchar(255) DEFAULT '' NOT NULL COMMENT 'Title',
@@ -44,9 +44,9 @@ CREATE INDEX idx_categories_path
4444
DROP TABLE IF EXISTS ww_articles;
4545
CREATE TABLE ww_articles
4646
(
47-
id int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Primary Index' PRIMARY KEY,
48-
category_id int(11) UNSIGNED DEFAULT 0 NOT NULL COMMENT 'Category ID',
49-
page_id int(11) UNSIGNED DEFAULT 0 NOT NULL COMMENT 'Page ID',
47+
id int(8) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Primary Index' PRIMARY KEY,
48+
category_id int(8) UNSIGNED DEFAULT 0 NOT NULL COMMENT 'Category ID',
49+
page_id int(8) UNSIGNED DEFAULT 0 NOT NULL COMMENT 'Page ID',
5050
type enum('foo','bar','yoo') DEFAULT 'bar' NOT NULL,
5151
price decimal(20,6) UNSIGNED DEFAULT 0.0,
5252
title varchar(255) DEFAULT '' NOT NULL COMMENT 'Title',
@@ -64,8 +64,8 @@ CREATE TABLE ww_articles
6464
ALTER TABLE ww_articles ADD CONSTRAINT fk_articles_category_id
6565
FOREIGN KEY (category_id) REFERENCES ww_categories(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
6666

67-
ALTER TABLE ww_articles ADD CONSTRAINT fk_articles_category_more
68-
FOREIGN KEY (page_id, created_by) REFERENCES ww_categories(parent_id, level) ON DELETE RESTRICT ON UPDATE RESTRICT;
67+
-- ALTER TABLE ww_articles ADD CONSTRAINT fk_articles_category_more
68+
-- FOREIGN KEY (page_id, created_by) REFERENCES ww_categories(parent_id, level) ON DELETE RESTRICT ON UPDATE RESTRICT;
6969

7070
CREATE UNIQUE INDEX idx_articles_alias
7171
ON ww_articles (alias(150));

0 commit comments

Comments
 (0)