{"record":{"id":"afbc9ac5abc0f1b6","repo":"ToolJet/ToolJet","slug":"a-column-entry-has-a-value-but-no-column-name-spec","errorCode":null,"errorMessage":"A column entry has a value but no column name specified","messagePattern":"A column entry has a value but no column name specified","errorType":"validation","errorClass":"QueryBuilderError","httpStatus":null,"severity":"error","filePath":"plugins/packages/common/lib/queryBuilder.ts","lineNumber":398,"sourceCode":"    return parts.length > 0 ? parts.join(', ') : '*';\n  }\n\n  // ── Operations ──────────────────────────────────────────────────────────────\n  createRow(\n    tableName: string,\n    schema: string | undefined | null,\n    columns: Record<string, CreateRowEntry> | undefined | null\n  ): QueryResult {\n    this._reset();\n    this._assertTableName(tableName, 'create_row');\n\n    const table = this._buildTableRef(tableName, schema);\n\n    const entries = Object.values(columns || {}).filter((entry) => {\n      const hasColumn = !!(entry.column && String(entry.column).trim());\n      const isValueEmpty = entry.value === undefined || entry.value === null || entry.value === '';\n      if (!hasColumn && isValueEmpty) return false; // skip if both key and value is empty\n      if (!hasColumn) throw new QueryBuilderError('A column entry has a value but no column name specified'); // Throw error if column name is missing but value is provided\n      return true;\n    });\n\n    // If no valid columns are provided, generate an INSERT with DEFAULT VALUES\n    if (entries.length === 0) {\n      const query = `INSERT INTO ${table} DEFAULT VALUES`;\n      return { query, params: [] };\n    }\n\n    const cols = entries.map((e) => this._dialect.quote(e.column));\n    const placeholders = entries.map((e) => this._addParam(e.value));\n\n    const query = `INSERT INTO ${table} (${cols.join(', ')}) VALUES (${placeholders.join(', ')})`;\n    return { query, params: [...this._params] };\n  }\n\n  updateRows(tableName: string, updateRows: UpdateRowsInput): QueryResult {\n    this._reset();","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/ToolJet/ToolJet/blob/20602a8e101f2e59686c9afde0d1402aac2c8871/plugins/packages/common/lib/queryBuilder.ts#L380-L416","documentation":"Thrown by createRow when a columns entry carries a value but its column name is blank or whitespace. The builder needs a column name to quote into the INSERT column list; a value without a target column is rejected. Fully-empty entries (no column and empty value) are silently skipped, and if all are empty it falls back to INSERT ... DEFAULT VALUES.","triggerScenarios":"qb.createRow('users', 'public', { c1: { column: '', value: 'alice' } }), { column: '   ', value: 42 }, or a columns map built from a form row whose column key was cleared.","commonSituations":"An editable grid where a cell value was typed but the row's column selector is empty; serializing form state that includes a value but lost its column binding; copying a template row and not setting the column.","solutions":["Ensure each columns entry with a value also has a non-empty column.","Drop fully-empty rows before calling createRow; if all are empty, DEFAULT VALUES is used automatically.","Build the columns map from a concrete column list, not free-form input."],"exampleFix":"// before\ncolumns: { c1: { column: '', value: 'alice' } }\n// after\ncolumns: { c1: { column: 'name', value: 'alice' } }","handlingStrategy":"validation","validationCode":"function cleanCreateColumns(columns = {}) {\n  const out = {};\n  for (const [k, e] of Object.entries(columns)) {\n    const col = (e.column ?? '').toString().trim();\n    const empty = e.value === undefined || e.value === null || e.value === '';\n    if (!col && empty) continue; // fully empty -> skip\n    if (!col) continue;           // value without column -> drop (or surface error)\n    out[k] = { ...e, column: col };\n  }\n  return out;\n}\n// usage: qb.createRow('users', 'public', cleanCreateColumns(input.columns))","typeGuard":"function isCompleteCreateEntry(e: { column?: string; value?: unknown }): boolean {\n  const hasCol = !!(e.column && String(e.column).trim());\n  const empty = e.value === undefined || e.value === null || e.value === '';\n  return hasCol || empty; // valid if column set, or fully empty (auto-skipped)\n}","tryCatchPattern":"try {\n  qb.createRow('users', 'public', columns);\n} catch (e) {\n  if (e instanceof QueryBuilderError && /no column name specified/.test(e.message)) {\n    return { error: 'Each value needs a target column.' };\n  }\n  throw e;\n}","preventionTips":["Build the columns map from a concrete column list, not free-form rows.","Prune entries with blank columns before calling createRow.","Pair each value with its column name in form state."],"tags":["query-builder","create-row","insert","validation"],"backgroundTag":null,"analyzedSha":"20602a8e101f2e59686c9afde0d1402aac2c8871","analyzedAt":"2026-08-13T05:58:54.221Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}