@@ -20,7 +20,7 @@ const actionDefinition: ActionDefinition = {
20
20
{
21
21
key : 'updateQuery' ,
22
22
name : 'Update Query Template' ,
23
- description : 'SQL UPDATE query template with {record } and {value } placeholders' ,
23
+ description : 'SQL UPDATE query template with {record_id } and {new_value } placeholders' ,
24
24
type : 'string' ,
25
25
validation : {
26
26
required : true ,
@@ -89,9 +89,10 @@ export async function handler({ input }: ActionContext): Promise<OutputObject> {
89
89
90
90
const updateQuery = constructUpdateQuery (
91
91
input . updateQuery ,
92
- input . record ,
93
- input . updateValue
92
+ input . recordId ,
93
+ input . newValue
94
94
) ;
95
+
95
96
const result = await executeTransaction ( client , updateQuery ) ;
96
97
97
98
return {
@@ -146,16 +147,16 @@ function formatQueryResponse(updateQuery: string): string {
146
147
return updateQuery ;
147
148
}
148
149
149
- function constructUpdateQuery ( queryTemplate : string , record : string , value : string ) : string {
150
+ function constructUpdateQuery ( queryTemplate : string , recordId : string , newValue : string ) : string {
150
151
// Validate that the template contains both placeholders
151
- if ( ! queryTemplate . includes ( '{record }' ) || ! queryTemplate . includes ( '{value }' ) ) {
152
- throw new Error ( 'Update query template must contain both {record } and {value } placeholders' ) ;
152
+ if ( ! queryTemplate . includes ( '{record_id }' ) || ! queryTemplate . includes ( '{new_value }' ) ) {
153
+ throw new Error ( 'Update query template must contain both {record_id } and {new_value } placeholders' ) ;
153
154
}
154
155
155
156
// Use String.prototype.replace with a replacer function to preserve case
156
157
const updateStatement = queryTemplate
157
- . replace ( / { r e c o r d } / g, ( match ) => `'${ record } '` ) // Preserve case of record
158
- . replace ( / { v a l u e } / g, ( match ) => `'${ value } '` ) ; // Preserve case of value
158
+ . replace ( / { r e c o r d _ i d } / g, ( match ) => `'${ recordId } '` )
159
+ . replace ( / { n e w _ v a l u e } / g, ( match ) => `'${ newValue } '` ) ;
159
160
160
161
// Extract the WHERE clause to use in the SELECT statement
161
162
const whereClauseMatch = updateStatement . match ( / W H E R E \s + ( .+ ) $ / i) ;
0 commit comments