@fachkraftfreund/n8n-nodes-supabase 1.2.18 → 1.2.19
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.
|
@@ -206,44 +206,64 @@ async function handleRead(supabase, itemIndex, hostUrl) {
|
|
|
206
206
|
const filterChunks = (0, supabaseClient_1.expandChunkedFilters)(filters, maxInChars, maxItems);
|
|
207
207
|
console.log(`[Supabase READ] item=${itemIndex} table=${table} returnAll=${returnAll} chunks=${filterChunks.length} maxItems=${maxItems} maxInChars=${maxInChars}`);
|
|
208
208
|
const returnData = [];
|
|
209
|
-
|
|
210
|
-
const inFilter = chunkFilters.find(f => f.operator === 'in');
|
|
211
|
-
const chunkIds = inFilter && Array.isArray(inFilter.value) ? inFilter.value.length : '?';
|
|
212
|
-
console.log(`[Supabase READ] chunk ${chunkIndex + 1}/${totalChunks} (${chunkIds} IDs) - starting...`);
|
|
213
|
-
const chunkStart = Date.now();
|
|
214
|
-
const rows = [];
|
|
209
|
+
if (returnAll) {
|
|
215
210
|
const batchSize = 1000;
|
|
216
|
-
let
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
211
|
+
for (let ci = 0; ci < filterChunks.length; ci++) {
|
|
212
|
+
const chunkFilters = filterChunks[ci];
|
|
213
|
+
const inFilter = chunkFilters.find(f => f.operator === 'in');
|
|
214
|
+
const chunkIds = inFilter && Array.isArray(inFilter.value) ? inFilter.value.length : '?';
|
|
215
|
+
console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} (${chunkIds} IDs) - starting...`);
|
|
216
|
+
const chunkStart = Date.now();
|
|
217
|
+
let lastId = null;
|
|
218
|
+
let hasMore = true;
|
|
219
|
+
let batchCount = 0;
|
|
220
|
+
while (hasMore) {
|
|
221
|
+
let query = buildReadQuery(supabase, table, returnFields, chunkFilters, []);
|
|
222
|
+
if (lastId !== null) {
|
|
223
|
+
query = query.gt('id', lastId);
|
|
224
|
+
}
|
|
225
|
+
query = query.order('id', { ascending: true }).limit(batchSize);
|
|
226
|
+
const { data, error } = await query;
|
|
227
|
+
if (error) {
|
|
228
|
+
console.log(`[Supabase READ] chunk ${ci + 1} batch ${batchCount + 1} FAILED after ${Date.now() - chunkStart}ms: ${(0, supabaseClient_1.formatSupabaseError)(error)}`);
|
|
229
|
+
throw new Error((0, supabaseClient_1.formatSupabaseError)(error));
|
|
230
|
+
}
|
|
231
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
232
|
+
for (const row of data) {
|
|
233
|
+
returnData.push({ json: row });
|
|
234
|
+
}
|
|
235
|
+
lastId = data[data.length - 1].id;
|
|
236
|
+
hasMore = data.length === batchSize;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
hasMore = false;
|
|
240
|
+
}
|
|
241
|
+
batchCount++;
|
|
242
|
+
if (batchCount % 50 === 0) {
|
|
243
|
+
console.log(`[Supabase READ] chunk ${ci + 1} progress: ${batchCount} batches, ${returnData.length} rows, ${Date.now() - chunkStart}ms`);
|
|
228
244
|
}
|
|
229
|
-
hasMore = batchData.length === batchSize;
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
hasMore = false;
|
|
233
245
|
}
|
|
234
|
-
|
|
246
|
+
console.log(`[Supabase READ] chunk ${ci + 1}/${filterChunks.length} done in ${Date.now() - chunkStart}ms — ${batchCount} batches, ${returnData.length} total rows`);
|
|
235
247
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
248
|
+
if (sort.length > 0) {
|
|
249
|
+
returnData.sort((a, b) => {
|
|
250
|
+
var _a, _b;
|
|
251
|
+
for (const s of sort) {
|
|
252
|
+
const aVal = (_a = a.json[s.column]) !== null && _a !== void 0 ? _a : null;
|
|
253
|
+
const bVal = (_b = b.json[s.column]) !== null && _b !== void 0 ? _b : null;
|
|
254
|
+
if (aVal === bVal)
|
|
255
|
+
continue;
|
|
256
|
+
if (aVal === null)
|
|
257
|
+
return 1;
|
|
258
|
+
if (bVal === null)
|
|
259
|
+
return -1;
|
|
260
|
+
if (aVal < bVal)
|
|
261
|
+
return s.ascending ? -1 : 1;
|
|
262
|
+
if (aVal > bVal)
|
|
263
|
+
return s.ascending ? 1 : -1;
|
|
264
|
+
}
|
|
265
|
+
return 0;
|
|
266
|
+
});
|
|
247
267
|
}
|
|
248
268
|
}
|
|
249
269
|
else {
|
package/package.json
CHANGED