[jOOQ/jOOQ#15723] Generate comments also on other PG object types

This includes:

- [jOOQ/jOOQ#16600] Add a <commentsOnDomains/> flag
- [jOOQ/jOOQ#16601] Add more <comment/> support to jooq-meta.xsd
This commit is contained in:
Lukas Eder 2024-04-26 15:15:48 +02:00
parent 8c084188a9
commit b0d80284f4
24 changed files with 529 additions and 102 deletions

View File

@ -165,6 +165,7 @@ abstract class AbstractGenerator implements Generator {
boolean generateCommentsOnRoutines = true;
boolean generateCommentsOnSchemas = true;
boolean generateCommentsOnSequences = true;
boolean generateCommentsOnDomains = true;
boolean generateCommentsOnTables = true;
boolean generateCommentsOnUDTs = true;
boolean generateCommentsOnEmbeddables = true;
@ -1239,6 +1240,16 @@ abstract class AbstractGenerator implements Generator {
this.generateCommentsOnSequences = commentsOnSequences;
}
@Override
public boolean generateCommentsOnDomains() {
return generateComments() && generateCommentsOnDomains;
}
@Override
public void setGenerateCommentsOnDomains(boolean commentsOnDomains) {
this.generateCommentsOnDomains = commentsOnDomains;
}
@Override
public boolean generateCommentsOnTables() {
return generateComments() && generateCommentsOnTables;

View File

@ -919,6 +919,8 @@ public class GenerationTool {
generator.setGenerateCommentsOnSchemas(g.getGenerate().isCommentsOnSchemas());
if (g.getGenerate().isCommentsOnSequences() != null)
generator.setGenerateCommentsOnSequences(g.getGenerate().isCommentsOnSequences());
if (g.getGenerate().isCommentsOnDomains() != null)
generator.setGenerateCommentsOnDomains(g.getGenerate().isCommentsOnDomains());
if (g.getGenerate().isCommentsOnTables() != null)
generator.setGenerateCommentsOnTables(g.getGenerate().isCommentsOnTables());
if (g.getGenerate().isCommentsOnEmbeddables() != null)

View File

@ -1068,6 +1068,16 @@ public interface Generator {
*/
void setGenerateCommentsOnSequences(boolean commentsOnSequences);
/**
* Whether SQL comments on domains should be generated as Javadoc.
*/
boolean generateCommentsOnDomains();
/**
* Whether SQL comments on domains should be generated as Javadoc.
*/
void setGenerateCommentsOnDomains(boolean commentsOnDomains);
/**
* Whether SQL comments on tables should be generated as Javadoc.
*/

View File

@ -65,6 +65,7 @@ import static org.jooq.impl.QOM.GenerationOption.STORED;
import static org.jooq.impl.QOM.GenerationOption.VIRTUAL;
import static org.jooq.meta.AbstractTypedElementDefinition.getDataType;
import static org.jooq.tools.StringUtils.isBlank;
import static org.jooq.tools.StringUtils.isEmpty;
import java.io.File;
import java.io.IOException;
@ -3334,6 +3335,7 @@ public class JavaGenerator extends AbstractGenerator {
: null;
final String packageId = pkg == null ? null : out.ref(getStrategy().getFullJavaIdentifier(pkg), 2);
final String udtId = out.ref(getStrategy().getJavaIdentifier(udt), 2);
final String comment = comment(udt);
printPackage(out, udt);
@ -3362,10 +3364,10 @@ public class JavaGenerator extends AbstractGenerator {
if (scala) {
out.println("%sclass %s extends %s[%s](%s.name(\"%s\"), null, %s, %s)[[before= with ][separator= with ][%s]] {", visibility(), className, classExtends, recordType, DSL.class, escapeString(udt.getOutputName()), packageId, synthetic, interfaces);
out.println("%sclass %s extends %s[%s](%s.name(\"%s\"), null, %s, %s.comment(\"[[%s]]\"), %s)[[before= with ][separator= with ][%s]] {", visibility(), className, classExtends, recordType, DSL.class, escapeString(udt.getOutputName()), packageId, DSL.class, asList(escapeString(comment)), synthetic, interfaces);
}
else if (kotlin) {
out.println("%sopen class %s : %s<%s>(%s.name(\"%s\"), null, %s, %s)[[before=, ][%s]] {", visibility(), className, classExtends, recordType, DSL.class, escapeString(udt.getOutputName()), packageId, synthetic, interfaces);
out.println("%sopen class %s : %s<%s>(%s.name(\"%s\"), null, %s, %s.comment(\"[[%s]]\"), %s)[[before=, ][%s]] {", visibility(), className, classExtends, recordType, DSL.class, escapeString(udt.getOutputName()), packageId, DSL.class, asList(escapeString(comment)), synthetic, interfaces);
out.println();
out.println("public companion object {");
@ -3433,7 +3435,7 @@ public class JavaGenerator extends AbstractGenerator {
else {
out.javadoc(NO_FURTHER_INSTANCES_ALLOWED);
out.println("private %s() {", className);
out.println("super(%s.name(\"%s\"), null, %s, %s);", DSL.class, udt.getOutputName(), packageId, synthetic);
out.println("super(%s.name(\"%s\"), null, %s, %s.comment(\"[[%s]]\"), %s);", DSL.class, udt.getOutputName(), packageId, DSL.class, asList(escapeString(comment)), synthetic);
out.println("}");
}
@ -3837,13 +3839,18 @@ public class JavaGenerator extends AbstractGenerator {
final String domainTypeRef = getJavaTypeReference(domain.getDatabase(), domain.getType(resolver(out)), out);
final List<String> converter = out.ref(list(domain.getType(resolver(out)).getConverter()));
final List<String> binding = out.ref(list(domain.getType(resolver(out)).getBinding()));
final String comment = comment(domain);
out.javadocAndAnnotations(domain, "The domain <code>%s</code>.", domain.getQualifiedOutputName());
if (generateCommentsOnDomains() && !isEmpty(comment))
out.javadocAndAnnotations(domain, comment);
else
out.javadocAndAnnotations(domain, "The domain <code>%s</code>.", domain.getQualifiedOutputName());
if (scala) {
out.println("%sval %s: %s[%s] = %s.createDomain(", visibility(), scalaWhitespaceSuffix(id), Domain.class, domainType, Internal.class);
out.println(" %s", schemaId != null ? "schema" : null);
out.println(", %s.name(\"%s\")", DSL.class, escapeString(domain.getOutputName()));
out.println(", %s.comment(\"[[%s]]\")", DSL.class, asList(escapeString(comment)));
out.println(", %s", domainTypeRef);
if (!converter.isEmpty() || !binding.isEmpty())
out.println(converterTemplate(converter) + converterTemplate(binding), converter, binding);
@ -3857,6 +3864,7 @@ public class JavaGenerator extends AbstractGenerator {
out.println("%sval %s: %s<%s> = %s.createDomain(", visibility(), id, Domain.class, domainType, Internal.class);
out.println(" %s", schemaId != null ? "schema()" : null);
out.println(", %s.name(\"%s\")", DSL.class, escapeString(domain.getOutputName()));
out.println(", %s.comment(\"[[%s]]\")", DSL.class, asList(escapeString(comment)));
out.println(", %s", domainTypeRef);
if (!converter.isEmpty() || !binding.isEmpty())
out.println(converterTemplate(converter) + converterTemplate(binding), converter, binding);
@ -3871,6 +3879,7 @@ public class JavaGenerator extends AbstractGenerator {
out.println("%sstatic final %s<%s> %s = %s.createDomain(", visibility(), Domain.class, domainType, id, Internal.class);
out.println(" %s", schemaId != null ? "schema()" : null);
out.println(", %s.name(\"%s\")", DSL.class, escapeString(domain.getOutputName()));
out.println(", %s.comment(\"[[%s]]\")", DSL.class, asList(escapeString(comment)));
out.println(", %s", domainTypeRef);
if (!converter.isEmpty() || !binding.isEmpty())
out.println(converterTemplate(converter) + converterTemplate(binding), converter, binding);
@ -8243,14 +8252,18 @@ public class JavaGenerator extends AbstractGenerator {
? out.ref(getStrategy().getFullJavaIdentifier(schema), 2)
: null;
final String typeRef = getJavaTypeReference(sequence.getDatabase(), sequence.getType(resolver(out)), out);
final String comment = comment(sequence);
if (!printDeprecationIfUnknownType(out, seqTypeFull))
out.javadocAndAnnotations(sequence, "The sequence <code>%s</code>", sequence.getQualifiedOutputName());
if (generateCommentsOnSequences() && !isEmpty(comment))
out.javadocAndAnnotations(sequence, comment);
else
out.javadocAndAnnotations(sequence, "The sequence <code>%s</code>", sequence.getQualifiedOutputName());
boolean flags = generateSequenceFlags();
if (scala)
out.println("%sval %s: %s[%s] = %s.createSequence(\"%s\", %s, %s, %s, %s, %s, %s, %s, %s)",
out.println("%sval %s: %s[%s] = %s.createSequence(\"%s\", %s, %s.comment(\"[[%s]]\"), %s, %s, %s, %s, %s, %s, %s)",
visibility(),
scalaWhitespaceSuffix(seqId),
Sequence.class,
@ -8258,6 +8271,8 @@ public class JavaGenerator extends AbstractGenerator {
Internal.class,
seqName,
schemaId,
DSL.class,
asList(escapeString(comment)),
typeRef,
flags ? numberLiteral(sequence.getStartWith()) : "null",
flags ? numberLiteral(sequence.getIncrementBy()) : "null",
@ -8267,7 +8282,7 @@ public class JavaGenerator extends AbstractGenerator {
flags ? numberLiteral(sequence.getCache()) : "null"
);
else if (kotlin)
out.println("%sval %s: %s<%s> = %s.createSequence(\"%s\", %s, %s, %s, %s, %s, %s, %s, %s)",
out.println("%sval %s: %s<%s> = %s.createSequence(\"%s\", %s, %s.comment(\"[[%s]]\"), %s, %s, %s, %s, %s, %s, %s)",
visibility(),
seqId,
Sequence.class,
@ -8275,6 +8290,8 @@ public class JavaGenerator extends AbstractGenerator {
Internal.class,
seqName,
schemaId,
DSL.class,
asList(escapeString(comment)),
typeRef,
flags ? numberLiteral(sequence.getStartWith()) : "null",
flags ? numberLiteral(sequence.getIncrementBy()) : "null",
@ -8284,7 +8301,7 @@ public class JavaGenerator extends AbstractGenerator {
flags ? numberLiteral(sequence.getCache()) : "null"
);
else
out.println("%sstatic final %s<%s> %s = %s.createSequence(\"%s\", %s, %s, %s, %s, %s, %s, %s, %s);",
out.println("%sstatic final %s<%s> %s = %s.createSequence(\"%s\", %s, %s.comment(\"[[%s]]\"), %s, %s, %s, %s, %s, %s, %s);",
visibility(),
Sequence.class,
seqType,
@ -8292,6 +8309,8 @@ public class JavaGenerator extends AbstractGenerator {
Internal.class,
seqName,
schemaId,
DSL.class,
asList(escapeString(comment)),
typeRef,
flags ? numberLiteral(sequence.getStartWith()) : "null",
flags ? numberLiteral(sequence.getIncrementBy()) : "null",
@ -8687,6 +8706,7 @@ public class JavaGenerator extends AbstractGenerator {
final String className = getStrategy().getJavaClassName(schema);
final String classExtends = out.ref(getStrategy().getJavaClassExtends(schema));
final List<String> interfaces = out.ref(getStrategy().getJavaClassImplements(schema, Mode.DEFAULT));
final String comment = comment(schema);
printPackage(out, schema);
@ -8702,12 +8722,12 @@ public class JavaGenerator extends AbstractGenerator {
printClassAnnotations(out, schema, Mode.DEFAULT);
if (scala) {
out.println("%sclass %s extends %s(\"%s\", %s)[[before= with ][separator= with ][%s]] {",
visibility(), className, classExtends, escapeString(schema.getOutputName()), catalogId, interfaces);
out.println("%sclass %s extends %s(%s.name(\"%s\"), %s, %s.comment(\"[[%s]]\"))[[before= with ][separator= with ][%s]] {",
visibility(), className, classExtends, DSL.class, escapeString(schema.getOutputName()), catalogId, DSL.class, asList(escapeString(comment)), interfaces);
}
else if (kotlin) {
out.println("%sopen class %s : %s(\"%s\", %s)[[before=, ][%s]] {",
visibility(), className, classExtends, escapeString(schema.getOutputName()), catalogId, interfaces);
out.println("%sopen class %s : %s(%s.name(\"%s\"), %s, %s.comment(\"[[%s]]\"))[[before=, ][%s]] {",
visibility(), className, classExtends, DSL.class, escapeString(schema.getOutputName()), catalogId, DSL.class, asList(escapeString(comment)), interfaces);
out.println("public companion object {");
out.javadoc("The reference instance of <code>%s</code>", schemaName);
@ -8758,7 +8778,7 @@ public class JavaGenerator extends AbstractGenerator {
if (!scala && !kotlin) {
out.javadoc(NO_FURTHER_INSTANCES_ALLOWED);
out.println("private %s() {", className);
out.println("super(\"%s\", null);", escapeString(schema.getOutputName()));
out.println("super(%s.name(\"%s\"), null, %s.comment(\"[[%s]]\"));", DSL.class, escapeString(schema.getOutputName()), DSL.class, asList(escapeString(comment)));
out.println("}");
}
@ -9427,6 +9447,7 @@ public class JavaGenerator extends AbstractGenerator {
? out.ref(getStrategy().getFullJavaIdentifier(schema), 2)
: null;
final List<String> packageId = out.ref(getStrategy().getFullJavaIdentifiers(routine.getPackage()), 2);
final String comment = comment(routine);
printPackage(out, routine);
@ -9460,13 +9481,13 @@ public class JavaGenerator extends AbstractGenerator {
printClassAnnotations(out, routine, Mode.DEFAULT);
if (scala) {
out.println("%sclass %s extends %s[%s](\"%s\", %s[[before=, ][%s]][[before=, ][%s]]" + converterTemplate(returnConverter) + converterTemplate(returnBinding) + ")[[before= with ][separator= with ][%s]] {",
visibility(), className, classExtends, returnType, escapeString(routine.getName()), schemaId, packageId, returnTypeRef, returnConverter, returnBinding, interfaces);
out.println("%sclass %s extends %s[%s](\"%s\", %s[[before=, ][%s]], %s.comment(\"[[%s]]\")[[before=, ][%s]]" + converterTemplate(returnConverter) + converterTemplate(returnBinding) + ")[[before= with ][separator= with ][%s]] {",
visibility(), className, classExtends, returnType, escapeString(routine.getName()), schemaId, packageId, DSL.class, asList(escapeString(comment)), returnTypeRef, returnConverter, returnBinding, interfaces);
}
else {
if (kotlin) {
out.println("%sopen class %s : %s<%s>(\"%s\", %s[[before=, ][%s]][[before=, ][%s]]" + converterTemplate(returnConverter) + converterTemplate(returnBinding) + ")[[before=, ][%s]] {",
visibility(), className, classExtends, returnType, escapeString(routine.getName()), schemaId, packageId, returnTypeRef, returnConverter, returnBinding, interfaces);
out.println("%sopen class %s : %s<%s>(\"%s\", %s[[before=, ][%s]], %s.comment(\"[[%s]]\")[[before=, ][%s]]" + converterTemplate(returnConverter) + converterTemplate(returnBinding) + ")[[before=, ][%s]] {",
visibility(), className, classExtends, returnType, escapeString(routine.getName()), schemaId, packageId, DSL.class, asList(escapeString(comment)), returnTypeRef, returnConverter, returnBinding, interfaces);
}
else {
out.println("%sclass %s extends %s<%s>[[before= implements ][%s]] {",
@ -9512,7 +9533,8 @@ public class JavaGenerator extends AbstractGenerator {
else {
out.javadoc("Create a new routine call instance");
out.println("%s%s() {", visibility(), className);
out.println("super(\"%s\", %s[[before=, ][%s]][[before=, ][%s]]" + converterTemplate(returnConverter) + converterTemplate(returnBinding) + ");", routine.getName(), schemaId, packageId, returnTypeRef, returnConverter, returnBinding);
out.println("super(\"%s\", %s[[before=, ][%s]], %s.comment(\"[[%s]]\")[[before=, ][%s]]" + converterTemplate(returnConverter) + converterTemplate(returnBinding) + ");",
routine.getName(), schemaId, packageId, DSL.class, asList(escapeString(comment)), returnTypeRef, returnConverter, returnBinding);
if (routine.getAllParameters().size() > 0)
@ -10211,11 +10233,13 @@ public class JavaGenerator extends AbstractGenerator {
|| definition instanceof ColumnDefinition && generateCommentsOnColumns()
|| definition instanceof EmbeddableDefinition && generateCommentsOnEmbeddables()
|| definition instanceof UDTDefinition && generateCommentsOnUDTs()
|| definition instanceof EnumDefinition && generateCommentsOnUDTs()
|| definition instanceof AttributeDefinition && generateCommentsOnAttributes()
|| definition instanceof PackageDefinition && generateCommentsOnPackages()
|| definition instanceof RoutineDefinition && generateCommentsOnRoutines()
|| definition instanceof ParameterDefinition && generateCommentsOnParameters()
|| definition instanceof SequenceDefinition && generateCommentsOnSequences()
|| definition instanceof DomainDefinition && generateCommentsOnDomains()
? StringUtils.defaultIfBlank(definition.getComment(), "")
: "";
}

View File

@ -47,14 +47,11 @@ import static org.jooq.Log.Level.ERROR;
// ...
import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.FIREBIRD;
// ...
import static org.jooq.SQLDialect.SQLITE;
// ...
import static org.jooq.impl.DSL.case_;
import static org.jooq.impl.DSL.count;
import static org.jooq.impl.DSL.falseCondition;
import static org.jooq.impl.DSL.field;
import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.noCondition;
import static org.jooq.impl.DSL.one;
import static org.jooq.impl.DSL.partitionBy;
@ -62,7 +59,6 @@ import static org.jooq.impl.DSL.rowNumber;
import static org.jooq.impl.DSL.table;
import static org.jooq.impl.DSL.when;
import static org.jooq.meta.AbstractTypedElementDefinition.customType;
import static org.jooq.meta.hsqldb.information_schema.Tables.TRIGGERS;
import static org.jooq.tools.StringUtils.defaultIfBlank;
import static org.jooq.tools.StringUtils.defaultIfEmpty;
import static org.jooq.tools.StringUtils.defaultIfNull;
@ -121,10 +117,10 @@ import org.jooq.Schema;
import org.jooq.Select;
import org.jooq.Table;
import org.jooq.TableField;
// ...
// ...
// ...
import org.jooq.TableOptions.TableType;
// ...
// ...
// ...
import org.jooq.conf.ParseWithMetaLookups;
import org.jooq.conf.RenderQuotedNames;
import org.jooq.exception.DataAccessException;
@ -133,7 +129,6 @@ import org.jooq.impl.DSL;
import org.jooq.impl.ParserException;
import org.jooq.impl.QOM;
import org.jooq.impl.SQLDataType;
import org.jooq.meta.hsqldb.information_schema.tables.Triggers;
import org.jooq.meta.jaxb.CatalogMappingType;
import org.jooq.meta.jaxb.CommentType;
import org.jooq.meta.jaxb.CustomType;
@ -1885,6 +1880,26 @@ public abstract class AbstractDatabase implements Database {
return filterSchema(getSequences(), schema, sequencesBySchema);
}
@Override
public final SequenceDefinition getSequence(SchemaDefinition schema, String name) {
return getSequence(schema, name, false);
}
@Override
public final SequenceDefinition getSequence(SchemaDefinition schema, String name, boolean ignoreCase) {
return getDefinition(getSequences(schema), name, ignoreCase);
}
@Override
public final SequenceDefinition getSequence(SchemaDefinition schema, Name name) {
return getSequence(schema, name, false);
}
@Override
public final SequenceDefinition getSequence(SchemaDefinition schema, Name name, boolean ignoreCase) {
return getDefinition(getSequences(schema), name, ignoreCase);
}
@Override
public final List<IdentityDefinition> getIdentities(SchemaDefinition schema) {
if (identities == null) {
@ -3174,6 +3189,26 @@ public abstract class AbstractDatabase implements Database {
return filterSchema(routines, schema, routinesBySchema);
}
@Override
public final RoutineDefinition getRoutine(SchemaDefinition schema, String name) {
return getRoutine(schema, name, false);
}
@Override
public final RoutineDefinition getRoutine(SchemaDefinition schema, String name, boolean ignoreCase) {
return getDefinition(getRoutines(schema), name, ignoreCase);
}
@Override
public final RoutineDefinition getRoutine(SchemaDefinition schema, Name name) {
return getRoutine(schema, name, false);
}
@Override
public final RoutineDefinition getRoutine(SchemaDefinition schema, Name name, boolean ignoreCase) {
return getDefinition(getRoutines(schema), name, ignoreCase);
}
@Override
public final List<PackageDefinition> getPackages(SchemaDefinition schema) {
if (packages == null) {
@ -4048,15 +4083,31 @@ public abstract class AbstractDatabase implements Database {
if (schema != null) {
String name = r.value3();
Definition o = getTable(schema, name);
Definition o = null;
if (o != null) {
if (!isEmpty(r.value4()))
if (o instanceof TableDefinition t)
o = t.getColumn(r.value4());
result.put(o, r.value5());
if (isEmpty(name)) {
o = schema;
}
else {
o = getTable(schema, name);
if (o != null && !isEmpty(r.value4())) {
o = ((TableDefinition) o).getColumn(r.value4());
}
else {
if (o == null)
o = getDomain(schema, name);
if (o == null)
o = getRoutine(schema, name);
if (o == null)
o = getSequence(schema, name);
if (o == null)
o = getUDT(schema, name);
}
}
if (o != null)
result.put(o, r.value5());
}
}));
}

View File

@ -144,6 +144,26 @@ public interface Database extends AutoCloseable {
*/
List<SequenceDefinition> getSequences(SchemaDefinition schema);
/**
* Get a sequence in this database by name.
*/
SequenceDefinition getSequence(SchemaDefinition schema, String name);
/**
* Get a sequence in this database by name.
*/
SequenceDefinition getSequence(SchemaDefinition schema, String name, boolean ignoreCase);
/**
* Get a sequence in this database by name.
*/
SequenceDefinition getSequence(SchemaDefinition schema, Name name);
/**
* Get a sequence in this database by name.
*/
SequenceDefinition getSequence(SchemaDefinition schema, Name name, boolean ignoreCase);
/**
* The identities contained in this database.
*/
@ -421,6 +441,26 @@ public interface Database extends AutoCloseable {
*/
List<RoutineDefinition> getRoutines(SchemaDefinition schema);
/**
* Get a routine in this database by name.
*/
RoutineDefinition getRoutine(SchemaDefinition schema, String name);
/**
* Get a routine in this database by name.
*/
RoutineDefinition getRoutine(SchemaDefinition schema, String name, boolean ignoreCase);
/**
* Get a routine in this database by name.
*/
RoutineDefinition getRoutine(SchemaDefinition schema, Name name);
/**
* Get a routine in this database by name.
*/
RoutineDefinition getRoutine(SchemaDefinition schema, Name name, boolean ignoreCase);
/**
* The packages contained in this database.
*/

View File

@ -215,6 +215,8 @@ public class Generate implements Serializable, XMLAppendable
@XmlElement(defaultValue = "true")
protected Boolean commentsOnSequences = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnDomains = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnLinks = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnQueues = true;
@ -2453,6 +2455,30 @@ public class Generate implements Serializable, XMLAppendable
this.commentsOnSequences = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all domains.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnDomains() {
return commentsOnDomains;
}
/**
* Turn off generation of all SQL comments as Javadoc on all domains.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnDomains(Boolean value) {
this.commentsOnDomains = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all links.
*
@ -3967,6 +3993,15 @@ public class Generate implements Serializable, XMLAppendable
return this;
}
/**
* Turn off generation of all SQL comments as Javadoc on all domains.
*
*/
public Generate withCommentsOnDomains(Boolean value) {
setCommentsOnDomains(value);
return this;
}
/**
* Turn off generation of all SQL comments as Javadoc on all links.
*
@ -4344,6 +4379,7 @@ public class Generate implements Serializable, XMLAppendable
builder.append("commentsOnRoutines", commentsOnRoutines);
builder.append("commentsOnParameters", commentsOnParameters);
builder.append("commentsOnSequences", commentsOnSequences);
builder.append("commentsOnDomains", commentsOnDomains);
builder.append("commentsOnLinks", commentsOnLinks);
builder.append("commentsOnQueues", commentsOnQueues);
builder.append("commentsOnKeys", commentsOnKeys);
@ -5212,6 +5248,15 @@ public class Generate implements Serializable, XMLAppendable
return false;
}
}
if (commentsOnDomains == null) {
if (other.commentsOnDomains!= null) {
return false;
}
} else {
if (!commentsOnDomains.equals(other.commentsOnDomains)) {
return false;
}
}
if (commentsOnLinks == null) {
if (other.commentsOnLinks!= null) {
return false;
@ -5562,6 +5607,7 @@ public class Generate implements Serializable, XMLAppendable
result = ((prime*result)+((commentsOnRoutines == null)? 0 :commentsOnRoutines.hashCode()));
result = ((prime*result)+((commentsOnParameters == null)? 0 :commentsOnParameters.hashCode()));
result = ((prime*result)+((commentsOnSequences == null)? 0 :commentsOnSequences.hashCode()));
result = ((prime*result)+((commentsOnDomains == null)? 0 :commentsOnDomains.hashCode()));
result = ((prime*result)+((commentsOnLinks == null)? 0 :commentsOnLinks.hashCode()));
result = ((prime*result)+((commentsOnQueues == null)? 0 :commentsOnQueues.hashCode()));
result = ((prime*result)+((commentsOnKeys == null)? 0 :commentsOnKeys.hashCode()));

View File

@ -22,20 +22,7 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Matchers", propOrder = {
"catalogs",
"schemas",
"tables",
"indexes",
"primaryKeys",
"uniqueKeys",
"foreignKeys",
"fields",
"routines",
"sequences",
"enums",
"embeddables",
"udts",
"attributes"
})
@SuppressWarnings({
"all"

View File

@ -20,9 +20,7 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Strategy", propOrder = {
"name",
"java",
"matchers"
})
@SuppressWarnings({
"all"

View File

@ -77,6 +77,7 @@ import static org.jooq.impl.DSL.selectFrom;
import static org.jooq.impl.DSL.sql;
import static org.jooq.impl.DSL.substring;
import static org.jooq.impl.DSL.table;
import static org.jooq.impl.DSL.unquotedName;
import static org.jooq.impl.DSL.values;
import static org.jooq.impl.DSL.when;
import static org.jooq.impl.SQLDataType.BIGINT;
@ -107,14 +108,12 @@ import static org.jooq.meta.postgres.pg_catalog.Tables.PG_NAMESPACE;
import static org.jooq.meta.postgres.pg_catalog.Tables.PG_PROC;
import static org.jooq.meta.postgres.pg_catalog.Tables.PG_SEQUENCE;
import static org.jooq.meta.postgres.pg_catalog.Tables.PG_TYPE;
import static org.jooq.tools.StringUtils.defaultIfNull;
import static org.jooq.util.postgres.PostgresDSL.arrayAppend;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@ -144,8 +143,6 @@ import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions.TableType;
// ...
// ...
// ...
import org.jooq.conf.ParseUnknownFunctions;
import org.jooq.exception.DataAccessException;
import org.jooq.impl.DSL;
@ -164,7 +161,7 @@ import org.jooq.meta.DefaultEnumDefinition;
import org.jooq.meta.DefaultIndexColumnDefinition;
import org.jooq.meta.DefaultRelations;
import org.jooq.meta.DefaultSequenceDefinition;
// ...
import org.jooq.meta.Definition;
import org.jooq.meta.DomainDefinition;
import org.jooq.meta.EnumDefinition;
import org.jooq.meta.IndexColumnDefinition;
@ -175,7 +172,6 @@ import org.jooq.meta.RoutineDefinition;
import org.jooq.meta.SchemaDefinition;
import org.jooq.meta.SequenceDefinition;
import org.jooq.meta.TableDefinition;
// ...
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.XMLSchemaCollectionDefinition;
import org.jooq.meta.hsqldb.HSQLDBDatabase;
@ -190,8 +186,6 @@ import org.jooq.meta.postgres.pg_catalog.tables.PgInherits;
import org.jooq.meta.postgres.pg_catalog.tables.PgType;
import org.jooq.tools.JooqLogger;
import org.jetbrains.annotations.Nullable;
/**
* Postgres uses the ANSI default INFORMATION_SCHEMA, but unfortunately ships
* with a non-capitalised version of it: <code>information_schema</code>. Hence
@ -686,9 +680,56 @@ public class PostgresDatabase extends AbstractDatabase implements ResultQueryDat
.orderBy(1, 2, 3);
}
private static final Field<String> objDescription(Field<Long> oid) {
return DSL.function(unquotedName("obj_description"), VARCHAR, oid);
}
@Override
public ResultQuery<Record5<String, String, String, String, String>> comments(List<String> schemas) {
return null;
Table<?> c =
select(
PG_CLASS.pgNamespace().NSPNAME.as("schema_name"),
PG_CLASS.RELNAME.as("table_name"),
inline(null, VARCHAR).as("column_name"),
objDescription(PG_CLASS.OID).as("remarks"))
.from(PG_CLASS)
.where(objDescription(PG_CLASS.OID).isNotNull())
.unionAll(
select(
PG_NAMESPACE.NSPNAME,
inline(null, VARCHAR),
inline(null, VARCHAR),
objDescription(PG_NAMESPACE.OID).as("remarks"))
.from(PG_NAMESPACE)
.where(objDescription(PG_NAMESPACE.OID).isNotNull()))
.unionAll(
select(
PG_PROC.pgNamespace().NSPNAME,
PG_PROC.PRONAME,
inline(null, VARCHAR),
objDescription(PG_PROC.OID).as("remarks"))
.from(PG_PROC)
.where(objDescription(PG_PROC.OID).isNotNull()))
.unionAll(
select(
PG_TYPE.pgNamespace().NSPNAME,
PG_TYPE.TYPNAME,
inline(null, VARCHAR),
objDescription(PG_TYPE.OID).as("remarks"))
.from(PG_TYPE)
.where(objDescription(PG_TYPE.OID).isNotNull()))
.asTable("c");
return create()
.select(
currentCatalog().as("catalog_name"),
c.field("schema_name", VARCHAR),
c.field("table_name", VARCHAR),
c.field("column_name", VARCHAR),
c.field("remarks", VARCHAR))
.from(c)
.where(c.field("schema_name", VARCHAR).in(schemas))
.orderBy(1, 2, 3, 4);
}
@Override

View File

@ -2825,6 +2825,10 @@ jOOQ version used for source code.]]></jxb:javadoc></jxb:property></appinfo></an
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all sequences.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnDomains" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all domains.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnLinks" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all links.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>

View File

@ -60,7 +60,6 @@ import static org.jooq.impl.DSL.name;
import static org.jooq.impl.DSL.param;
import static org.jooq.impl.DSL.sql;
import static org.jooq.impl.DSL.table;
import static org.jooq.impl.DSL.using;
import static org.jooq.impl.DSL.val;
import static org.jooq.impl.DefaultBinding.DefaultBooleanBinding.BIND_AS_1_0;
import static org.jooq.impl.Keywords.K_BEGIN;
@ -103,7 +102,6 @@ import static org.jooq.impl.Tools.configurationOrThrow;
// ...
import static org.jooq.impl.Tools.executeStatementAndGetFirstResultSet;
import static org.jooq.impl.Tools.getRecordQualifier;
import static org.jooq.impl.Tools.settings;
import static org.jooq.impl.Tools.toSQLDDLTypeDeclaration;
import java.sql.CallableStatement;
@ -128,6 +126,7 @@ import org.jooq.BindContext;
import org.jooq.Binding;
import org.jooq.Catalog;
import org.jooq.Clause;
import org.jooq.Comment;
import org.jooq.Configuration;
import org.jooq.Context;
import org.jooq.Converter;
@ -158,14 +157,11 @@ import org.jooq.UDTRecord;
import org.jooq.conf.SettingsTools;
import org.jooq.exception.ControlFlowSignal;
import org.jooq.exception.MappingException;
import org.jooq.impl.DefaultBinding.DefaultBooleanBinding;
import org.jooq.impl.QOM.UNotYetImplemented;
import org.jooq.impl.QOM.UTransient;
import org.jooq.impl.ResultsImpl.ResultOrRowsImpl;
import org.jooq.tools.reflect.Reflect;
// ...
/**
* A common base class for stored procedures
* <p>
@ -249,46 +245,124 @@ implements
// Constructors
// ------------------------------------------------------------------------
/**
* @deprecated - 3.20.0 - [#15723] - Re-generate your code.
*/
@Deprecated
protected AbstractRoutine(String name, Schema schema) {
this(name, schema, null, null, null, null);
this(name, schema, (Package) null, (DataType<?>) null, null, null);
}
protected AbstractRoutine(String name, Schema schema, Comment comment) {
this(name, schema, (Package) null, comment, (DataType<?>) null, null, null);
}
/**
* @deprecated - 3.20.0 - [#15723] - Re-generate your code.
*/
@Deprecated
protected AbstractRoutine(String name, Schema schema, Package pkg) {
this(name, schema, pkg, null, null, null);
this(name, schema, pkg, (DataType<?>) null, null, null);
}
protected AbstractRoutine(String name, Schema schema, Package pkg, Comment comment) {
this(name, schema, pkg, comment, (DataType<?>) null, null, null);
}
/**
* @deprecated - 3.20.0 - [#15723] - Re-generate your code.
*/
@Deprecated
protected AbstractRoutine(String name, Schema schema, DataType<T> type) {
this(name, schema, null, type, null, null);
this(name, schema, (Package) null, type, null, null);
}
protected AbstractRoutine(String name, Schema schema, Comment comment, DataType<T> type) {
this(name, schema, (Package) null, comment, type, null, null);
}
/**
* @deprecated - 3.20.0 - [#15723] - Re-generate your code.
*/
@Deprecated
protected <X> AbstractRoutine(String name, Schema schema, DataType<X> type, Converter<X, T> converter) {
this(name, schema, null, type, converter, null);
this(name, schema, (Package) null, type, converter, null);
}
protected <X> AbstractRoutine(String name, Schema schema, Comment comment, DataType<X> type, Converter<X, T> converter) {
this(name, schema, (Package) null, comment, type, converter, null);
}
/**
* @deprecated - 3.20.0 - [#15723] - Re-generate your code.
*/
@Deprecated
protected <X> AbstractRoutine(String name, Schema schema, DataType<X> type, Binding<X, T> binding) {
this(name, schema, null, type, null, binding);
this(name, schema, (Package) null, type, null, binding);
}
protected <X> AbstractRoutine(String name, Schema schema, Comment comment, DataType<X> type, Binding<X, T> binding) {
this(name, schema, (Package) null, comment, type, null, binding);
}
/**
* @deprecated - 3.20.0 - [#15723] - Re-generate your code.
*/
@Deprecated
protected <X, Y> AbstractRoutine(String name, Schema schema, DataType<X> type, Converter<Y, T> converter, Binding<X, Y> binding) {
this(name, schema, null, type, converter, binding);
this(name, schema, (Package) null, type, converter, binding);
}
protected <X, Y> AbstractRoutine(String name, Schema schema, Comment comment, DataType<X> type, Converter<Y, T> converter, Binding<X, Y> binding) {
this(name, schema, null, comment, type, converter, binding);
}
/**
* @deprecated - 3.20.0 - [#15723] - Re-generate your code.
*/
@Deprecated
protected AbstractRoutine(String name, Schema schema, Package pkg, DataType<T> type) {
this(name, schema, pkg, type, null, null);
}
protected AbstractRoutine(String name, Schema schema, Package pkg, Comment comment, DataType<T> type) {
this(name, schema, pkg, comment, type, null, null);
}
/**
* @deprecated - 3.20.0 - [#15723] - Re-generate your code.
*/
@Deprecated
protected <X> AbstractRoutine(String name, Schema schema, Package pkg, DataType<X> type, Converter<X, T> converter) {
this(name, schema, pkg, type, converter, null);
}
protected <X> AbstractRoutine(String name, Schema schema, Package pkg, Comment comment, DataType<X> type, Converter<X, T> converter) {
this(name, schema, pkg, comment, type, converter, null);
}
/**
* @deprecated - 3.20.0 - [#15723] - Re-generate your code.
*/
@Deprecated
protected <X> AbstractRoutine(String name, Schema schema, Package pkg, DataType<X> type, Binding<X, T> binding) {
this(name, schema, pkg, type, null, binding);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
protected <X> AbstractRoutine(String name, Schema schema, Package pkg, Comment comment, DataType<X> type, Binding<X, T> binding) {
this(name, schema, pkg, comment, type, null, binding);
}
/**
* @deprecated - 3.20.0 - [#15723] - Re-generate your code.
*/
@Deprecated
protected <X, Y> AbstractRoutine(String name, Schema schema, Package pkg, DataType<X> type, Converter<Y, T> converter, Binding<X, Y> binding) {
super(qualify(pkg != null ? pkg : schema, DSL.name(name)), CommentImpl.NO_COMMENT);
this(name, schema, pkg, null, type, converter, binding);
}
protected <X, Y> AbstractRoutine(String name, Schema schema, Package pkg, Comment comment, DataType<X> type, Converter<Y, T> converter, Binding<X, Y> binding) {
super(qualify(pkg != null ? pkg : schema, DSL.name(name)), comment);
this.resultIndexes = new HashMap<>();

View File

@ -13685,6 +13685,7 @@ public class DSL {
return new SequenceImpl<>(
name.unqualifiedName(),
name.qualified() ? schema(name.qualifier()) : null,
CommentImpl.NO_COMMENT,
type,
false
);
@ -15274,7 +15275,7 @@ public class DSL {
@Support({ CUBRID, DERBY, DUCKDB, FIREBIRD, H2, HSQLDB, POSTGRES, YUGABYTEDB })
@PlainSQL
public static <T extends Number> Sequence<T> sequence(String sql, DataType<T> type) {
return new SequenceImpl<>(sql, null, type, true);
return new SequenceImpl<>(sql, null, CommentImpl.NO_COMMENT, type, true);
}
/**
@ -15372,6 +15373,7 @@ public class DSL {
return new DomainImpl<>(
name.qualified() ? schema(name.qualifier()) : null,
name.unqualifiedName(),
CommentImpl.NO_COMMENT,
new DefaultDataType<>(null, type.getSQLDataType(), name)
);
}

View File

@ -45,6 +45,7 @@ import java.util.List;
import org.jooq.Binding;
import org.jooq.Catalog;
import org.jooq.Check;
import org.jooq.Comment;
import org.jooq.Configuration;
import org.jooq.Context;
import org.jooq.Converter;
@ -64,13 +65,20 @@ import org.jetbrains.annotations.NotNull;
/**
* @author Lukas Eder
*/
class DomainImpl<T> extends AbstractNamed implements Domain<T>, UNotYetImplemented {
class DomainImpl<T>
extends
AbstractNamed
implements
Domain<T>,
UNotYetImplemented
{
private final Schema schema;
private final Check<?>[] checks;
private final DataType<T> type;
DomainImpl(Schema schema, Name name, DataType<T> type, Check<?>... checks) {
super(qualify(schema, name), null);
DomainImpl(Schema schema, Name name, Comment comment, DataType<T> type, Check<?>... checks) {
super(qualify(schema, name), comment);
this.schema = schema;
this.checks = checks;

View File

@ -185,6 +185,7 @@ final class InformationSchemaExport {
id.setDomainSchema(schemaName);
id.setDomainName(domainName);
id.setComment(d.getComment());
id.setDataType(d.getDataType().getTypeName(configuration));
if (d.getDataType().lengthDefined())
@ -237,6 +238,7 @@ final class InformationSchemaExport {
iq.setSequenceSchema(schemaName);
iq.setSequenceName(q.getName());
iq.setComment(q.getComment());
iq.setDataType(q.getDataType().getTypeName(configuration));
if (q.getDataType().lengthDefined())

View File

@ -42,6 +42,7 @@ import static java.lang.Boolean.TRUE;
import static java.util.Collections.emptyList;
import static java.util.Comparator.comparing;
import static java.util.Comparator.comparingInt;
import static org.jooq.impl.DSL.comment;
import static org.jooq.impl.DSL.name;
import static org.jooq.impl.QOM.GenerationOption.STORED;
import static org.jooq.impl.QOM.GenerationOption.VIRTUAL;
@ -232,6 +233,7 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
InformationSchemaDomain<?> id = new InformationSchemaDomain<Object>(
schema,
name(d.getDomainName()),
comment(d.getComment()),
(DataType) type(d.getDataType(), length, precision, scale, nullable, false, false, null, null),
checks.toArray(EMPTY_CHECK)
);
@ -548,6 +550,7 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
InformationSchemaSequence is = new InformationSchemaSequence(
xs.getSequenceName(),
schema,
comment(xs.getComment()),
type(typeName, length, precision, scale, nullable, false, false, null, null),
startWith,
incrementBy,
@ -796,8 +799,8 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
private static final class InformationSchemaDomain<T> extends DomainImpl<T> {
InformationSchemaDomain(Schema schema, Name name, DataType<T> type, Check<?>[] checks) {
super(schema, name, type, checks);
InformationSchemaDomain(Schema schema, Name name, Comment comment, DataType<T> type, Check<?>[] checks) {
super(schema, name, comment, type, checks);
}
}
@ -827,9 +830,10 @@ final class InformationSchemaMetaImpl extends AbstractMeta {
private static final class InformationSchemaSequence<N extends Number> extends SequenceImpl<N> {
InformationSchemaSequence(String name, Schema schema, DataType<N> type, Number startWith, Number incrementBy, Number minvalue, Number maxvalue, Boolean cycle, Number cache) {
InformationSchemaSequence(String name, Schema schema, Comment comment, DataType<N> type, Number startWith, Number incrementBy, Number minvalue, Number maxvalue, Boolean cycle, Number cache) {
super(DSL.name(name),
schema,
comment,
type,
false,
startWith != null ? Tools.field(startWith, type) : null,

View File

@ -447,20 +447,43 @@ public final class Internal {
/**
* Factory method for sequences.
*
* @deprecated - 3.20.0 - [#15723] - Regenerate your code.
*/
@Deprecated
@NotNull
public static final <T extends Number> Sequence<T> createSequence(String name, Schema schema, DataType<T> type) {
return new SequenceImpl<>(name, schema, type, false);
return createSequence(name, schema, null, type);
}
/**
* Factory method for sequences.
*
* @deprecated - 3.20.0 - [#15723] - Regenerate your code.
*/
@Deprecated
@NotNull
public static final <T extends Number> Sequence<T> createSequence(String name, Schema schema, DataType<T> type, Number startWith, Number incrementBy, Number minvalue, Number maxvalue, boolean cycle, Number cache) {
return createSequence(name, schema, null, type, startWith, incrementBy, minvalue, maxvalue, cycle, cache);
}
/**
* Factory method for sequences.
*/
@NotNull
public static final <T extends Number> Sequence<T> createSequence(String name, Schema schema, DataType<T> type, Number startWith, Number incrementBy, Number minvalue, Number maxvalue, boolean cycle, Number cache) {
public static final <T extends Number> Sequence<T> createSequence(String name, Schema schema, Comment comment, DataType<T> type) {
return new SequenceImpl<>(name, schema, comment, type, false);
}
/**
* Factory method for sequences.
*/
@NotNull
public static final <T extends Number> Sequence<T> createSequence(String name, Schema schema, Comment comment, DataType<T> type, Number startWith, Number incrementBy, Number minvalue, Number maxvalue, boolean cycle, Number cache) {
return new SequenceImpl<>(
DSL.name(name),
schema,
comment,
type,
false,
startWith != null ? Tools.field(startWith, type) : null,
@ -490,7 +513,10 @@ public final class Internal {
/**
* Factory method for domain specifications.
*
* @deprecated - 3.20.0 - [#15723] - Regenerate your code.
*/
@Deprecated
@NotNull
public static final <T> Domain<T> createDomain(Schema schema, Name name, DataType<T> type, Check<?>... checks) {
return createDomain(schema, name, type, null, null, checks);
@ -499,6 +525,16 @@ public final class Internal {
/**
* Factory method for domain specifications.
*/
public static final <T> Domain<T> createDomain(Schema schema, Name name, Comment comment, DataType<T> type, Check<?>... checks) {
return createDomain(schema, name, comment, type, null, null, checks);
}
/**
* Factory method for domain specifications.
*
* @deprecated - 3.20.0 - [#15723] - Regenerate your code.
*/
@Deprecated
@NotNull
public static final <T, U> Domain<U> createDomain(Schema schema, Name name, DataType<T> type, Converter<T, U> converter, Check<?>... checks) {
return createDomain(schema, name, type, converter, null, checks);
@ -508,6 +544,17 @@ public final class Internal {
* Factory method for domain specifications.
*/
@NotNull
public static final <T, U> Domain<U> createDomain(Schema schema, Name name, Comment comment, DataType<T> type, Converter<T, U> converter, Check<?>... checks) {
return createDomain(schema, name, comment, type, converter, null, checks);
}
/**
* Factory method for domain specifications.
*
* @deprecated - 3.20.0 - [#15723] - Regenerate your code.
*/
@Deprecated
@NotNull
public static final <T, U> Domain<U> createDomain(Schema schema, Name name, DataType<T> type, Binding<T, U> binding, Check<?>... checks) {
return createDomain(schema, name, type, null, binding, checks);
}
@ -516,14 +563,33 @@ public final class Internal {
* Factory method for domain specifications.
*/
@NotNull
public static final <T, U> Domain<U> createDomain(Schema schema, Name name, Comment comment, DataType<T> type, Binding<T, U> binding, Check<?>... checks) {
return createDomain(schema, name, comment, type, null, binding, checks);
}
/**
* Factory method for domain specifications.
*
* @deprecated - 3.20.0 - [#15723] - Regenerate your code.
*/
@Deprecated
@NotNull
public static final <T, X, U> Domain<U> createDomain(Schema schema, Name name, DataType<T> type, Converter<X, U> converter, Binding<T, X> binding, Check<?>... checks) {
return createDomain(schema, name, null, type, converter, binding, checks);
}
/**
* Factory method for domain specifications.
*/
@NotNull
public static final <T, X, U> Domain<U> createDomain(Schema schema, Name name, Comment comment, DataType<T> type, Converter<X, U> converter, Binding<T, X> binding, Check<?>... checks) {
Binding<T, U> actualBinding = DefaultBinding.newBinding(converter, type, binding);
DataType<U> actualType =
converter == null && binding == null
? (DataType<U>) type
: type.asConvertedDataType(actualBinding);
return new DomainImpl<>(schema, name, actualType, checks);
return new DomainImpl<>(schema, name, comment, actualType, checks);
}

View File

@ -1980,7 +1980,7 @@ final class Interpreter {
private final class InterpretedDomain extends DomainImpl {
InterpretedDomain(Schema schema) {
super(schema, MutableDomain.this.name(), dataType, interpretedChecks());
super(schema, MutableDomain.this.name(), comment(), dataType, interpretedChecks());
}
}
}
@ -2017,7 +2017,10 @@ final class Interpreter {
private final class InterpretedSequence extends SequenceImpl<T> {
InterpretedSequence(Schema schema) {
super(MutableSequence.this.name(), schema,
super(
MutableSequence.this.name(),
schema,
MutableSequence.this.comment(),
MutableSequence.this.dataType != null
? MutableSequence.this.dataType
: (DataType<T>) SQLDataType.BIGINT,

View File

@ -63,6 +63,7 @@ import static org.jooq.impl.Tools.getMappedSchema;
import org.jooq.Catalog;
import org.jooq.Clause;
import org.jooq.Comment;
import org.jooq.Configuration;
import org.jooq.Context;
import org.jooq.DataType;
@ -112,20 +113,21 @@ implements
@Deprecated
public SequenceImpl(String name, Schema schema, DataType<T> type) {
this(name, schema, type, false);
this(name, schema, null, type, false);
}
SequenceImpl(String name, Schema schema, DataType<T> type, boolean nameIsPlainSQL) {
this(DSL.name(name), schema, type, nameIsPlainSQL);
SequenceImpl(String name, Schema schema, Comment comment, DataType<T> type, boolean nameIsPlainSQL) {
this(DSL.name(name), schema, comment, type, nameIsPlainSQL);
}
SequenceImpl(Name name, Schema schema, DataType<T> type, boolean nameIsPlainSQL) {
this(name, schema, type, nameIsPlainSQL, null, null, null, null, false, null);
SequenceImpl(Name name, Schema schema, Comment comment, DataType<T> type, boolean nameIsPlainSQL) {
this(name, schema, comment, type, nameIsPlainSQL, null, null, null, null, false, null);
}
SequenceImpl(
Name name,
Schema schema,
Comment comment,
DataType<T> type,
boolean nameIsPlainSQL,
Field<T> startWith,
@ -135,7 +137,7 @@ implements
boolean cycle,
Field<T> cache
) {
super(qualify(schema, name), CommentImpl.NO_COMMENT, type);
super(qualify(schema, name), comment, type);
this.schema = schema;
this.nameIsPlainSQL = nameIsPlainSQL;

View File

@ -44,37 +44,27 @@ import static org.jooq.impl.Tools.map;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.jooq.Catalog;
import org.jooq.Check;
import org.jooq.Comment;
import org.jooq.Condition;
import org.jooq.Domain;
import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Index;
import org.jooq.Meta;
import org.jooq.Name;
// ...
import org.jooq.Record;
import org.jooq.Schema;
import org.jooq.Sequence;
import org.jooq.SortField;
import org.jooq.Statement;
import org.jooq.Table;
import org.jooq.TableField;
// ...
// ...
// ...
// ...
import org.jooq.UDT;
import org.jooq.UDTRecord;
import org.jooq.UniqueKey;
import org.jooq.exception.DataAccessException;
import org.jetbrains.annotations.NotNull;
/**
* An implementation of {@code Meta} which can be used to create fully
* self-contained copies of other {@code Meta} objects.
@ -182,7 +172,7 @@ final class Snapshot extends AbstractMeta {
private class SnapshotDomain<T> extends DomainImpl<T> {
SnapshotDomain(SnapshotSchema schema, Domain<T> domain) {
super(schema, domain.getQualifiedName(), domain.getDataType(), domain.getChecks().toArray(EMPTY_CHECK));
super(schema, domain.getQualifiedName(), domain.getCommentPart(), domain.getDataType(), domain.getChecks().toArray(EMPTY_CHECK));
}
}
@ -298,6 +288,7 @@ final class Snapshot extends AbstractMeta {
super(
sequence.getQualifiedName(),
schema,
sequence.getCommentPart(),
sequence.getDataType(),
false,
sequence.getStartWith(),

View File

@ -39,6 +39,7 @@ package org.jooq.impl;
import org.jooq.Binding;
import org.jooq.Catalog;
import org.jooq.Comment;
import org.jooq.Context;
import org.jooq.Converter;
import org.jooq.DataType;
@ -111,7 +112,11 @@ implements
}
public UDTImpl(Name name, Schema schema, Package pkg, boolean synthetic) {
super(qualify(pkg != null ? pkg : schema, name), CommentImpl.NO_COMMENT);
this(name, schema, pkg, null, synthetic);
}
public UDTImpl(Name name, Schema schema, Package pkg, Comment comment, boolean synthetic) {
super(qualify(pkg != null ? pkg : schema, name), comment);
this.fields = new FieldsImpl<>();
this.schema = schema;

View File

@ -30,6 +30,7 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
* &lt;element name="numeric_precision" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/&gt;
* &lt;element name="numeric_scale" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/&gt;
* &lt;element name="domain_default" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="comment" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;/all&gt;
* &lt;/restriction&gt;
* &lt;/complexContent&gt;
@ -70,6 +71,8 @@ public class Domain implements Serializable, XMLAppendable
@XmlElement(name = "domain_default")
@XmlJavaTypeAdapter(StringAdapter.class)
protected String domainDefault;
@XmlJavaTypeAdapter(StringAdapter.class)
protected String comment;
public String getDomainCatalog() {
return domainCatalog;
@ -135,6 +138,14 @@ public class Domain implements Serializable, XMLAppendable
this.domainDefault = value;
}
public String getComment() {
return comment;
}
public void setComment(String value) {
this.comment = value;
}
public Domain withDomainCatalog(String value) {
setDomainCatalog(value);
return this;
@ -175,6 +186,11 @@ public class Domain implements Serializable, XMLAppendable
return this;
}
public Domain withComment(String value) {
setComment(value);
return this;
}
@Override
public final void appendTo(XMLBuilder builder) {
builder.append("domain_catalog", domainCatalog);
@ -185,6 +201,7 @@ public class Domain implements Serializable, XMLAppendable
builder.append("numeric_precision", numericPrecision);
builder.append("numeric_scale", numericScale);
builder.append("domain_default", domainDefault);
builder.append("comment", comment);
}
@Override
@ -278,6 +295,15 @@ public class Domain implements Serializable, XMLAppendable
return false;
}
}
if (comment == null) {
if (other.comment!= null) {
return false;
}
} else {
if (!comment.equals(other.comment)) {
return false;
}
}
return true;
}
@ -293,6 +319,7 @@ public class Domain implements Serializable, XMLAppendable
result = ((prime*result)+((numericPrecision == null)? 0 :numericPrecision.hashCode()));
result = ((prime*result)+((numericScale == null)? 0 :numericScale.hashCode()));
result = ((prime*result)+((domainDefault == null)? 0 :domainDefault.hashCode()));
result = ((prime*result)+((comment == null)? 0 :comment.hashCode()));
return result;
}

View File

@ -39,6 +39,7 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
* &lt;element name="action_reference_new_table" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="action_reference_old_row" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="action_reference_new_row" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;element name="comment" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
* &lt;/all&gt;
* &lt;/restriction&gt;
* &lt;/complexContent&gt;
@ -105,6 +106,8 @@ public class Trigger implements Serializable, XMLAppendable
@XmlElement(name = "action_reference_new_row")
@XmlJavaTypeAdapter(StringAdapter.class)
protected String actionReferenceNewRow;
@XmlJavaTypeAdapter(StringAdapter.class)
protected String comment;
public String getTriggerCatalog() {
return triggerCatalog;
@ -234,6 +237,14 @@ public class Trigger implements Serializable, XMLAppendable
this.actionReferenceNewRow = value;
}
public String getComment() {
return comment;
}
public void setComment(String value) {
this.comment = value;
}
public Trigger withTriggerCatalog(String value) {
setTriggerCatalog(value);
return this;
@ -314,6 +325,11 @@ public class Trigger implements Serializable, XMLAppendable
return this;
}
public Trigger withComment(String value) {
setComment(value);
return this;
}
@Override
public final void appendTo(XMLBuilder builder) {
builder.append("trigger_catalog", triggerCatalog);
@ -332,6 +348,7 @@ public class Trigger implements Serializable, XMLAppendable
builder.append("action_reference_new_table", actionReferenceNewTable);
builder.append("action_reference_old_row", actionReferenceOldRow);
builder.append("action_reference_new_row", actionReferenceNewRow);
builder.append("comment", comment);
}
@Override
@ -497,6 +514,15 @@ public class Trigger implements Serializable, XMLAppendable
return false;
}
}
if (comment == null) {
if (other.comment!= null) {
return false;
}
} else {
if (!comment.equals(other.comment)) {
return false;
}
}
return true;
}
@ -520,6 +546,7 @@ public class Trigger implements Serializable, XMLAppendable
result = ((prime*result)+((actionReferenceNewTable == null)? 0 :actionReferenceNewTable.hashCode()));
result = ((prime*result)+((actionReferenceOldRow == null)? 0 :actionReferenceOldRow.hashCode()));
result = ((prime*result)+((actionReferenceNewRow == null)? 0 :actionReferenceNewRow.hashCode()));
result = ((prime*result)+((comment == null)? 0 :comment.hashCode()));
return result;
}

View File

@ -125,6 +125,7 @@
<element name="numeric_precision" type="int" minOccurs="0" maxOccurs="1" />
<element name="numeric_scale" type="int" minOccurs="0" maxOccurs="1" />
<element name="domain_default" type="string" minOccurs="0" maxOccurs="1" />
<element name="comment" type="string" minOccurs="0" maxOccurs="1" />
</all>
</complexType>
@ -395,6 +396,7 @@
<element name="action_reference_new_table" type="string" minOccurs="0" maxOccurs="1" />
<element name="action_reference_old_row" type="string" minOccurs="0" maxOccurs="1" />
<element name="action_reference_new_row" type="string" minOccurs="0" maxOccurs="1" />
<element name="comment" type="string" minOccurs="0" maxOccurs="1" />
</all>
</complexType>