diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 5b5f05bc58..876b52c0a6 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -1309,6 +1309,25 @@ describe.each([ { auto: 2 }, { auto: 1 }, ])) + + // This is important for pagination. The order of results must always + // be stable or pagination will break. We don't want the user to need + // to specify an order for pagination to work. + it("is stable without a sort specified", async () => { + let { rows } = await config.api.row.search(table._id!, { + tableId: table._id!, + query: {}, + }) + + for (let i = 0; i < 10; i++) { + const response = await config.api.row.search(table._id!, { + tableId: table._id!, + limit: 1, + query: {}, + }) + expect(response.rows).toEqual(rows) + } + }) }) // TODO(samwho): fix for SQS diff --git a/packages/server/src/integrations/tests/sql.spec.ts b/packages/server/src/integrations/tests/sql.spec.ts index 377c1d65e0..4fc964b320 100644 --- a/packages/server/src/integrations/tests/sql.spec.ts +++ b/packages/server/src/integrations/tests/sql.spec.ts @@ -235,21 +235,6 @@ describe("SQL query builder", () => { }) }) - it("should sort SQL Server tables by the primary key if no sort data is provided", () => { - let query = new Sql(SqlClient.MS_SQL, limit)._query( - generateReadJson({ - sort: {}, - paginate: { - limit: 10, - }, - }) - ) - expect(query).toEqual({ - bindings: [10], - sql: `select * from (select top (@p0) * from [test] order by [test].[id] asc) as [test]`, - }) - }) - it("should not parse JSON string as Date", () => { let query = new Sql(SqlClient.POSTGRES, limit)._query( generateCreateJson(TABLE_NAME, {