drizzle-team/drizzle-orm · error · RangeError

count exceeds max number of unique phone numbers(${maxUnique

Error message

count exceeds max number of unique phone numbers(${maxUniquePhoneNumbersCount}).

What it means

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

Source

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

		let { generatedDigitsNumbers } = this.params;
		const { prefixes, template } = this.params;

		const rng = prand.xoroshiro128plus(seed);

		if (template !== undefined) {
			if (this.stringLength !== undefined && this.stringLength < template.length) {
				throw new Error(
					`Length of phone number template is shorter than db column length restriction: ${this.stringLength}. 
					Set the maximum string length to at least ${template.length}.`,
				);
			}

			const iterArray = [...template.matchAll(/#/g)];
			const placeholdersCount = iterArray.length;

			const maxUniquePhoneNumbersCount = Math.pow(10, placeholdersCount);
			if (maxUniquePhoneNumbersCount < count) {
				throw new RangeError(
					`count exceeds max number of unique phone numbers(${maxUniquePhoneNumbersCount}).`,
				);
			}

			const generatorsMap = new Map<string, GenerateUniqueInt>();
			const genObj = new GenerateUniqueInt({ minValue: 0, maxValue: maxUniquePhoneNumbersCount - 1 });
			genObj.init({
				count,
				seed,
			});

			generatorsMap.set(
				template,
				genObj,
			);

			const prefixesArray: string[] = [];
			const generatedDigitsNumbers: number[] = [];

View on GitHub (pinned to b7862528fd)

Solutions

  1. Reduce the requested unique phone-number count or drop the unique constraint.

When it happens

Trigger: Requesting more unique phone numbers than the template/prefix space allows.

Common situations: Few prefixes and short digit templates with a large unique count.


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