typeorm 0.3.11-dev.5253c8f → 0.3.11-dev.6eb674b

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.
Files changed (33) hide show
  1. package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js +21 -4
  2. package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
  3. package/browser/driver/postgres/PostgresQueryRunner.js +3 -0
  4. package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
  5. package/browser/find-options/operator/Any.d.ts +1 -1
  6. package/browser/find-options/operator/Any.js.map +1 -1
  7. package/browser/find-options/operator/ArrayContainedBy.d.ts +1 -1
  8. package/browser/find-options/operator/ArrayContainedBy.js.map +1 -1
  9. package/browser/find-options/operator/ArrayContains.d.ts +1 -1
  10. package/browser/find-options/operator/ArrayContains.js.map +1 -1
  11. package/browser/find-options/operator/ArrayOverlap.d.ts +1 -1
  12. package/browser/find-options/operator/ArrayOverlap.js.map +1 -1
  13. package/browser/find-options/operator/In.d.ts +1 -1
  14. package/browser/find-options/operator/In.js.map +1 -1
  15. package/browser/util/OrmUtils.js +2 -1
  16. package/browser/util/OrmUtils.js.map +1 -1
  17. package/driver/aurora-mysql/AuroraMysqlQueryRunner.js +21 -4
  18. package/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
  19. package/driver/postgres/PostgresQueryRunner.js +3 -0
  20. package/driver/postgres/PostgresQueryRunner.js.map +1 -1
  21. package/find-options/operator/Any.d.ts +1 -1
  22. package/find-options/operator/Any.js.map +1 -1
  23. package/find-options/operator/ArrayContainedBy.d.ts +1 -1
  24. package/find-options/operator/ArrayContainedBy.js.map +1 -1
  25. package/find-options/operator/ArrayContains.d.ts +1 -1
  26. package/find-options/operator/ArrayContains.js.map +1 -1
  27. package/find-options/operator/ArrayOverlap.d.ts +1 -1
  28. package/find-options/operator/ArrayOverlap.js.map +1 -1
  29. package/find-options/operator/In.d.ts +1 -1
  30. package/find-options/operator/In.js.map +1 -1
  31. package/package.json +1 -1
  32. package/util/OrmUtils.js +2 -1
  33. package/util/OrmUtils.js.map +1 -1
@@ -1223,6 +1223,11 @@ export class AuroraMysqlQueryRunner extends BaseQueryRunner {
1223
1223
  const tableColumn = new TableColumn();
1224
1224
  tableColumn.name = dbColumn["COLUMN_NAME"];
1225
1225
  tableColumn.type = dbColumn["DATA_TYPE"].toLowerCase();
1226
+ // Unsigned columns are handled differently when it comes to width.
1227
+ // Hence, we need to set the unsigned attribute before we check the width.
1228
+ tableColumn.unsigned = tableColumn.zerofill
1229
+ ? true
1230
+ : dbColumn["COLUMN_TYPE"].indexOf("unsigned") !== -1;
1226
1231
  if (this.driver.withWidthColumnTypes.indexOf(tableColumn.type) !== -1) {
1227
1232
  const width = dbColumn["COLUMN_TYPE"].substring(dbColumn["COLUMN_TYPE"].indexOf("(") + 1, dbColumn["COLUMN_TYPE"].indexOf(")"));
1228
1233
  tableColumn.width =
@@ -1269,9 +1274,6 @@ export class AuroraMysqlQueryRunner extends BaseQueryRunner {
1269
1274
  });
1270
1275
  tableColumn.zerofill =
1271
1276
  dbColumn["COLUMN_TYPE"].indexOf("zerofill") !== -1;
1272
- tableColumn.unsigned = tableColumn.zerofill
1273
- ? true
1274
- : dbColumn["COLUMN_TYPE"].indexOf("unsigned") !== -1;
1275
1277
  tableColumn.isGenerated =
1276
1278
  dbColumn["EXTRA"].indexOf("auto_increment") !== -1;
1277
1279
  if (tableColumn.isGenerated)
@@ -1673,7 +1675,22 @@ export class AuroraMysqlQueryRunner extends BaseQueryRunner {
1673
1675
  this.connection.driver.dataTypeDefaults[column.type] &&
1674
1676
  this.connection.driver.dataTypeDefaults[column.type].width;
1675
1677
  if (defaultWidthForType) {
1676
- return defaultWidthForType === width;
1678
+ // In MariaDB & MySQL 5.7, the default widths of certain numeric types are 1 less than
1679
+ // the usual defaults when the column is unsigned.
1680
+ // This also applies to Aurora MySQL.
1681
+ const typesWithReducedUnsignedDefault = [
1682
+ "int",
1683
+ "tinyint",
1684
+ "smallint",
1685
+ "mediumint",
1686
+ ];
1687
+ const needsAdjustment = typesWithReducedUnsignedDefault.indexOf(column.type) !== -1;
1688
+ if (column.unsigned && needsAdjustment) {
1689
+ return defaultWidthForType - 1 === width;
1690
+ }
1691
+ else {
1692
+ return defaultWidthForType === width;
1693
+ }
1677
1694
  }
1678
1695
  return false;
1679
1696
  }