Skip to content

Commit

Permalink
fix: Only check first row if no changes required (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobdenOs committed Jun 19, 2024
1 parent 27d700e commit 39b0b85
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions db-service/lib/SQLService.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,30 @@ class SQLService extends DatabaseService {
return
}

let changes = false
for (let col of columns) {
const name = col.as || col.ref?.[col.ref.length - 1] || (typeof col === 'string' && col)
if (col.element?.isAssociation) {
if (one) this._changeToStreams(col.SELECT.columns, rows[0][name], false, compat)
else
rows.forEach(row => {
this._changeToStreams(col.SELECT.columns, row[name], false, compat)
})
changes = rows.some(row => !this._changeToStreams(col.SELECT.columns, row[name], false, compat))
} else if (col.element?.type === 'cds.LargeBinary') {
changes = true
if (one) rows[0][name] = this._stream(rows[0][name])
else
rows.forEach(row => {
row[name] = this._stream(row[name])
})
} else if (col.element?.type in BINARY_TYPES) {
changes = true
if (one) rows[0][name] = this._buffer(rows[0][name])
else
rows.forEach(row => {
row[name] = this._buffer(row[name])
})
}
}
return changes
}

_stream(val) {
Expand Down

0 comments on commit 39b0b85

Please sign in to comment.