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: Allow only for array of arrays as data for plain SQL #449

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Changes from all commits
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
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
Loading