File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -58,9 +58,21 @@ export const queryTool: ToolConfig<SupabaseQueryParams, SupabaseQueryResponse> =
5858
5959 // Add order by if provided
6060 if ( params . orderBy ) {
61- const orderParam = params . orderBy . includes ( 'DESC' )
62- ? `${ params . orderBy . replace ( ' DESC' , '' ) . replace ( 'DESC' , '' ) } .desc`
63- : `${ params . orderBy } .asc`
61+ let orderParam = params . orderBy . trim ( )
62+
63+ // Check if DESC is specified (case-insensitive)
64+ if ( / \s + D E S C $ / i. test ( orderParam ) ) {
65+ orderParam = `${ orderParam . replace ( / \s + D E S C $ / i, '' ) . trim ( ) } .desc`
66+ }
67+ // Check if ASC is specified (case-insensitive)
68+ else if ( / \s + A S C $ / i. test ( orderParam ) ) {
69+ orderParam = `${ orderParam . replace ( / \s + A S C $ / i, '' ) . trim ( ) } .asc`
70+ }
71+ // Default to ascending if no direction specified
72+ else {
73+ orderParam = `${ orderParam } .asc`
74+ }
75+
6476 url += `&order=${ orderParam } `
6577 }
6678
You can’t perform that action at this time.
0 commit comments