-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2743 - Postgres DDL - For create table, improve column ordering for …
…tighter storage
- Loading branch information
Showing
10 changed files
with
134 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
...erator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/YugabyteDdl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
package io.ebeaninternal.dbmigration.ddlgeneration.platform; | ||
|
||
import io.ebean.config.dbplatform.DatabasePlatform; | ||
import io.ebeaninternal.dbmigration.migration.Column; | ||
|
||
public class YugabyteDdl extends PostgresDdl { | ||
import java.util.List; | ||
|
||
public final class YugabyteDdl extends PostgresDdl { | ||
|
||
public YugabyteDdl(DatabasePlatform platform) { | ||
super(platform); | ||
this.historyDdl = new YugabyteHistoryDdl(); | ||
} | ||
|
||
@Override | ||
protected List<Column> sortColumns(List<Column> columns) { | ||
return columns; | ||
} | ||
} |
48 changes: 45 additions & 3 deletions
48
...or/src/test/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/PostgresDdlTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,60 @@ | ||
package io.ebeaninternal.dbmigration.ddlgeneration.platform; | ||
|
||
import io.ebean.platform.postgres.PostgresPlatform; | ||
import io.ebeaninternal.dbmigration.migration.Column; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class PostgresDdlTest { | ||
class PostgresDdlTest { | ||
|
||
private PostgresDdl postgresDdl = new PostgresDdl(new PostgresPlatform()); | ||
|
||
@Test | ||
public void setLockTimeout() { | ||
|
||
void setLockTimeout() { | ||
final String sql = postgresDdl.setLockTimeout(5); | ||
assertThat(sql).isEqualTo("set lock_timeout = 5000"); | ||
} | ||
|
||
@Test | ||
void sortColumns_noAdjustment() { | ||
List<Column> cols = postgresDdl.sortColumns(columns("integer", "bigint")); | ||
assertThat(cols).extracting("type").containsExactly("integer", "bigint"); | ||
|
||
List<Column> colsReverse = postgresDdl.sortColumns(columns("bigint", "integer")); | ||
assertThat(colsReverse).extracting("type").containsExactly("bigint", "integer"); | ||
} | ||
|
||
@Test | ||
void sortColumns_decimalVarchar() { | ||
List<Column> cols = postgresDdl.sortColumns(columns("decimal(1)", "varchar(1)", "varchar(2)", "int", "decimal(2)")); | ||
assertThat(cols).extracting("type").containsExactly("int", "decimal(1)", "decimal(2)", "varchar(1)", "varchar(2)"); | ||
} | ||
|
||
@Test | ||
void sortColumns_varbinary() { | ||
List<Column> cols = postgresDdl.sortColumns(columns("decimal(1)", "varbinary(1)", "varbinary(2)", "int", "decimal(2)")); | ||
assertThat(cols).extracting("type").containsExactly("int", "decimal(1)", "decimal(2)", "varbinary(1)", "varbinary(2)"); | ||
} | ||
|
||
@Test | ||
void sortColumns_clobs() { | ||
List<Column> cols = postgresDdl.sortColumns(columns("clob", "blob", "longvarchar(1)", "int", "longvarbinary(2)")); | ||
assertThat(cols).extracting("type").containsExactly("int", "clob", "blob", "longvarchar(1)", "longvarbinary(2)"); | ||
} | ||
|
||
private List<Column> columns(String... types) { | ||
int counter = 0; | ||
List<Column> cols = new ArrayList<>(); | ||
for (String s : types) { | ||
Column col = new Column(); | ||
col.setName("c" + counter++); | ||
col.setType(s); | ||
cols.add(col); | ||
} | ||
return cols; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters