This repository was archived by the owner on Jun 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +256
-17
lines changed Expand file tree Collapse file tree 2 files changed +256
-17
lines changed Original file line number Diff line number Diff line change @@ -4739,6 +4739,42 @@ public function testIndexNamePrecedesConstraintName(): void {
4739
4739
);
4740
4740
}
4741
4741
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
+
4742
4778
public function testNoBackslashEscapesSqlMode (): void {
4743
4779
$ backslash = chr ( 92 );
4744
4780
You can’t perform that action at this time.
0 commit comments