Resolving PR comments.

This commit is contained in:
mike12345567 2024-06-28 13:49:52 +01:00
parent fa10140ef7
commit 2d31e327e7
1 changed files with 5 additions and 7 deletions

View File

@ -140,12 +140,11 @@ function reverseUserColumnMapping(rows: Row[]) {
return rows.map(row => { return rows.map(row => {
const finalRow: Row = {} const finalRow: Row = {}
for (let key of Object.keys(row)) { for (let key of Object.keys(row)) {
// it should be the last prefix // it should be the first prefix
const lastIndex = key.lastIndexOf(USER_COLUMN_PREFIX) const index = key.indexOf(USER_COLUMN_PREFIX)
if (lastIndex !== -1 && lastIndex < key.length - prefixLength) { if (index !== -1) {
// cut out the prefix // cut out the prefix
const newKey = const newKey = key.slice(0, index) + key.slice(index + prefixLength)
key.slice(0, lastIndex) + key.slice(lastIndex + prefixLength)
finalRow[newKey] = row[key] finalRow[newKey] = row[key]
} else { } else {
finalRow[key] = row[key] finalRow[key] = row[key]
@ -198,9 +197,8 @@ async function runSqlQuery(
return processRowCountResponse(response) return processRowCountResponse(response)
} else if (Array.isArray(response)) { } else if (Array.isArray(response)) {
return reverseUserColumnMapping(response) return reverseUserColumnMapping(response)
} else {
return response
} }
return response
} }
export async function search( export async function search(