Skip to content

Commit

Permalink
fix: Allow only for array of arrays as data for plain SQL (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobdenOs authored Feb 12, 2024
1 parent cdf1b52 commit 22e1c43
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions db-service/lib/SQLService.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SQLService extends DatabaseService {
return Object.assign(acc, obj)
}, {}),
)
const invalidColumns = columns.filter(c => !(c in elements))
const invalidColumns = columns.filter(c => !(c in elements))

if (invalidColumns.length > 0) {
cds.error(`STRICT MODE: Trying to ${kind} non existent columns (${invalidColumns})`)
Expand Down Expand Up @@ -245,7 +245,7 @@ class SQLService extends DatabaseService {
DEBUG?.(query, data)
const ps = await this.prepare(query)
const exec = this.hasResults(query) ? d => ps.all(d) : d => ps.run(d)
if (Array.isArray(data) && typeof data[0] === 'object') return await Promise.all(data.map(exec))
if (Array.isArray(data) && Array.isArray(data[0])) return await Promise.all(data.map(exec))
else return exec(data)
} else return next()
}
Expand Down

0 comments on commit 22e1c43

Please sign in to comment.