Skip to content

Commit

Permalink
fix: SELECT cds.hana.BINARY (#870)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkozyura authored Oct 25, 2024
1 parent da629d9 commit 33c3ebe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions db-service/lib/cqn2sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ const cqn4sql = require('./cqn4sql')
const _simple_queries = cds.env.features.sql_simple_queries
const _strict_booleans = _simple_queries < 2

const BINARY_TYPES = {
'cds.Binary': 1,
'cds.LargeBinary': 1,
'cds.hana.BINARY': 1,
}

const { Readable } = require('stream')

const DEBUG = (() => {
Expand Down Expand Up @@ -42,6 +36,12 @@ class CQN2SQLRenderer {
}
}

BINARY_TYPES = {
'cds.Binary': 1,
'cds.LargeBinary': 1,
'cds.hana.BINARY': 1,
}

static _add_mixins(aspect, mixins) {
const fqn = this.name + aspect
const types = cds.builtin.types
Expand Down Expand Up @@ -565,7 +565,7 @@ class CQN2SQLRenderer {

buffer += '"'
} else {
if (elements[key]?.type in BINARY_TYPES) {
if (elements[key]?.type in this.BINARY_TYPES) {
val = transformBase64(val)
}
buffer += `${keyJSON}${JSON.stringify(val)}`
Expand Down Expand Up @@ -613,7 +613,7 @@ class CQN2SQLRenderer {

buffer += '"'
} else {
if (elements[this.columns[key]]?.type in BINARY_TYPES) {
if (elements[this.columns[key]]?.type in this.BINARY_TYPES) {
val = transformBase64(val)
}
buffer += `${sepsub}${val === undefined ? 'null' : JSON.stringify(val)}`
Expand Down
2 changes: 1 addition & 1 deletion hana/lib/HANAService.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ class HANAService extends SQLService {
this.values = values
return false
}
if (x.element?.type?.indexOf('Binary') > -1) {
if (x.element?.type in this.BINARY_TYPES) {
blobs[this.column_name(x)] = null
return false
}
Expand Down

0 comments on commit 33c3ebe

Please sign in to comment.