Skip to content

Commit 3fa21ea

Browse files
authored
Merge pull request #791 from sekikn/771-fix-sql-generation-for-either
Fix SQL generation for samm-c:Either
2 parents 3a40937 + 10e9bcb commit 3fa21ea

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/sql/databricks/AspectModelDatabricksDenormalizedSqlVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public String visitEither( final Either either, final Context context ) {
214214
.forceOptional( true )
215215
.forceDescriptionFromElement( either.getRight() )
216216
.build() );
217-
return leftResult + "\n" + ( rightResult.startsWith( " " ) ? "" : " " ) + rightResult;
217+
return leftResult + ( leftResult.isBlank() ? "" : ",\n" ) + ( rightResult.startsWith( " " ) ? "" : " " ) + rightResult;
218218
}
219219

220220
@Override

core/esmf-aspect-model-document-generators/src/test/java/org/eclipse/esmf/aspectmodel/generator/sql/databricks/AspectModelDatabricksDenormalizedSqlVisitorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ CREATE TABLE IF NOT EXISTS aspect_with_curie (
140140
void testAspectWithEither() {
141141
assertThat( sql( TestAspect.ASPECT_WITH_EITHER ) ).isEqualTo( """
142142
CREATE TABLE IF NOT EXISTS aspect_with_either (
143-
test_property__left STRING COMMENT 'Describes a Property which contains plain text. This is intended exclusively for human readable strings, not for identifiers, measurement values, etc.'
143+
test_property__left STRING COMMENT 'Describes a Property which contains plain text. This is intended exclusively for human readable strings, not for identifiers, measurement values, etc.',
144144
test_property__right BOOLEAN COMMENT 'Represents a boolean value (i.e. a "flag").'
145145
)
146146
TBLPROPERTIES ('x-samm-aspect-model-urn'='urn:samm:org.eclipse.esmf.test:1.0.0#AspectWithEither');
@@ -151,7 +151,7 @@ CREATE TABLE IF NOT EXISTS aspect_with_either (
151151
void testAspectWithEitherWithComplexTypes() {
152152
assertThat( sql( TestAspect.ASPECT_WITH_EITHER_WITH_COMPLEX_TYPES ) ).isEqualTo( """
153153
CREATE TABLE IF NOT EXISTS aspect_with_either_with_complex_types (
154-
test_property__left__result STRING COMMENT 'Left Type Characteristic'
154+
test_property__left__result STRING COMMENT 'Left Type Characteristic',
155155
test_property__right__error STRING COMMENT 'Right Type Characteristic'
156156
)
157157
TBLPROPERTIES ('x-samm-aspect-model-urn'='urn:samm:org.eclipse.esmf.test:1.0.0#AspectWithEitherWithComplexTypes');
@@ -280,7 +280,7 @@ CREATE TABLE IF NOT EXISTS aspect_with_multiple_entities_and_either (
280280
test_either_property__left__test_int INT COMMENT 'Left type Characteristic',
281281
test_either_property__left__test_float FLOAT COMMENT 'Left type Characteristic',
282282
test_either_property__left__test_local_date_time TIMESTAMP COMMENT 'Left type Characteristic',
283-
test_either_property__left__random_value STRING COMMENT 'Left type Characteristic'
283+
test_either_property__left__random_value STRING COMMENT 'Left type Characteristic',
284284
test_either_property__right__test_string STRING COMMENT 'Right type Characteristic',
285285
test_either_property__right__test_int INT COMMENT 'Right type Characteristic',
286286
test_either_property__right__test_float FLOAT COMMENT 'Right type Characteristic',

0 commit comments

Comments
 (0)