forge-sql-orm 2.1.6 → 2.1.7

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.
@@ -1085,7 +1085,7 @@ async function processDDLResult(method, result) {
1085
1085
  if (result.metadata) {
1086
1086
  await saveMetaDataToContext(result.metadata);
1087
1087
  }
1088
- if (!result.rows) {
1088
+ if (!result?.rows) {
1089
1089
  return { rows: [] };
1090
1090
  }
1091
1091
  if (isUpdateQueryResponse(result.rows)) {
@@ -1109,7 +1109,7 @@ async function processExecuteMethod(query, params) {
1109
1109
  }
1110
1110
  const result = await withTimeout$1(sqlStatement.execute());
1111
1111
  await saveMetaDataToContext(result.metadata);
1112
- if (!result.rows) {
1112
+ if (!result?.rows) {
1113
1113
  return { rows: [] };
1114
1114
  }
1115
1115
  if (isUpdateQueryResponse(result.rows)) {
@@ -1125,7 +1125,7 @@ async function processAllMethod(query, params) {
1125
1125
  }
1126
1126
  const result = await withTimeout$1(sqlStatement.execute());
1127
1127
  await saveMetaDataToContext(result.metadata);
1128
- if (!result.rows) {
1128
+ if (!result?.rows) {
1129
1129
  return { rows: [] };
1130
1130
  }
1131
1131
  const rows = result.rows.map((r) => Object.values(r));
@@ -1214,7 +1214,7 @@ async function handleSuccessfulExecution(rows, onfulfilled, table2, options, isC
1214
1214
  if (isCached && !cacheApplicationContext.getStore()) {
1215
1215
  await clearCache(table2, options);
1216
1216
  }
1217
- const result = onfulfilled?.(rows);
1217
+ const result = onfulfilled ? onfulfilled(rows) : rows;
1218
1218
  return result;
1219
1219
  } catch (error) {
1220
1220
  if (shouldClearCacheOnError(error)) {
@@ -1285,11 +1285,11 @@ async function handleCachedQuery(target, options, cacheTtl, selections, aliasMap
1285
1285
  try {
1286
1286
  const localCached = await getQueryLocalCacheQuery(target, options);
1287
1287
  if (localCached) {
1288
- return onfulfilled?.(localCached);
1288
+ return onfulfilled ? onfulfilled(localCached) : localCached;
1289
1289
  }
1290
1290
  const cacheResult = await getFromCache(target, options);
1291
1291
  if (cacheResult) {
1292
- return onfulfilled?.(cacheResult);
1292
+ return onfulfilled ? onfulfilled(cacheResult) : cacheResult;
1293
1293
  }
1294
1294
  const rows = await target.execute();
1295
1295
  const transformed = applyFromDriverTransform(rows, selections, aliasMap);
@@ -1297,23 +1297,29 @@ async function handleCachedQuery(target, options, cacheTtl, selections, aliasMap
1297
1297
  await setCacheResult(target, options, transformed, cacheTtl).catch((cacheError) => {
1298
1298
  console.warn("Cache set error:", cacheError);
1299
1299
  });
1300
- return onfulfilled?.(transformed);
1300
+ return onfulfilled ? onfulfilled(transformed) : transformed;
1301
1301
  } catch (error) {
1302
- return onrejected?.(error);
1302
+ if (onrejected) {
1303
+ return onrejected(error);
1304
+ }
1305
+ throw error;
1303
1306
  }
1304
1307
  }
1305
1308
  async function handleNonCachedQuery(target, options, selections, aliasMap, onfulfilled, onrejected) {
1306
1309
  try {
1307
1310
  const localCached = await getQueryLocalCacheQuery(target, options);
1308
1311
  if (localCached) {
1309
- return onfulfilled?.(localCached);
1312
+ return onfulfilled ? onfulfilled(localCached) : localCached;
1310
1313
  }
1311
1314
  const rows = await target.execute();
1312
1315
  const transformed = applyFromDriverTransform(rows, selections, aliasMap);
1313
1316
  await saveQueryLocalCacheQuery(target, transformed, options);
1314
- return onfulfilled?.(transformed);
1317
+ return onfulfilled ? onfulfilled(transformed) : transformed;
1315
1318
  } catch (error) {
1316
- return onrejected?.(error);
1319
+ if (onrejected) {
1320
+ return onrejected(error);
1321
+ }
1322
+ throw error;
1317
1323
  }
1318
1324
  }
1319
1325
  function createAliasedSelectBuilder(db, fields, selectFn, useCache, options, cacheTtl) {