You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@empire-db.apache.org by Rainer Döbele <do...@esteam.de.INVALID> on 2023/08/04 10:06:36 UTC
re: Problem inserting LocalTime to TIME Columns
Hello Jan,
I have been able to reproduce your bug with SQL-Server but only by disabling Prepared Statements.
I have provided a fix that works for me on SQL Server.
The fix requires the following SQL-Phrases in the corresponding DBMSHandler to be set correctly:
case SQL_TIME_PATTERN: return "HH:mm:ss";
case SQL_TIME_TEMPLATE: return "convert(time, '{0}')";
The example is taken from the SQL-Server implementation (DBMSHandlerMSSQL).
Please check.
Regards
Rainer
P.S. Please consider creating a Jira ticket yourself next time. Thanks.
-----Original Message -----
From: Jan Glaubitz <ja...@glaubitz.org>
To: dev@empire-db.apache.org
Subject: Re: Problem inserting LocalTime to TIME Columns
Can anyone confirm or deny this is a bug?
Thanks,
jan
> Am 14.07.2023 um 09:51 schrieb Jan Glaubitz <ja...@glaubitz.org>:
>
> Hi,
>
> I want to insert LocalTime objects into DataType.TIME-columns.
>
> Empire-db:
>
> [...]
> this.ABFAHRT_PLAN = addColumn("ABFAHRT_PLAN", DataType.TIME, 0.0,
> false); this.ABFAHRT_IST = addColumn("ABFAHRT_IST", DataType.TIME,
> 0.0, false); [...]
>
> PostgreSQL:
>
> [...]
> ABFAHRT_PLAN TIME,
> ABFAHRT_IST TIME,
> [...]
>
> but inserting throws an exception:
>
> org.apache.empire.exceptions.InvalidArgumentException: Invalid Argument 02:24 for parameter value.
> at
> org.apache.empire.db.DBSQLBuilder.getDateTimeString(DBSQLBuilder.java:
> 387) ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> at
> org.apache.empire.db.DBSQLBuilder.appendSimpleValue(DBSQLBuilder.java:
> 297) ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> at
> org.apache.empire.db.DBSQLBuilder.appendValue(DBSQLBuilder.java:218)
> ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> at org.apache.empire.db.expr.set.DBSetExpr.addSQL(DBSetExpr.java:143)
> ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> at
> org.apache.empire.db.DBCommandExpr.addListExpr(DBCommandExpr.java:669)
> ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> at org.apache.empire.db.DBCommand.getInsert(DBCommand.java:1685)
> ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> at
> org.apache.empire.db.context.DBContextBase.executeInsert(DBContextBase
> .java:115) ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
>
> When I convert the LocalTime object to a Date object it works.
>
> Is LocalTime unsupported or is this a bug?
>
> Thanks,
>
> jan
re: Problem inserting LocalTime to TIME Columns
Posted by Jan Glaubitz <ja...@glaubitz.org>.
Hello Rainer,
works for me on PostgreSQL. Thanks for the fix!
- jan
> Rainer Döbele <do...@esteam.de.invalid> hat am 04.08.2023 12:06 CEST geschrieben:
>
>
> Hello Jan,
>
> I have been able to reproduce your bug with SQL-Server but only by disabling Prepared Statements.
>
> I have provided a fix that works for me on SQL Server.
> The fix requires the following SQL-Phrases in the corresponding DBMSHandler to be set correctly:
>
> case SQL_TIME_PATTERN: return "HH:mm:ss";
> case SQL_TIME_TEMPLATE: return "convert(time, '{0}')";
>
> The example is taken from the SQL-Server implementation (DBMSHandlerMSSQL).
>
> Please check.
> Regards
> Rainer
>
> P.S. Please consider creating a Jira ticket yourself next time. Thanks.
>
>
> -----Original Message -----
> From: Jan Glaubitz <ja...@glaubitz.org>
> To: dev@empire-db.apache.org
> Subject: Re: Problem inserting LocalTime to TIME Columns
>
> Can anyone confirm or deny this is a bug?
>
> Thanks,
>
> jan
>
> > Am 14.07.2023 um 09:51 schrieb Jan Glaubitz <ja...@glaubitz.org>:
> >
> > Hi,
> >
> > I want to insert LocalTime objects into DataType.TIME-columns.
> >
> > Empire-db:
> >
> > [...]
> > this.ABFAHRT_PLAN = addColumn("ABFAHRT_PLAN", DataType.TIME, 0.0,
> > false); this.ABFAHRT_IST = addColumn("ABFAHRT_IST", DataType.TIME,
> > 0.0, false); [...]
> >
> > PostgreSQL:
> >
> > [...]
> > ABFAHRT_PLAN TIME,
> > ABFAHRT_IST TIME,
> > [...]
> >
> > but inserting throws an exception:
> >
> > org.apache.empire.exceptions.InvalidArgumentException: Invalid Argument 02:24 for parameter value.
> > at
> > org.apache.empire.db.DBSQLBuilder.getDateTimeString(DBSQLBuilder.java:
> > 387) ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> > at
> > org.apache.empire.db.DBSQLBuilder.appendSimpleValue(DBSQLBuilder.java:
> > 297) ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> > at
> > org.apache.empire.db.DBSQLBuilder.appendValue(DBSQLBuilder.java:218)
> > ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> > at org.apache.empire.db.expr.set.DBSetExpr.addSQL(DBSetExpr.java:143)
> > ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> > at
> > org.apache.empire.db.DBCommandExpr.addListExpr(DBCommandExpr.java:669)
> > ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> > at org.apache.empire.db.DBCommand.getInsert(DBCommand.java:1685)
> > ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> > at
> > org.apache.empire.db.context.DBContextBase.executeInsert(DBContextBase
> > .java:115) ~[empire-db-3.1.1-SNAPSHOT.jar:3.1.1-SNAPSHOT]
> >
> > When I convert the LocalTime object to a Date object it works.
> >
> > Is LocalTime unsupported or is this a bug?
> >
> > Thanks,
> >
> > jan