{"id":"7374251cff5870c2","repo":"drizzle-team/drizzle-orm","slug":"you-can-t-use-lorem-ipsum-generator-with-a-db-colu","errorCode":null,"errorMessage":"You can't use lorem ipsum generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxLoremIpsumSentencesLength}.","messagePattern":"You can't use lorem ipsum 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":2787,"sourceCode":"\tsentencesCount?: number;\n\tarraySize?: number;\n}> {\n\tstatic override readonly entityKind: string = 'GenerateLoremIpsum';\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\t\tif (this.params.sentencesCount === undefined) this.params.sentencesCount = 1;\n\n\t\tconst maxLoremIpsumSentencesLength = maxLoremIpsumLength * this.params.sentencesCount + this.params.sentencesCount\n\t\t\t- 1;\n\t\tif (this.stringLength !== undefined && this.stringLength < maxLoremIpsumSentencesLength) {\n\t\t\tthrow new Error(\n\t\t\t\t`You can't use lorem ipsum generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxLoremIpsumSentencesLength}.`,\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, resultText: string = '';\n\t\tfor (let i = 0; i < this.params.sentencesCount!; i++) {\n\t\t\t[idx, this.state.rng] = prand.uniformIntDistribution(0, loremIpsumSentences.length - 1, this.state.rng);\n\t\t\tresultText += loremIpsumSentences[idx] + ' ';\n\t\t}\n","sourceCodeStart":2769,"sourceCodeEnd":2805,"githubUrl":"https://github.com/drizzle-team/drizzle-orm/blob/b7862528fd8fc39bc2653a6c18dad7c1f4e68d10/drizzle-seed/src/services/Generators.ts#L2769-L2805","documentation":"GenerateLoremIpsum concatenates one or more random lorem-ipsum sentences. The worst-case output length is maxLoremIpsumLength * sentencesCount + sentencesCount - 1 (longest sentence times the sentence count, plus joining spaces). If the target column's varchar length is below this, the generator cannot guarantee its output fits and throws at init().","triggerScenarios":"A varchar column with a small length assigned GenerateLoremIpsum, or auto-assigned because the column name matches the lorem-ipsum heuristic, where the column width is below maxLoremIpsumSentencesLength. Increasing sentencesCount in params without widening the column also triggers it.","commonSituations":"A short description/notes varchar(50) column that gets the lorem-ipsum generator; raising sentencesCount for richer text without adjusting the column length.","solutions":["Widen the column to at least the maxLoremIpsumSentencesLength value printed in the error.","Reduce the sentencesCount param so the worst-case output fits the current column width.","Override the generator in refinements with GenerateString or a shorter text generator that respects the column limit."],"exampleFix":"// before\nbio: varchar('bio', { length: 40 })\n// refinements override insufficient width — widen instead\n// after\nbio: varchar('bio', { length: 200 })","handlingStrategy":"validation","validationCode":"// maxLoremIpsumSentencesLength = maxLoremIpsumLength * sentencesCount + sentencesCount - 1\n// maxLoremIpsumLength comes from the longest bundled sentence.\n// Use a generous column width based on sentencesCount.\nconst MAX_LOREM_SENTENCE_LENGTH = 200; // conservative; bundled longest sentence\nfunction minColumnForLoremIpsum(sentencesCount: number): number {\n  return MAX_LOREM_SENTENCE_LENGTH * sentencesCount + sentencesCount - 1;\n}\nfunction columnFitsLoremIpsum(colLength: number | undefined, sentencesCount = 1): boolean {\n  return colLength === undefined || colLength >= minColumnForLoremIpsum(sentencesCount);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use varchar(500)+ for lorem-ipsum columns, or TEXT type.","When increasing sentencesCount, proportionally widen the column.","Override short text columns with GenerateString in refinements."],"tags":["lorem-ipsum","string-length","varchar","generator-config"],"analyzedSha":"b7862528fd8fc39bc2653a6c18dad7c1f4e68d10","analyzedAt":"2026-08-03T18:11:14.318Z","schemaVersion":2}