beekeeper-studio/beekeeper-studio · error
can't add a column without name or data type
Error message
can't add a column without name or data type
What it means
ClickHouseChangeBuilder.addColumn builds an ALTER TABLE ... ADD COLUMN statement and refuses to proceed when the SchemaItem is missing either a columnName or a dataType. A column with no name or no type cannot be expressed in valid ClickHouse DDL, so the builder throws early instead of emitting broken SQL. This is a defensive guard against incomplete schema-edit inputs.
Source
Thrown at apps/studio/src/shared/lib/sql/change_builder/ClickHouseChangeBuilder.ts:19
import { ChangeBuilderBase } from "@shared/lib/sql/change_builder/ChangeBuilderBase";
import { ClickHouseData } from "@shared/lib/dialects/clickhouse";
import { Dialect, SchemaItem } from "@shared/lib/dialects/models";
import _ from 'lodash'
export class ClickHouseChangeBuilder extends ChangeBuilderBase {
dialect: Dialect = 'clickhouse'
wrapIdentifier = ClickHouseData.wrapIdentifier
wrapLiteral = ClickHouseData.wrapLiteral
escapeString = ClickHouseData.escapeString
constructor(table: string, schema: string, private columns: SchemaItem[]) {
super(table, schema)
}
// new columns
addColumn(item: SchemaItem) {
if (!item.columnName || !item.dataType) {
throw new Error("can't add a column without name or data type")
}
let dataType = this.wrapLiteral(item.dataType)
if (item.nullable) {
dataType = `Nullable(${dataType})`
}
return [
'ADD COLUMN',
this.wrapIdentifier(item.columnName),
dataType,
item.defaultValue ? `DEFAULT ${this.wrapLiteral(item.defaultValue)}` : null,
item.extra,
item.comment ? `COMMENT ${this.escapeString(item.comment, true)}` : null
].filter((i) => !!i).join(" ")
}
alterDefault(column: string, newDefault: string | boolean | null) {View on GitHub (pinned to 4e3e03e322)
Solutions
- Set both item.columnName and item.dataType on the SchemaItem before calling addColumn
- Filter out blank/incomplete schema rows before passing them to the change builder
- Add form-level validation in the UI so the add-column action cannot be triggered with an empty name or type
- Wrap addColumn in try/catch and surface a user-facing message about the missing name/type
Example fix
// before
builder.addColumn({ dataType: 'String' }) // throws
// after
builder.addColumn({ columnName: 'status', dataType: 'String', nullable: true }) Defensive patterns
Strategy: validation
Validate before calling
function canAddColumn(item) { return Boolean(item && item.columnName && item.columnName.trim() && item.dataType && item.dataType.trim()); }
if (!canAddColumn(item)) throw new Error('Column name and data type are required'); Type guard
function isCompleteSchemaItem(item): item is SchemaItem & { columnName: string; dataType: string } {
return typeof item?.columnName === 'string' && item.columnName.trim() !== '' && typeof item?.dataType === 'string' && item.dataType.trim() !== '';
} Try / catch
try {
builder.addColumn(item);
} catch (e) {
if (e.message.includes("without name or data type")) {
notifyUser('New column needs a name and a data type');
} else throw e;
} Prevention
- Validate column-editor forms before submit (name + type required)
- Filter out blank rows before building alter scripts
- Give new columns a sensible default type in the UI
- Unit-test addColumn with empty-name and empty-type items
When it happens
Trigger: Calling addColumn(item) with item.columnName === '' / undefined / null, or with item.dataType === '' / undefined / null. Typically happens when a UI form or script submits a partially filled row from a table-structure editor.
Common situations: User clicks Save/Add in the table structure editor without filling in the new column's name or type; a migration generator iterates schema items where some entries were auto-created as blanks; programmatic schema tooling passing SparseSchemaItem objects with optional fields left unset.
Related errors
- can't add a column without name or data type
- can't add a column without name or data type
- can't add a column without name or data type
- can't add a column without name or data type
- Schemas are not supported
AI-assisted analysis of beekeeper-studio/beekeeper-studio@4e3e03e322 (2026-08-31).
Data as JSON: /api/errors/b5419b49a8820666.
Report an issue: GitHub.