Skip to content

Commit

Permalink
dbmodel: refactoring Column.GeneratedInfo.autoIncrement
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrugz committed Oct 17, 2024
1 parent 277dd76 commit 7c41344
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/tbrugz/sqldump/dbmodel/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,19 @@ public static boolean isBoolean(String type) {

}

/* XXX generated/virtual columns
/*
generated/virtual columns
https://www.postgresql.org/docs/current/ddl-generated-columns.html
https://blog.jooq.org/2012/02/19/subtle-sql-differences-identity-columns/
GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY ; start-with, increment
*/
public static class GeneratedInfo {
boolean generated;
boolean generatedAlways = true;
boolean identity;
boolean stored;
boolean virtual;
boolean autoIncrement; // GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY ; start-with, increment
//boolean autoIncrement; //using 'identity'
}

private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -276,7 +278,7 @@ public String getGeneratedSnippet() {
: ""
) +
(ColTypeUtil.useAutoIncrement()?
((generated.autoIncrement)?" auto_increment":"")
((generated.identity)?" auto_increment":"")
:"");
}

Expand Down Expand Up @@ -348,14 +350,14 @@ public void setNullable(boolean nullable) {
}

public Boolean getAutoIncrement() {
return generated!=null?generated.autoIncrement:null;
return generated!=null?generated.identity:null;
}

public void setAutoIncrement(Boolean autoIncrement) {
if(generated==null) {
initGeneratedInfo();
}
this.generated.autoIncrement = autoIncrement;
this.generated.identity = autoIncrement;
}

public Integer getOrdinalPosition() {
Expand Down

0 comments on commit 7c41344

Please sign in to comment.