{"id":"e326573804dffea5","repo":"drizzle-team/drizzle-orm","slug":"you-can-t-use-state-generator-with-a-db-column-len","errorCode":null,"errorMessage":"You can't use state generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxStateLength}.","messagePattern":"You can't use state generator with a db column length restriction of (.+?)\\. Set the maximum string length to at least (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"drizzle-seed/src/services/Generators.ts","lineNumber":2568,"sourceCode":"\t}\n}\n\nexport class GenerateState extends AbstractGenerator<{\n\tarraySize?: number;\n}> {\n\tstatic override readonly entityKind: string = 'GenerateState';\n\n\tprivate state: {\n\t\trng: prand.RandomGenerator;\n\t} | undefined;\n\n\toverride init({ count, seed }: { count: number; seed: number }) {\n\t\tsuper.init({ count, seed });\n\n\t\tconst rng = prand.xoroshiro128plus(seed);\n\n\t\tif (this.stringLength !== undefined && this.stringLength < maxStateLength) {\n\t\t\tthrow new Error(\n\t\t\t\t`You can't use state generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxStateLength}.`,\n\t\t\t);\n\t\t}\n\n\t\tthis.state = { rng };\n\t}\n\n\tgenerate() {\n\t\tif (this.state === undefined) {\n\t\t\tthrow new Error('state is not defined.');\n\t\t}\n\n\t\tlet idx;\n\t\t[idx, this.state.rng] = prand.uniformIntDistribution(0, states.length - 1, this.state.rng);\n\n\t\treturn states[idx];\n\t}\n}","sourceCodeStart":2550,"sourceCodeEnd":2586,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-seed/src/services/Generators.ts#L2550-L2586","documentation":"Error \"You can't use state generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxStateLength}.\" thrown in drizzle-team/drizzle-orm.","triggerScenarios":"Using the state generator on a column shorter than the longest state name.","commonSituations":"Short varchar for states; raise to maxStateLength.","solutions":["Increase the column's maximum string length to at least the maximum state name length, or use a different generator."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"b7862528fd8fc39bc2653a6c18dad7c1f4e68d10","analyzedAt":"2026-08-03T18:11:14.318Z","schemaVersion":2}