Skip to content
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

Generated indexes are not including "desc" #956

Merged
merged 4 commits into from Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -351,14 +351,8 @@ protected <T extends DatabaseObject> T include(T example) throws DatabaseExcepti
private void includeNestedObjects(DatabaseObject object) throws DatabaseException, InvalidExampleException, ReflectiveOperationException {
for (String field : new HashSet<>(object.getAttributes())) {
Object fieldValue = object.getAttribute(field, Object.class);
if ("columns".equals(field) && ((object.getClass() == PrimaryKey.class) || (object.getClass() == Index
.class) || (object.getClass() == UniqueConstraint.class))) {
if ((fieldValue != null) && !((Collection) fieldValue).isEmpty()) {
String columnName = ((Column) ((Collection) fieldValue).iterator().next()).getName();
if (columnName.endsWith(" ASC") || columnName.endsWith(" DESC") || columnName.endsWith(" RANDOM")) {
continue;
}
}
if ("columns".equals(field) && ((object.getClass() == PrimaryKey.class) || (object.getClass() == Index.class) || (object.getClass() == UniqueConstraint.class))) {
continue;
}
Object newFieldValue = replaceObject(fieldValue);
if (newFieldValue == null) { //sometimes an object references a non-snapshotted object. Leave it with the unsnapshotted example
Expand Down
Expand Up @@ -57,9 +57,6 @@ protected DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot
Database database = snapshot.getDatabase();

Relation relation = ((Column) example).getRelation();
if (((Column) example).getComputed() != null && ((Column) example).getComputed()) {
return example;
}

Schema schema = relation.getSchema();
try {
Expand Down
Expand Up @@ -11,11 +11,15 @@
public class ColumnSnapshotGeneratorH2 extends ColumnSnapshotGenerator {
@Override
public int getPriority(Class<? extends DatabaseObject> objectType, Database database) {
if (Column.class.isAssignableFrom(objectType) && (database instanceof H2Database)) {
return PRIORITY_DATABASE;
} else {
if (!(database instanceof H2Database)) {
return PRIORITY_NONE;
}

int priority = super.getPriority(objectType, database);
if (priority == 0) {
return priority;
}
return priority + 5;
}

@Override
Expand Down