|
24 | 24 | import com.arcadedb.query.sql.executor.Result; |
25 | 25 | import com.arcadedb.query.sql.executor.ResultSet; |
26 | 26 | import com.arcadedb.remote.RemoteDatabase; |
| 27 | +import com.arcadedb.schema.Schema; |
27 | 28 | import com.arcadedb.utility.CollectionUtils; |
28 | 29 | import org.junit.jupiter.api.AfterEach; |
29 | 30 | import org.junit.jupiter.api.BeforeEach; |
@@ -166,6 +167,47 @@ void renameTypeAndAliases() { |
166 | 167 |
|
167 | 168 | } |
168 | 169 |
|
| 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 | + |
169 | 211 | @Test |
170 | 212 | @Disabled |
171 | 213 | void testMultipleInsert() throws SQLException, ClassNotFoundException { |
|
0 commit comments