mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
fix(tools): fixed supabase order by (#1467)
Co-authored-by: Adam Gough <adamgough@Mac.attlocal.net>
This commit is contained in:
@@ -58,9 +58,21 @@ export const queryTool: ToolConfig<SupabaseQueryParams, SupabaseQueryResponse> =
|
||||
|
||||
// Add order by if provided
|
||||
if (params.orderBy) {
|
||||
const orderParam = params.orderBy.includes('DESC')
|
||||
? `${params.orderBy.replace(' DESC', '').replace('DESC', '')}.desc`
|
||||
: `${params.orderBy}.asc`
|
||||
let orderParam = params.orderBy.trim()
|
||||
|
||||
// Check if DESC is specified (case-insensitive)
|
||||
if (/\s+DESC$/i.test(orderParam)) {
|
||||
orderParam = `${orderParam.replace(/\s+DESC$/i, '').trim()}.desc`
|
||||
}
|
||||
// Check if ASC is specified (case-insensitive)
|
||||
else if (/\s+ASC$/i.test(orderParam)) {
|
||||
orderParam = `${orderParam.replace(/\s+ASC$/i, '').trim()}.asc`
|
||||
}
|
||||
// Default to ascending if no direction specified
|
||||
else {
|
||||
orderParam = `${orderParam}.asc`
|
||||
}
|
||||
|
||||
url += `&order=${orderParam}`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user