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

Commit 70b7aa8

Browse files
committed
Implement "table_constraints" table in information schema
1 parent 33e6114 commit 70b7aa8

File tree

2 files changed

+256
-17
lines changed

2 files changed

+256
-17
lines changed

tests/WP_SQLite_Driver_Tests.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,6 +4739,42 @@ public function testIndexNamePrecedesConstraintName(): void {
47394739
);
47404740
}
47414741

4742+
public function testValidDuplicateConstraintNames(): void {
4743+
$this->assertQuery(
4744+
'CREATE TABLE t (
4745+
id INT,
4746+
CONSTRAINT cid PRIMARY KEY (id),
4747+
CONSTRAINT cid UNIQUE (id)
4748+
-- Not yet supported: CONSTRAINT cid CHECK (id > 0),
4749+
-- Not yet supported: CONSTRAINT cid FOREIGN KEY (id) REFERENCES t (id)
4750+
)'
4751+
);
4752+
4753+
// No exception. This table definition is valid in MySQL.
4754+
// Constraint names must be unique per constraint type, not per table.
4755+
}
4756+
4757+
public function testMultipleTablesWithSameConstraintNames(): void {
4758+
$this->assertQuery(
4759+
'CREATE TABLE t1 (
4760+
id INT,
4761+
CONSTRAINT c_primary PRIMARY KEY (id),
4762+
CONSTRAINT c_unique UNIQUE (id)
4763+
)'
4764+
);
4765+
4766+
$this->assertQuery(
4767+
'CREATE TABLE t2 (
4768+
id INT,
4769+
CONSTRAINT c_primary PRIMARY KEY (id),
4770+
CONSTRAINT c_unique UNIQUE (id)
4771+
)'
4772+
);
4773+
4774+
// No exception. This is valid in MySQL.
4775+
// Primary and unique key names must be unique per table, not per schema.
4776+
}
4777+
47424778
public function testNoBackslashEscapesSqlMode(): void {
47434779
$backslash = chr( 92 );
47444780

0 commit comments

Comments
 (0)