Repository navigation
Fix Job.payload/result MySQL column size (text 64KB -> longtext) - #38
Merged
Merged
Conversation
JsonColumn (simple-json) always maps to MySQL text (64KB) regardless of any type override -- TypeORM's mysql driver hardcodes this. The user-data-export handler can return a base64 zip in Job.result when S3 isn't configured, which routinely exceeds 64KB and fails to save with "Data too long for column 'result'". Add LongJsonColumn (LongTextColumn + a JSON transformer) and use it for Job.payload/Job.result. Verified against real MySQL: a longtext column accepts a 200KB value that a text column rejects. Found by Copilot review on buzz-code/react-admin-nestjs#141. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011dEYULADLgGNfZ4nv6gz8s
buzz-code
pushed a commit
to buzz-code/react-admin-nestjs
that referenced
this pull request
Aug 19, 2026
jobs.result can hold a base64-encoded zip from the user-data-export handler when S3 isn't configured, which routinely exceeds MySQL text's 64KB limit. Widen to longtext (matches the entity-side fix in buzz-code/nra-server#38, picked up by the server/shared bump). Verified against real MySQL: a longtext column now accepts a 200KB value that the previous text column would have rejected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011dEYULADLgGNfZ4nv6gz8s
There was a problem hiding this comment.
Pull request overview
This PR introduces a new TypeORM column decorator helper to store JSON in a MySQL longtext column (instead of text via simple-json), and migrates Job.payload / Job.result to use it so large JSON payloads (e.g., base64-encoded zips) can be persisted without hitting the 64KB limit.
Changes:
- Add
LongJsonColumnimplemented asLongTextColumn+ explicit JSON transformer (bypassingsimple-json’s MySQLtextmapping). - Update
Job.payloadandJob.resultto use@LongJsonColumn({ nullable: true }). - Add unit tests validating
LongJsonColumn’s options wiring and transformer behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| utils/entity/column-types.util.ts | Adds LongJsonColumn helper built on LongTextColumn with a JSON transformer to avoid MySQL text size limits. |
| utils/entity/tests/column-types.util.spec.ts | Adds unit tests covering LongJsonColumn wiring/round-trip/null handling/custom transformer override. |
| entities/Job.entity.ts | Switches payload and result columns from JsonColumn to LongJsonColumn to support larger stored results. |
Suppressed comments (1)
utils/entity/column-types.util.ts:164
- The default transformer
fromcallback is typed as(value: string), but the implementation explicitly handlesnull/undefinedand the tests call it withnull. Usingany(orunknown) here better matches TypeORM's ValueTransformer contract and avoids potential strictFunctionTypes issues.
from: (value: string) => (value == null || value === '' ? null : JSON.parse(value)),
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| * instead. | ||
| */ | ||
| export function LongJsonColumn(options?: ColumnOptions) { | ||
| const { transformer, ...rest } = options ?? {}; |
Comment on lines
+21
to
+27
| it('backs the column with a longtext-mapped type (via LongTextColumn)', () => { | ||
| LongJsonColumn({ nullable: true }); | ||
| expect(columnCalls).toHaveLength(1); | ||
| const [, options] = columnCalls[0]; | ||
| expect(options.nullable).toBe(true); | ||
| expect(options.transformer).toBeDefined(); | ||
| }); |
Comment on lines
+35
to
39
| @LongJsonColumn({ nullable: true }) | ||
| payload: Record<string, any>; | ||
|
|
||
| @JsonColumn({ nullable: true }) | ||
| @LongJsonColumn({ nullable: true }) | ||
| result: Record<string, any>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
JsonColumn(backed by TypeORM'ssimple-json) always maps to MySQLtext(64KB) — the mysql driver hardcodes this regardless of anytypeoverride.Job.resultcan hold a base64-encoded zip from theuser-data-exporthandler when S3 isn't configured, which routinely exceeds 64KB and fails to save withData too long for column 'result'.Found by Copilot review on buzz-code/react-admin-nestjs#141.
Fix
LongJsonColumnhelper:LongTextColumn+ a JSON transformer (same to/from shape asJsonColumn), so MySQL getslongtext/ SQLite getstext(unlimited there anyway).Job.payloadandJob.resultnow use it.Testing
LongJsonColumn(options wiring, round-trip, null handling, custom-transformer override) — 4/4 passing.tsc --noEmit(0 errors) + e2e app boot — all green.longtextcolumn accepts a 200KB value; the same value against atextcolumn reproduces the exactData too long for columnerror this fixes.🤖 Generated with Claude Code
https://claude.ai/code/session_011dEYULADLgGNfZ4nv6gz8s
Generated by Claude Code