drizzle-team/drizzle-orm · error · Error

You can't use state generator with a db column length restri

Error message

You can't use state generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxStateLength}.

What it means

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.

Source

Thrown at drizzle-seed/src/services/Generators.ts:2568

	}
}

export class GenerateState extends AbstractGenerator<{
	arraySize?: number;
}> {
	static override readonly entityKind: string = 'GenerateState';

	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.stringLength !== undefined && this.stringLength < maxStateLength) {
			throw new 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}.`,
			);
		}

		this.state = { rng };
	}

	generate() {
		if (this.state === undefined) {
			throw new Error('state is not defined.');
		}

		let idx;
		[idx, this.state.rng] = prand.uniformIntDistribution(0, states.length - 1, this.state.rng);

		return states[idx];
	}
}

View on GitHub (pinned to b7862528fd)

Solutions

  1. Increase the column's maximum string length to at least the maximum state name length, or use a different generator.

When it happens

Trigger: Using the state generator on a column shorter than the longest state name.

Common situations: Short varchar for states; raise to maxStateLength.


AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03). Data as JSON: /data/errors/e326573804dffea5.json. Report an issue: GitHub.