mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#552 - wrong DDL generation with complex columnDefinition
This commit is contained in:
+16
@@ -10,6 +10,22 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class PlatformTypeConverterTest {
|
||||
|
||||
@Test
|
||||
public void convert_withSuffix_expect_suffix() {
|
||||
|
||||
PostgresPlatform pg = new PostgresPlatform();
|
||||
DbTypeMap dbTypeMap = pg.getDbTypeMap();
|
||||
|
||||
PlatformTypeConverter converter = new PlatformTypeConverter(dbTypeMap);
|
||||
|
||||
assertThat(converter.convert("varchar(10)")).isEqualTo("varchar(10)");
|
||||
assertThat(converter.convert("VARCHAR(10) default 'en' not null")).isEqualTo("varchar(10) default 'en' not null");
|
||||
assertThat(converter.convert("DECIMAL(10,2) DEFAULT '0.00' NOT NULL")).isEqualTo("decimal(10,2) DEFAULT '0.00' NOT NULL");
|
||||
assertThat(converter.convert("CRAZY(12,0) suffix")).isEqualTo("CRAZY(12,0) suffix");
|
||||
assertThat(converter.convert("CRAZY(12) suffix")).isEqualTo("CRAZY(12) suffix");
|
||||
assertThat(converter.convert("CRAZY suffix")).isEqualTo("CRAZY suffix");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert_given_postgres() throws Exception {
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.avaje.tests.model.zero;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
@@ -11,10 +12,13 @@ public class WithZero {
|
||||
@Id
|
||||
long id = 0;
|
||||
|
||||
String name = null;
|
||||
String name;
|
||||
|
||||
@ManyToOne
|
||||
WithZeroParent parent = null;
|
||||
WithZeroParent parent;
|
||||
|
||||
@Column(columnDefinition = "varchar(2) default 'en' not null")
|
||||
String lang = "en";
|
||||
|
||||
@Version
|
||||
long version = 0;
|
||||
@@ -35,6 +39,14 @@ public class WithZero {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLang() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
public void setLang(String lang) {
|
||||
this.lang = lang;
|
||||
}
|
||||
|
||||
public WithZeroParent getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user