refactor: update primarky logic
This commit is contained in:
parent
5a9a42eaf7
commit
1e6846c9b0
|
@ -51,7 +51,6 @@ public interface DocumentPojoConverter extends BaseConverter {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Mapping(target = "isPrimary", source = "meta.isPrimaryKey")
|
||||
@Mapping(target = "isUnique", source = "meta.isUniqueKey")
|
||||
@Mapping(target = "columnNameArray", source = "meta.columnNames")
|
||||
TableIndexDocumentPojo toIndexPojo(Integer databaseDocumentId,
|
||||
|
|
|
@ -72,6 +72,8 @@ public class DatabaseDocumentResponse {
|
|||
|
||||
private String comment;
|
||||
|
||||
private Boolean isPrimaryKey;
|
||||
|
||||
private String nullable;
|
||||
|
||||
private String autoIncrement;
|
||||
|
@ -91,8 +93,6 @@ public class DatabaseDocumentResponse {
|
|||
|
||||
private String name;
|
||||
|
||||
private Boolean isPrimary;
|
||||
|
||||
private Boolean isUnique;
|
||||
|
||||
@Builder.Default
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.jooq.Identity;
|
|||
import org.jooq.Index;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Row12;
|
||||
import org.jooq.Row13;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableField;
|
||||
|
@ -98,6 +98,11 @@ public class TableColumnDocument extends TableImpl<TableColumnDocumentRecord> {
|
|||
*/
|
||||
public final TableField<TableColumnDocumentRecord, Integer> DECIMAL_DIGITS = createField(DSL.name("decimal_digits"), SQLDataType.INTEGER, this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.table_column_document.is_primary_key</code>.
|
||||
*/
|
||||
public final TableField<TableColumnDocumentRecord, Boolean> IS_PRIMARY_KEY = createField(DSL.name("is_primary_key"), SQLDataType.BOOLEAN.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.table_column_document.nullable</code>. YES,
|
||||
* NO, UNKNOWN
|
||||
|
@ -197,11 +202,11 @@ public class TableColumnDocument extends TableImpl<TableColumnDocumentRecord> {
|
|||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Row12 type methods
|
||||
// Row13 type methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row12<Integer, Integer, Integer, String, String, String, String, Integer, Integer, String, String, LocalDateTime> fieldsRow() {
|
||||
return (Row12) super.fieldsRow();
|
||||
public Row13<Integer, Integer, Integer, String, String, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> fieldsRow() {
|
||||
return (Row13) super.fieldsRow();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.jooq.Index;
|
|||
import org.jooq.JSON;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Row8;
|
||||
import org.jooq.Row7;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableField;
|
||||
|
@ -73,11 +73,6 @@ public class TableIndexDocument extends TableImpl<TableIndexDocumentRecord> {
|
|||
*/
|
||||
public final TableField<TableIndexDocumentRecord, String> NAME = createField(DSL.name("name"), SQLDataType.CLOB.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.table_index_document.is_primary</code>.
|
||||
*/
|
||||
public final TableField<TableIndexDocumentRecord, Boolean> IS_PRIMARY = createField(DSL.name("is_primary"), SQLDataType.BOOLEAN.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>databasir.table_index_document.is_unique</code>.
|
||||
*/
|
||||
|
@ -175,11 +170,11 @@ public class TableIndexDocument extends TableImpl<TableIndexDocumentRecord> {
|
|||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Row8 type methods
|
||||
// Row7 type methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row8<Integer, Integer, Integer, String, Boolean, Boolean, JSON, LocalDateTime> fieldsRow() {
|
||||
return (Row8) super.fieldsRow();
|
||||
public Row7<Integer, Integer, Integer, String, Boolean, JSON, LocalDateTime> fieldsRow() {
|
||||
return (Row7) super.fieldsRow();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public class TableColumnDocumentPojo implements Serializable {
|
|||
private String defaultValue;
|
||||
private Integer size;
|
||||
private Integer decimalDigits;
|
||||
private Boolean isPrimaryKey;
|
||||
private String nullable;
|
||||
private String autoIncrement;
|
||||
private LocalDateTime createAt;
|
||||
|
@ -41,6 +42,7 @@ public class TableColumnDocumentPojo implements Serializable {
|
|||
this.defaultValue = value.defaultValue;
|
||||
this.size = value.size;
|
||||
this.decimalDigits = value.decimalDigits;
|
||||
this.isPrimaryKey = value.isPrimaryKey;
|
||||
this.nullable = value.nullable;
|
||||
this.autoIncrement = value.autoIncrement;
|
||||
this.createAt = value.createAt;
|
||||
|
@ -56,6 +58,7 @@ public class TableColumnDocumentPojo implements Serializable {
|
|||
String defaultValue,
|
||||
Integer size,
|
||||
Integer decimalDigits,
|
||||
Boolean isPrimaryKey,
|
||||
String nullable,
|
||||
String autoIncrement,
|
||||
LocalDateTime createAt
|
||||
|
@ -69,6 +72,7 @@ public class TableColumnDocumentPojo implements Serializable {
|
|||
this.defaultValue = defaultValue;
|
||||
this.size = size;
|
||||
this.decimalDigits = decimalDigits;
|
||||
this.isPrimaryKey = isPrimaryKey;
|
||||
this.nullable = nullable;
|
||||
this.autoIncrement = autoIncrement;
|
||||
this.createAt = createAt;
|
||||
|
@ -204,6 +208,20 @@ public class TableColumnDocumentPojo implements Serializable {
|
|||
this.decimalDigits = decimalDigits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.table_column_document.is_primary_key</code>.
|
||||
*/
|
||||
public Boolean getIsPrimaryKey() {
|
||||
return this.isPrimaryKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.table_column_document.is_primary_key</code>.
|
||||
*/
|
||||
public void setIsPrimaryKey(Boolean isPrimaryKey) {
|
||||
this.isPrimaryKey = isPrimaryKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.table_column_document.nullable</code>. YES,
|
||||
* NO, UNKNOWN
|
||||
|
@ -263,6 +281,7 @@ public class TableColumnDocumentPojo implements Serializable {
|
|||
sb.append(", ").append(defaultValue);
|
||||
sb.append(", ").append(size);
|
||||
sb.append(", ").append(decimalDigits);
|
||||
sb.append(", ").append(isPrimaryKey);
|
||||
sb.append(", ").append(nullable);
|
||||
sb.append(", ").append(autoIncrement);
|
||||
sb.append(", ").append(createAt);
|
||||
|
|
|
@ -22,7 +22,6 @@ public class TableIndexDocumentPojo implements Serializable {
|
|||
private Integer tableDocumentId;
|
||||
private Integer databaseDocumentId;
|
||||
private String name;
|
||||
private Boolean isPrimary;
|
||||
private Boolean isUnique;
|
||||
private JSON columnNameArray;
|
||||
private LocalDateTime createAt;
|
||||
|
@ -34,7 +33,6 @@ public class TableIndexDocumentPojo implements Serializable {
|
|||
this.tableDocumentId = value.tableDocumentId;
|
||||
this.databaseDocumentId = value.databaseDocumentId;
|
||||
this.name = value.name;
|
||||
this.isPrimary = value.isPrimary;
|
||||
this.isUnique = value.isUnique;
|
||||
this.columnNameArray = value.columnNameArray;
|
||||
this.createAt = value.createAt;
|
||||
|
@ -45,7 +43,6 @@ public class TableIndexDocumentPojo implements Serializable {
|
|||
Integer tableDocumentId,
|
||||
Integer databaseDocumentId,
|
||||
String name,
|
||||
Boolean isPrimary,
|
||||
Boolean isUnique,
|
||||
JSON columnNameArray,
|
||||
LocalDateTime createAt
|
||||
|
@ -54,7 +51,6 @@ public class TableIndexDocumentPojo implements Serializable {
|
|||
this.tableDocumentId = tableDocumentId;
|
||||
this.databaseDocumentId = databaseDocumentId;
|
||||
this.name = name;
|
||||
this.isPrimary = isPrimary;
|
||||
this.isUnique = isUnique;
|
||||
this.columnNameArray = columnNameArray;
|
||||
this.createAt = createAt;
|
||||
|
@ -118,20 +114,6 @@ public class TableIndexDocumentPojo implements Serializable {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.table_index_document.is_primary</code>.
|
||||
*/
|
||||
public Boolean getIsPrimary() {
|
||||
return this.isPrimary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.table_index_document.is_primary</code>.
|
||||
*/
|
||||
public void setIsPrimary(Boolean isPrimary) {
|
||||
this.isPrimary = isPrimary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.table_index_document.is_unique</code>.
|
||||
*/
|
||||
|
@ -182,7 +164,6 @@ public class TableIndexDocumentPojo implements Serializable {
|
|||
sb.append(", ").append(tableDocumentId);
|
||||
sb.append(", ").append(databaseDocumentId);
|
||||
sb.append(", ").append(name);
|
||||
sb.append(", ").append(isPrimary);
|
||||
sb.append(", ").append(isUnique);
|
||||
sb.append(", ").append(columnNameArray);
|
||||
sb.append(", ").append(createAt);
|
||||
|
|
|
@ -11,8 +11,8 @@ import java.time.LocalDateTime;
|
|||
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.Record12;
|
||||
import org.jooq.Row12;
|
||||
import org.jooq.Record13;
|
||||
import org.jooq.Row13;
|
||||
import org.jooq.impl.UpdatableRecordImpl;
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ import org.jooq.impl.UpdatableRecordImpl;
|
|||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDocumentRecord> implements Record12<Integer, Integer, Integer, String, String, String, String, Integer, Integer, String, String, LocalDateTime> {
|
||||
public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDocumentRecord> implements Record13<Integer, Integer, Integer, String, String, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -154,12 +154,26 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
return (Integer) get(8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.table_column_document.is_primary_key</code>.
|
||||
*/
|
||||
public void setIsPrimaryKey(Boolean value) {
|
||||
set(9, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.table_column_document.is_primary_key</code>.
|
||||
*/
|
||||
public Boolean getIsPrimaryKey() {
|
||||
return (Boolean) get(9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.table_column_document.nullable</code>. YES,
|
||||
* NO, UNKNOWN
|
||||
*/
|
||||
public void setNullable(String value) {
|
||||
set(9, value);
|
||||
set(10, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,7 +181,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
* NO, UNKNOWN
|
||||
*/
|
||||
public String getNullable() {
|
||||
return (String) get(9);
|
||||
return (String) get(10);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,7 +189,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
* YES, NO, UNKNOWN
|
||||
*/
|
||||
public void setAutoIncrement(String value) {
|
||||
set(10, value);
|
||||
set(11, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,21 +197,21 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
* YES, NO, UNKNOWN
|
||||
*/
|
||||
public String getAutoIncrement() {
|
||||
return (String) get(10);
|
||||
return (String) get(11);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.table_column_document.create_at</code>.
|
||||
*/
|
||||
public void setCreateAt(LocalDateTime value) {
|
||||
set(11, value);
|
||||
set(12, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.table_column_document.create_at</code>.
|
||||
*/
|
||||
public LocalDateTime getCreateAt() {
|
||||
return (LocalDateTime) get(11);
|
||||
return (LocalDateTime) get(12);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -210,17 +224,17 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Record12 type implementation
|
||||
// Record13 type implementation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row12<Integer, Integer, Integer, String, String, String, String, Integer, Integer, String, String, LocalDateTime> fieldsRow() {
|
||||
return (Row12) super.fieldsRow();
|
||||
public Row13<Integer, Integer, Integer, String, String, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> fieldsRow() {
|
||||
return (Row13) super.fieldsRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Row12<Integer, Integer, Integer, String, String, String, String, Integer, Integer, String, String, LocalDateTime> valuesRow() {
|
||||
return (Row12) super.valuesRow();
|
||||
public Row13<Integer, Integer, Integer, String, String, String, String, Integer, Integer, Boolean, String, String, LocalDateTime> valuesRow() {
|
||||
return (Row13) super.valuesRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -269,17 +283,22 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field10() {
|
||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.NULLABLE;
|
||||
public Field<Boolean> field10() {
|
||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.IS_PRIMARY_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field11() {
|
||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.NULLABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field12() {
|
||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.AUTO_INCREMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<LocalDateTime> field12() {
|
||||
public Field<LocalDateTime> field13() {
|
||||
return TableColumnDocument.TABLE_COLUMN_DOCUMENT.CREATE_AT;
|
||||
}
|
||||
|
||||
|
@ -329,17 +348,22 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
}
|
||||
|
||||
@Override
|
||||
public String component10() {
|
||||
return getNullable();
|
||||
public Boolean component10() {
|
||||
return getIsPrimaryKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String component11() {
|
||||
return getNullable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String component12() {
|
||||
return getAutoIncrement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime component12() {
|
||||
public LocalDateTime component13() {
|
||||
return getCreateAt();
|
||||
}
|
||||
|
||||
|
@ -389,17 +413,22 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
}
|
||||
|
||||
@Override
|
||||
public String value10() {
|
||||
return getNullable();
|
||||
public Boolean value10() {
|
||||
return getIsPrimaryKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value11() {
|
||||
return getNullable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value12() {
|
||||
return getAutoIncrement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime value12() {
|
||||
public LocalDateTime value13() {
|
||||
return getCreateAt();
|
||||
}
|
||||
|
||||
|
@ -458,25 +487,31 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
}
|
||||
|
||||
@Override
|
||||
public TableColumnDocumentRecord value10(String value) {
|
||||
setNullable(value);
|
||||
public TableColumnDocumentRecord value10(Boolean value) {
|
||||
setIsPrimaryKey(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableColumnDocumentRecord value11(String value) {
|
||||
setNullable(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableColumnDocumentRecord value12(String value) {
|
||||
setAutoIncrement(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableColumnDocumentRecord value12(LocalDateTime value) {
|
||||
public TableColumnDocumentRecord value13(LocalDateTime value) {
|
||||
setCreateAt(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableColumnDocumentRecord values(Integer value1, Integer value2, Integer value3, String value4, String value5, String value6, String value7, Integer value8, Integer value9, String value10, String value11, LocalDateTime value12) {
|
||||
public TableColumnDocumentRecord values(Integer value1, Integer value2, Integer value3, String value4, String value5, String value6, String value7, Integer value8, Integer value9, Boolean value10, String value11, String value12, LocalDateTime value13) {
|
||||
value1(value1);
|
||||
value2(value2);
|
||||
value3(value3);
|
||||
|
@ -489,6 +524,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
value10(value10);
|
||||
value11(value11);
|
||||
value12(value12);
|
||||
value13(value13);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -506,7 +542,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
/**
|
||||
* Create a detached, initialised TableColumnDocumentRecord
|
||||
*/
|
||||
public TableColumnDocumentRecord(Integer id, Integer tableDocumentId, Integer databaseDocumentId, String name, String type, String comment, String defaultValue, Integer size, Integer decimalDigits, String nullable, String autoIncrement, LocalDateTime createAt) {
|
||||
public TableColumnDocumentRecord(Integer id, Integer tableDocumentId, Integer databaseDocumentId, String name, String type, String comment, String defaultValue, Integer size, Integer decimalDigits, Boolean isPrimaryKey, String nullable, String autoIncrement, LocalDateTime createAt) {
|
||||
super(TableColumnDocument.TABLE_COLUMN_DOCUMENT);
|
||||
|
||||
setId(id);
|
||||
|
@ -518,6 +554,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
setDefaultValue(defaultValue);
|
||||
setSize(size);
|
||||
setDecimalDigits(decimalDigits);
|
||||
setIsPrimaryKey(isPrimaryKey);
|
||||
setNullable(nullable);
|
||||
setAutoIncrement(autoIncrement);
|
||||
setCreateAt(createAt);
|
||||
|
@ -539,6 +576,7 @@ public class TableColumnDocumentRecord extends UpdatableRecordImpl<TableColumnDo
|
|||
setDefaultValue(value.getDefaultValue());
|
||||
setSize(value.getSize());
|
||||
setDecimalDigits(value.getDecimalDigits());
|
||||
setIsPrimaryKey(value.getIsPrimaryKey());
|
||||
setNullable(value.getNullable());
|
||||
setAutoIncrement(value.getAutoIncrement());
|
||||
setCreateAt(value.getCreateAt());
|
||||
|
|
|
@ -12,8 +12,8 @@ import java.time.LocalDateTime;
|
|||
import org.jooq.Field;
|
||||
import org.jooq.JSON;
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.Record8;
|
||||
import org.jooq.Row8;
|
||||
import org.jooq.Record7;
|
||||
import org.jooq.Row7;
|
||||
import org.jooq.impl.UpdatableRecordImpl;
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ import org.jooq.impl.UpdatableRecordImpl;
|
|||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class TableIndexDocumentRecord extends UpdatableRecordImpl<TableIndexDocumentRecord> implements Record8<Integer, Integer, Integer, String, Boolean, Boolean, JSON, LocalDateTime> {
|
||||
public class TableIndexDocumentRecord extends UpdatableRecordImpl<TableIndexDocumentRecord> implements Record7<Integer, Integer, Integer, String, Boolean, JSON, LocalDateTime> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -83,60 +83,46 @@ public class TableIndexDocumentRecord extends UpdatableRecordImpl<TableIndexDocu
|
|||
return (String) get(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.table_index_document.is_primary</code>.
|
||||
*/
|
||||
public void setIsPrimary(Boolean value) {
|
||||
set(4, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.table_index_document.is_primary</code>.
|
||||
*/
|
||||
public Boolean getIsPrimary() {
|
||||
return (Boolean) get(4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.table_index_document.is_unique</code>.
|
||||
*/
|
||||
public void setIsUnique(Boolean value) {
|
||||
set(5, value);
|
||||
set(4, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.table_index_document.is_unique</code>.
|
||||
*/
|
||||
public Boolean getIsUnique() {
|
||||
return (Boolean) get(5);
|
||||
return (Boolean) get(4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.table_index_document.column_name_array</code>.
|
||||
*/
|
||||
public void setColumnNameArray(JSON value) {
|
||||
set(6, value);
|
||||
set(5, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.table_index_document.column_name_array</code>.
|
||||
*/
|
||||
public JSON getColumnNameArray() {
|
||||
return (JSON) get(6);
|
||||
return (JSON) get(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.table_index_document.create_at</code>.
|
||||
*/
|
||||
public void setCreateAt(LocalDateTime value) {
|
||||
set(7, value);
|
||||
set(6, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.table_index_document.create_at</code>.
|
||||
*/
|
||||
public LocalDateTime getCreateAt() {
|
||||
return (LocalDateTime) get(7);
|
||||
return (LocalDateTime) get(6);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -149,17 +135,17 @@ public class TableIndexDocumentRecord extends UpdatableRecordImpl<TableIndexDocu
|
|||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Record8 type implementation
|
||||
// Record7 type implementation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row8<Integer, Integer, Integer, String, Boolean, Boolean, JSON, LocalDateTime> fieldsRow() {
|
||||
return (Row8) super.fieldsRow();
|
||||
public Row7<Integer, Integer, Integer, String, Boolean, JSON, LocalDateTime> fieldsRow() {
|
||||
return (Row7) super.fieldsRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Row8<Integer, Integer, Integer, String, Boolean, Boolean, JSON, LocalDateTime> valuesRow() {
|
||||
return (Row8) super.valuesRow();
|
||||
public Row7<Integer, Integer, Integer, String, Boolean, JSON, LocalDateTime> valuesRow() {
|
||||
return (Row7) super.valuesRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,21 +170,16 @@ public class TableIndexDocumentRecord extends UpdatableRecordImpl<TableIndexDocu
|
|||
|
||||
@Override
|
||||
public Field<Boolean> field5() {
|
||||
return TableIndexDocument.TABLE_INDEX_DOCUMENT.IS_PRIMARY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<Boolean> field6() {
|
||||
return TableIndexDocument.TABLE_INDEX_DOCUMENT.IS_UNIQUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<JSON> field7() {
|
||||
public Field<JSON> field6() {
|
||||
return TableIndexDocument.TABLE_INDEX_DOCUMENT.COLUMN_NAME_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Field<LocalDateTime> field8() {
|
||||
public Field<LocalDateTime> field7() {
|
||||
return TableIndexDocument.TABLE_INDEX_DOCUMENT.CREATE_AT;
|
||||
}
|
||||
|
||||
|
@ -224,21 +205,16 @@ public class TableIndexDocumentRecord extends UpdatableRecordImpl<TableIndexDocu
|
|||
|
||||
@Override
|
||||
public Boolean component5() {
|
||||
return getIsPrimary();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean component6() {
|
||||
return getIsUnique();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSON component7() {
|
||||
public JSON component6() {
|
||||
return getColumnNameArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime component8() {
|
||||
public LocalDateTime component7() {
|
||||
return getCreateAt();
|
||||
}
|
||||
|
||||
|
@ -264,21 +240,16 @@ public class TableIndexDocumentRecord extends UpdatableRecordImpl<TableIndexDocu
|
|||
|
||||
@Override
|
||||
public Boolean value5() {
|
||||
return getIsPrimary();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean value6() {
|
||||
return getIsUnique();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSON value7() {
|
||||
public JSON value6() {
|
||||
return getColumnNameArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime value8() {
|
||||
public LocalDateTime value7() {
|
||||
return getCreateAt();
|
||||
}
|
||||
|
||||
|
@ -308,30 +279,24 @@ public class TableIndexDocumentRecord extends UpdatableRecordImpl<TableIndexDocu
|
|||
|
||||
@Override
|
||||
public TableIndexDocumentRecord value5(Boolean value) {
|
||||
setIsPrimary(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableIndexDocumentRecord value6(Boolean value) {
|
||||
setIsUnique(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableIndexDocumentRecord value7(JSON value) {
|
||||
public TableIndexDocumentRecord value6(JSON value) {
|
||||
setColumnNameArray(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableIndexDocumentRecord value8(LocalDateTime value) {
|
||||
public TableIndexDocumentRecord value7(LocalDateTime value) {
|
||||
setCreateAt(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableIndexDocumentRecord values(Integer value1, Integer value2, Integer value3, String value4, Boolean value5, Boolean value6, JSON value7, LocalDateTime value8) {
|
||||
public TableIndexDocumentRecord values(Integer value1, Integer value2, Integer value3, String value4, Boolean value5, JSON value6, LocalDateTime value7) {
|
||||
value1(value1);
|
||||
value2(value2);
|
||||
value3(value3);
|
||||
|
@ -339,7 +304,6 @@ public class TableIndexDocumentRecord extends UpdatableRecordImpl<TableIndexDocu
|
|||
value5(value5);
|
||||
value6(value6);
|
||||
value7(value7);
|
||||
value8(value8);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -357,14 +321,13 @@ public class TableIndexDocumentRecord extends UpdatableRecordImpl<TableIndexDocu
|
|||
/**
|
||||
* Create a detached, initialised TableIndexDocumentRecord
|
||||
*/
|
||||
public TableIndexDocumentRecord(Integer id, Integer tableDocumentId, Integer databaseDocumentId, String name, Boolean isPrimary, Boolean isUnique, JSON columnNameArray, LocalDateTime createAt) {
|
||||
public TableIndexDocumentRecord(Integer id, Integer tableDocumentId, Integer databaseDocumentId, String name, Boolean isUnique, JSON columnNameArray, LocalDateTime createAt) {
|
||||
super(TableIndexDocument.TABLE_INDEX_DOCUMENT);
|
||||
|
||||
setId(id);
|
||||
setTableDocumentId(tableDocumentId);
|
||||
setDatabaseDocumentId(databaseDocumentId);
|
||||
setName(name);
|
||||
setIsPrimary(isPrimary);
|
||||
setIsUnique(isUnique);
|
||||
setColumnNameArray(columnNameArray);
|
||||
setCreateAt(createAt);
|
||||
|
@ -381,7 +344,6 @@ public class TableIndexDocumentRecord extends UpdatableRecordImpl<TableIndexDocu
|
|||
setTableDocumentId(value.getTableDocumentId());
|
||||
setDatabaseDocumentId(value.getDatabaseDocumentId());
|
||||
setName(value.getName());
|
||||
setIsPrimary(value.getIsPrimary());
|
||||
setIsUnique(value.getIsUnique());
|
||||
setColumnNameArray(value.getColumnNameArray());
|
||||
setCreateAt(value.getCreateAt());
|
||||
|
|
|
@ -4,6 +4,7 @@ package com.databasir.dao.impl;
|
|||
import com.databasir.dao.exception.DataNotExistsException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jooq.*;
|
||||
import org.jooq.Record;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
|
|
@ -167,6 +167,7 @@ CREATE TABLE table_column_document
|
|||
default_value VARCHAR(512) DEFAULT NULL,
|
||||
size INT NOT NULL,
|
||||
decimal_digits INT DEFAULT NULL,
|
||||
is_primary_key BOOLEAN NOT NULL,
|
||||
nullable VARCHAR(64) NOT NULL COMMENT 'YES, NO, UNKNOWN',
|
||||
auto_increment VARCHAR(64) NOT NULL COMMENT 'YES, NO, UNKNOWN',
|
||||
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
@ -182,7 +183,6 @@ CREATE TABLE table_index_document
|
|||
table_document_id INT NOT NULL,
|
||||
database_document_id INT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
is_primary BOOLEAN NOT NULL,
|
||||
is_unique BOOLEAN NOT NULL,
|
||||
column_name_array JSON NOT NULL,
|
||||
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
|
|
@ -26,4 +26,5 @@ public class ColumnMeta {
|
|||
|
||||
private String autoIncrement;
|
||||
|
||||
private Boolean isPrimaryKey;
|
||||
}
|
|
@ -15,7 +15,5 @@ public class IndexMeta {
|
|||
@Builder.Default
|
||||
private List<String> columnNames = Collections.emptyList();
|
||||
|
||||
private Boolean isPrimaryKey;
|
||||
|
||||
private Boolean isUniqueKey;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -29,6 +30,7 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
|
|||
List<ColumnMeta> columnDocs = new ArrayList<>();
|
||||
String databaseName = tableCondition.getDatabaseName();
|
||||
String tableName = tableCondition.getTableName();
|
||||
List<String> primaryKeyColumns = selectPrimaryKeyColumns(connection.getMetaData(), databaseName, tableName);
|
||||
ResultSet columnsResult;
|
||||
try {
|
||||
columnsResult = connection.getMetaData().getColumns(databaseName, null, tableName, null);
|
||||
|
@ -73,6 +75,7 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
|
|||
.autoIncrement(isAutoIncrement)
|
||||
.comment(columnComment)
|
||||
.defaultValue(defaultValue)
|
||||
.isPrimaryKey(primaryKeyColumns.contains(columnName))
|
||||
.build();
|
||||
columnDocs.add(columnMeta);
|
||||
}
|
||||
|
@ -80,4 +83,14 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
|
|||
}
|
||||
return columnDocs;
|
||||
}
|
||||
|
||||
private List<String> selectPrimaryKeyColumns(DatabaseMetaData meta, String catalog, String tableName) throws SQLException {
|
||||
ResultSet result = meta.getPrimaryKeys(catalog, null, tableName);
|
||||
List<String> columns = new ArrayList<>();
|
||||
while (result.next()) {
|
||||
String columnName = result.getString("COLUMN_NAME");
|
||||
columns.add(columnName);
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ public class JdbcIndexMetaRepository implements IndexMetaRepository {
|
|||
IndexMeta indexMeta = IndexMeta.builder()
|
||||
.name(indexName)
|
||||
.columnNames(columns)
|
||||
.isPrimaryKey(Objects.equals("PRIMARY", indexName))
|
||||
.isUniqueKey(Objects.equals(nonUnique, false))
|
||||
.build();
|
||||
pojoGroupByName.put(indexName, indexMeta);
|
||||
|
|
|
@ -57,7 +57,6 @@ public class RenderConfig {
|
|||
protected LinkedHashMap<String, Function<IndexMeta, String>> indexTitleAndValueMapping() {
|
||||
LinkedHashMap<String, Function<IndexMeta, String>> mapping = new LinkedHashMap<>();
|
||||
mapping.put("Name", IndexMeta::getName);
|
||||
mapping.put("IsPrimary", index -> index.getIsPrimaryKey() ? "YES" : "");
|
||||
mapping.put("IsUnique", index -> index.getIsUniqueKey() ? "YES" : "");
|
||||
mapping.put("Columns", index -> String.join(", ", index.getColumnNames()));
|
||||
return mapping;
|
||||
|
|
|
@ -33,7 +33,7 @@ public class App {
|
|||
// this config is used by mysql
|
||||
info.put("useInformationSchema", "true");
|
||||
|
||||
String url = "jdbc:mysql://localhost:3306/patient?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true";
|
||||
String url = "jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true";
|
||||
return DriverManager.getConnection(url, info);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue