Skip to content

Commit

Permalink
fix: Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
larshelge committed Dec 16, 2024
1 parent 04bbdf5 commit dac941f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected String getColumnExpression(ValueType valueType, String columnExpressio
return getCastExpression(columnExpression, NUMERIC_REGEXP, sqlBuilder.dataTypeBigInt());
} else if (valueType.isBoolean()) {
return sqlBuilder.ifThenElse(
columnExpression + " = 'true", "1", columnExpression + " = 'false'", "0", "null");
columnExpression + " = 'true'", "1", columnExpression + " = 'false'", "0", "null");
} else if (valueType.isDate()) {
return getCastExpression(columnExpression, DATE_REGEXP, sqlBuilder.dataTypeTimestamp());
} else if (valueType.isGeo() && isSpatialSupport()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void testGetCastExpression() {
"""
case when eventdatavalues #>> '{GieVkTxp4HH, value}' ~* '^(-?[0-9]+)(\\.[0-9]+)?$' \
then cast(eventdatavalues #>> '{GieVkTxp4HH, value}' as double precision) \
else null end""";
end""";

String actual =
manager.getCastExpression(
Expand All @@ -91,7 +91,7 @@ void testGetSelectExpressionNumber() {
"""
case when eventdatavalues #>> '{GieVkTxp4HH, value}' ~* '^(-?[0-9]+)(\\.[0-9]+)?$' \
then cast(eventdatavalues #>> '{GieVkTxp4HH, value}' as double precision) \
else null end""";
end""";

String actual =
manager.getColumnExpression(ValueType.NUMBER, "eventdatavalues #>> '{GieVkTxp4HH, value}'");
Expand All @@ -103,7 +103,9 @@ then cast(eventdatavalues #>> '{GieVkTxp4HH, value}' as double precision) \
void testGetSelectExpressionBoolean() {
String expected =
"""
case when eventdatavalues #>> '{Xl3voRRcmpo, value}' = 'true' then 1 when eventdatavalues #>> '{Xl3voRRcmpo, value}' = 'false' then 0 else null end""";
case when eventdatavalues #>> '{Xl3voRRcmpo, value}' = 'true' then 1 \
when eventdatavalues #>> '{Xl3voRRcmpo, value}' = 'false' then 0 \
else null end""";

String actual =
manager.getColumnExpression(
Expand All @@ -118,7 +120,7 @@ void testGetSelectExpressionDate() {
"""
case when eventdatavalues #>> '{AL04Wbutskk, value}' ~* '^\\d{4}-\\d{2}-\\d{2}(\\s|T)?((\\d{2}:)(\\d{2}:)?(\\d{2}))?(|.(\\d{3})|.(\\d{3})Z)?$' \
then cast(eventdatavalues #>> '{AL04Wbutskk, value}' as timestamp) \
else null end""";
end""";

String actual =
manager.getColumnExpression(ValueType.DATE, "eventdatavalues #>> '{AL04Wbutskk, value}'");
Expand Down

0 comments on commit dac941f

Please sign in to comment.