[jOOQ/jOOQ#15276] Add literalsFromColumnContent

Also, make literalsFromCheckConstraints explicit
This commit is contained in:
Lukas Eder 2023-06-26 15:22:29 +02:00
parent 360642d00c
commit 1785649ba5
3 changed files with 102 additions and 0 deletions

View File

@ -52,10 +52,12 @@ import static org.jooq.SQLDialect.SQLITE;
// ...
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.noCondition;
import static org.jooq.impl.DSL.one;
import static org.jooq.impl.DSL.partitionBy;
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.tools.StringUtils.defaultIfBlank;
@ -2149,6 +2151,14 @@ public abstract class AbstractDatabase implements Database {

View File

@ -31,6 +31,8 @@ import org.jooq.util.jaxb.tools.XMLBuilder;
* <element name="fields" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="literals" type="{http://www.jooq.org/xsd/jooq-codegen-3.19.0.xsd}SyntheticEnumLiteralsType" minOccurs="0"/>
* <element name="literalSql" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="literalsFromColumnContent" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
* <element name="literalsFromCheckConstraints" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
* <element name="comment" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </all>
* </restriction>
@ -59,6 +61,8 @@ public class SyntheticEnumType implements Serializable, XMLAppendable
protected String fields;
@XmlJavaTypeAdapter(StringAdapter.class)
protected String literalSql;
protected Boolean literalsFromColumnContent;
protected Boolean literalsFromCheckConstraints;
@XmlJavaTypeAdapter(StringAdapter.class)
protected String comment;
@XmlElementWrapper(name = "literals")
@ -129,6 +133,54 @@ public class SyntheticEnumType implements Serializable, XMLAppendable
this.literalSql = value;
}
/**
* The matched column's content defines the literals (this is convenience for {@link #literalSql} being <code>SELECT DISTINCT matched_column FROM matched_table</code>).
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isLiteralsFromColumnContent() {
return literalsFromColumnContent;
}
/**
* Sets the value of the literalsFromColumnContent property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setLiteralsFromColumnContent(Boolean value) {
this.literalsFromColumnContent = value;
}
/**
* The list of literals is parsed from the applicable <code>CHECK</code> constraints for the matched column, if possible.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isLiteralsFromCheckConstraints() {
return literalsFromCheckConstraints;
}
/**
* Sets the value of the literalsFromCheckConstraints property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setLiteralsFromCheckConstraints(Boolean value) {
this.literalsFromCheckConstraints = value;
}
/**
* The enum comment.
*
@ -192,6 +244,16 @@ public class SyntheticEnumType implements Serializable, XMLAppendable
return this;
}
public SyntheticEnumType withLiteralsFromColumnContent(Boolean value) {
setLiteralsFromColumnContent(value);
return this;
}
public SyntheticEnumType withLiteralsFromCheckConstraints(Boolean value) {
setLiteralsFromCheckConstraints(value);
return this;
}
/**
* The enum comment.
*
@ -228,6 +290,8 @@ public class SyntheticEnumType implements Serializable, XMLAppendable
builder.append("tables", tables);
builder.append("fields", fields);
builder.append("literalSql", literalSql);
builder.append("literalsFromColumnContent", literalsFromColumnContent);
builder.append("literalsFromCheckConstraints", literalsFromCheckConstraints);
builder.append("comment", comment);
builder.append("literals", "literal", literals);
}
@ -287,6 +351,24 @@ public class SyntheticEnumType implements Serializable, XMLAppendable
return false;
}
}
if (literalsFromColumnContent == null) {
if (other.literalsFromColumnContent!= null) {
return false;
}
} else {
if (!literalsFromColumnContent.equals(other.literalsFromColumnContent)) {
return false;
}
}
if (literalsFromCheckConstraints == null) {
if (other.literalsFromCheckConstraints!= null) {
return false;
}
} else {
if (!literalsFromCheckConstraints.equals(other.literalsFromCheckConstraints)) {
return false;
}
}
if (comment == null) {
if (other.comment!= null) {
return false;
@ -316,6 +398,8 @@ public class SyntheticEnumType implements Serializable, XMLAppendable
result = ((prime*result)+((tables == null)? 0 :tables.hashCode()));
result = ((prime*result)+((fields == null)? 0 :fields.hashCode()));
result = ((prime*result)+((literalSql == null)? 0 :literalSql.hashCode()));
result = ((prime*result)+((literalsFromColumnContent == null)? 0 :literalsFromColumnContent.hashCode()));
result = ((prime*result)+((literalsFromCheckConstraints == null)? 0 :literalsFromCheckConstraints.hashCode()));
result = ((prime*result)+((comment == null)? 0 :comment.hashCode()));
result = ((prime*result)+((literals == null)? 0 :literals.hashCode()));
return result;

View File

@ -1309,6 +1309,14 @@ Use this along with the synthetic primary key feature to replace existing primar
<element name="literalSql" type="string" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A SQL query producing the literals.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="literalsFromColumnContent" type="boolean" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The matched column's content defines the literals (this is convenience for {@link #literalSql} being <code>SELECT DISTINCT matched_column FROM matched_table</code>).]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="literalsFromCheckConstraints" type="boolean" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The list of literals is parsed from the applicable <code>CHECK</code> constraints for the matched column, if possible.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="comment" type="string" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The enum comment.]]></jxb:javadoc></jxb:property></appinfo></annotation>