Search in sources :

Example 1 with ColumnChecker

use of io.vertx.sqlclient.ColumnChecker in project vertx-sql-client by eclipse-vertx.

the class MSSQLPreparedQueryNullableDataTypeTest method testEncodeBitValue.

private void testEncodeBitValue(TestContext ctx, Boolean value) {
    testPreparedQueryEncodeGeneric(ctx, "nullable_datatype", "test_boolean", value, row -> {
        ColumnChecker checker = ColumnChecker.checkColumn(0, "test_boolean");
        if (value == null) {
            checker.returnsNull();
        } else {
            checker.returns(Tuple::getValue, Row::getValue, value).returns(Tuple::getBoolean, Row::getBoolean, value).returns(Boolean.class, value);
        }
        checker.forRow(row);
    });
}
Also used : ColumnChecker(io.vertx.sqlclient.ColumnChecker) Row(io.vertx.sqlclient.Row) Tuple(io.vertx.sqlclient.Tuple)

Example 2 with ColumnChecker

use of io.vertx.sqlclient.ColumnChecker in project vertx-sql-client by eclipse-vertx.

the class MSSQLPreparedQueryNullableDataTypeTest method testEncodeBufferValue.

private void testEncodeBufferValue(TestContext ctx, String columnName, Object value, Object expected) {
    Object param = value == null ? NullValue.Buffer : value;
    testPreparedQueryEncodeGeneric(ctx, "nullable_datatype", columnName, param, row -> {
        ColumnChecker checker = ColumnChecker.checkColumn(0, columnName);
        if (value == null || value instanceof NullValue) {
            checker.returnsNull();
        } else {
            checker.returns(Tuple::getValue, Row::getValue, expected).returns(Tuple::getBuffer, Row::getBuffer, expected).returns(Buffer.class, (Buffer) expected).forRow(row);
        }
    });
}
Also used : Buffer(io.vertx.core.buffer.Buffer) NullValue(io.vertx.sqlclient.data.NullValue) ColumnChecker(io.vertx.sqlclient.ColumnChecker) Row(io.vertx.sqlclient.Row) Tuple(io.vertx.sqlclient.Tuple)

Example 3 with ColumnChecker

use of io.vertx.sqlclient.ColumnChecker in project vertx-sql-client by eclipse-vertx.

the class MSSQLPreparedQueryNullableDataTypeTest method testEncodeTimeValue.

private void testEncodeTimeValue(TestContext ctx, LocalTime value) {
    testPreparedQueryEncodeGeneric(ctx, "nullable_datatype", "test_time", value, row -> {
        ColumnChecker checker = ColumnChecker.checkColumn(0, "test_time");
        if (value == null) {
            checker.returnsNull();
        } else {
            checker.returns(Tuple::getValue, Row::getValue, value).returns(Tuple::getLocalTime, Row::getLocalTime, value).returns(LocalTime.class, value);
        }
        checker.forRow(row);
    });
}
Also used : ColumnChecker(io.vertx.sqlclient.ColumnChecker) Row(io.vertx.sqlclient.Row) Tuple(io.vertx.sqlclient.Tuple)

Example 4 with ColumnChecker

use of io.vertx.sqlclient.ColumnChecker in project vertx-sql-client by eclipse-vertx.

the class MSSQLPreparedQueryNullableDataTypeTest method testEncodeDateValue.

private void testEncodeDateValue(TestContext ctx, LocalDate value) {
    testPreparedQueryEncodeGeneric(ctx, "nullable_datatype", "test_date", value, row -> {
        ColumnChecker checker = ColumnChecker.checkColumn(0, "test_date");
        if (value == null) {
            checker.returnsNull();
        } else {
            checker.returns(Tuple::getValue, Row::getValue, value).returns(Tuple::getLocalDate, Row::getLocalDate, value).returns(LocalDate.class, value);
        }
        checker.forRow(row);
    });
}
Also used : ColumnChecker(io.vertx.sqlclient.ColumnChecker) Row(io.vertx.sqlclient.Row) Tuple(io.vertx.sqlclient.Tuple)

Example 5 with ColumnChecker

use of io.vertx.sqlclient.ColumnChecker in project vertx-sql-client by eclipse-vertx.

the class DateTimeTypesExtendedCodecTest method testDecodeTimestampTzMinusInfinity.

@Test
public void testDecodeTimestampTzMinusInfinity(TestContext ctx) {
    OffsetDateTime expected = OffsetDateTime.MIN;
    ColumnChecker checker = ColumnChecker.checkColumn(0, "TimestampTz").returns(Tuple::getValue, Row::getValue, expected).returns(Tuple::getOffsetTime, Row::getOffsetTime, expected.toOffsetTime()).returns(Tuple::getOffsetDateTime, Row::getOffsetDateTime, expected).returns(Tuple::getLocalDate, Row::getLocalDate, expected.toLocalDate()).returns(Tuple::getLocalTime, Row::getLocalTime, expected.toLocalTime()).returns(Tuple::getLocalDateTime, Row::getLocalDateTime, expected.toLocalDateTime()).returns(Tuple::getTemporal, Row::getTemporal, expected);
    testDecodeDataTimeGeneric(ctx, "TIMESTAMP WITH TIME ZONE", "TimestampTz", checker, expected);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) ColumnChecker(io.vertx.sqlclient.ColumnChecker) Row(io.vertx.sqlclient.Row) Tuple(io.vertx.sqlclient.Tuple) Test(org.junit.Test)

Aggregations

ColumnChecker (io.vertx.sqlclient.ColumnChecker)19 Row (io.vertx.sqlclient.Row)19 Tuple (io.vertx.sqlclient.Tuple)19 Test (org.junit.Test)13 OffsetDateTime (java.time.OffsetDateTime)5 LocalDateTime (java.time.LocalDateTime)4 Async (io.vertx.ext.unit.Async)2 TestContext (io.vertx.ext.unit.TestContext)2 PgConnection (io.vertx.pgclient.PgConnection)2 Buffer (io.vertx.core.buffer.Buffer)1 NullValue (io.vertx.sqlclient.data.NullValue)1 LocalDate (java.time.LocalDate)1 LocalTime (java.time.LocalTime)1 OffsetTime (java.time.OffsetTime)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1