From 325f6b748064007ad468735bd314d9302948b61c Mon Sep 17 00:00:00 2001 From: Dmitry Dorofeev Date: Sun, 21 Feb 2021 16:17:03 +0300 Subject: [PATCH 1/2] Added ExclusionConstraint to the MetaModel generation process. --- ...mxSQLStructuralMetamodelGenerator.class.st | 15 +++++++++++- src/FamixNGSQL/FmxSQLEntity.class.st | 7 ++++++ .../FmxSQLExclusionConstraint.class.st | 24 +++++++++++++++++++ src/FamixNGSQL/FmxSQLTable.class.st | 5 ++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/FamixNGSQL/FmxSQLExclusionConstraint.class.st diff --git a/src/FAMIXNGSQLMetamodelGenerator/FmxSQLStructuralMetamodelGenerator.class.st b/src/FAMIXNGSQLMetamodelGenerator/FmxSQLStructuralMetamodelGenerator.class.st index cc60f926..03e366c3 100644 --- a/src/FAMIXNGSQLMetamodelGenerator/FmxSQLStructuralMetamodelGenerator.class.st +++ b/src/FAMIXNGSQLMetamodelGenerator/FmxSQLStructuralMetamodelGenerator.class.st @@ -24,7 +24,8 @@ Class { 'tWithColumnReference', 'tWithTableReference', 'namespaceReference', - 'tWithNamespaceReference' + 'tWithNamespaceReference', + 'exclusionConstraint' ], #category : #FAMIXNGSQLMetamodelGenerator } @@ -107,6 +108,11 @@ FmxSQLStructuralMetamodelGenerator >> defineStructuralEntities [ newClassNamed: #CheckConstraint comment: self checkConstraintComment. checkConstraint withTesting. + exclusionConstraint := builder + newClassNamed: #ExclusionConstraint + comment: self exclusionConstraintComment. + exclusionConstraint withTesting. + primaryKeyConstraint := builder newClassNamed: #PrimaryKeyConstraint comment: self primaryKeyConstraintComment. @@ -181,6 +187,8 @@ FmxSQLStructuralMetamodelGenerator >> defineStructuralHierarchy [ type --|> structuralEntity. type --|> tAbstractType. + checkConstraint --|> constraint. + exclusionConstraint --|> constraint. primaryKeyConstraint --|> constraint. foreignKeyConstraint --|> constraint. notNullConstraint --|> constraint. @@ -261,6 +269,11 @@ FmxSQLStructuralMetamodelGenerator >> entityInNamespaceComment [ ^ 'I am a trait that any entity which can be part of a namespace use.' ] +{ #category : #'comments - SQL' } +FmxSQLStructuralMetamodelGenerator >> exclusionConstraintComment [ + ^ 'I represent an EXCLUSION constraint as defined in SQL standard.' +] + { #category : #'comments - SQL' } FmxSQLStructuralMetamodelGenerator >> foreignKeyConstraintComment [ ^ 'I represent a FOREIGN KEY constraint as defined in SQL standard.' diff --git a/src/FamixNGSQL/FmxSQLEntity.class.st b/src/FamixNGSQL/FmxSQLEntity.class.st index 9aaf79e4..48ab4cd2 100644 --- a/src/FamixNGSQL/FmxSQLEntity.class.st +++ b/src/FamixNGSQL/FmxSQLEntity.class.st @@ -102,6 +102,13 @@ FmxSQLEntity >> isExceptClause [ ^ false ] +{ #category : #testing } +FmxSQLEntity >> isExclusionConstraint [ + + + ^ false +] + { #category : #testing } FmxSQLEntity >> isForeignKey [ self deprecated: 'Use #isForeignKeyConstraint instead.' transformWith: '`@receiver isForeignKey' -> '`@receiver isForeignKeyConstraint'. diff --git a/src/FamixNGSQL/FmxSQLExclusionConstraint.class.st b/src/FamixNGSQL/FmxSQLExclusionConstraint.class.st new file mode 100644 index 00000000..cfbe0057 --- /dev/null +++ b/src/FamixNGSQL/FmxSQLExclusionConstraint.class.st @@ -0,0 +1,24 @@ +" +I represent a EXCLUSION constraint as defined in SQL standard. +" +Class { + #name : #FmxSQLExclusionConstraint, + #superclass : #FmxSQLConstraint, + #category : #'FamixNGSQL-Entities' +} + +{ #category : #meta } +FmxSQLExclusionConstraint class >> annotation [ + + + + + ^self +] + +{ #category : #testing } +FmxSQLExclusionConstraint >> isExclusionConstraint [ + + + ^ true +] diff --git a/src/FamixNGSQL/FmxSQLTable.class.st b/src/FamixNGSQL/FmxSQLTable.class.st index eff41a86..1b8a1bd2 100644 --- a/src/FamixNGSQL/FmxSQLTable.class.st +++ b/src/FamixNGSQL/FmxSQLTable.class.st @@ -87,6 +87,11 @@ FmxSQLTable >> constraintsSatisfying: aBlock [ ^ self constraints select: aBlock ] +{ #category : #accessing } +FmxSQLTable >> exclusionConstraints [ + ^ self constraintsSatisfying: [ :c | c class = FmxSQLExclusionConstraint ] +] + { #category : #accessing } FmxSQLTable >> foreignKeyConstraints [ ^ self constraintsSatisfying: [ :c | c class = FmxSQLForeignKeyConstraint ] From 7af7700305360d03f4af5292c3f73418979ec434 Mon Sep 17 00:00:00 2001 From: Dmitriy Dorofeev Date: Sun, 21 Feb 2021 16:20:42 +0300 Subject: [PATCH 2/2] Fix the update metamodel help text --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d450eebe..c1bbe125 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,4 @@ meta-model. If you modified the generator and want to re-generate the meta-model, you have to: 1. Ensure that no more instances of the meta-model exist in the system. -2. Run `FmxNewSQLMetamodelGenerator class>>#regenerateMetaModel` +2. Run `FmxSQLMetamodelGenerator generate.`