Closed dgeissl closed 7 years ago
I've had a closer look at how the xml process workes out and my guess about the exampleValue was wrong.
With xml the setTarget method is called by AbstractChange#load wich iterates over all ChangeParameterMetaData
. If a value is not provided it simply sets null
.
Seems that would be some bigger rewrite of ChangeSetDelegate#makeChangeFromMap.
Another thing that comes to my mind when inspecting the code is that custom changes (implemented as individual dsl elements) isn't supported at the moment, right? https://github.com/liquibase/liquibase-groovy-dsl/blob/master/src/main/groovy/org/liquibase/groovy/delegate/ChangeSetDelegate.groovy#L550
I'll have to take a closer look at the Output change over the weekend.
As for the custom changes, you are correct that only changes that map directly to Liquibase core changes are currently supported. When Liquibase 4 comes out, I plan to use Liquibase's ParsedNode functionality to translate any arbitrary groovy method found in the DSL into a matching ParsedNode, which Liquiabse would then validate. This would make the DSL just a thin wrapper around Liquibase, and we'd be able to support updates to Liquibase without updating the DSL.
We started looking into Liquibase 4 a year ago, but I haven't seen any commits to that branch for at least 6 months...
AbstractChange#load is part of the ParsedNode parsing which I can't use as described in Issue #26.
I think the real bug here is in Liquibase itself. If Liquibase wants the default value of target
to be "STDERR", it should initialize the attribute accordingly and let others override it if needed. Or at the very least, it should be initialized to null instead of the empty string. getTarget
could even be changed to check for null or an empty string. That said, I will put a workaround for that into the groovy DSL. I'll also take a quick sweep through the current changes to see if any others have this problem.
At a quick glance, it doesn't look like any other properties of any other changes suffer from this problem. I created Issue 2998 in the Liquibase Jira system to track the underlying issue with the OutputChange.
Release 1.2.2 is out with a workaround for this issue.
With xml you can not simply use the OutputChange, but that's no problem in groovy as we are not limited by the xml validation:
however the liquibase.change.core.OutputChange does not require the target property to be set
if i extend the OutputChange class and override the getSerializedObjectNamespace method to use a different xml namespace, i can use it in xml and do not need to provide the target. If i use the output change with groovy-dsl directly (and without target) i get the following error:
So i debuged the code and found that
target
is a empty string (that s the way the class initializes the property) and notnull
or"STDERR"
. When watching thesetTarget
inOutputChange
, i can see that theChangeFactory
initializes properties with theexampleValue
from the annotation when it callscreateChangeParameterMetadata
but it seems not to be called when used from the groovy-dsl plugin.So this looks like a combination of a unclear default value in
OutputChange
and inconsistent behavior of the groovy-dsl plugin that may affect other Changes too.