{"id":"f404e5266f549d34","repo":"drizzle-team/drizzle-orm","slug":"you-can-t-use-postcode-generator-with-a-db-column","errorCode":null,"errorMessage":"You can't use postcode generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxPostcodeLength}.","messagePattern":"You can't use postcode 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":2431,"sourceCode":"\tarraySize?: number;\n}> {\n\tstatic override readonly entityKind: string = 'GeneratePostcode';\n\n\tprivate state: {\n\t\trng: prand.RandomGenerator;\n\t\ttemplates: string[];\n\t} | undefined;\n\toverride uniqueVersionOfGen = GenerateUniquePostcode;\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\t\tconst templates = ['#####', '#####-####'];\n\n\t\tconst maxPostcodeLength = Math.max(...templates.map((template) => template.length));\n\t\tif (this.stringLength !== undefined && this.stringLength < maxPostcodeLength) {\n\t\t\tthrow new Error(\n\t\t\t\t`You can't use postcode generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxPostcodeLength}.`,\n\t\t\t);\n\t\t}\n\n\t\tthis.state = { rng, templates };\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: number, postcodeNumber: number;\n\n\t\t[idx, this.state.rng] = prand.uniformIntDistribution(0, this.state.templates.length - 1, this.state.rng);\n\t\tconst template = this.state.templates[idx]!;\n\n\t\tconst iterArray = [...template.matchAll(/#/g)];","sourceCodeStart":2413,"sourceCodeEnd":2449,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-seed/src/services/Generators.ts#L2413-L2449","documentation":"Error \"You can't use postcode generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxPostcodeLength}.\" thrown in drizzle-team/drizzle-orm.","triggerScenarios":"Using the postcode generator on a column shorter than the longest postcode.","commonSituations":"Short varchar for postcodes; raise to maxPostcodeLength.","solutions":["Increase the column's maximum string length to at least the maximum postcode 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}