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.
@@ -1066,7 +1066,7 @@ async function processDDLResult(method, result) {
1066
1066
  if (result.metadata) {
1067
1067
  await saveMetaDataToContext(result.metadata);
1068
1068
  }
1069
- if (!result.rows) {
1069
+ if (!result?.rows) {
1070
1070
  return { rows: [] };
1071
1071
  }
1072
1072
  if (isUpdateQueryResponse(result.rows)) {
@@ -1090,7 +1090,7 @@ async function processExecuteMethod(query, params) {
1090
1090
  }
1091
1091
  const result = await withTimeout$1(sqlStatement.execute());
1092
1092
  await saveMetaDataToContext(result.metadata);
1093
- if (!result.rows) {
1093
+ if (!result?.rows) {
1094
1094
  return { rows: [] };
1095
1095
  }
1096
1096
  if (isUpdateQueryResponse(result.rows)) {
@@ -1106,7 +1106,7 @@ async function processAllMethod(query, params) {
1106
1106
  }
1107
1107
  const result = await withTimeout$1(sqlStatement.execute());
1108
1108
  await saveMetaDataToContext(result.metadata);
1109
- if (!result.rows) {
1109
+ if (!result?.rows) {
1110
1110
  return { rows: [] };
1111
1111
  }
1112
1112
  const rows = result.rows.map((r) => Object.values(r));
@@ -1195,7 +1195,7 @@ async function handleSuccessfulExecution(rows, onfulfilled, table, options, isCa
1195
1195
  if (isCached && !cacheApplicationContext.getStore()) {
1196
1196
  await clearCache(table, options);
1197
1197
  }
1198
- const result = onfulfilled?.(rows);
1198
+ const result = onfulfilled ? onfulfilled(rows) : rows;
1199
1199
  return result;
1200
1200
  } catch (error) {
1201
1201
  if (shouldClearCacheOnError(error)) {
@@ -1266,11 +1266,11 @@ async function handleCachedQuery(target, options, cacheTtl, selections, aliasMap
1266
1266
  try {
1267
1267
  const localCached = await getQueryLocalCacheQuery(target, options);
1268
1268
  if (localCached) {
1269
- return onfulfilled?.(localCached);
1269
+ return onfulfilled ? onfulfilled(localCached) : localCached;
1270
1270
  }
1271
1271
  const cacheResult = await getFromCache(target, options);
1272
1272
  if (cacheResult) {
1273
- return onfulfilled?.(cacheResult);
1273
+ return onfulfilled ? onfulfilled(cacheResult) : cacheResult;
1274
1274
  }
1275
1275
  const rows = await target.execute();
1276
1276
  const transformed = applyFromDriverTransform(rows, selections, aliasMap);
@@ -1278,23 +1278,29 @@ async function handleCachedQuery(target, options, cacheTtl, selections, aliasMap
1278
1278
  await setCacheResult(target, options, transformed, cacheTtl).catch((cacheError) => {
1279
1279
  console.warn("Cache set error:", cacheError);
1280
1280
  });
1281
- return onfulfilled?.(transformed);
1281
+ return onfulfilled ? onfulfilled(transformed) : transformed;
1282
1282
  } catch (error) {
1283
- return onrejected?.(error);
1283
+ if (onrejected) {
1284
+ return onrejected(error);
1285
+ }
1286
+ throw error;
1284
1287
  }
1285
1288
  }
1286
1289
  async function handleNonCachedQuery(target, options, selections, aliasMap, onfulfilled, onrejected) {
1287
1290
  try {
1288
1291
  const localCached = await getQueryLocalCacheQuery(target, options);
1289
1292
  if (localCached) {
1290
- return onfulfilled?.(localCached);
1293
+ return onfulfilled ? onfulfilled(localCached) : localCached;
1291
1294
  }
1292
1295
  const rows = await target.execute();
1293
1296
  const transformed = applyFromDriverTransform(rows, selections, aliasMap);
1294
1297
  await saveQueryLocalCacheQuery(target, transformed, options);
1295
- return onfulfilled?.(transformed);
1298
+ return onfulfilled ? onfulfilled(transformed) : transformed;
1296
1299
  } catch (error) {
1297
- return onrejected?.(error);
1300
+ if (onrejected) {
1301
+ return onrejected(error);
1302
+ }
1303
+ throw error;
1298
1304
  }
1299
1305
  }
1300
1306
  function createAliasedSelectBuilder(db, fields, selectFn, useCache, options, cacheTtl) {