[#3018] Add <outputSchemaToDefault/> to support "default schemas" during code generation

This commit is contained in:
Lukas Eder 2014-05-27 12:35:41 +02:00
parent 2d3e032a11
commit d7c07da369
3 changed files with 33 additions and 2 deletions

View File

@ -248,10 +248,14 @@ public class GenerationTool {
Database database = databaseClass.newInstance();
List<Schema> schemata = d.getSchemata();
// For convenience and backwards-compatibility, the schema configuration can be set also directly
// in the <database/> element
if (schemata.isEmpty()) {
Schema schema = new Schema();
schema.setInputSchema(trim(d.getInputSchema()));
schema.setOutputSchema(trim(d.getOutputSchema()));
schema.setOutputSchemaToDefault(d.isOutputSchemaToDefault());
schemata.add(schema);
}
else {
@ -272,7 +276,19 @@ public class GenerationTool {
schema.setInputSchema(trim(j.getSchema()));
}
if (schema.getOutputSchema() == null) {
// [#3018] Prior to <outputSchemaToDefault/>, empty <outputSchema/> elements meant that
// the outputSchema should be the default schema. This is a bit too clever, and doesn't
// work when Maven parses the XML configurations.
if ("".equals(schema.getOutputSchema())) {
log.warn("WARNING: Empty <outputSchema/> should no longer be used to model default outputSchemas. Use <outputSchemaToDefault>true</outputSchemaToDefault>, instead. See also: https://github.com/jOOQ/jOOQ/issues/3018");
}
// [#3018] If users want the output schema to be "" then, ignore the actual <outputSchema/> configuration
if (TRUE.equals(schema.isOutputSchemaToDefault())) {
schema.setOutputSchema("");
}
else if (schema.getOutputSchema() == null) {
schema.setOutputSchema(trim(schema.getInputSchema()));
}

View File

@ -410,9 +410,17 @@
production schema. Use this to override your local development
schema name for source code generation. If not specified, this
will be the same as the input-schema.
This will be ignored if outputSchemaToDefault is set to true
-->
<element name="outputSchema" type="string" minOccurs="0" maxOccurs="1" />
<!--
A flag to indicate that the outputSchema should be the "default" schema,
which generates schema-less, unqualified tables, procedures, etc.
-->
<element name="outputSchemaToDefault" type="boolean" minOccurs="0" maxOccurs="1" default="false" />
<!--
A configuration element to configure several input and/or output
schemata for jooq-meta, in case you're using jooq-meta in a multi-
@ -457,6 +465,9 @@
<!-- See also database/outputSchema -->
<element name="outputSchema" type="string" minOccurs="0" maxOccurs="1" />
<!-- See also database/outputSchemaDefault -->
<element name="outputSchemaToDefault" type="boolean" minOccurs="0" maxOccurs="1" default="false" />
</all>
</complexType>

View File

@ -4376,8 +4376,9 @@
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxx
xxxxxxxx
xxxx xxxxxxx xxxx xx xxxxxxxxxxx xx xxxxx xxx xxxxxx xxxxxxxxxxxxxxxxxx xx xxxxxx xxxxx xxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxx
xxxxxxxxxxx
xxxxxxxxxxx
@ -4388,7 +4389,10 @@
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxx
xxxx
xxxxxxx xxxx xxxxxxxxx xxxxxxxxx xxxxxxxxx xxxxxxx xx xxxxxxxxxx xxx xxx xxxxx xxxx xxxxxxxx xxx xxxxxxxxxxxxx xxx xxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxx
xxxxxxxx