-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correctly added foreign key constraint on table create
- Loading branch information
Showing
13 changed files
with
269 additions
and
1,938 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
dbms/src/test/java/org/polypheny/db/catalog/RestoreTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2019-2023 The Polypheny Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.polypheny.db.catalog; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.polypheny.db.TestHelper; | ||
import org.polypheny.db.catalog.entity.logical.LogicalTable; | ||
|
||
@SuppressWarnings({ "SqlDialectInspection", "SqlNoDataSourceInspection" }) | ||
public class RestoreTest { | ||
|
||
|
||
private final String CONSTRAINT_CREATE = "CREATE TABLE IF NOT EXISTS constraint_test (" | ||
+ "ctid INTEGER NOT NULL, " | ||
+ "a INTEGER NOT NULL, " | ||
+ "b INTEGER NOT NULL, " | ||
+ "c INTEGER NOT NULL, " | ||
+ "PRIMARY KEY (ctid), " | ||
+ "CONSTRAINT u_a UNIQUE (a), " | ||
+ "CONSTRAINT u_ab UNIQUE (a,b))"; | ||
private final String CONSTRAINT2_CREATE = "CREATE TABLE IF NOT EXISTS constraint_test2 (" | ||
+ "ctid INTEGER NOT NULL, " | ||
+ "a INTEGER NOT NULL, " | ||
+ "b INTEGER NOT NULL, " | ||
+ "c INTEGER NOT NULL, " | ||
+ "PRIMARY KEY (ctid), " | ||
+ "FOREIGN KEY (a) REFERENCES public.constraint_test(a))"; | ||
|
||
|
||
@BeforeClass | ||
public static void setUp() { | ||
//noinspection ResultOfMethodCallIgnored | ||
TestHelper.getInstance(); | ||
} | ||
|
||
|
||
@Test | ||
public void foreignTableKeyTest() { | ||
TestHelper.executeSql( | ||
( c, s ) -> s.executeUpdate( CONSTRAINT_CREATE ), | ||
( c, s ) -> s.executeUpdate( CONSTRAINT2_CREATE ), | ||
( c, s ) -> c.commit() | ||
); | ||
LogicalTable table = Catalog.snapshot().rel().getTable( "public", "constraint_test2" ).orElseThrow(); | ||
assert Catalog.snapshot().rel().getForeignKeys( table.id ).size() == 1; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
plugins/sql-language/src/main/codegen/includes/compoundIdentifier.ftl
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.