drizzle-team/drizzle-orm · error · Error
You can't use lorem ipsum generator with a db column length…
Error message
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}. What it means
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().
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.
Example fix
// before
bio: varchar('bio', { length: 40 })
// refinements override insufficient width — widen instead
// after
bio: varchar('bio', { length: 200 }) Defensive patterns
Strategy: validation
Validate before calling
// maxLoremIpsumSentencesLength = maxLoremIpsumLength * sentencesCount + sentencesCount - 1
// maxLoremIpsumLength comes from the longest bundled sentence.
// Use a generous column width based on sentencesCount.
const MAX_LOREM_SENTENCE_LENGTH = 200; // conservative; bundled longest sentence
function minColumnForLoremIpsum(sentencesCount: number): number {
return MAX_LOREM_SENTENCE_LENGTH * sentencesCount + sentencesCount - 1;
}
function columnFitsLoremIpsum(colLength: number | undefined, sentencesCount = 1): boolean {
return colLength === undefined || colLength >= minColumnForLoremIpsum(sentencesCount);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: A short description/notes varchar(50) column that gets the lorem-ipsum generator; raising sentencesCount for richer text without adjusting the column length.
Related errors
- You can't use company name generator with a db column…
- column with type is not supported for now.
- You can't generate unique strings, with a maximum string…
AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03).
Data as JSON: /api/errors/7374251cff5870c2.
Report an issue: GitHub.
Appendix: source
Thrown at drizzle-seed/src/services/Generators.ts:2787
sentencesCount?: number;
arraySize?: number;
}> {
static override readonly entityKind: string = 'GenerateLoremIpsum';
private state: {
rng: prand.RandomGenerator;
} | undefined;
override init({ count, seed }: { count: number; seed: number }) {
super.init({ count, seed });
const rng = prand.xoroshiro128plus(seed);
if (this.params.sentencesCount === undefined) this.params.sentencesCount = 1;
const maxLoremIpsumSentencesLength = maxLoremIpsumLength * this.params.sentencesCount + this.params.sentencesCount
- 1;
if (this.stringLength !== undefined && this.stringLength < maxLoremIpsumSentencesLength) {
throw new Error(
`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}.`,
);
}
this.state = { rng };
}
generate() {
if (this.state === undefined) {
throw new Error('state is not defined.');
}
let idx, resultText: string = '';
for (let i = 0; i < this.params.sentencesCount!; i++) {
[idx, this.state.rng] = prand.uniformIntDistribution(0, loremIpsumSentences.length - 1, this.state.rng);
resultText += loremIpsumSentences[idx] + ' ';
}
View on GitHub (pinned to b7862528fd)