@fachkraftfreund/n8n-nodes-supabase 1.2.20 → 1.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -211,44 +211,71 @@ async function handleRead(supabase, itemIndex, hostUrl) {
211
211
  const returnData = [];
212
212
  if (returnAll) {
213
213
  const batchSize = 1000;
214
+ const selectFields = returnFields && returnFields !== '*' ? returnFields : '*';
215
+ const hasIdColumn = selectFields === '*' || selectFields.split(',').some(f => f.trim() === 'id');
214
216
  for (let ci = 0; ci < filterChunks.length; ci++) {
215
217
  const chunkFilters = filterChunks[ci];
216
218
  const inFilter = chunkFilters.find(f => f.operator === 'in');
217
219
  const chunkIds = inFilter && Array.isArray(inFilter.value) ? inFilter.value.length : '?';
218
- console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} (${chunkIds} IDs) - starting...`);
220
+ console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} (${chunkIds} IDs) keyset=${hasIdColumn} - starting...`);
219
221
  const chunkStart = Date.now();
220
- let lastId = null;
221
- let hasMore = true;
222
222
  let batchCount = 0;
223
- while (hasMore) {
224
- let query = buildReadQuery(supabase, table, returnFields, chunkFilters, []);
225
- if (lastId !== null) {
226
- query = query.gt('id', lastId);
227
- }
228
- query = query.order('id', { ascending: true }).limit(batchSize);
229
- const { data, error } = await query;
230
- if (error) {
231
- console.log(`[Supabase READ] chunk ${ci + 1} batch ${batchCount + 1} FAILED after ${Date.now() - chunkStart}ms: ${(0, supabaseClient_1.formatSupabaseError)(error)}`);
232
- throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
233
- }
234
- if (Array.isArray(data) && data.length > 0) {
235
- for (const row of data) {
236
- returnData.push({ json: row });
223
+ let hasMore = true;
224
+ if (hasIdColumn) {
225
+ let lastId = null;
226
+ while (hasMore) {
227
+ let query = buildReadQuery(supabase, table, returnFields, chunkFilters, []);
228
+ if (lastId !== null) {
229
+ query = query.gt('id', lastId);
230
+ }
231
+ query = query.order('id', { ascending: true }).limit(batchSize);
232
+ const { data, error } = await query;
233
+ if (error) {
234
+ console.log(`[Supabase READ] chunk ${ci + 1} batch ${batchCount + 1} FAILED after ${Date.now() - chunkStart}ms: ${(0, supabaseClient_1.formatSupabaseError)(error)}`);
235
+ throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
236
+ }
237
+ if (Array.isArray(data) && data.length > 0) {
238
+ for (const row of data)
239
+ returnData.push({ json: row });
240
+ lastId = data[data.length - 1].id;
241
+ hasMore = data.length === batchSize;
242
+ }
243
+ else {
244
+ hasMore = false;
245
+ }
246
+ batchCount++;
247
+ if (batchCount % 50 === 0) {
248
+ console.log(`[Supabase READ] chunk ${ci + 1} progress: ${batchCount} batches, ${returnData.length} rows, ${Date.now() - chunkStart}ms`);
237
249
  }
238
- lastId = data[data.length - 1].id;
239
- hasMore = data.length === batchSize;
240
- }
241
- else {
242
- hasMore = false;
243
250
  }
244
- batchCount++;
245
- if (batchCount % 50 === 0) {
246
- console.log(`[Supabase READ] chunk ${ci + 1} progress: ${batchCount} batches, ${returnData.length} rows, ${Date.now() - chunkStart}ms`);
251
+ }
252
+ else {
253
+ let batchOffset = 0;
254
+ while (hasMore) {
255
+ const query = buildReadQuery(supabase, table, returnFields, chunkFilters, sort);
256
+ const { data, error } = await query.range(batchOffset, batchOffset + batchSize - 1);
257
+ if (error) {
258
+ console.log(`[Supabase READ] chunk ${ci + 1} batch ${batchCount + 1} FAILED after ${Date.now() - chunkStart}ms: ${(0, supabaseClient_1.formatSupabaseError)(error)}`);
259
+ throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
260
+ }
261
+ if (Array.isArray(data) && data.length > 0) {
262
+ for (const row of data)
263
+ returnData.push({ json: row });
264
+ hasMore = data.length === batchSize;
265
+ }
266
+ else {
267
+ hasMore = false;
268
+ }
269
+ batchOffset += batchSize;
270
+ batchCount++;
271
+ if (batchCount % 50 === 0) {
272
+ console.log(`[Supabase READ] chunk ${ci + 1} progress: ${batchCount} batches, ${returnData.length} rows, ${Date.now() - chunkStart}ms`);
273
+ }
247
274
  }
248
275
  }
249
276
  console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} done in ${Date.now() - chunkStart}ms — ${batchCount} batches, ${returnData.length} total rows`);
250
277
  }
251
- if (sort.length > 0) {
278
+ if (hasIdColumn && sort.length > 0) {
252
279
  returnData.sort((a, b) => {
253
280
  var _a, _b;
254
281
  for (const s of sort) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fachkraftfreund/n8n-nodes-supabase",
3
- "version": "1.2.20",
3
+ "version": "1.2.21",
4
4
  "description": "Comprehensive n8n community node for Supabase with database and storage operations",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",