Skip to content
Prev Previous commit
Next Next commit
Use SQLIdentifiers for Table and Column names
  • Loading branch information
kurtn718 committed Apr 10, 2023
commit c59f8a7165781f5245faef8ba3d0cf400df1848d
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ public SchemaSQLGenerationDataModel generateSchemaSQL() {
SchemaSQLGenerationDataModel model = new SchemaSQLGenerationDataModel();

for (RelationalPersistentEntity entity : getPersistentEntities()) {
TableModel tableModel = new TableModel(entity.getTableName().getReference());
TableModel tableModel = new TableModel(entity.getTableName());

Iterator<BasicRelationalPersistentProperty> iter =
entity.getPersistentProperties(Column.class).iterator();

while (iter.hasNext()) {
BasicRelationalPersistentProperty p = iter.next();
ColumnModel columnModel = new ColumnModel(p.getColumnName().getReference(), p.getActualType());
ColumnModel columnModel = new ColumnModel(p.getColumnName(), p.getActualType());
tableModel.getColumns().add(columnModel);
}
model.getTableData().add(tableModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.springframework.data.relational.core.mapping.schemasqlgeneration;

import org.springframework.data.relational.core.sql.SqlIdentifier;

import java.io.Serial;
import java.io.Serializable;

Expand All @@ -26,23 +28,23 @@
public class ColumnModel implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private final String name;
private final SqlIdentifier name;
private final Class<?> type;
private final boolean nullable;

public ColumnModel(String name, Class<?> type, boolean nullable) {
public ColumnModel(SqlIdentifier name, Class<?> type, boolean nullable) {
this.name = name;
this.type = type;
this.nullable = nullable;
}

public ColumnModel(String name, Class<?> type) {
public ColumnModel(SqlIdentifier name, Class<?> type) {
this.name = name;
this.type = type;
this.nullable = false;
}

public String getName() {
public SqlIdentifier getName() {
return name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.springframework.data.relational.core.mapping.schemasqlgeneration;

import org.springframework.data.relational.core.sql.SqlIdentifier;

import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
Expand All @@ -29,24 +31,24 @@ public class TableModel implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private final String schema;
private final String name;
private final SqlIdentifier name;
private final List<ColumnModel> columns = new ArrayList<ColumnModel>();
private final List<ColumnModel> keyColumns = new ArrayList<ColumnModel>();
private final List<ForeignKeyColumnModel> foreignKeyColumns = new ArrayList<ForeignKeyColumnModel>();

public TableModel(String schema, String name) {
public TableModel(String schema, SqlIdentifier name) {
this.schema = schema;
this.name = name;
}
public TableModel(String name) {
this(name, null);
public TableModel(SqlIdentifier name) {
this(null, name);
}

public String getSchema() {
return schema;
}

public String getName() {
public SqlIdentifier getName() {
return name;
}

Expand Down