Skip to content

feat(mysql)!: remove deprecated MySQL integer display width and zerofill support#12084

Merged
alumni merged 1 commit intomasterfrom
remove-width-zerofill
Mar 4, 2026
Merged

feat(mysql)!: remove deprecated MySQL integer display width and zerofill support#12084
alumni merged 1 commit intomasterfrom
remove-width-zerofill

Conversation

@pkuczynski
Copy link
Copy Markdown
Member

Remove the width and zerofill column options that were deprecated in MySQL 8.0.17
and removed in MySQL 8.4. These options only applied to MySQL/MariaDB/Aurora-MySQL
integer types and controlled display formatting, not storage.

Fixes #12076

Changes:

  • Remove width and zerofill from all column option interfaces, metadata, and schema builder types
  • Remove width/zerofill handling from MySQL, Aurora-MySQL, and CockroachDB drivers
  • Remove dead code from SpannerDriver's createFullType() that referenced column.width
    (unreachable since Spanner's INT64 has no display width concept and the driver never populated this field)
  • Remove dataTypeDefaults width entries for MySQL integer types
  • Delete tests specific to width/zerofill behavior (issues how can i define unsigned column? #438, @JoinTable does not respect inverseJoinColumns referenced column width #6442, column-width tests)
  • Update remaining tests and entity definitions to remove width/zerofill usage
  • Add migration guide entry documenting the removal

@alumni Should we also remove unsignedColumnTypes from MysqlDriver and AuroraMysqlDriver? After removing zerofill, it's no longer referenced anywhere in the codebase.

@pkuczynski pkuczynski self-assigned this Mar 4, 2026
@qodo-free-for-open-source-projects
Copy link
Copy Markdown

Review Summary by Qodo

Remove deprecated MySQL integer display width and zerofill support

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Remove deprecated width and zerofill column options from all interfaces and implementations
• Delete width/zerofill handling from MySQL, Aurora-MySQL, and CockroachDB drivers
• Remove width entries from dataTypeDefaults for MySQL integer types
• Delete tests and test entities specific to width/zerofill functionality
• Add migration guide documenting the removal and recommended alternatives
Diagram
flowchart LR
  A["Column Option Interfaces"] -->|Remove width/zerofill| B["ColumnOptions, ColumnNumericOptions, etc."]
  C["Driver Implementations"] -->|Remove width/zerofill handling| D["MySQL, Aurora-MySQL, CockroachDB"]
  E["Metadata & Schema"] -->|Remove width/zerofill properties| F["ColumnMetadata, TableColumn"]
  G["Tests & Entities"] -->|Delete deprecated tests| H["column-width, issue-438, issue-6442"]
  I["Documentation"] -->|Add migration guide| J["Migration v1 guide"]
Loading

Grey Divider

File Changes

1. src/decorator/options/ColumnNumericOptions.ts ✨ Enhancement +0/-11

Remove zerofill option from numeric column options

src/decorator/options/ColumnNumericOptions.ts


2. src/decorator/options/ColumnOptions.ts ✨ Enhancement +0/-18

Remove width and zerofill from column options interface

src/decorator/options/ColumnOptions.ts


3. src/decorator/options/ColumnUnsignedOptions.ts ✨ Enhancement +1/-22

Remove width and zerofill from unsigned options interface

src/decorator/options/ColumnUnsignedOptions.ts


View more (31)
4. src/decorator/options/PrimaryGeneratedColumnNumericOptions.ts ✨ Enhancement +0/-9

Remove zerofill from primary generated column options

src/decorator/options/PrimaryGeneratedColumnNumericOptions.ts


5. src/driver/aurora-mysql/AuroraMysqlDriver.ts ✨ Enhancement +0/-34

Remove width defaults and width handling from Aurora MySQL driver

src/driver/aurora-mysql/AuroraMysqlDriver.ts


6. src/driver/aurora-mysql/AuroraMysqlQueryRunner.ts ✨ Enhancement +4/-79

Remove zerofill and width parsing from Aurora MySQL query runner

src/driver/aurora-mysql/AuroraMysqlQueryRunner.ts


7. src/driver/cockroachdb/CockroachDriver.ts ✨ Enhancement +0/-28

Remove debug comments referencing width from CockroachDB driver

src/driver/cockroachdb/CockroachDriver.ts


8. src/driver/mysql/MysqlDriver.ts ✨ Enhancement +0/-100

Remove width defaults and width handling from MySQL driver

src/driver/mysql/MysqlDriver.ts


9. src/driver/mysql/MysqlQueryRunner.ts ✨ Enhancement +2/-83

Remove zerofill and width parsing from MySQL query runner

src/driver/mysql/MysqlQueryRunner.ts


10. src/driver/spanner/SpannerDriver.ts ✨ Enhancement +0/-2

Remove unreachable width handling from Spanner driver

src/driver/spanner/SpannerDriver.ts


11. src/driver/types/DataTypeDefaults.ts ✨ Enhancement +0/-1

Remove width property from DataTypeDefaults interface

src/driver/types/DataTypeDefaults.ts


12. src/entity-schema/EntitySchemaColumnOptions.ts ✨ Enhancement +0/-12

Remove width and zerofill from entity schema column options

src/entity-schema/EntitySchemaColumnOptions.ts


13. src/entity-schema/EntitySchemaTransformer.ts ✨ Enhancement +0/-2

Remove width and zerofill from entity schema transformer

src/entity-schema/EntitySchemaTransformer.ts


14. src/metadata-builder/ClosureJunctionEntityMetadataBuilder.ts ✨ Enhancement +0/-4

Remove width and zerofill from closure junction metadata builder

src/metadata-builder/ClosureJunctionEntityMetadataBuilder.ts


15. src/metadata-builder/JunctionEntityMetadataBuilder.ts ✨ Enhancement +2/-10

Remove width and zerofill from junction entity metadata builder

src/metadata-builder/JunctionEntityMetadataBuilder.ts


16. src/metadata-builder/RelationJoinColumnBuilder.ts ✨ Enhancement +0/-2

Remove width and zerofill from relation join column builder

src/metadata-builder/RelationJoinColumnBuilder.ts


17. src/metadata/ColumnMetadata.ts ✨ Enhancement +0/-16

Remove width and zerofill properties from column metadata

src/metadata/ColumnMetadata.ts


18. src/query-runner/BaseQueryRunner.ts ✨ Enhancement +0/-2

Remove width and zerofill from column comparison logic

src/query-runner/BaseQueryRunner.ts


19. src/schema-builder/options/TableColumnOptions.ts ✨ Enhancement +0/-12

Remove width and zerofill from table column options interface

src/schema-builder/options/TableColumnOptions.ts


20. src/schema-builder/table/TableColumn.ts ✨ Enhancement +1/-17

Remove width and zerofill properties from TableColumn class

src/schema-builder/table/TableColumn.ts


21. src/schema-builder/util/TableUtils.ts ✨ Enhancement +0/-2

Remove width and zerofill from table utilities

src/schema-builder/util/TableUtils.ts


22. test/functional/database-schema/column-width/mysql/column-width.test.ts 🧪 Tests +0/-88

Delete column width test file

test/functional/database-schema/column-width/mysql/column-width.test.ts


23. test/functional/database-schema/column-width/mysql/entity/Post.ts 🧪 Tests +0/-24

Delete column width test entity

test/functional/database-schema/column-width/mysql/entity/Post.ts


24. test/functional/entity-schema/columns/mysql/columns-mysql.test.ts 🧪 Tests +0/-15

Remove zerofill and width assertions from MySQL entity schema tests

test/functional/entity-schema/columns/mysql/columns-mysql.test.ts


25. test/functional/entity-schema/columns/mysql/entity/Person.ts 🧪 Tests +0/-2

Remove width and zerofill from Person test entity

test/functional/entity-schema/columns/mysql/entity/Person.ts


26. test/functional/tree-tables/closure-table/closure-table-mysql.test.ts 🧪 Tests +1/-7

Remove zerofill and width assertions from closure table tests

test/functional/tree-tables/closure-table/closure-table-mysql.test.ts


27. test/functional/tree-tables/closure-table/entity/Foo2.ts 🧪 Tests +0/-4

Remove width and zerofill from Foo2 test entity

test/functional/tree-tables/closure-table/entity/Foo2.ts


28. test/github-issues/2006/entity/User.ts 🧪 Tests +0/-1

Remove width option from User test entity

test/github-issues/2006/entity/User.ts


29. test/github-issues/438/entity/Post.ts 🧪 Tests +0/-10

Delete issue 438 test entity with zerofill

test/github-issues/438/entity/Post.ts


30. test/github-issues/438/issue-438.test.ts 🧪 Tests +0/-50

Delete issue 438 zerofill and unsigned test

test/github-issues/438/issue-438.test.ts


31. test/github-issues/6442/entity/v1/entities.ts 🧪 Tests +0/-18

Delete issue 6442 v1 test entities with width

test/github-issues/6442/entity/v1/entities.ts


32. test/github-issues/6442/entity/v2/entities.ts 🧪 Tests +0/-41

Delete issue 6442 v2 test entities with width

test/github-issues/6442/entity/v2/entities.ts


33. test/github-issues/6442/issue-6442.test.ts 🧪 Tests +0/-86

Delete issue 6442 width handling test

test/github-issues/6442/issue-6442.test.ts


34. docs/docs/guides/8-migration-v1.md 📝 Documentation +18/-0

Add migration guide for width and zerofill removal

docs/docs/guides/8-migration-v1.md


Grey Divider

Qodo Logo

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 4, 2026

commit: b85bfdd

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying typeorm with  Cloudflare Pages  Cloudflare Pages

Latest commit: b85bfdd
Status: ✅  Deploy successful!
Preview URL: https://0b7a8e81.typeorm.pages.dev
Branch Preview URL: https://remove-width-zerofill.typeorm.pages.dev

View logs

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Docs miss UNSIGNED implication 🐞 Bug ✓ Correctness
Description
zerofill previously implied unsigned, but after this change unsigned is only set when
explicitly provided. The migration guide tells users to remove zerofill without noting they may
need to add unsigned: true, which can cause schema sync/migration generation to attempt dropping
UNSIGNED on existing columns and on relation/junction columns derived from them.
Code

docs/docs/guides/8-migration-v1.md[R19-34]

+### `width` and `zerofill` column options removed
+
+MySQL 8.0.17 deprecated display width for integer types and the `ZEROFILL` attribute, and MySQL 8.4 removed them entirely. TypeORM no longer supports the `width` and `zerofill` column options. If you were using these options, remove them from your column definitions:
+
+```typescript
+// Before
+@Column({ type: "int", width: 9, zerofill: true })
+postCode: number
+
+// After
+@Column({ type: "int" })
+postCode: number
+```
+
+If you need zero-padded display formatting, handle it in your application layer using `String.prototype.padStart()` or the MySQL `LPAD()` function in a raw query. The `unsigned` option for integer types is **not** affected by this change and continues to work as before.
+
Evidence
The guide’s example removes zerofill and does not add unsigned. In code,
ColumnMetadata.unsigned is now only set when unsigned is explicitly present, so removing
zerofill can change metadata from unsigned->signed. Schema diff logic still treats unsigned
mismatches as a column change, which can produce ALTERs. Relation/junction columns inherit
unsigned from the referenced column metadata, so they can be impacted too.

docs/docs/guides/8-migration-v1.md[19-34]
src/metadata/ColumnMetadata.ts[404-406]
src/query-runner/BaseQueryRunner.ts[583-595]
src/driver/mysql/MysqlDriver.ts[1032-1041]
src/metadata-builder/JunctionEntityMetadataBuilder.ts[115-121]
src/schema-builder/table/TableColumn.ts[146-156]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The migration guide instructs users to remove `zerofill`, but it does not mention that `zerofill` previously implied `unsigned` in TypeORM/MySQL semantics. After this PR, `unsigned` is only set when explicitly provided, so following the guide literally can create a metadata-vs-database mismatch and lead to unexpected schema diffs / generated ALTER statements.

### Issue Context
- `ColumnMetadata` no longer forces `unsigned = true` when `zerofill` was set.
- Schema diff logic still treats `unsigned` mismatches as a column change.
- Relation/junction columns propagate `unsigned` from referenced columns.

### Fix Focus Areas
- docs/docs/guides/8-migration-v1.md[19-34]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@alumni
Copy link
Copy Markdown
Collaborator

alumni commented Mar 4, 2026

Hmm, I believe unsigned still works (it's not a formatting/display option, it's an actual data type option). But initially that constant was called "with width column types", IIRC, I refactored it when I added support for MySQL v9 and deprecated width and zerofill that no longer work. So it could be it's just an unused constant. The type for column options should probably still be used though.

@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 80.225% (+0.06%) from 80.168%
when pulling b85bfdd on remove-width-zerofill
into daeeba1 on master.

@alumni alumni merged commit d22467c into master Mar 4, 2026
71 checks passed
@alumni alumni deleted the remove-width-zerofill branch March 4, 2026 23:02
@alumni
Copy link
Copy Markdown
Collaborator

alumni commented Mar 4, 2026

I merged this first since it has more files changed, hope it's fine :)

Later edit: probably should've waited until unsignedColumnTypes

@pkuczynski pkuczynski added this to the 1.0 milestone Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Remove MySQL deprecations (width, zerofill etc) (XS-S)

4 participants