Skip to content

Commit

Permalink
PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
paulr34 committed Aug 13, 2024
1 parent 155d7b9 commit 3996bcf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions src-electron/db/query-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,18 +705,19 @@ async function getAllPackages(db) {
*/
async function getAttributeAccessInterface(db, code, packageIds) {
try {
// Ensure packageIds is always an array
if (!Array.isArray(packageIds)) {
packageIds = [packageIds]
}

let packageRefCondition = `po.PACKAGE_REF = ?`
let attributePackageRefCondition = `a.PACKAGE_REF = ?`
let queryParams = [code, packageIds, code, packageIds]
let queryParams = [code, ...packageIds, code, ...packageIds]

// Check if packageIds is an array and adjust the query and parameters accordingly
if (Array.isArray(packageIds)) {
const placeholders = packageIds.map(() => '?').join(', ')
packageRefCondition = `po.PACKAGE_REF IN (${placeholders})`
attributePackageRefCondition = `a.PACKAGE_REF IN (${placeholders})`
// Adjust queryParams for the IN clause
queryParams = [code, ...packageIds, code, ...packageIds]
}
// Since packageIds is now always an array, adjust the query and parameters accordingly
const placeholders = packageIds.map(() => '?').join(', ')
packageRefCondition = `po.PACKAGE_REF IN (${placeholders})`
attributePackageRefCondition = `a.PACKAGE_REF IN (${placeholders})`

const extendedQuery = `
SELECT
Expand Down
4 changes: 2 additions & 2 deletions src-electron/rest/user-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ function httpPostForcedExternal(db) {
db,
sessionId
)
let packageId = packages[0].pkg.id
let forcedExternal = await upgrade.getForcedExternalStorage(db, packageId)
let packageIds = packages.map((pkg) => pkg.id)
let forcedExternal = await upgrade.getForcedExternalStorage(db, packageIds)
response.status(StatusCodes.OK).json(forcedExternal)
}
}
Expand Down

0 comments on commit 3996bcf

Please sign in to comment.