drizzle-team/drizzle-orm · error · Error

Can't fill notNull column with null values.

Error message

Can't fill notNull column with null values.

What it means

Error "Can't fill notNull column with null values." thrown in drizzle-team/drizzle-orm.

Source

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

			throw new Error('maxRepeatedValuesCount should be greater than zero.');
		}

		let allValuesCount = values.length;
		if (isObject(values[0])) {
			allValuesCount = (values as { values: any[] }[]).reduce((acc, currVal) => acc + currVal.values.length, 0);
		}

		if (
			notNull === true
			&& maxRepeatedValuesCount !== undefined
			&& (
				(!isObject(values[0]) && typeof maxRepeatedValuesCount === 'number'
					&& maxRepeatedValuesCount * values.length < count)
				|| (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 && (

View on GitHub (pinned to b7862528fd)

Solutions

  1. Remove null from the values pool or allow nulls by dropping the notNull constraint on the column.

When it happens

Trigger: A generator is asked to emit null into a NOT NULL column (e.g. defaultNullChance/weighted nulls on a notNull column).

Common situations: Including null among weighted values for a notNull column; high null weight on required fields.


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