mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1880 - Cidr type stored as INET (instead of CIDR) + named as Cdir (typo)
This commit is contained in:
@@ -29,6 +29,8 @@ public class DbPlatformTypeMapping {
|
||||
|
||||
private static final DbPlatformType INET_NATIVE = new DbPlatformType("inet", false);
|
||||
private static final DbPlatformType INET_VARCHAR = new DbPlatformType("varchar", 50);
|
||||
private static final DbPlatformType CIDR_NATIVE = new DbPlatformType("cidr", false);
|
||||
private static final DbPlatformType CIDR_VARCHAR = new DbPlatformType("varchar", 50);
|
||||
|
||||
private static final DbPlatformType UUID_NATIVE = new DbPlatformType("uuid", false);
|
||||
@SuppressWarnings("unused")
|
||||
@@ -110,6 +112,7 @@ public class DbPlatformTypeMapping {
|
||||
put(DbType.JSONVARCHAR, new DbPlatformType("jsonvarchar", 1000));
|
||||
put(DbType.UUID, UUID_NATIVE);
|
||||
put(DbType.INET, INET_NATIVE);
|
||||
put(DbType.CIDR, CIDR_NATIVE);
|
||||
|
||||
} else {
|
||||
put(DbType.VARCHAR, new DbPlatformType("varchar", 255));
|
||||
@@ -126,6 +129,7 @@ public class DbPlatformTypeMapping {
|
||||
// default to native UUID and override on platform configure()
|
||||
put(DbType.UUID, UUID_NATIVE);
|
||||
put(DbType.INET, INET_VARCHAR);
|
||||
put(DbType.CIDR, CIDR_VARCHAR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public enum DbType {
|
||||
|
||||
UUID(ExtraDbTypes.UUID),
|
||||
INET(ExtraDbTypes.INET),
|
||||
CDIR(ExtraDbTypes.CDIR),
|
||||
CIDR(ExtraDbTypes.CIDR),
|
||||
|
||||
POINT(ExtraDbTypes.POINT),
|
||||
POLYGON(ExtraDbTypes.POLYGON),
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface ExtraDbTypes {
|
||||
int JSONBlob = 5005;
|
||||
|
||||
int INET = 5020;
|
||||
int CDIR = 5021;
|
||||
int CIDR = 5021;
|
||||
|
||||
/**
|
||||
* Geo Point
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ClickHousePlatform extends DatabasePlatform {
|
||||
|
||||
dbTypeMap.put(DbType.UUID, new DbPlatformType("UUID", false));
|
||||
dbTypeMap.put(DbType.INET, new DbPlatformType("String", false));
|
||||
dbTypeMap.put(DbType.CDIR, new DbPlatformType("String", false));
|
||||
dbTypeMap.put(DbType.CIDR, new DbPlatformType("String", false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -63,6 +63,7 @@ public class PostgresPlatform extends DatabasePlatform {
|
||||
|
||||
dbTypeMap.put(DbType.UUID, new DbPlatformType("uuid", false));
|
||||
dbTypeMap.put(DbType.INET, new DbPlatformType("inet", false));
|
||||
dbTypeMap.put(DbType.CIDR, new DbPlatformType("cidr", false));
|
||||
dbTypeMap.put(DbType.HSTORE, new DbPlatformType("hstore", false));
|
||||
dbTypeMap.put(DbType.JSON, new DbPlatformType("json", false));
|
||||
dbTypeMap.put(DbType.JSONB, new DbPlatformType("jsonb", false));
|
||||
|
||||
@@ -14,7 +14,7 @@ import io.ebean.config.ScalarTypeConverter;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.DbPlatformType;
|
||||
import io.ebean.types.Cdir;
|
||||
import io.ebean.types.Cidr;
|
||||
import io.ebean.types.Inet;
|
||||
import io.ebean.util.AnnotationUtil;
|
||||
import io.ebeaninternal.api.ExtraTypeFactory;
|
||||
@@ -993,10 +993,10 @@ public final class DefaultTypeManager implements TypeManager {
|
||||
}
|
||||
|
||||
if (offlineMigrationGeneration || postgres) {
|
||||
addType(Cdir.class, new ScalarTypeCdir.Postgres());
|
||||
addType(Cidr.class, new ScalarTypeCdir.Postgres());
|
||||
addType(Inet.class, new ScalarTypeInet.Postgres());
|
||||
} else {
|
||||
addType(Cdir.class, new ScalarTypeCdir.Varchar());
|
||||
addType(Cidr.class, new ScalarTypeCdir.Varchar());
|
||||
addType(Inet.class, new ScalarTypeInet.Varchar());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import io.ebean.config.dbplatform.ExtraDbTypes;
|
||||
import io.ebean.types.Cdir;
|
||||
import io.ebean.types.Cidr;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
@@ -9,33 +9,33 @@ import java.sql.Types;
|
||||
/**
|
||||
* ScalarType for Cdir to Varchar or Postgres CDIR.
|
||||
*/
|
||||
public abstract class ScalarTypeCdir extends ScalarTypeBaseVarchar<Cdir> {
|
||||
public abstract class ScalarTypeCdir extends ScalarTypeBaseVarchar<Cidr> {
|
||||
|
||||
ScalarTypeCdir() {
|
||||
super(Cdir.class, false, ExtraDbTypes.INET);
|
||||
super(Cidr.class, false, ExtraDbTypes.CIDR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void bind(DataBind b, Cdir value) throws SQLException;
|
||||
public abstract void bind(DataBind b, Cidr value) throws SQLException;
|
||||
|
||||
@Override
|
||||
public Cdir convertFromDbString(String dbValue) {
|
||||
public Cidr convertFromDbString(String dbValue) {
|
||||
return parse(dbValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertToDbString(Cdir beanValue) {
|
||||
public String convertToDbString(Cidr beanValue) {
|
||||
return formatValue(beanValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatValue(Cdir value) {
|
||||
public String formatValue(Cidr value) {
|
||||
return value.getAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cdir parse(String value) {
|
||||
return new Cdir(value);
|
||||
public Cidr parse(String value) {
|
||||
return new Cidr(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +44,7 @@ public abstract class ScalarTypeCdir extends ScalarTypeBaseVarchar<Cdir> {
|
||||
public static class Varchar extends ScalarTypeCdir {
|
||||
|
||||
@Override
|
||||
public void bind(DataBind b, Cdir value) throws SQLException {
|
||||
public void bind(DataBind b, Cidr value) throws SQLException {
|
||||
if (value == null) {
|
||||
b.setNull(Types.VARCHAR);
|
||||
} else {
|
||||
@@ -59,7 +59,7 @@ public abstract class ScalarTypeCdir extends ScalarTypeBaseVarchar<Cdir> {
|
||||
public static class Postgres extends ScalarTypeCdir {
|
||||
|
||||
@Override
|
||||
public void bind(DataBind b, Cdir value) throws SQLException {
|
||||
public void bind(DataBind b, Cidr value) throws SQLException {
|
||||
if (value == null) {
|
||||
b.setNull(Types.OTHER);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user