drizzle-team/drizzle-orm · error · DrizzleError

No fields selected for table "${tableConfig.tsName}" ("${tab

Error message

No fields selected for table "${tableConfig.tsName}" ("${tableAlias}")

What it means

Error "No fields selected for table "${tableConfig.tsName}" ("${tableAlias}")" thrown in drizzle-team/drizzle-orm.

Source

Thrown at drizzle-orm/src/gel-core/dialect.ts:1339

					on: sql`true`,
					table: new Subquery(builtRelation.sql as SQL, {}, relationTableAlias),
					alias: relationTableAlias,
					joinType: 'left',
					lateral: true,
				});
				selection.push({
					dbKey: selectedRelationTsKey,
					tsKey: selectedRelationTsKey,
					field,
					relationTableTsKey: relationTableTsName,
					isJson: true,
					selection: builtRelation.selection,
				});
			}
		}

		if (selection.length === 0) {
			throw new DrizzleError({ message: `No fields selected for table "${tableConfig.tsName}" ("${tableAlias}")` });
		}

		let result;

		where = and(joinOn, where);

		if (nestedQueryRelation) {
			let field = sql`json_build_array(${
				sql.join(
					selection.map(({ field, tsKey, isJson }) =>
						isJson
							? sql`${sql.identifier(`${tableAlias}_${tsKey}`)}.${sql.identifier('data')}`
							: is(field, SQL.Aliased)
							? field.sql
							: field
					),
					sql`, `,
				)

View on GitHub (pinned to b7862528fd)

Solutions

  1. Select at least one column for the table, e.g. pass a "columns" object with at least one key, a "with" clause, or "extras".
  2. To select all columns, omit the "columns" key entirely or set it to undefined.

When it happens

Trigger: A relational query for a Gel table selects zero fields: columns, with, and extras are all empty for that table.

Common situations: columns: {} or all-false column map; dynamic column selection producing an empty object; omitted columns key with no extras.


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