drizzle-team/drizzle-orm · error · Error

Length of phone number template is shorter than db column le

Error message

Length of phone number template is shorter than db column length restriction: ${this.stringLength}. 
					Set the maximum string length to at least ${template.length}.

What it means

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}." thrown in drizzle-team/drizzle-orm.

Source

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

		placeholdersCount?: number;
		prefixesArray: string[];
		generatedDigitsNumbers: number[];
		generatorsMap: Map<string, GenerateUniqueInt>;
		phoneNumbersSet: Set<string>;
	} | undefined;
	public override isUnique = true;

	override init({ count, seed }: { count: number; seed: number }) {
		super.init({ count, seed });

		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({

View on GitHub (pinned to b7862528fd)

Solutions

  1. Increase the column's maximum string length to at least the phone template length, or shorten the template.

When it happens

Trigger: Phone-number template produces strings longer than the column's length restriction.

Common situations: Template with many digit placeholders on a short varchar; align column length with template length.


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