Skip to content

[mssql] Incorrect encoding of datatime2 for LocalDateTime values to the ms  #977

@DavideD

Description

@DavideD

With MS Sql Server.

Testcase to add to MSSQLPreparedQueryNotNullableDataTypeTest

  @Test
  public void testEncodeDateTimeWithMillis(TestContext ctx) {
    final LocalDateTime start = LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    testPreparedQueryEncodeGeneric(ctx, "not_nullable_datatype", "test_datetime2", start, row -> {
      ColumnChecker.checkColumn(0, "test_datetime2")
        .returns(Tuple::getValue, Row::getValue, start)
        .returns(Tuple::getLocalDateTime, Row::getLocalDateTime, start)
        .returns(Tuple::getLocalDate, Row::getLocalDate, start.toLocalDate())
        .returns(Tuple::getLocalTime, Row::getLocalTime, start.toLocalTime())
        .returns(LocalDateTime.class, start)
        .forRow(row);
    });
  }

Result:

junit.framework.AssertionFailedError: Expected that public abstract java.lang.Object io.vertx.sqlclient.Tuple.getValue(int) would not fail: 
Expected :2021-06-09T17:20:40.643
Actual   :2021-06-09T17:31:23

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions