@@ -245,7 +245,8 @@ CREATE TABLE sourceTable_test (
245245 },
246246 },
247247 {
248- Name : "GMS issue 2369" ,
248+ // https://github.com/dolthub/go-mysql-server/issues/2369
249+ Name : "auto_increment with self-referencing foreign key" ,
249250 SetUpScript : []string {
250251 `CREATE TABLE table1 (
251252 id int NOT NULL AUTO_INCREMENT,
@@ -278,6 +279,31 @@ CREATE TABLE sourceTable_test (
278279 },
279280 },
280281 },
282+ {
283+ // https://github.com/dolthub/go-mysql-server/issues/2349
284+ Name : "auto_increment with foreign key" ,
285+ SetUpScript : []string {
286+ "CREATE TABLE table1 (id int NOT NULL AUTO_INCREMENT primary key, name text)" ,
287+ `
288+ CREATE TABLE table2 (
289+ id int NOT NULL AUTO_INCREMENT,
290+ name text,
291+ fk int,
292+ PRIMARY KEY (id),
293+ CONSTRAINT myConstraint FOREIGN KEY (fk) REFERENCES table1 (id)
294+ )` ,
295+ },
296+ Assertions : []ScriptTestAssertion {
297+ {
298+ Query : "INSERT INTO table1 (name) VALUES ('tbl1 row 1');" ,
299+ Expected : []sql.Row {{types.OkResult {RowsAffected : 1 , InsertID : 1 }}},
300+ },
301+ {
302+ Query : "INSERT INTO table1 (name) VALUES ('tbl1 row 2');" ,
303+ Expected : []sql.Row {{types.OkResult {RowsAffected : 1 , InsertID : 2 }}},
304+ },
305+ },
306+ },
281307 {
282308 Name : "index match only exact string, no prefix" ,
283309 SetUpScript : []string {
@@ -517,30 +543,6 @@ SET entity_test.value = joined.value;`,
517543 },
518544 },
519545 },
520- {
521- Name : "GMS issue 2349" ,
522- SetUpScript : []string {
523- "CREATE TABLE table1 (id int NOT NULL AUTO_INCREMENT primary key, name text)" ,
524- `
525- CREATE TABLE table2 (
526- id int NOT NULL AUTO_INCREMENT,
527- name text,
528- fk int,
529- PRIMARY KEY (id),
530- CONSTRAINT myConstraint FOREIGN KEY (fk) REFERENCES table1 (id)
531- )` ,
532- },
533- Assertions : []ScriptTestAssertion {
534- {
535- Query : "INSERT INTO table1 (name) VALUES ('tbl1 row 1');" ,
536- Expected : []sql.Row {{types.OkResult {RowsAffected : 1 , InsertID : 1 }}},
537- },
538- {
539- Query : "INSERT INTO table1 (name) VALUES ('tbl1 row 2');" ,
540- Expected : []sql.Row {{types.OkResult {RowsAffected : 1 , InsertID : 2 }}},
541- },
542- },
543- },
544546 {
545547 Name : "missing indexes" ,
546548 SetUpScript : []string {
@@ -3675,18 +3677,6 @@ CREATE TABLE tab3 (
36753677 },
36763678 },
36773679 },
3678- {
3679- Name : "ALTER AUTO INCREMENT TABLE ADD column" ,
3680- SetUpScript : []string {
3681- "CREATE TABLE test (pk int primary key, uk int UNIQUE KEY auto_increment);" ,
3682- },
3683- Assertions : []ScriptTestAssertion {
3684- {
3685- Query : "alter table test add column j int;" ,
3686- Expected : []sql.Row {{types .NewOkResult (0 )}},
3687- },
3688- },
3689- },
36903680 {
36913681 Name : "alter json column default; from scorewarrior: https://github.com/dolthub/dolt/issues/4543" ,
36923682 SetUpScript : []string {
@@ -3897,42 +3887,6 @@ CREATE TABLE tab3 (
38973887 },
38983888 },
38993889 },
3900- {
3901- Name : "ALTER TABLE MODIFY column with multiple UNIQUE KEYS" ,
3902- Dialect : "mysql" ,
3903- SetUpScript : []string {
3904- "CREATE table test (pk int primary key, uk1 int, uk2 int, unique(uk1, uk2))" ,
3905- "ALTER TABLE `test` MODIFY column uk1 int auto_increment" ,
3906- },
3907- Assertions : []ScriptTestAssertion {
3908- {
3909- Query : "describe test" ,
3910- Expected : []sql.Row {
3911- {"pk" , "int" , "NO" , "PRI" , nil , "" },
3912- {"uk1" , "int" , "NO" , "MUL" , nil , "auto_increment" },
3913- {"uk2" , "int" , "YES" , "" , nil , "" },
3914- },
3915- },
3916- },
3917- },
3918- {
3919- Name : "ALTER TABLE MODIFY column with multiple KEYS" ,
3920- Dialect : "mysql" ,
3921- SetUpScript : []string {
3922- "CREATE table test (pk int primary key, mk1 int, mk2 int, index(mk1, mk2))" ,
3923- "ALTER TABLE `test` MODIFY column mk1 int auto_increment" ,
3924- },
3925- Assertions : []ScriptTestAssertion {
3926- {
3927- Query : "describe test" ,
3928- Expected : []sql.Row {
3929- {"pk" , "int" , "NO" , "PRI" , nil , "" },
3930- {"mk1" , "int" , "NO" , "MUL" , nil , "auto_increment" },
3931- {"mk2" , "int" , "YES" , "" , nil , "" },
3932- },
3933- },
3934- },
3935- },
39363890 {
39373891 // https://github.com/dolthub/dolt/issues/3065
39383892 Name : "join index lookups do not handle filters" ,
0 commit comments