Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support UUID type #163

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions liquibase-dialect/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<maven.compiler.source>1.8</maven.compiler.source>

<liquibase.core.version>4.24.0</liquibase.core.version>
<ydb.jdbc.version>2.2.0</ydb.jdbc.version>
<ydb.jdbc.version>2.3.3</ydb.jdbc.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -119,7 +119,7 @@
<configuration>
<environmentVariables>
<TESTCONTAINERS_REUSE_ENABLE>true</TESTCONTAINERS_REUSE_ENABLE>
<YDB_DOCKER_IMAGE>cr.yandex/yc/yandex-docker-local-ydb:24.1</YDB_DOCKER_IMAGE>
<YDB_DOCKER_IMAGE>cr.yandex/yc/yandex-docker-local-ydb:trunk</YDB_DOCKER_IMAGE>
</environmentVariables>
<systemPropertyVariables>
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package tech.ydb.liquibase.type;

import liquibase.change.core.LoadDataChange;
import liquibase.datatype.DataTypeInfo;
import liquibase.datatype.LiquibaseDataType;

/**
* @author Kirill Kurdyukov
*/
@DataTypeInfo(
name = "UUID",
aliases = {"uniqueidentifier", "java.util.UUID"},
minParameters = 0,
maxParameters = 0,
priority = LiquibaseDataType.PRIORITY_DATABASE
)
public class UuidTypeYdb extends BaseTypeYdb {

@Override
public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
return LoadDataChange.LOAD_DATA_TYPE.UUID;
}

@Override
protected String objectToSql(Object value) {
return "Uuid('" + value + "')";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ tech.ydb.liquibase.type.TinyIntTypeYdb
tech.ydb.liquibase.type.Uint8TypeYdb
tech.ydb.liquibase.type.Uint16TypeYdb
tech.ydb.liquibase.type.Uint32TypeYdb
tech.ydb.liquibase.type.Uint64TypeYdb
tech.ydb.liquibase.type.Uint64TypeYdb
tech.ydb.liquibase.type.UuidTypeYdb
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,32 @@ void changeLogLoadCSVFileTest() throws SQLException, LiquibaseException {
assertTrue(migrationStr.contains("UPSERT INTO all_types_table (id, bool_column, bigint_column, smallint_column, " +
"tinyint_column, float_column, double_column, decimal_column, uint8_column, " +
"uint16_column, uint32_column, uint64_column, text_column, binary_column, json_column, " +
"jsondocument_column, date_column, datetime_column, timestamp_column, interval_column) VALUES " +
"jsondocument_column, date_column, datetime_column, timestamp_column, interval_column, uuid_column) VALUES " +
"('1', 'true', '123123', '13000', '113', '1.123', '1.123123', '1.123123', '12', '13', '14', " +
"'15', 'Кирилл Курдюков Алексеевич', 'binary', '{\"asd\": \"asd\"}', '{\"asd\": \"asd\"}', " +
"'2014-04-06', '2023-09-16T12:30', '2023-07-31T17:00:00.000000Z', 'PT10S');"
"'2014-04-06', '2023-09-16T12:30', '2023-07-31T17:00:00.000000Z', 'PT10S', '689fd2b6-5764-4c43-8803-519da8f5f305');"
));

assertTrue(migrationStr.contains("UPSERT INTO all_types_table (id, bool_column, bigint_column, smallint_column, " +
"tinyint_column, float_column, double_column, decimal_column, uint8_column, " +
"uint16_column, uint32_column, uint64_column, text_column, binary_column, json_column, " +
"jsondocument_column, date_column, datetime_column, timestamp_column, interval_column) VALUES " +
"jsondocument_column, date_column, datetime_column, timestamp_column, interval_column, uuid_column) VALUES " +
"('5', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, " +
"NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"
"NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"
));

assertTrue(migrationStr.contains("INSERT INTO all_types_table (id, bool_column, bigint_column, smallint_column, " +
"tinyint_column, float_column, double_column, decimal_column, uint8_column, uint16_column, " +
"uint32_column, uint64_column, text_column, binary_column, json_column, jsondocument_column, " +
"date_column, datetime_column, timestamp_column, interval_column) VALUES " +
"date_column, datetime_column, timestamp_column, interval_column, uuid_column) VALUES " +
"('2', 'true', '123123', '13000', '112', '1.123', '1.123123', '1.123123', '12', '13', " +
"'14', '15', 'Кирилл Курдюков Алексеевич', 'binary', '{\"asd\": \"asd\"}', '{\"asd\": \"asd\"}', " +
"'2014-04-06', '2023-09-16T12:30', '2023-07-31T17:00:00.000000Z', 'PT10S'), " +
"'2014-04-06', '2023-09-16T12:30', '2023-07-31T17:00:00.000000Z', 'PT10S', '689fd2b6-5764-4c43-8803-519da8f5f305'), " +
"('3', 'true', '123123', '13000', '112', '1.123', '1.123123', '1.123123', '12', " +
"'13', '14', '15', 'Кирилл Курдюков Алексеевич', 'binary', '{\"asd\": \"asd\"}', " +
"'{\"asd\": \"asd\"}', '2014-04-06', '2023-09-16T12:30', '2023-07-31T17:00:00.000000Z', 'PT10S'), " +
"'{\"asd\": \"asd\"}', '2014-04-06', '2023-09-16T12:30', '2023-07-31T17:00:00.000000Z', 'PT10S', '689fd2b6-5764-4c43-8803-519da8f5f305'), " +
"('6', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, " +
"NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"
"NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);"
));

migrateChangeFile(changeLogFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void changelogXmlMigrationAllTypesTableTest() throws SQLException, LiquibaseExce
"datetime_column DATETIME, " +
"timestamp_column TIMESTAMP, " +
"interval_column INTERVAL, " +
"uuid_column UUID, " +
"PRIMARY KEY (id) " +
");"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id,bool_column,bigint_column,smallint_column,tinyint_column,float_column,double_column,decimal_column,uint8_column,uint16_column,uint32_column,uint64_column,text_column,binary_column,json_column,jsondocument_column,date_column,datetime_column,timestamp_column,interval_column
2,true,123123,13000,112,1.123,1.123123,1.123123,12,13,14,15,Кирилл Курдюков Алексеевич,binary,{"asd": "asd"},{"asd": "asd"},2014-04-06,2023-09-16T12:30,2023-07-31T17:00:00.000000Z,PT10S
3,true,123123,13000,112,1.123,1.123123,1.123123,12,13,14,15,Кирилл Курдюков Алексеевич,binary,{"asd": "asd"},{"asd": "asd"},2014-04-06,2023-09-16T12:30,2023-07-31T17:00:00.000000Z,PT10S
6,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null
id,bool_column,bigint_column,smallint_column,tinyint_column,float_column,double_column,decimal_column,uint8_column,uint16_column,uint32_column,uint64_column,text_column,binary_column,json_column,jsondocument_column,date_column,datetime_column,timestamp_column,interval_column,uuid_column
2,true,123123,13000,112,1.123,1.123123,1.123123,12,13,14,15,Кирилл Курдюков Алексеевич,binary,{"asd": "asd"},{"asd": "asd"},2014-04-06,2023-09-16T12:30,2023-07-31T17:00:00.000000Z,PT10S,689fd2b6-5764-4c43-8803-519da8f5f305
3,true,123123,13000,112,1.123,1.123123,1.123123,12,13,14,15,Кирилл Курдюков Алексеевич,binary,{"asd": "asd"},{"asd": "asd"},2014-04-06,2023-09-16T12:30,2023-07-31T17:00:00.000000Z,PT10S,689fd2b6-5764-4c43-8803-519da8f5f305
6,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
id,bool_column,bigint_column,smallint_column,tinyint_column,float_column,double_column,decimal_column,uint8_column,uint16_column,uint32_column,uint64_column,text_column,binary_column,json_column,jsondocument_column,date_column,datetime_column,timestamp_column,interval_column
1,true,123123,13000,113,1.123,1.123123,1.123123,12,13,14,15,Кирилл Курдюков Алексеевич,binary,{"asd": "asd"},{"asd": "asd"},2014-04-06,2023-09-16T12:30,2023-07-31T17:00:00.000000Z,PT10S
5,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null
id,bool_column,bigint_column,smallint_column,tinyint_column,float_column,double_column,decimal_column,uint8_column,uint16_column,uint32_column,uint64_column,text_column,binary_column,json_column,jsondocument_column,date_column,datetime_column,timestamp_column,interval_column,uuid_column
1,true,123123,13000,113,1.123,1.123123,1.123123,12,13,14,15,Кирилл Курдюков Алексеевич,binary,{"asd": "asd"},{"asd": "asd"},2014-04-06,2023-09-16T12:30,2023-07-31T17:00:00.000000Z,PT10S,689fd2b6-5764-4c43-8803-519da8f5f305
5,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
<column name="datetime_column" type="datetime" remarks="Date/time, precision to the second."/>
<column name="timestamp_column" type="timestamp" remarks="Date/time, precision to the microsecond."/>
<column name="interval_column" type="interval" remarks="Time interval (signed), precision to microseconds"/>

<column name="uuid_column" type="uuid" remarks="UUID value."/>
</createTable>

<rollback>
Expand Down
Loading