drizzle-team/drizzle-orm · error · RangeError

count exceeds max number of unique intervals(${maxUniqueInte

Error message

count exceeds max number of unique intervals(${maxUniqueIntervalsNumber})

What it means

Error "count exceeds max number of unique intervals(${maxUniqueIntervalsNumber})" thrown in drizzle-team/drizzle-orm.

Source

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

		let fieldsToGenerate: string[] = allFields;

		if (this.params.fields !== undefined && this.params.fields?.includes(' to ')) {
			const tokens = this.params.fields.split(' to ');
			const endIdx = allFields.indexOf(tokens[1]!);
			fieldsToGenerate = allFields.slice(0, endIdx + 1);
		} else if (this.params.fields !== undefined) {
			const endIdx = allFields.indexOf(this.params.fields);
			fieldsToGenerate = allFields.slice(0, endIdx + 1);
		}

		let maxUniqueIntervalsNumber = 1;
		for (const field of fieldsToGenerate) {
			const from = this.config[field]!.from, to = this.config[field]!.to;
			maxUniqueIntervalsNumber *= from - to + 1;
		}

		if (count > maxUniqueIntervalsNumber) {
			throw new RangeError(`count exceeds max number of unique intervals(${maxUniqueIntervalsNumber})`);
		}

		const rng = prand.xoroshiro128plus(seed);
		const intervalSet = new Set<string>();
		this.state = { rng, fieldsToGenerate, intervalSet };
	}

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

		let interval, numb: number;

		for (;;) {
			interval = '';

			for (const field of this.state.fieldsToGenerate) {

View on GitHub (pinned to b7862528fd)

Solutions

  1. Widen the interval range, increase the interval length limits, or reduce the requested unique count.

When it happens

Trigger: Requesting more unique date/timestamp intervals than the configured interval range can yield.

Common situations: Unique datetime columns with a tight date range and a large row count.


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