Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changelog query converts CURRENT_DATE HANA Variable to CURRENT_DATE() which give an invalid query. #129

Open
llouw-drs opened this issue Oct 17, 2024 · 0 comments

Comments

@llouw-drs
Copy link

I have the following case statement on a table for the ON READ. For some reason the query gets converted to current_date() which does not exist in HANA. I am unsure if it is the changelog doing it or the CAP cds-dbs module, but this only happens on change logs getting saved.

case 
when (ReportHeaders.status_code = ? and ReportHeaders.dueDate < ReportHeaders.modifiedAt) then true 
when (ReportHeaders.status_code <> ? and ReportHeaders.dueDate < current_date)

Query generated by cap-js/changelog

WITH ReportHeaders as (SELECT *,('$[' || lpad("$$RN$$",6,'0')) as _path_ FROM (SELECT *,ROW_NUMBER() OVER () as "$$RN$$" FROM (SELECT ReportHeaders.ID,ReportHeaders.createdAt,ReportHeaders.createdBy,ReportHeaders.modifiedAt,ReportHeaders.modifiedBy,ReportHeaders.createdByName,ReportHeaders.modifiedByName,ReportHeaders.report_ID,ReportHeaders.payrollYear,ReportHeaders.payrollPeriod,ReportHeaders.payrollArea,ReportHeaders.position_ID,ReportHeaders.organisation_ID,ReportHeaders.payPeriodStartDate,ReportHeaders.payPeriodEndDate,ReportHeaders.previousPayrollYear,ReportHeaders.previousPayrollPeriod,ReportHeaders.status_code,ReportHeaders.assigned_ID,ReportHeaders.processId,ReportHeaders.escalationId,ReportHeaders.dueDate,case when (ReportHeaders.status_code = ? and ReportHeaders.dueDate < ReportHeaders.modifiedAt) then true when (ReportHeaders.status_code <> ? and ReportHeaders.dueDate < current_date()) then true else false end as isLate,case when (ReportHeaders.status_code = ? and ReportHeaders.dueDate < ReportHeaders.modifiedAt) then days_between(ReportHeaders.dueDate,ReportHeaders.modifiedAt) when (ReportHeaders.status_code <> ? and ReportHeaders.dueDate < current_date()) then days_between(ReportHeaders.dueDate,current_date()) else ? end as daysLate FROM tmr_csr_db_ReportHeaders as ReportHeaders WHERE ReportHeaders.ID = ?) as ReportHeaders) as ReportHeaders) SELECT "_path_","_blobs_","_expands_","_json_" FROM (SELECT _path_ as "_path_",'{}' as "_blobs_",'{}' as "_expands_",(SELECT ID as "ID",to_char(createdAt, 'YYYY-MM-DD"T"HH24:MI:SS.FF3"Z"') as "createdAt",createdBy as "createdBy",to_char(modifiedAt, 'YYYY-MM-DD"T"HH24:MI:SS.FF3"Z"') as "modifiedAt",modifiedBy as "modifiedBy",createdByName as "createdByName",modifiedByName as "modifiedByName",report_ID as "report_ID",payrollYear as "payrollYear",payrollPeriod as "payrollPeriod",payrollArea as "payrollArea",position_ID as "position_ID",organisation_ID as "organisation_ID",to_char(payPeriodStartDate, 'YYYY-MM-DD') as "payPeriodStartDate",to_char(payPeriodEndDate, 'YYYY-MM-DD') as "payPeriodEndDate",previousPayrollYear as "previousPayrollYear",previousPayrollPeriod as "previousPayrollPeriod",status_code as "status_code",assigned_ID as "assigned_ID",processId as "processId",escalationId as "escalationId",to_char(dueDate, 'YYYY-MM-DD') as "dueDate",isLate as "isLate",daysLate as "daysLate" FROM JSON_TABLE('[{}]', '$' COLUMNS("'$$FaKeDuMmYCoLuMn$$'" FOR ORDINALITY)) FOR JSON ('format'='no', 'omitnull'='no', 'arraywrap'='no') RETURNS NVARCHAR(2147483647)) as "_json_" FROM ReportHeaders) ORDER BY "_path_" ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant