@@ -3,6 +3,7 @@ import type { PostgrestBuilder } from '@supabase/postgrest-js';
3
3
import { encodeObject } from './lib/encode-object' ;
4
4
import { getTableFromUrl } from './lib/get-table-from-url' ;
5
5
import { isObject } from './lib/is-object' ;
6
+ import { parseOrderBy } from './lib/parse-order-by' ;
6
7
import type { OrderDefinition } from './lib/query-types' ;
7
8
import { sortSearchParams } from './lib/sort-search-param' ;
8
9
import {
@@ -69,22 +70,7 @@ export class PostgrestParser<Result> extends PostgrestQueryParser {
69
70
const offset = this . _url . searchParams . get ( 'offset' ) ;
70
71
this . offset = offset ? Number ( offset ) : undefined ;
71
72
72
- this . _url . searchParams . forEach ( ( value , key ) => {
73
- const split = key . split ( '.' ) ;
74
- if ( split [ split . length === 2 ? 1 : 0 ] === 'order' ) {
75
- // separated by ,
76
- const orderByDefs = value . split ( ',' ) ;
77
- orderByDefs . forEach ( ( def ) => {
78
- const [ column , ascending , nullsFirst ] = def . split ( '.' ) ;
79
- this . orderBy . push ( {
80
- ascending : ascending === 'asc' ,
81
- column,
82
- nullsFirst : nullsFirst === 'nullsfirst' ,
83
- foreignTable : split . length === 2 ? split [ 0 ] : undefined ,
84
- } ) ;
85
- } ) ;
86
- }
87
- } ) ;
73
+ this . orderBy = parseOrderBy ( this . _url . searchParams ) ;
88
74
this . orderByKey = this . orderBy
89
75
. map (
90
76
( { column, ascending, nullsFirst, foreignTable } ) =>
0 commit comments