Skip to content

Commit 99ec709

Browse files
committed
feat: add dynamic SQL script for schema creation and property indexing
1 parent 3b8d3c7 commit 99ec709

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

e2e/src/test/java/com/arcadedb/e2e/RemoteDatabaseJavaApiTest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.arcadedb.query.sql.executor.Result;
2525
import com.arcadedb.query.sql.executor.ResultSet;
2626
import com.arcadedb.remote.RemoteDatabase;
27+
import com.arcadedb.schema.Schema;
2728
import com.arcadedb.utility.CollectionUtils;
2829
import org.junit.jupiter.api.AfterEach;
2930
import org.junit.jupiter.api.BeforeEach;
@@ -166,6 +167,47 @@ void renameTypeAndAliases() {
166167

167168
}
168169

170+
@Test
171+
void createSchemaWithDynamicSqlScript() {
172+
database.command("sqlscript", """
173+
BEGIN;
174+
175+
LET vTypes = ['V1', 'V2', 'V3'];
176+
FOREACH ($vType IN $vTypes) {
177+
CREATE VERTEX TYPE $vType;
178+
}
179+
180+
LET eTypes = ['E1', 'E2', 'E3'];
181+
FOREACH ($eType IN $eTypes) {
182+
CREATE EDGE TYPE $eType;
183+
}
184+
185+
LET dTypes = ['D1', 'D2', 'D3'];
186+
FOREACH ($dType IN $dTypes) {
187+
CREATE DOCUMENT TYPE $dType ;
188+
}
189+
190+
LET types = ['V1', 'V2', 'V3','E1', 'E2', 'E3','D1', 'D2', 'D3'];
191+
FOREACH ($type IN $types) {
192+
CREATE PROPERTY $type.id STRING;
193+
CREATE INDEX ON $type (id) UNIQUE NULL_STRATEGY SKIP;
194+
}
195+
COMMIT;
196+
""");
197+
198+
Schema schema = database.getSchema();
199+
System.out.println("schema.toString() = " + schema.toString());
200+
assertThat(schema.existsType("V1")).isTrue();
201+
assertThat(schema.existsType("V2")).isTrue();
202+
assertThat(schema.existsType("V3")).isTrue();
203+
assertThat(schema.existsType("D1")).isTrue();
204+
assertThat(schema.existsType("D2")).isTrue();
205+
assertThat(schema.existsType("D3")).isTrue();
206+
assertThat(schema.existsType("E1")).isTrue();
207+
assertThat(schema.existsType("E2")).isTrue();
208+
assertThat(schema.existsType("E3")).isTrue();
209+
}
210+
169211
@Test
170212
@Disabled
171213
void testMultipleInsert() throws SQLException, ClassNotFoundException {

0 commit comments

Comments
 (0)