drizzle-team/drizzle-orm · error · Error

count exceeds max number of unique cities.

Error message

count exceeds max number of unique cities.

What it means

Error "count exceeds max number of unique cities." thrown in drizzle-team/drizzle-orm.

Source

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

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

		return cityNames[idx];
	}
}

export class GenerateUniqueCity extends AbstractGenerator<{ isUnique?: boolean }> {
	static override readonly entityKind: string = 'GenerateUniqueCity';

	private state: {
		genIndicesObj: GenerateUniqueInt;
	} | undefined;
	public override isUnique = true;

	override init({ count, seed }: { count: number; seed: number }) {
		if (count > cityNames.length) {
			throw new Error('count exceeds max number of unique cities.');
		}

		if (this.stringLength !== undefined && this.stringLength < maxCityNameLength) {
			throw new Error(
				`You can't use city generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxCityNameLength}.`,
			);
		}

		const genIndicesObj = new GenerateUniqueInt({ minValue: 0, maxValue: cityNames.length - 1 });
		genIndicesObj.init({ count, seed });

		this.state = { genIndicesObj };
	}

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

View on GitHub (pinned to b7862528fd)

Solutions

  1. Reduce the requested unique city count or drop the unique constraint.

When it happens

Trigger: Requesting more unique cities than the city pool contains.

Common situations: Unique city column with oversized count.


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