Merge pull request #1909 from ebean-orm/feature/mySqlJson

For MySql map @DbJson to mysql JSON db type
This commit is contained in:
Rob Bygrave
2020-01-10 23:59:18 +13:00
committed by GitHub
4 changed files with 24 additions and 22 deletions
@@ -65,6 +65,8 @@ public class MySqlPlatform extends DatabasePlatform {
dbTypeMap.put(DbType.BLOB, new MySqlBlob());
dbTypeMap.put(DbType.BINARY, new DbPlatformType("binary", 255));
dbTypeMap.put(DbType.VARBINARY, new DbPlatformType("varbinary", 255));
dbTypeMap.put(DbType.JSON, new DbPlatformType("json", false));
dbTypeMap.put(DbType.JSONB, new DbPlatformType("json", false));
}
@Override
+19 -19
View File
@@ -1,4 +1,4 @@
-- Generated by ebean unknown at 2020-01-10T01:11:55.722473Z
-- Generated by ebean unknown at 2020-01-10T01:29:41.798461Z
create table asimple_bean (
id bigint auto_increment not null,
name varchar(255),
@@ -982,10 +982,10 @@ create table ebasic_hstore (
create table ebasic_json_jackson (
id bigint auto_increment not null,
name varchar(255),
value_set varchar(700),
value_list longtext,
value_map varchar(700),
plain_value varchar(500),
value_set json,
value_list json,
value_map json,
plain_value json,
version bigint not null,
constraint pk_ebasic_json_jackson primary key (id)
);
@@ -993,10 +993,10 @@ create table ebasic_json_jackson (
create table ebasic_json_jackson2 (
id bigint auto_increment not null,
name varchar(255),
value_set varchar(700),
value_list longtext,
value_map varchar(700),
plain_value varchar(500),
value_set json,
value_list json,
value_map json,
plain_value json,
version bigint not null,
constraint pk_ebasic_json_jackson2 primary key (id)
);
@@ -1004,11 +1004,11 @@ create table ebasic_json_jackson2 (
create table ebasic_json_list (
id bigint auto_increment not null,
name varchar(255),
bean_set varchar(700),
bean_list longtext,
bean_map varchar(700),
plain_bean varchar(500),
flags varchar(50),
bean_set json,
bean_list json,
bean_map json,
plain_bean json,
flags json,
tags varchar(100),
version bigint not null,
constraint pk_ebasic_json_list primary key (id)
@@ -1017,7 +1017,7 @@ create table ebasic_json_list (
create table ebasic_json_map (
id bigint auto_increment not null,
name varchar(255),
content longtext,
content json,
version bigint not null,
constraint pk_ebasic_json_map primary key (id)
);
@@ -1042,7 +1042,7 @@ create table ebasic_json_map_detail (
id bigint auto_increment not null,
owner_id bigint,
name varchar(255),
content longtext,
content json,
version bigint not null,
constraint pk_ebasic_json_map_detail primary key (id)
);
@@ -1050,7 +1050,7 @@ create table ebasic_json_map_detail (
create table ebasic_json_map_json_b (
id bigint auto_increment not null,
name varchar(255),
content longtext,
content json,
version bigint not null,
constraint pk_ebasic_json_map_json_b primary key (id)
);
@@ -1066,7 +1066,7 @@ create table ebasic_json_map_varchar (
create table ebasic_json_node (
id bigint auto_increment not null,
name varchar(255),
content longtext,
content json,
version bigint not null,
constraint pk_ebasic_json_node primary key (id)
);
@@ -1082,7 +1082,7 @@ create table ebasic_json_node_blob (
create table ebasic_json_node_json_b (
id bigint auto_increment not null,
name varchar(255),
content longtext,
content json,
version bigint not null,
constraint pk_ebasic_json_node_json_b primary key (id)
);
+1 -1
View File
@@ -1,4 +1,4 @@
-- Generated by ebean unknown at 2020-01-10T01:11:55.722473Z
-- Generated by ebean unknown at 2020-01-10T01:29:41.798461Z
alter table bar drop foreign key fk_bar_foo_id;
drop index ix_bar_foo_id on bar;
@@ -16,8 +16,8 @@ public class MySqlPlatformTest {
public void testTypeConversion() {
PlatformDdl ddl = PlatformDdlBuilder.create(mySqlPlatform);
assertThat(ddl.convert("clob", false)).isEqualTo("longtext");
assertThat(ddl.convert("json", false)).isEqualTo("longtext");
assertThat(ddl.convert("jsonb", false)).isEqualTo("longtext");
assertThat(ddl.convert("json", false)).isEqualTo("json");
assertThat(ddl.convert("jsonb", false)).isEqualTo("json");
assertThat(ddl.convert("varchar(20)", false)).isEqualTo("varchar(20)");
assertThat(ddl.convert("boolean", false)).isEqualTo("tinyint(1)");
assertThat(ddl.convert("bit", false)).isEqualTo("tinyint(1)");