Timestamp and Time types in SQL queries

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Timestamp and Time types in SQL queries

Igor Sapego-2
Hi guys,

I'm working on java.sql.Time type support for ODBC [1], and I'm facing
following behaviour:

Lets suppose I perform an SQL query from C++ on field of java.sql.Time type:

SELECT dateField from SomeType

Nothing special here. The problem is in C++ I get value of type Date
instead of Time. The similar behaviour can be observed for the
java.sql.Date type (returned as Timestamp in binary protocol). I have not
investigated issue yet but I suppose it has to do something with
java.sql.Time and java.sql.Timestamp both being a subclasses of the
java.util.Date.

So the question is, is this an expected behaviour or is it a bug?

[1] - https://issues.apache.org/jira/browse/IGNITE-4691
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp and Time types in SQL queries

Sergi
This happens because H2 does not work with these classes directly and we do
some conversions to SQL types, then from H2 JDBC API we get what H2 gives
us. The resulting types can be different. I guess you have to just write
tests for all these types and cover all these cases in C++ code.

Sergi

2017-03-16 18:14 GMT+03:00 Igor Sapego <[hidden email]>:

> Hi guys,
>
> I'm working on java.sql.Time type support for ODBC [1], and I'm facing
> following behaviour:
>
> Lets suppose I perform an SQL query from C++ on field of java.sql.Time
> type:
>
> SELECT dateField from SomeType
>
> Nothing special here. The problem is in C++ I get value of type Date
> instead of Time. The similar behaviour can be observed for the
> java.sql.Date type (returned as Timestamp in binary protocol). I have not
> investigated issue yet but I suppose it has to do something with
> java.sql.Time and java.sql.Timestamp both being a subclasses of the
> java.util.Date.
>
> So the question is, is this an expected behaviour or is it a bug?
>
> [1] - https://issues.apache.org/jira/browse/IGNITE-4691
>
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp and Time types in SQL queries

Igor Sapego
Well, I wrote tests and they are failing. So what is the solution here?
Can it be fixed somewhere in Ignite or is it not possible without edits in
H2?

Best Regards,
Igor

On Thu, Mar 16, 2017 at 6:31 PM, Sergi Vladykin <[hidden email]>
wrote:

> This happens because H2 does not work with these classes directly and we do
> some conversions to SQL types, then from H2 JDBC API we get what H2 gives
> us. The resulting types can be different. I guess you have to just write
> tests for all these types and cover all these cases in C++ code.
>
> Sergi
>
> 2017-03-16 18:14 GMT+03:00 Igor Sapego <[hidden email]>:
>
> > Hi guys,
> >
> > I'm working on java.sql.Time type support for ODBC [1], and I'm facing
> > following behaviour:
> >
> > Lets suppose I perform an SQL query from C++ on field of java.sql.Time
> > type:
> >
> > SELECT dateField from SomeType
> >
> > Nothing special here. The problem is in C++ I get value of type Date
> > instead of Time. The similar behaviour can be observed for the
> > java.sql.Date type (returned as Timestamp in binary protocol). I have not
> > investigated issue yet but I suppose it has to do something with
> > java.sql.Time and java.sql.Timestamp both being a subclasses of the
> > java.util.Date.
> >
> > So the question is, is this an expected behaviour or is it a bug?
> >
> > [1] - https://issues.apache.org/jira/browse/IGNITE-4691
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp and Time types in SQL queries

Sergi
Fix C++ :)

Sergi

2017-03-16 18:36 GMT+03:00 Igor Sapego <[hidden email]>:

> Well, I wrote tests and they are failing. So what is the solution here?
> Can it be fixed somewhere in Ignite or is it not possible without edits in
> H2?
>
> Best Regards,
> Igor
>
> On Thu, Mar 16, 2017 at 6:31 PM, Sergi Vladykin <[hidden email]>
> wrote:
>
> > This happens because H2 does not work with these classes directly and we
> do
> > some conversions to SQL types, then from H2 JDBC API we get what H2 gives
> > us. The resulting types can be different. I guess you have to just write
> > tests for all these types and cover all these cases in C++ code.
> >
> > Sergi
> >
> > 2017-03-16 18:14 GMT+03:00 Igor Sapego <[hidden email]>:
> >
> > > Hi guys,
> > >
> > > I'm working on java.sql.Time type support for ODBC [1], and I'm facing
> > > following behaviour:
> > >
> > > Lets suppose I perform an SQL query from C++ on field of java.sql.Time
> > > type:
> > >
> > > SELECT dateField from SomeType
> > >
> > > Nothing special here. The problem is in C++ I get value of type Date
> > > instead of Time. The similar behaviour can be observed for the
> > > java.sql.Date type (returned as Timestamp in binary protocol). I have
> not
> > > investigated issue yet but I suppose it has to do something with
> > > java.sql.Time and java.sql.Timestamp both being a subclasses of the
> > > java.util.Date.
> > >
> > > So the question is, is this an expected behaviour or is it a bug?
> > >
> > > [1] - https://issues.apache.org/jira/browse/IGNITE-4691
> > >
> >
>