Skip to content

Incorrect behavior of temporal types as sql variant types. #449

@rodionstl

Description

@rodionstl

Driver version or jar name

6.3.0.jre8-preview

SQL Server version

Microsoft SQL Server vNext (CTP2.0) - 14.0.500.272 (X64)

Client operating system

Ubuntu 16.04.2 LTS

Java/JVM version

openjdk version "1.8.0_131"

Problem description

  1. Null value is returned if you cast a value of time to sql variant.
  2. Value of String class is return if you cast a value of datetimeoffset to sql variant.

Repro code

    //issue #1
ResultSet resultSet = statement.executeQuery("select cast(cast('2017-08-16 17:31:09.995 +07:00' as datetimeoffset) as sql_variant)");
resultSet.next();
if (resultSet.getObject(1) == null) {
    throw new IllegalStateException("value must not be null");
}


    //issue #2
ResultSet resultSet = statement.executeQuery("select cast(cast('17:31:09.995' as time(3)) as sql_variant)");
resultSet.next();
Object object = resultSet.getObject(1);
if (object.getClass() != java.sql.Time.class) {
   throw new IllegalStateException("value must be of java.sql.Time class");
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions