Skip to content

Commit 518c2fe

Browse files
committed
Reimplement the update method to support postgres
1 parent 936f5aa commit 518c2fe

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/query/drivers/sql/TableRepository.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,20 @@ export abstract class TableRepository<
151151
UPDATE
152152
"${this.tableName}"
153153
SET
154-
?
154+
${Object.keys(filteredPayload).map(() => "?? = ?")}
155155
${filterQuery !== "" ? "WHERE" : ""}
156156
${filterQuery}
157157
`
158158

159+
let payloadParameters: Array<any> = []
160+
Object.keys(filteredPayload).forEach((k) => {
161+
payloadParameters.push(k)
162+
payloadParameters.push(filteredPayload[k])
163+
})
164+
159165
let [processedQuery, processedParameters] = pgQueryPostProcessor(
160166
lookupQuery,
161-
parameters
167+
[...payloadParameters, ...parameters]
162168
)
163169
await connection.query(processedQuery, processedParameters)
164170
}

0 commit comments

Comments
 (0)