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

fix: expressions with not on HANA #925

Merged
merged 19 commits into from
Dec 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
interm state
vkozyura committed Dec 2, 2024
commit ae6bde976721032a366986ed458c1c5263a5f178
17 changes: 9 additions & 8 deletions hana/lib/HANAService.js
Original file line number Diff line number Diff line change
@@ -905,7 +905,7 @@ SELECT ${mixing} FROM JSON_TABLE(SRC.JSON, '$' COLUMNS(${extraction})) AS NEW LE
}

const sql = []
let indexEndWithCompare = -1
let indexNotXpr = -1
for (let i = 0; i < xpr.length; ++i) {
const x = xpr[i]
if (typeof x === 'string') {
@@ -920,18 +920,18 @@ SELECT ${mixing} FROM JSON_TABLE(SRC.JSON, '$' COLUMNS(${extraction})) AS NEW LE
sql.push(this.operator(x, i, xpr))
// Add "= TRUE" after NOT statements
if (
up === 'NOT' && !xpr.includes('AND') && !xpr.includes('OR') &&
up === 'NOT' && !xpr.includes('AND') && !xpr.includes('OR') && !xpr.includes('CASE') &&
(!xpr[i+1].xpr || !this.is_comparator({ xpr: xpr[i+1].xpr }))
) {
indexEndWithCompare = i + 1
indexNotXpr = i + 1
}
} else if (x.xpr) sql.push(`(${this.xpr(x, caseSuffix)})`)
// default
else sql.push(this.expr(x))

if (indexEndWithCompare === i) {
if (indexNotXpr === i) {
sql.push(` = ${this.val({ val: true })}`)
indexEndWithCompare = -1
indexNotXpr = -1
}
}

@@ -978,12 +978,13 @@ SELECT ${mixing} FROM JSON_TABLE(SRC.JSON, '$' COLUMNS(${extraction})) AS NEW LE
const up = cur.toUpperCase()
// When a logic operator is found the expression is not a comparison
// When it is a local check it cannot be compared outside of the xpr
if (up in logicOperators || up === 'NOT') {
if (up in logicOperators) {
// ensure AND is not part of BETWEEN
if (up === 'AND' && xpr[i - 2]?.toUpperCase?.() in { 'BETWEEN': 1, 'NOT BETWEEN': 1 }) return true
if (up === 'NOT') return true
if (up === 'AND' && xpr[i - 2]?.toUpperCase?.() in { 'BETWEEN': 1, 'NOT BETWEEN': 1 }) return true
return !local
}
// When NOT operator is found not in CASE expression
if (up === 'NOT' && !xpr.includes('CASE')) return true
// When a compare operator is found the expression is a comparison
if (up in compareOperators) return true
// When a case operator is found it is the start of the expression

Unchanged files with check annotations Beta

const JoinTree = require('./join-tree')
const { pseudos } = require('./pseudos')
const { isCalculatedOnRead } = require('../utils')
const cdsTypes = cds.linked({

Check warning on line 8 in db-service/lib/infer/index.js

GitHub Actions / Tests (22)

't' is assigned a value but never used
definitions: {
Timestamp: { type: 'cds.Timestamp' },
DateTime: { type: 'cds.DateTime' },
queryElements[k] = element
}
if (isCalculatedOnRead(element)) {
linkCalculatedElement(element)

Check warning on line 1065 in db-service/lib/infer/index.js

GitHub Actions / Tests (22)

'init$refLinks' is defined but never used
}
}
}