Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ protected void renderLengthScale(int deployLength, int deployScale, StringBuilde
private static final DbPlatformType VECTOR_BIT = new DbPlatformType("bit", 64000, null);
private static final DbPlatformType VECTOR_SPARSE = new DbPlatformType("sparsevec", 1000, null);

/**
* Timestamp with max precision of 15, and fallback to plain timestamp without precision defined.
*/
private static final DbPlatformType TIMESTAMP =
new DbPlatformType("timestamp", 0, 15,
new DbPlatformType("timestamp", false));

private final Map<DbType, DbPlatformType> typeMap = new EnumMap<>(DbType.class);

/**
Expand Down Expand Up @@ -87,7 +94,8 @@ private void loadDefaults(boolean logicalTypes) {
put(DbType.ARRAY);
put(DbType.DATE);
put(DbType.TIME);
put(DbType.TIMESTAMP);
put(DbType.TIMESTAMP, TIMESTAMP);

put(DbType.LONGVARBINARY);
put(DbType.LONGVARCHAR);
// most commonly real maps to db float
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@

import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.config.dbplatform.DbPlatformTypeMapping;
import io.ebean.config.dbplatform.DbType;
import org.junit.jupiter.api.Test;

import java.sql.Types;

import static org.assertj.core.api.Assertions.assertThat;

public class DbPlatformTypeMappingTest {
class DbPlatformTypeMappingTest {

@Test
public void logicalBoolean_renderType_expect_noLength() {
void logicalBoolean_renderType_expect_noLength() {

DbPlatformTypeMapping logicalMapping = DbPlatformTypeMapping.logicalTypes();

DbPlatformType type = logicalMapping.get(Types.BOOLEAN);
String colDefinition = type.renderType(1, 1, false);
assertThat(colDefinition).isEqualTo("boolean");
}

@Test
void timestamp_with_255_expectNoPrecision() {
DbPlatformType timestampType = new DbPlatformTypeMapping().get(DbType.TIMESTAMP);
String colDefinition = timestampType.renderType(255, 0, true);
assertThat(colDefinition).isEqualTo("timestamp");
}
}
Loading