cuba-platform / reports

CUBA Reports Addon
https://www.cuba-platform.com/
Apache License 2.0
9 stars 4 forks source link

Incorrect handling of LocalDate input parameters #219

Closed glebfox closed 4 years ago

glebfox commented 5 years ago

Environment

Description of the bug or enhancement

sample-sales.zip

The Order entity has the date attribute as TemporalType.DATE and the localDate attribute as LocalDate.

Case 1:

  1. Create a new report using Wizard.
    1. Entity: Order
    2. Report type: Reports for list of entities, selected by query
    3. In the Define query window add two condition properties for the localDate attribute, e.g. start_date and end_date
  2. The other settings on your choice
  3. Run the report

See report: Order.LocalDate by Wizard

AR:

  1. Parameters have the String type. The type can't be changed due to an exception:
    ClassCastException: java.time.LocalDate cannot be cast to java.lang.String
  2. An exception when the report is executed:
An error occurred while loading data for band [Orders] and query [Dataset]. Report name [Order.LocalDate by Wizard]
An error occurred while loading data for data set [Dataset]
You have attempted to set a value of type class java.lang.String for parameter 1 with expected type of class java.time.LocalDate from query string select
customer.name ,
e.amount from sales_Order e 
left join e.customer customer 
 where (e.localDate >= ?1 and e.localDate <= ?2).

Case 2

For the report above

  1. Remove incorrect parameters
  2. Add parameters with the Date type
  3. Run the report

AR:

HSQLDB

An error occurred while loading data for band [Orders] and query [Dataset]. Report name [Order.LocalDate by Wizard]
An error occurred while loading data for data set [Dataset]
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLDataException: data exception: datetime field overflow
Error Code: -3408
Call: SELECT t0.NAME, t1.AMOUNT FROM SALES_ORDER t1 LEFT OUTER JOIN SALES_CUSTOMER t0 ON (t0.ID = t1.CUSTOMER_ID) WHERE (((t1.LOCAL_DATE >= ?) AND (t1.LOCAL_DATE <= ?)) AND (t1.DELETE_TS IS NULL))
    bind => [+4141882-07-11, +4148979-03-07]
Query: ReportQuery(referenceClass=Order sql="SELECT t0.NAME, t1.AMOUNT FROM SALES_ORDER t1 LEFT OUTER JOIN SALES_CUSTOMER t0 ON (t0.ID = t1.CUSTOMER_ID) WHERE (((t1.LOCAL_DATE >= ?) AND (t1.LOCAL_DATE <= ?)) AND (t1.DELETE_TS IS NULL))")

Internal Exception: java.sql.SQLDataException: data exception: datetime field overflow
Error Code: -3408
Call: SELECT t0.NAME, t1.AMOUNT FROM SALES_ORDER t1 LEFT OUTER JOIN SALES_CUSTOMER t0 ON (t0.ID = t1.CUSTOMER_ID) WHERE (((t1.LOCAL_DATE >= ?) AND (t1.LOCAL_DATE <= ?)) AND (t1.DELETE_TS IS NULL))
    bind => [+4141882-07-11, +4148979-03-07]
Query: ReportQuery(referenceClass=Order sql="SELECT t0.NAME, t1.AMOUNT FROM SALES_ORDER t1 LEFT OUTER JOIN SALES_CUSTOMER t0 ON (t0.ID = t1.CUSTOMER_ID) WHERE (((t1.LOCAL_DATE >= ?) AND (t1.LOCAL_DATE <= ?)) AND (t1.DELETE_TS IS NULL))")
data exception: datetime field overflow
data exception: datetime field overflow

PostgreSQL

No data is shown

In the log you can see the following:

Finished report [Report for entity "Order"] with parameters [localDate1:Thu Sep 05 00:00:00 SAMT 2019]

Even though we defined a parameter with Date type, a timestamp value is passed.

soraksh commented 4 years ago

Case 2 should be fixed by Cuba #2479