mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
Yugabyte - Use Postgres ScalarTypes for JSON/JSONB but not HSTORE
This commit is contained in:
1 parent
94ae513d85
commit
1359d534d5
2 files changed
+13
-6
No files matched your search
@@ -95,6 +95,7 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
private final TypeJsonManager jsonManager;
|
private final TypeJsonManager jsonManager;
|
||||||
private final boolean offlineMigrationGeneration;
|
private final boolean offlineMigrationGeneration;
|
||||||
private final EnumType defaultEnumType;
|
private final EnumType defaultEnumType;
|
||||||
|
private final DatabasePlatform databasePlatform;
|
||||||
|
|
||||||
// OPTIONAL ScalarTypes registered if Jackson/JsonNode is in the classpath
|
// OPTIONAL ScalarTypes registered if Jackson/JsonNode is in the classpath
|
||||||
|
|
||||||
@@ -132,7 +133,8 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
this.typeMap = new ConcurrentHashMap<>();
|
this.typeMap = new ConcurrentHashMap<>();
|
||||||
this.nativeMap = new ConcurrentHashMap<>();
|
this.nativeMap = new ConcurrentHashMap<>();
|
||||||
this.logicalMap = new ConcurrentHashMap<>();
|
this.logicalMap = new ConcurrentHashMap<>();
|
||||||
this.postgres = isPostgres(config.getDatabasePlatform());
|
this.databasePlatform = config.getDatabasePlatform();
|
||||||
|
this.postgres = isPostgresCompatible(config.getDatabasePlatform());
|
||||||
this.objectMapperPresent = config.getClassLoadConfig().isJacksonObjectMapperPresent();
|
this.objectMapperPresent = config.getClassLoadConfig().isJacksonObjectMapperPresent();
|
||||||
this.objectMapper = (objectMapperPresent) ? initObjectMapper(config) : null;
|
this.objectMapper = (objectMapperPresent) ? initObjectMapper(config) : null;
|
||||||
this.jsonManager = (objectMapperPresent) ? new TypeJsonManager(postgres, objectMapper, config.getJsonMutationDetection()) : null;
|
this.jsonManager = (objectMapperPresent) ? new TypeJsonManager(postgres, objectMapper, config.getJsonMutationDetection()) : null;
|
||||||
@@ -198,8 +200,13 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPostgres(DatabasePlatform databasePlatform) {
|
private boolean isPostgresCompatible(DatabasePlatform databasePlatform) {
|
||||||
return databasePlatform.getPlatform().base() == Platform.POSTGRES;
|
return databasePlatform.isPlatform(Platform.POSTGRES)
|
||||||
|
|| databasePlatform.isPlatform(Platform.YUGABYTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hstoreSupport() {
|
||||||
|
return databasePlatform.isPlatform(Platform.POSTGRES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -302,7 +309,7 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScalarType<?> getDbMapScalarType() {
|
public ScalarType<?> getDbMapScalarType() {
|
||||||
return (postgres) ? hstoreType : ScalarTypeJsonMap.typeFor(false, Types.VARCHAR, false);
|
return hstoreSupport() ? hstoreType : ScalarTypeJsonMap.typeFor(false, Types.VARCHAR, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -740,7 +747,7 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
jsonNodeVarchar = new ScalarTypeJsonNode.Varchar(mapper);
|
jsonNodeVarchar = new ScalarTypeJsonNode.Varchar(mapper);
|
||||||
jsonNodeJson = jsonNodeClob; // Default for non-Postgres databases
|
jsonNodeJson = jsonNodeClob; // Default for non-Postgres databases
|
||||||
jsonNodeJsonb = jsonNodeClob; // Default for non-Postgres databases
|
jsonNodeJsonb = jsonNodeClob; // Default for non-Postgres databases
|
||||||
if (isPostgres(config.getDatabasePlatform())) {
|
if (postgres) {
|
||||||
jsonNodeJson = new ScalarTypeJsonNodePostgres.JSON(mapper);
|
jsonNodeJson = new ScalarTypeJsonNodePostgres.JSON(mapper);
|
||||||
jsonNodeJsonb = new ScalarTypeJsonNodePostgres.JSONB(mapper);
|
jsonNodeJsonb = new ScalarTypeJsonNodePostgres.JSONB(mapper);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
drop view order_agg_vw if exists;
|
drop view order_agg_vw if exists;
|
||||||
</ddl-script>
|
</ddl-script>
|
||||||
|
|
||||||
<ddl-script name="order views" platforms="db2,h2,postgres,oracle,mysql,mariadb,nuodb">
|
<ddl-script name="order views" platforms="db2,h2,postgres,oracle,mysql,mariadb,nuodb,yugabyte">
|
||||||
create or replace view order_agg_vw as
|
create or replace view order_agg_vw as
|
||||||
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
|
||||||
sum(d.ship_qty * d.unit_price) as ship_total
|
sum(d.ship_qty * d.unit_price) as ship_total
|
||||||
|
|||||||
Reference in new issue
Block a user