Repository navigation
core, relational: select by rules what is read from a database, written as DDL and compared - #91
Merged
Conversation
…and as text Reading a database into CWM, writing DDL from a model and comparing the two each choose their part of a model. The core now has one notion for it: a Selection of include and exclude rules on model elements, written in code as ElementRules or as text, one rule per line, <selector>:<pattern> with a leading ! to exclude, in the words of a RuleVocabulary. Selections lists the selected elements of a type or cuts a copy down to a selection; ConsequenceRules decide what a reference from what stays to what is left out brings along or removes, and the result names what was left out and retained, each with its reason. QualifiedNames and Stereotypes read names and brands; the ids of an unnamed root are alike in every locale. The relational, business information and privilege models bring their words and consequences: RelationalRules with is:constraint, is:documentary and is:materialized, BusinessInformationRules with is:comment, PrivilegeRules with is:privilege, is:role and is:user. RelationalNames is the one rule for the names of unnamed keys, constraints, indexes and triggers, and keeps the specific name a database gives an overload of a routine. Tables, ForeignKeys, SQLIndexes and the other helpers gain what the readers and writers share. The tests of the privilege loader ask a party whether it is a role or a user, as the stereotype helpers now do, and read their parties from one package. Left out: the readers and writers that use the rules, which follow, and the default of the deferrability of keys. Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
… and can be skipped CwmPackages.loadModel loads a CWM model with the files it refers to, for every plugin alike, and save writes a copy with ids built from the name path and leaves the model where it was. The goals of cwm-ecore, fennec-eorm and fennec-atlas load their models through it and can be skipped; maven/README.md describes the plugins and how they fit together. Left out: the goals of the relational tooling, which come with their own modules. Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
The relational tooling chooses its part of a catalog by the rules of the model and keeps the names the model gives. The loader reads a database into a catalog with roles, users and privileges as a selection selects, skipping a kind the selection excludes; it names what a database reports without a name by RelationalNames, binds the parameters of an overload by its specific name, leaves out the index a database makes for a foreign key and an INSTEAD OF trigger, and reads the comments SQL Server and Oracle keep apart from their drivers. The DDL generator writes create and drop scripts per SQL dialect in one order over all schemas, the drop script the exact reverse; a constraint the dialect cannot add to an existing table goes into CREATE TABLE, and each statement names its element. Users are created where the dialect has users. What a dialect cannot write as the model has it is one rule: written plainer or left out with a warning, or, with DdlSettings.strict, a failure that names every case. Materialized views, indexes over part of the rows and descending index columns are written where the dialect has them. ddl.render writes the scripts of a cut model per dialect into files. The differ compares catalogs both ways with named tolerances for what a database spells its own way, and the migration is written by the code of the create script. The Liquibase writer, the SQL resolver and the test kit follow. Round trips run on H2, PostgreSQL, MariaDB, MySQL, SQL Server, Oracle and DuckDB. Left out: the deferrability of foreign keys, the comments on views as the dialect says it keeps them, and functions and procedures, which need more of the SQL dialect API; the modules without OSGi and the Maven goals, which come with their own modules. Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
A deferrable foreign key is written DEFERRABLE INITIALLY DEFERRED or INITIALLY IMMEDIATE, in CREATE TABLE as in ALTER TABLE, where the dialect has deferrable keys, and not deferrable elsewhere, a case the dialect cannot write; the differ compares the deferrability with the key. The deferrability of unique constraints, checks and foreign keys defaults to notDeferrable, as in SQL, so INITIALLY DEFERRED is told apart from nothing stated. Whether a dialect writes a comment on a view and its columns is asked of the dialect in one place, and one code path writes the comments of tables, views and their columns. The differ compares the comments of paired views; a changed one becomes SetViewComment, and a view a migration creates brings its comments along. The loader reads the word VIEW, which MySQL and MariaDB report for every view, as no comment. Left out: functions and procedures. Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
…nd migrated A function or procedure with a body in a language the dialect writes routines in is written with CREATE FUNCTION or CREATE PROCEDURE, after the views and before the triggers: its parameters with their direction and their types by name, the type a function returns, the body as it is; the drop script drops it by its signature, and a grant on one of several overloads names it by the same types. The procedure a trigger keeps its body in comes with the trigger only. Where the dialect writes no routine in the language, cannot write a parameter, or the model does not say the type a function returns, the routine is a case the dialect cannot write, and so is a comment on a routine. The loader reads the language of a body and takes the unnamed OUT parameter Oracle and SQL Server report for the result of a function as its RETURN parameter. The differ tells routines apart by the parameters that pass values and compares the result where both state one. A migration creates, drops and replaces routines, with OR REPLACE where the dialect writes it; the Liquibase writer leaves them to the dialects. Left out: the export without OSGi, the Maven goals and the example, which come with their own modules. Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
stbischof
force-pushed
the
feature/selection
branch
from
November 13, 2026 18:21
46bfd51 to
6e4b300
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reading a database into CWM, writing DDL from a model and comparing the two each chose their part of a model in their own way: schema and table filters and include switches when reading, a list of schemas and a set of features when writing. Now one notion does it, from the util packages of the models up to the relational tooling: a
Selectionof include and exclude rules on model elements, written in code or as text, one rule per line.Commits
objectmodel.core,resource.relational,businessinformation,resource.relational.privilege).SelectionwithElementRules(name, path, kind, tag, stereotype, owner) and the text form in the words of aRuleVocabularythat the models extend:is:constraint,is:documentary,is:materialized,is:comment,is:privilege,is:role,is:user.Selectionslists what a selection selects or cuts a copy of a model down to it; consequence rules decide what a reference from what stays to what is left out brings along or removes, and the result names each element left out with its reason.QualifiedNamesandStereotypesread names and stereotypes;RelationalNamesis the one rule for the names of unnamed keys, constraints, indexes and triggers.emf/standalone,maven). Every goal ofcwm-ecore,fennec-eormandfennec-atlasloads its model throughCwmPackages.loadModeland can be skipped;CwmPackages.savewrites a copy and leaves the model where it was.maven/README.mddescribes the plugins and how they fit together.load.jdbc,load.privilege,ddl,ddl.render,diff;liquibase.render,sql.resolveand the test kit follow).DdlSettings.strict, the generation fails and names every case. Materialized views, partial indexes and descending index columns are written where the dialect has them.CatalogDiffercompares catalogs in both directions. Named tolerances, collected per database inTolerance.roundTrip(dialect), let pass what a database spells its own way. A migration is written by the same code as the create script.notDeferrable, as in SQL.Breaking
The old ways of choosing are gone:
JdbcToCwmConfigloses its schema and table filters and itsinclude…switches.Featureset.PrivilegeLoadResult.ViewBodyChangebecomesViewChange.None of this has been released.
Needs
The SQL dialect API of eclipse-daanse/org.eclipse.daanse.sql#92, published as a snapshot: deferrable foreign keys, comments on views, functions and procedures, roles.
Follows
These come separately: the module that reads a database into CWM and writes a model into it without OSGi, the Maven goals
cwm-ddl:generate,cwm-jdbc:importandcwm-jdbc:export, and an example.