-
Notifications
You must be signed in to change notification settings - Fork 356
Changes to support generating Liquibase change-sets #1520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
f5fa502
201ba55
e5e993f
ebde99f
4d08588
f7a5ead
989d4b2
7e21cfc
046d916
33e3308
2335a4b
a22eccc
d2d7845
023b34f
03597b9
86c52f1
c68584b
c9efa82
9757b71
0c01a9c
e3e123d
cf21d29
c9841c5
1693d24
212d07a
9749dcf
0ea5833
187e55d
d8b105d
e4f1a0a
e85ab13
cd8d041
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,12 +32,12 @@ | |
* @author Kurt Niemi | ||
* @since 2.0 | ||
*/ | ||
class DerivedSqlIdentifier implements SqlIdentifier { | ||
public class DerivedSqlIdentifier implements SqlIdentifier { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Open to alternatives if we don't want to make this public. The TableModel and ColumnModel classes take in a SQLIdentifier in their constructor - and the LiquibaseChangeSetGenerator class creates a SchemaSQLGenerationModel (which I think I am going to rename/refactor to SchemaModel) |
||
private final String name; | ||
private final boolean quoted; | ||
|
||
DerivedSqlIdentifier(String name, boolean quoted) { | ||
public DerivedSqlIdentifier(String name, boolean quoted) { | ||
|
||
Assert.hasText(name, "A database object must have at least on name part."); | ||
this.name = name; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.data.relational.core.mapping.schemasqlgeneration; | ||
|
||
import java.util.HashMap; | ||
|
||
public class BaseTypeMapper { | ||
|
||
final HashMap<Class<?>,String> mapClassToDatabaseType = new HashMap<Class<?>,String>(); | ||
|
||
public BaseTypeMapper() { | ||
|
||
mapClassToDatabaseType.put(String.class, "VARCHAR(255 BYTE)"); | ||
mapClassToDatabaseType.put(Boolean.class, "TINYINT"); | ||
mapClassToDatabaseType.put(Double.class, "DOUBLE"); | ||
mapClassToDatabaseType.put(Float.class, "FLOAT"); | ||
mapClassToDatabaseType.put(Integer.class, "INT"); | ||
mapClassToDatabaseType.put(Long.class, "BIGINT"); | ||
} | ||
public String databaseTypeFromClass(Class<?> type) { | ||
|
||
return mapClassToDatabaseType.get(type); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.data.relational.core.mapping.schemasqlgeneration; | ||
|
||
import org.springframework.data.relational.core.sql.SqlIdentifier; | ||
|
||
import java.util.Objects; | ||
|
||
|
||
/** | ||
* Class that models a Column for generating SQL for Schema generation. | ||
* | ||
* @author Kurt Niemi | ||
*/ | ||
public class ColumnModel { | ||
private final SqlIdentifier name; | ||
private final String type; | ||
private final boolean nullable; | ||
private final boolean identityColumn; | ||
|
||
public ColumnModel(SqlIdentifier name, String type, boolean nullable, boolean identityColumn) { | ||
this.name = name; | ||
this.type = type; | ||
this.nullable = nullable; | ||
this.identityColumn = identityColumn; | ||
} | ||
|
||
public ColumnModel(SqlIdentifier name, String type) { | ||
this.name = name; | ||
this.type = type; | ||
this.nullable = false; | ||
this.identityColumn = false; | ||
} | ||
|
||
public SqlIdentifier getName() { | ||
return name; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public boolean isNullable() { | ||
return nullable; | ||
} | ||
|
||
public boolean isIdentityColumn() { | ||
return identityColumn; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ColumnModel that = (ColumnModel) o; | ||
return Objects.equals(name, that.name); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should clean up the
developer
sections as these information are inherited from parent pom's.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, all of the developers should go into the parent spring-data-relational.pom? (and we remove from the spring-data-jdbc and spring-data-r2dbc) and also make sure that nobody gets deleted :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. I assume that we missed the cleanup when we split modules and added the R2DBC module during the course of our repository rearrangement one or two years ago.