Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/main/java/net/sf/jsqlparser/schema/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public Table getResolvedTable() {
public Table setResolvedTable(Table resolvedTable) {
// clone, not reference
if (resolvedTable != null) {
this.resolvedTable = new Table(resolvedTable.getFullyQualifiedName());
this.resolvedTable = resolvedTable.copyName();
}
return this;
}
Expand Down Expand Up @@ -579,9 +579,16 @@ public static Table[] setUnsetCatalogAndSchema(String currentCatalogName,

@Override
public Table clone() {
Table clone = new Table(this.getFullyQualifiedName());
Table clone = copyName();
clone.setTableVariable(tableVariable);
clone.setResolvedTable(this.resolvedTable != null ? this.resolvedTable.clone() : null);
return clone;
}

private Table copyName() {
Table copy = new Table();
copy.partItems = new ArrayList<>(partItems);
copy.partDelimiters = new ArrayList<>(partDelimiters);
return copy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,27 @@ public ColDataType() {
}

public ColDataType(String dataType, int precision, int scale) {
this.dataType = dataType;
this(dataType);
setNumericParameters(precision < 0 ? null : Integer.valueOf(precision),
scale < 0 ? null : Integer.valueOf(scale));
}

/**
* Creates a parameterized type, using {@code null} for an omitted parameter. Unlike the legacy
* primitive constructor, this accepts negative scales, including {@code -1}.
*/
public static ColDataType fromNumericParameters(String dataType, Integer precision,
Integer scale) {
ColDataType type = new ColDataType(dataType);
type.setNumericParameters(precision, scale);
return type;
}

if (precision >= 0) {
private void setNumericParameters(Integer precision, Integer scale) {
if (precision != null) {
this.precision = precision;
this.dataType += " (" + (precision == Integer.MAX_VALUE ? "MAX" : precision);
if (scale >= 0) {
if (scale != null) {
this.scale = scale;
this.dataType += ", " + scale;
}
Expand Down Expand Up @@ -211,8 +226,8 @@ public void setPrecision(Integer precision) {
}

/**
* The second numeric type parameter, e.g. {@code 2} for {@code DECIMAL(10, 2)}. Returns
* {@code null} when absent.
* The second numeric type parameter, e.g. {@code 2} for {@code DECIMAL(10, 2)} or {@code -3}
* for PostgreSQL {@code NUMERIC(2, -3)}. Returns {@code null} when absent.
*/
public Integer getScale() {
return scale;
Expand Down
Loading
Loading