diff --git a/packages/sql-to-rest/src/renderers/http.test.ts b/packages/sql-to-rest/src/renderers/http.test.ts index 2cf4062f2b7..7ca08a7d132 100644 --- a/packages/sql-to-rest/src/renderers/http.test.ts +++ b/packages/sql-to-rest/src/renderers/http.test.ts @@ -259,6 +259,24 @@ describe('select', () => { expect(fullPath).toBe('/books?title=eq.Cheese&description=ilike.*salsa*') }) + test('"and" expression using the same column multiple times', async () => { + const sql = stripIndents` + select + * + from + books + where + pages > 100 and + pages < 1000 + ` + + const statement = await processSql(sql) + const { method, fullPath } = await renderHttp(statement) + + expect(method).toBe('GET') + expect(fullPath).toBe('/books?pages=gt.100&pages=lt.1000') + }) + test('"or" expression', async () => { const sql = stripIndents` select diff --git a/packages/sql-to-rest/src/renderers/http.ts b/packages/sql-to-rest/src/renderers/http.ts index ffa81873634..fdb0354f128 100644 --- a/packages/sql-to-rest/src/renderers/http.ts +++ b/packages/sql-to-rest/src/renderers/http.ts @@ -100,7 +100,7 @@ function formatSelectFilterRoot(params: URLSearchParams, filter: Filter) { value = filter.value.replaceAll('%', '*') } - params.set(filter.column, `${maybeNot}${filter.operator}.${value}`) + params.append(filter.column, `${maybeNot}${filter.operator}.${value}`) } // Logical operator filter, eg. "or=(title.eq.Cheese,title.eq.Salsa)"" else if (type === 'logical') { @@ -113,7 +113,7 @@ function formatSelectFilterRoot(params: URLSearchParams, filter: Filter) { } // Otherwise use the =(...) syntax else { - params.set( + params.append( `${maybeNot}${filter.operator}`, `(${filter.values.map((subFilter) => formatSelectFilter(subFilter)).join(',')})` )