typeorm 0.3.25-dev.a9c16ee → 0.3.25-dev.eb3093d

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.
@@ -1334,12 +1334,15 @@ export class SelectQueryBuilder extends QueryBuilder {
1334
1334
  // in the case if nothing is joined in the query builder we don't need to make two requests to get paginated results
1335
1335
  // we can use regular limit / offset, that's why we add offset and limit construction here based on skip and take values
1336
1336
  let offset = this.expressionMap.offset, limit = this.expressionMap.limit;
1337
- if (!offset &&
1338
- !limit &&
1337
+ if (offset === undefined &&
1338
+ limit === undefined &&
1339
1339
  this.expressionMap.joinAttributes.length === 0) {
1340
1340
  offset = this.expressionMap.skip;
1341
1341
  limit = this.expressionMap.take;
1342
1342
  }
1343
+ // Helper functions to check if values are set (including 0)
1344
+ const hasLimit = limit !== undefined && limit !== null;
1345
+ const hasOffset = offset !== undefined && offset !== null;
1343
1346
  if (this.connection.driver.options.type === "mssql") {
1344
1347
  // Due to a limitation in SQL Server's parser implementation it does not support using
1345
1348
  // OFFSET or FETCH NEXT without an ORDER BY clause being provided. In cases where the
@@ -1347,59 +1350,59 @@ export class SelectQueryBuilder extends QueryBuilder {
1347
1350
  // have no effect on the query planner or on the order of the results returned.
1348
1351
  // https://dba.stackexchange.com/a/193799
1349
1352
  let prefix = "";
1350
- if ((limit || offset) &&
1353
+ if ((hasLimit || hasOffset) &&
1351
1354
  Object.keys(this.expressionMap.allOrderBys).length <= 0) {
1352
1355
  prefix = " ORDER BY (SELECT NULL)";
1353
1356
  }
1354
- if (limit && offset)
1357
+ if (hasLimit && hasOffset)
1355
1358
  return (prefix +
1356
1359
  " OFFSET " +
1357
1360
  offset +
1358
1361
  " ROWS FETCH NEXT " +
1359
1362
  limit +
1360
1363
  " ROWS ONLY");
1361
- if (limit)
1364
+ if (hasLimit)
1362
1365
  return (prefix + " OFFSET 0 ROWS FETCH NEXT " + limit + " ROWS ONLY");
1363
- if (offset)
1366
+ if (hasOffset)
1364
1367
  return prefix + " OFFSET " + offset + " ROWS";
1365
1368
  }
1366
1369
  else if (DriverUtils.isMySQLFamily(this.connection.driver) ||
1367
1370
  this.connection.driver.options.type === "aurora-mysql" ||
1368
1371
  this.connection.driver.options.type === "sap" ||
1369
1372
  this.connection.driver.options.type === "spanner") {
1370
- if (limit && offset)
1373
+ if (hasLimit && hasOffset)
1371
1374
  return " LIMIT " + limit + " OFFSET " + offset;
1372
- if (limit)
1375
+ if (hasLimit)
1373
1376
  return " LIMIT " + limit;
1374
- if (offset)
1377
+ if (hasOffset)
1375
1378
  throw new OffsetWithoutLimitNotSupportedError();
1376
1379
  }
1377
1380
  else if (DriverUtils.isSQLiteFamily(this.connection.driver)) {
1378
- if (limit && offset)
1381
+ if (hasLimit && hasOffset)
1379
1382
  return " LIMIT " + limit + " OFFSET " + offset;
1380
- if (limit)
1383
+ if (hasLimit)
1381
1384
  return " LIMIT " + limit;
1382
- if (offset)
1385
+ if (hasOffset)
1383
1386
  return " LIMIT -1 OFFSET " + offset;
1384
1387
  }
1385
1388
  else if (this.connection.driver.options.type === "oracle") {
1386
- if (limit && offset)
1389
+ if (hasLimit && hasOffset)
1387
1390
  return (" OFFSET " +
1388
1391
  offset +
1389
1392
  " ROWS FETCH NEXT " +
1390
1393
  limit +
1391
1394
  " ROWS ONLY");
1392
- if (limit)
1395
+ if (hasLimit)
1393
1396
  return " FETCH NEXT " + limit + " ROWS ONLY";
1394
- if (offset)
1397
+ if (hasOffset)
1395
1398
  return " OFFSET " + offset + " ROWS";
1396
1399
  }
1397
1400
  else {
1398
- if (limit && offset)
1401
+ if (hasLimit && hasOffset)
1399
1402
  return " LIMIT " + limit + " OFFSET " + offset;
1400
- if (limit)
1403
+ if (hasLimit)
1401
1404
  return " LIMIT " + limit;
1402
- if (offset)
1405
+ if (hasOffset)
1403
1406
  return " OFFSET " + offset;
1404
1407
  }
1405
1408
  return "";