Merge branch 'master-rob2' into issue-2774/encryption-support-for-in

This commit is contained in:
Roland Praml committed 2022-11-02 08:15:10 +01:00
commit 5170b9f329
23 files changed
+412 -26

No files matched your search

@@ -121,7 +121,7 @@ public interface SpiOrmQueryRequest<T> extends BeanQueryRequest<T>, DocQueryRequ
<K> Map<K, T> findMap();
/**
* Execute the findSingleAttributeList query.
* Execute the findSingleAttributeCollection query.
*/
<A extends Collection<?>> A findSingleAttributeCollection(A collection);
@@ -237,6 +237,11 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
return and(le(lowProperty, value), gtOrNull(highProperty, value));
}
@Override
public Expression inRangeWithProperties(String propertyName, String lowProperty, String highProperty) {
return raw(lowProperty + " <= " + propertyName + " and (" + propertyName + " < " + highProperty + " or " + highProperty + " is null)");
}
/**
* Between - property between the two given values.
*/
@@ -833,6 +833,11 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
return add(expr.inRangeWith(lowProperty, highProperty, value));
}
@Override
public ExpressionList<T> inRangeWithProperties(String propertyName, String lowProperty, String highProperty) {
return add(expr.inRangeWithProperties(propertyName, lowProperty, highProperty));
}
@Override
public ExpressionList<T> inRange(String propertyName, Object value1, Object value2) {
return add(expr.inRange(propertyName, value1, value2));
@@ -279,6 +279,11 @@ final class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expr
return exprList.inRangeWith(lowProperty, highProperty, value);
}
@Override
public ExpressionList<T> inRangeWithProperties(String propertyName, String lowProperty, String highProperty) {
return exprList.inRangeWithProperties(propertyName, lowProperty, highProperty);
}
@Override
public ExpressionList<T> inRange(String propertyName, Object value1, Object value2) {
return exprList.inRange(propertyName, value1, value2);
@@ -106,7 +106,7 @@ public class UuidV1RndIdGenerator implements PlatformIdGenerator {
delta = current - last;
if (delta < -10000 * 20000) {
log.log(INFO, "Clock skew of {} ms detected", delta / -10000);
log.log(INFO, "Clock skew of {0} ms detected", delta / -10000);
// The clock was adjusted back about 2 seconds, or we were generating a lot of ids too fast
// if so, we try to set the current as last and also increment the clockSeq.
lock.lock();
@@ -885,6 +885,9 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
public final void preCommit() {
internalBatchFlush();
firePreCommit();
// we must flush the batch queue again, because the callback can
// modify current transaction
internalBatchFlush();
}
/**
@@ -61,7 +61,7 @@ final class ScalarTypeCalendar extends ScalarTypeBaseDateTime<Calendar> {
@Override
protected String toJsonNanos(Calendar value) {
return String.valueOf(value.getTime());
return String.valueOf(value.getTime().getTime());
}
@Override
@@ -11,6 +11,7 @@ import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeParseException;
/**
* ScalarType for java.sql.Timestamp.
@@ -48,7 +49,7 @@ final class ScalarTypeLocalDateTime extends ScalarTypeBaseDateTime<LocalDateTime
@Override
public LocalDateTime jsonRead(JsonParser parser) throws IOException {
return LocalDateTime.parse(parser.getText());
return parse(parser.getText());
}
@Override
@@ -63,7 +64,11 @@ final class ScalarTypeLocalDateTime extends ScalarTypeBaseDateTime<LocalDateTime
@Override
public LocalDateTime parse(String value) {
return LocalDateTime.parse(value);
try {
return LocalDateTime.parse(value);
} catch (DateTimeParseException pe) {
return super.parse(value);
}
}
@Override
@@ -2,15 +2,20 @@ package io.ebeaninternal.server.type;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import io.ebean.config.JsonConfig;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.TimeZone;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ScalarTypeLocalDateTimeTest {
@@ -123,4 +128,35 @@ public class ScalarTypeLocalDateTimeTest {
LocalDateTime value = typeIso.fromJsonISO8601(asJson);
assertThat(localDateTime).isEqualToIgnoringNanos(value);
}
@Test
public void testParseEbean11() throws IOException {
ScalarTypeLocalDateTime type = new ScalarTypeLocalDateTime(JsonConfig.DateTime.ISO8601);
JsonFactory factory = new JsonFactory();
JsonParser parser11 = factory.createParser("1517627106000"); // its a number!
JsonParser parser13 = factory.createParser("\"2022-01-01T01:00:00\"");
// test parsing an ebean 11/13 timestamp, we do not expect an exception
LocalDateTime p = type.parse("1517627106000");
parser11.nextToken();
LocalDateTime q = type.jsonRead(parser11);
assertThat(p).isEqualTo(q);
p = type.parse("2022-01-01T01:00:00");
parser13.nextToken();
q = type.jsonRead(parser13);
assertThat(p).isEqualTo(q);
TimeZone tz = TimeZone.getDefault();
try {
// Adjust Timezone to run on build server
// Note Millis and Iso have a time offset according to TZ
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin"));
LocalDateTime fromMillis = type.parse("0");
LocalDateTime fromIso = type.parse("1970-01-01T01:00");
assertThat(fromMillis).isEqualToIgnoringNanos(fromIso);
} finally {
TimeZone.setDefault(tz);
}
}
}