The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(table-editor): use CTE optimization for table-editor selection (#35071)
Andrew Valleteauc0bddbba9ae0
diff --git a/packages/pg-meta/src/query/Query.utils.ts b/packages/pg-meta/src/query/Query.utils.tsindex f83a56ba265..dd4170230fb 100644--- a/packages/pg-meta/src/query/Query.utils.ts+++ b/packages/pg-meta/src/query/Query.utils.ts@@ -101,11 +101,13 @@ export function selectQuery(filters?: Filter[]pagination?: QueryPaginationsorts?: Sort[]- }+ },+ isFinal = true,+ isCTE = false) {let query = ''const queryColumn = columns ?? '*'- query += `select ${queryColumn} from ${queryTable(table)}`+ query += `select ${queryColumn} from ${isCTE ? queryCTE(table) : queryTable(table)}`const { filters, pagination, sorts } = options ?? {}if (filters) {@@ -118,7 +120,7 @@ export function selectQuery(const { limit, offset } = pagination ?? {}query += ` limit ${literal(limit)} offset ${literal(offset)}`}- return query + ';'+ return `${query}${isFinal ? ';' : ''}`}export function updateQuery(@@ -236,3 +238,7 @@ function applySorts(query: string, sorts: Sort[]) {function queryTable(table: QueryTable) {return `${ident(table.schema)}.${ident(table.name)}`}++function queryCTE(table: QueryTable) {+ return `${ident(table.name)}`+}diff --git a/packages/pg-meta/src/query/QueryFilter.ts b/packages/pg-meta/src/query/QueryFilter.tsindex 189e58feaba..d1a5ff6cda9 100644--- a/packages/pg-meta/src/query/QueryFilter.ts+++ b/packages/pg-meta/src/query/QueryFilter.ts@@ -44,8 +44,8 @@ export class QueryFilter implements IQueryFilter, IQueryModifier {return this._getQueryModifier().range(from, to)}- toSql() {- return this._getQueryModifier().toSql()+ toSql(options?: { isCTE: boolean; isFinal: boolean }) {+ return this._getQueryModifier().toSql(options)}_getQueryModifier() {diff --git a/packages/pg-meta/src/query/QueryModifier.ts b/packages/pg-meta/src/query/QueryModifier.tsindex 605da262185..644e6788c67 100644--- a/packages/pg-meta/src/query/QueryModifier.ts+++ b/packages/pg-meta/src/query/QueryModifier.ts@@ -41,7 +41,7 @@ export class QueryModifier implements IQueryModifier {/*** Return SQL string for query chains*/- toSql() {+ toSql(options: { isCTE: boolean; isFinal: boolean } = { isCTE: false, isFinal: true }) {try {const { actionValue, actionOptions, filters, sorts } = this.options ?? {}switch (this.action) {@@ -61,11 +61,17 @@ export class QueryModifier implements IQueryModifier {})}case 'select': {- return selectQuery(this.table, actionValue as string | undefined, {- filters,- pagination: this.pagination,- sorts,- })+ return selectQuery(+ this.table,+ actionValue as string | undefined,+ {+ filters,+ pagination: this.pagination,+ sorts,+ },+ options.isFinal,+ options.isCTE+ )}case 'update': {return updateQuery(this.table, actionValue as Dictionary<any>, {diff --git a/packages/pg-meta/src/query/table-row-query.ts b/packages/pg-meta/src/query/table-row-query.tsindex fe20c3f99c9..344430385a8 100644--- a/packages/pg-meta/src/query/table-row-query.ts+++ b/packages/pg-meta/src/query/table-row-query.ts@@ -111,6 +111,44 @@ export const getTableRowsSql = ({const query = new Query()+ // Properly escape the table name and schema+ let queryChains = query.from(table.name, table.schema).select()++ filters.forEach((x) => {+ const col = table.columns?.find((y) => y.name === x.column)+ const isStringTypeColumn = !!col ? TEXT_TYPES.includes(col.format) : true+ queryChains = queryChains.filter(+ x.column,+ x.operator,+ !isStringTypeColumn && x.value === '' ? null : x.value+ )+ })++ // If sorts is empty and table row count is within threshold, use the primary key as the default sort+ // Only apply for selections over a Table, not View, MaterializedViews, ...+ const liveRowCount = (table as PGTable).live_rows_estimate || 0+ if (sorts.length === 0 && liveRowCount <= THRESHOLD_COUNT && table.columns.length > 0) {+ const defaultOrderByColumns = getDefaultOrderByColumns(table as PGTable)+ if (defaultOrderByColumns.length > 0) {+ defaultOrderByColumns.forEach((col) => {+ queryChains = queryChains.order(table.name, col, true, true)+ })+ }+ } else {+ sorts.forEach((x) => {+ queryChains = queryChains.order(x.table, x.column, x.ascending, x.nullsFirst)+ })+ }++ // getPagination is expecting to start from 0+ const { from, to } = getPagination((page ?? 1) - 1, limit)++ // To have efficient query, we use CTE optimization, to first reduce the number of rows and order them in the right place+ // filtering, applying limits and order by, then we can apply selection with some conditional logic to truncate large columns+ // allowing postgres to only truncate the columns within the subset that we'll return instead of attemting to do it on+ // all the rows within the table+ const baseSelectQuery = `with _base_query as (${queryChains.range(from, to).toSql({ isCTE: false, isFinal: false })})`+const allColumnNames = table.columns.sort((a, b) => a.ordinal_position - b.ordinal_position).map((column) => ({ name: column.name, format: column.format.toLowerCase() }))@@ -167,39 +205,11 @@ export const getTableRowsSql = ({})const selectClause = selectExpressions.join(',')-- // Properly escape the table name and schema- let queryChains = query.from(table.name, table.schema).select(selectClause)-- filters.forEach((x) => {- const col = table.columns?.find((y) => y.name === x.column)- const isStringTypeColumn = !!col ? TEXT_TYPES.includes(col.format) : true- queryChains = queryChains.filter(- x.column,- x.operator,- !isStringTypeColumn && x.value === '' ? null : x.value- )- })-- // If sorts is empty and table row count is within threshold, use the primary key as the default sort- // Only apply for selections over a Table, not View, MaterializedViews, ...- const liveRowCount = (table as PGTable).live_rows_estimate || 0- if (sorts.length === 0 && liveRowCount <= THRESHOLD_COUNT && table.columns.length > 0) {- const defaultOrderByColumns = getDefaultOrderByColumns(table as PGTable)- if (defaultOrderByColumns.length > 0) {- defaultOrderByColumns.forEach((col) => {- queryChains = queryChains.order(table.name, col, true, true)- })- }- } else {- sorts.forEach((x) => {- queryChains = queryChains.order(x.table, x.column, x.ascending, x.nullsFirst)- })- }-- // getPagination is expecting to start from 0- const { from, to } = getPagination((page ?? 1) - 1, limit)- return queryChains.range(from, to).toSql()+ const finalQuery = new Query()+ // Now, we apply our selection logic with the tables truncation on the _base_query contructed before+ const finalQueryChain = finalQuery.from('_base_query').select(selectClause)+ return `${baseSelectQuery}+ ${finalQueryChain.toSql({ isCTE: true, isFinal: true })}`}export default {diff --git a/packages/pg-meta/test/query/advanced-query.test.ts b/packages/pg-meta/test/query/advanced-query.test.tsindex 1c6da421c19..4366e608a5f 100644--- a/packages/pg-meta/test/query/advanced-query.test.ts+++ b/packages/pg-meta/test/query/advanced-query.test.ts@@ -118,7 +118,7 @@ describe('Advanced Query Tests', () => {const query = new Query()const sql = query.from('table with spaces', 'public').select('*').toSql()- expect(sql).toMatchInlineSnapshot('"select * from public."table with spaces";"')+ expect(sql).toMatchInlineSnapshot(`"select * from public."table with spaces";"`)const result = await validateSql(db, sql)expect(result.length).toBe(2)expect(result[0]['column with spaces']).toBe('value with spaces')@@ -129,7 +129,7 @@ describe('Advanced Query Tests', () => {const query = new Query()const sql = query.from('quoted"table', 'public').select('*').toSql()- expect(sql).toMatchInlineSnapshot('"select * from public."quoted""table";"')+ expect(sql).toMatchInlineSnapshot(`"select * from public."quoted""table";"`)const result = await validateSql(db, sql)expect(result.length).toBe(2)expect(result[0].name).toBe('quoted table row 1')@@ -140,7 +140,7 @@ describe('Advanced Query Tests', () => {const query = new Query()const sql = query.from("quoted'table", 'public').select('*').toSql()- expect(sql).toMatchInlineSnapshot('"select * from public."quoted\'table";"')+ expect(sql).toMatchInlineSnapshot(`"select * from public."quoted'table";"`)const result = await validateSql(db, sql)expect(result.length).toBe(2)expect(result[0].name).toBe('single quoted table row 1')@@ -151,7 +151,7 @@ describe('Advanced Query Tests', () => {const query = new Query()const sql = query.from('camelCaseTable', 'public').select('*').toSql()- expect(sql).toMatchInlineSnapshot('"select * from public."camelCaseTable";"')+ expect(sql).toMatchInlineSnapshot(`"select * from public."camelCaseTable";"`)const result = await validateSql(db, sql)expect(result.length).toBe(2)expect(result[0].name).toBe('camel case table row 1')@@ -162,7 +162,7 @@ describe('Advanced Query Tests', () => {const query = new Query()const sql = query.from('special#$%^&Table', 'public').select('*').toSql()- expect(sql).toMatchInlineSnapshot('"select * from public."special#$%^&Table";"')+ expect(sql).toMatchInlineSnapshot(`"select * from public."special#$%^&Table";"`)const result = await validateSql(db, sql)expect(result.length).toBe(2)expect(result[0].name).toBe('special char table row 1')@@ -174,7 +174,7 @@ describe('Advanced Query Tests', () => {const sql = query.from('table with spaces', 'public').select('"column with spaces"').toSql()expect(sql).toMatchInlineSnapshot(- '"select "column with spaces" from public."table with spaces";"'+ `"select "column with spaces" from public."table with spaces";"`)const result = await validateSql(db, sql)expect(result.length).toBe(2)@@ -187,7 +187,7 @@ describe('Advanced Query Tests', () => {const sql = query.from('table with spaces', 'public').select('"quoted""column"').toSql()expect(sql).toMatchInlineSnapshot(- '"select "quoted""column" from public."table with spaces";"'+ `"select "quoted""column" from public."table with spaces";"`)const result = await validateSql(db, sql)expect(result.length).toBe(2)@@ -200,7 +200,7 @@ describe('Advanced Query Tests', () => {const sql = query.from('table with spaces', 'public').select('"quoted\'column"').toSql()expect(sql).toMatchInlineSnapshot(- '"select "quoted\'column" from public."table with spaces";"'+ `"select "quoted'column" from public."table with spaces";"`)const result = await validateSql(db, sql)expect(result.length).toBe(2)@@ -213,7 +213,7 @@ describe('Advanced Query Tests', () => {const sql = query.from('table with spaces', 'public').select('"camelCaseColumn"').toSql()expect(sql).toMatchInlineSnapshot(- '"select "camelCaseColumn" from public."table with spaces";"'+ `"select "camelCaseColumn" from public."table with spaces";"`)const result = await validateSql(db, sql)expect(result.length).toBe(2)@@ -226,7 +226,7 @@ describe('Advanced Query Tests', () => {const sql = query.from('table with spaces', 'public').select('"special#$%^&Column"').toSql()expect(sql).toMatchInlineSnapshot(- '"select "special#$%^&Column" from public."table with spaces";"'+ `"select "special#$%^&Column" from public."table with spaces";"`)const result = await validateSql(db, sql)expect(result.length).toBe(2)@@ -261,7 +261,7 @@ describe('Advanced Query Tests', () => {.toSql()expect(sql).toMatchInlineSnapshot(- '"select * from public."table with spaces" where "column with spaces" = \'test value\';"'+ `"select * from public."table with spaces" where "column with spaces" = 'test value';"`)// Validate the generated SQL directly against the database@@ -284,7 +284,7 @@ describe('Advanced Query Tests', () => {.toSql()expect(sql).toMatchInlineSnapshot(- "\"select * from public.normal_table where name = 'O''Reilly';\""+ `"select * from public.normal_table where name = 'O''Reilly';"`)const result = await validateSql(db, sql)@@ -345,7 +345,7 @@ describe('Advanced Query Tests', () => {.toSql()expect(sql).toMatchInlineSnapshot(- '"select id, name from public.normal_table where id > 10 and name ~~ \'%John%\' order by normal_table.name asc nulls last limit 10 offset 0;"'+ `"select id, name from public.normal_table where id > 10 and name ~~ '%John%' order by normal_table.name asc nulls last limit 10 offset 0;"`)const result = await validateSql(db, sql)@@ -507,7 +507,7 @@ describe('Advanced Query Tests', () => {.toSql()expect(sql).toMatchInlineSnapshot(- '"select * from public.normal_table where name = \'Special $ ^ & * ( ) _ + { } | : < > ? characters\';"'+ `"select * from public.normal_table where name = 'Special $ ^ & * ( ) _ + { } | : < > ? characters';"`)await validateSql(db, sql)})@@ -532,7 +532,7 @@ describe('Advanced Query Tests', () => {.filter('id', 'in', [1, 2, 3]).toSql()- expect(sql).toMatchInlineSnapshot('"select * from public.normal_table where id in (1,2,3);"')+ expect(sql).toMatchInlineSnapshot(`"select * from public.normal_table where id in (1,2,3);"`)const result = await validateSql(db, sql)expect(result.length).toBe(3)expect(result.map((row: any) => row.id).sort()).toEqual([1, 2, 3])@@ -554,7 +554,7 @@ describe('Advanced Query Tests', () => {.filter('name', 'is', 'null').toSql()- expect(sql).toMatchInlineSnapshot('"select * from public.normal_table where name is null;"')+ expect(sql).toMatchInlineSnapshot(`"select * from public.normal_table where name is null;"`)const result = await validateSql(db, sql)expect(result.length).toBe(1)expect(result[0].id).toBe(2)@@ -578,7 +578,7 @@ describe('Advanced Query Tests', () => {.toSql()expect(sql).toMatchInlineSnapshot(- '"select * from public.normal_table where name is not null;"'+ `"select * from public.normal_table where name is not null;"`)const result = await validateSql(db, sql)expect(result.length).toBe(1)diff --git a/packages/pg-meta/test/query/table-row-query.test.ts b/packages/pg-meta/test/query/table-row-query.test.tsindex dd59529ac05..39ab53c7014 100644--- a/packages/pg-meta/test/query/table-row-query.test.ts+++ b/packages/pg-meta/test/query/table-row-query.test.ts@@ -75,7 +75,8 @@ describe('Table Row Query', () => {// Verify SQL generation with snapshotexpect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_enum_array order by test_enum_array.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text@@ -85,7 +86,7 @@ describe('Table Row Query', () => {then (select array_cat(history[1:50]::text[], array['...']::text[]))::text[]else history::text[]end- from public.test_enum_array order by test_enum_array.id asc nulls first limit 10 offset 0;"+ from _base_query;"`)// Execute the generated SQL and verify the results@@ -140,7 +141,8 @@ describe('Table Row Query', () => {})expect(filtersStatusSQL).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_enum_array where status = 'active' order by test_enum_array.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text@@ -150,7 +152,7 @@ describe('Table Row Query', () => {then (select array_cat(history[1:50]::text[], array['...']::text[]))::text[]else history::text[]end- from public.test_enum_array where status = 'active' order by test_enum_array.id asc nulls first limit 10 offset 0;"+ from _base_query;"`)// Execute the filtered queryconst filtersStatusResult = await db.executeQuery(filtersStatusSQL)@@ -178,7 +180,8 @@ describe('Table Row Query', () => {})expect(filtersHistorySQL).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_enum_array where history = ARRAY['active']::status_type[] order by test_enum_array.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text@@ -188,7 +191,7 @@ describe('Table Row Query', () => {then (select array_cat(history[1:50]::text[], array['...']::text[]))::text[]else history::text[]end- from public.test_enum_array where history = ARRAY['active']::status_type[] order by test_enum_array.id asc nulls first limit 10 offset 0;"+ from _base_query;"`)const filtersHistoryResult = await db.executeQuery(filtersHistorySQL)expect(filtersHistoryResult).toMatchInlineSnapshot(`[]`)@@ -223,7 +226,8 @@ describe('Table Row Query', () => {limit: 10,})expect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_array_table order by test_array_table.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text@@ -233,7 +237,7 @@ describe('Table Row Query', () => {then (select array_cat(tags[1:50]::text[], array['...']::text[]))::text[]else tags::text[]end- from public.test_array_table order by test_array_table.id asc nulls first limit 10 offset 0;"+ from _base_query;"`)const queryResult = await db.executeQuery(sql)@@ -301,7 +305,8 @@ describe('Table Row Query', () => {// Verify SQL generation with snapshotexpect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_sql_gen order by test_sql_gen.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text@@ -309,7 +314,7 @@ describe('Table Row Query', () => {when octet_length(description::text) > 10240then left(description::text, 10240) || '...'else description::text- end as description,created_at from public.test_sql_gen order by test_sql_gen.id asc nulls first limit 10 offset 0;"+ end as description,created_at from _base_query;"`)@@ -361,7 +366,8 @@ describe('Table Row Query', () => {// Verify the SQL contains the array truncation logicexpect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_large_array_table order by test_large_array_table.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 2048then left(name::text, 2048) || '...'else name::text@@ -371,7 +377,7 @@ describe('Table Row Query', () => {then (select array_cat(large_array[1:10]::text[], array['...']::text[]))::text[]else large_array::text[]end- from public.test_large_array_table order by test_large_array_table.id asc nulls first limit 10 offset 0;"+ from _base_query;"`)// Execute the SQL and verify results@@ -587,24 +593,25 @@ describe('Table Row Query', () => {// Verify the SQL contains the array truncation logicexpect(sql).toMatchInlineSnapshot(`- "select id,case- when octet_length(name::text) > 2048- then left(name::text, 2048) || '...'- else name::text- end as name,- case- when octet_length(large_array_jsonb::text) > 2048- then (select array_cat(large_array_jsonb[1:10]::jsonb[], array['{"truncated": true}'::json]::jsonb[]))::jsonb[]- else large_array_jsonb::jsonb[]- end- ,- case- when octet_length(large_array_json::text) > 2048- then (select array_cat(large_array_json[1:10]::json[], array['{"truncated": true}'::json]::json[]))::json[]- else large_array_json::json[]- end- from public.test_large_array_table order by test_large_array_table.id asc nulls first limit 10 offset 0;"- `)+ "with _base_query as (select * from public.test_large_array_table order by test_large_array_table.id asc nulls first limit 10 offset 0)+ select id,case+ when octet_length(name::text) > 2048+ then left(name::text, 2048) || '...'+ else name::text+ end as name,+ case+ when octet_length(large_array_jsonb::text) > 2048+ then (select array_cat(large_array_jsonb[1:10]::jsonb[], array['{"truncated": true}'::json]::jsonb[]))::jsonb[]+ else large_array_jsonb::jsonb[]+ end+ ,+ case+ when octet_length(large_array_json::text) > 2048+ then (select array_cat(large_array_json[1:10]::json[], array['{"truncated": true}'::json]::json[]))::json[]+ else large_array_json::json[]+ end+ from _base_query;"+ `)// Execute the SQL and verify resultsconst queryResult = await db.executeQuery(sql)@@ -949,7 +956,8 @@ describe('Table Row Query', () => {// Verify the SQL contains the array truncation logicexpect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_large_array_table order by test_large_array_table.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 256then left(name::text, 256) || '...'else name::text@@ -959,7 +967,7 @@ describe('Table Row Query', () => {then (select array_cat(large_array[1:50]::text[], array['...']::text[]))::text[]else large_array::text[]end- from public.test_large_array_table order by test_large_array_table.id asc nulls first limit 10 offset 0;"+ from _base_query;"`)// Execute the SQL and verify results@@ -1034,7 +1042,8 @@ describe('Table Row Query', () => {// Verify SQL generation with snapshotexpect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_sql_filter where name ~~ 'Test%' and category = 'A' order by test_sql_filter.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text@@ -1042,7 +1051,7 @@ describe('Table Row Query', () => {when octet_length(category::text) > 10240then left(category::text, 10240) || '...'else category::text- end as category from public.test_sql_filter where name ~~ 'Test%' and category = 'A' order by test_sql_filter.id asc nulls first limit 10 offset 0;"+ end as category from _base_query;"`)@@ -1094,11 +1103,12 @@ describe('Table Row Query', () => {// Verify SQL generation with snapshotexpect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_sql_sort order by test_sql_sort.name asc nulls last, test_sql_sort.value desc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text- end as name,value from public.test_sql_sort order by test_sql_sort.name asc nulls last, test_sql_sort.value desc nulls first limit 10 offset 0;"+ end as name,value from _base_query;"`)@@ -1157,7 +1167,8 @@ describe('Table Row Query', () => {// Verify SQL generation with snapshotexpect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public."test sql spaces" order by "test sql spaces".id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length("user name"::text) > 10240then left("user name"::text, 10240) || '...'else "user name"::text@@ -1169,7 +1180,7 @@ describe('Table Row Query', () => {when octet_length("quoted""column"::text) > 10240then left("quoted""column"::text, 10240) || '...'else "quoted""column"::text- end as "quoted""column" from public."test sql spaces" order by "test sql spaces".id asc nulls first limit 10 offset 0;"+ end as "quoted""column" from _base_query;"`)@@ -1217,7 +1228,8 @@ describe('Table Row Query', () => {// Verify SQL generation with snapshotexpect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_large_text order by test_large_text.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(small_text::text) > 10240then left(small_text::text, 10240) || '...'else small_text::text@@ -1229,7 +1241,7 @@ describe('Table Row Query', () => {when octet_length(json_data::text) > 10240then left(json_data::text, 10240) || '...'else json_data::text- end as json_data from public.test_large_text order by test_large_text.id asc nulls first limit 10 offset 0;"+ end as json_data from _base_query;"`)@@ -1277,11 +1289,12 @@ describe('Table Row Query', () => {expect(sql1).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_pagination order by test_pagination.id asc nulls first limit 5 offset 0)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text- end as name from public.test_pagination order by test_pagination.id asc nulls first limit 5 offset 0;"+ end as name from _base_query;"`)@@ -1304,11 +1317,12 @@ describe('Table Row Query', () => {// Verify SQL generation for page 2expect(sql2).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_pagination order by test_pagination.id asc nulls first limit 5 offset 5)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text- end as name from public.test_pagination order by test_pagination.id asc nulls first limit 5 offset 5;"+ end as name from _base_query;"`)@@ -1360,11 +1374,12 @@ describe('Table Row Query', () => {// Verify SQL generation with snapshotexpect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_sql_view order by test_sql_view.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text- end as name,active from public.test_sql_view order by test_sql_view.id asc nulls first limit 10 offset 0;"+ end as name,active from _base_query;"`)@@ -1412,11 +1427,12 @@ describe('Table Row Query', () => {// Verify SQL generation with snapshotexpect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_sql_mv order by test_sql_mv.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text- end as name,value from public.test_sql_mv order by test_sql_mv.id asc nulls first limit 10 offset 0;"+ end as name,value from _base_query;"`)@@ -1478,7 +1494,8 @@ describe('Table Row Query', () => {// Verify SQL generation with snapshotexpect(sql).toMatchInlineSnapshot(`- "select id,case+ "with _base_query as (select * from public.test_sql_foreign order by test_sql_foreign.id asc nulls first limit 10 offset 0)+ select id,casewhen octet_length(name::text) > 10240then left(name::text, 10240) || '...'else name::text@@ -1486,7 +1503,7 @@ describe('Table Row Query', () => {when octet_length(description::text) > 10240then left(description::text, 10240) || '...'else description::text- end as description from public.test_sql_foreign order by test_sql_foreign.id asc nulls first limit 10 offset 0;"+ end as description from _base_query;"`)