Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection DSL does not require store #2528

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,14 @@ public MongoDBConnectionParseTreeWalker(ParseTreeWalkerSourceInformation walkerS
public void visitMongoDBConnectionValue(MongoDBConnectionParserGrammar.DefinitionContext ctx, MongoDBConnection connectionValue, boolean isEmbedded)
{
// store (optional if the store is provided by embedding context, if not provided, it is required)
MongoDBConnectionParserGrammar.ConnectionStoreContext connectionStoreContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.connectionStore(), "store", connectionValue.sourceInformation);
MongoDBConnectionParserGrammar.ConnectionStoreContext connectionStoreContext = PureGrammarParserUtility.validateAndExtractOptionalField(ctx.connectionStore(), "store", connectionValue.sourceInformation);
if (connectionStoreContext != null)
{
connectionValue.element = PureGrammarParserUtility.fromQualifiedName(connectionStoreContext.qualifiedName().packagePath() == null ? Collections.emptyList() : connectionStoreContext.qualifiedName().packagePath().identifier(), connectionStoreContext.qualifiedName().identifier());
connectionValue.elementSourceInformation = this.walkerSourceInformation.getSourceInformation(connectionStoreContext.qualifiedName());
connectionValue.type = DatabaseType.MongoDb;
}
else if (!isEmbedded)
{
// Copied from service store, do we need this??
PureGrammarParserUtility.validateAndExtractRequiredField(ctx.connectionStore(), "store", connectionValue.sourceInformation);
}
// database type
connectionValue.type = DatabaseType.MongoDb;
MongoDBDatasourceSpecification dsSpecification = getMongoDBDatasourceSpecification(ctx, connectionValue);
connectionValue.dataSourceSpecification = dsSpecification;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ protected String getDuplicatedElementTestCode()
"MongoDBConnection test::mongodb::connection" +
"{\n" +
" database: legend_db;\n" +
" store: mongo::test::db;\n" +
" serverURLs: [localhost:27071];\n" +
" authentication: # UserPassword {\n" +
" username: 'mongo_ro';\n" +
Expand All @@ -47,7 +46,7 @@ protected String getDuplicatedElementTestCode()
@Override
protected String getDuplicatedElementTestExpectedErrorMessage()
{
return "COMPILATION error at [16:1-18:1]: Duplicated element 'test::mongodb::connection'";
return "COMPILATION error at [15:1-17:1]: Duplicated element 'test::mongodb::connection'";
}

@Test
Expand All @@ -60,7 +59,6 @@ public void testMongoDBConnectionDefinitionv1()
"MongoDBConnection test::testConnection\n" +
"{\n" +
" database: legend_db;\n" +
" store: meta::external::store::mongodb::showcase::store::PersonDatabase;\n" +
" serverURLs: [localhost:27071];\n" +
" authentication: # UserPassword {\n" +
" username: 'mongo_ro';\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public String getParserGrammarIdentifierInclusionTestCode(List<String> keywords)
"MongoDBConnection " + ListAdapter.adapt(keywords).makeString("::") + "\n" +
"{\n" +
" database: legend_db;\n" +
" store: mongo::test::db;\n" +
" serverURLs: [localhost:27071];\n" +
" authentication: # UserPassword {\n" +
" username: 'mongo_ro';\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ public void visitRelationalDatabaseConnectionValue(RelationalDatabaseConnectionP
connectionValue.element = PureGrammarParserUtility.fromQualifiedName(storeContext.qualifiedName().packagePath() == null ? Collections.emptyList() : storeContext.qualifiedName().packagePath().identifier(), storeContext.qualifiedName().identifier());
connectionValue.elementSourceInformation = this.walkerSourceInformation.getSourceInformation(storeContext.qualifiedName());
}
else if (!isEmbedded)
{
// non-embedded connection requires store
PureGrammarParserUtility.validateAndExtractRequiredField(ctx.connectionStore(), "store", connectionValue.sourceInformation);
}
// database type
RelationalDatabaseConnectionParserGrammar.DbTypeContext dbTypeCtx = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.dbType(), "type", connectionValue.sourceInformation);
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,6 @@ public void testForMultipleRelationalConnections()
"###Connection\n" +
"RelationalDatabaseConnection relational::graphFetch::RelationalConnection\n" +
"{\n" +
" store: relational::graphFetch::dbInc;\n" +
" type: H2;\n" +
" specification: Static\n" +
" {\n" +
Expand Down Expand Up @@ -2225,7 +2224,7 @@ public void testForMultipleRelationalConnections()
" connection_1: relational::graphFetch::OneMappingConnection\n" +
" ]\n" +
" ];\n" +
"}\n", "COMPILATION error at [90:1-108:1]: Found 2 connections against store [dbInc] under a single runtime.");
"}\n", "COMPILATION error at [89:1-107:1]: Found 2 connections against store [dbInc] under a single runtime.");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testRelationalDatabaseConnection()
test("###Connection\n" +
"RelationalDatabaseConnection meta::mySimpleConnection\n" +
"{\n" +
"}\n\n", "PARSER error at [2:1-4:1]: Field 'store' is required");
"}\n\n", "PARSER error at [2:1-4:1]: Field 'type' is required");
test("###Connection\n" +
"RelationalDatabaseConnection meta::mySimpleConnection\n" +
"{\n" +
Expand Down
Loading