drizzle-team/drizzle-orm · error · Error

Can't be greater than 1 if column is unique.

Error message

Can't be greater than 1 if column is unique.

What it means

Error "Can't be greater than 1 if column is unique." thrown in drizzle-team/drizzle-orm.

Source

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

				|| (isObject(values[0]) && typeof maxRepeatedValuesCount === 'number'
					&& maxRepeatedValuesCount * allValuesCount < count)
			)
		) {
			throw new Error("Can't fill notNull column with null values.");
		}

		if (
			isUnique === true && maxRepeatedValuesCount !== undefined && (
				(typeof maxRepeatedValuesCount === 'number' && maxRepeatedValuesCount > 1)
				|| (typeof maxRepeatedValuesCount === 'object' && !maxRepeatedValuesCount
					.every((obj) =>
						(typeof obj.count) === 'number'
							? obj.count === 1
							: (obj.count as number[]).every((count) => count === 1)
					))
			)
		) {
			throw new Error("Can't be greater than 1 if column is unique.");
		}

		if (
			isUnique === true && notNull === true && (
				(!isObject(values[0]) && values.length < count)
				|| (isObject(values[0]) && allValuesCount < count)
			)
		) {
			// console.log(maxRepeatedValuesCount, values.length, allValuesCount, count)
			throw new Error('There are no enough values to fill unique column.');
		}
	}

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

		this.checks({ count });

View on GitHub (pinned to b7862528fd)

Solutions

  1. For unique columns, keep the repeat/probability value at 1 or below, or remove the unique constraint.

When it happens

Trigger: Setting a repeat/weight count greater than 1 for a unique column generator.

Common situations: Weighted values with weight >1 mapped to a unique column; maxRepeatedValuesCount >1 on unique fields.


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