Skip to content
Astera Technology

Why does a mapped column called order break table creation?

Quote destination identifiers and bind data values through separate mechanisms.

Download complete case notes and answer keys ↓

Read the source and its declared rule

The original mapping allows the supplied column names order and we"ird. SQL identifiers need double quoting with embedded quotes doubled. Text O'Neil is a data value and uses a bound parameter; identifier quoting does not replace value binding. Empty names are prohibited here.

Filled synthetic input
RecordInput JSON
Base input{"column":"order","value":"O'Neil"}
Download editable CSV ↓

Compare the actual paths

Unquoted order fails creation. Corrected table stores O'Neil exactly, and the embedded-quote identifier also works. The example runs only its fixed local names and values.

Misleading and corrected outputs
PathOutput JSON
Misleading path{"error":{"code":1},"values":[]}
Corrected path{"error":null,"values":[{"value":"O'Neil"}]}
Download editable CSV ↓
Local Node.js program: 22.23.3 or 24.14.1
import {DatabaseSync} from 'node:sqlite';
import {TextDecoder} from 'node:util';
import {inflateSync} from 'node:zlib';
import {posix} from 'node:path';
import {createHash} from 'node:crypto';
const rows=(db,sql)=>db.prepare(sql).all().map(r=>({...r}));
const failed=(action)=>{try{action();return null;}catch(e){return {code:e.errcode??e.code??e.name};}};

import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
    if(!['order','we"ird',''].includes(i.column))return {error:'outside-fixed-example',values:[]};
    if(!i.column)return {error:'empty-identifier',values:[]};
    const db=new DatabaseSync(':memory:');const name=corrected?'"'+i.column.replace(/"/g,'""')+'"':i.column;
    try{const error=failed(()=>{db.exec('CREATE TABLE target('+name+' TEXT);');db.prepare('INSERT INTO target('+name+') VALUES(?)').run(i.value);});
      return {error,values:error?[]:rows(db,'SELECT '+name+' AS value FROM target')};
    }finally{db.close();}
  };
const cases=[{"label":"misleading base","input":{"column":"order","value":"O'Neil"},"expected":{"error":{"code":1},"values":[]},"corrected":false},{"label":"corrected base","input":{"column":"order","value":"O'Neil"},"expected":{"error":null,"values":[{"value":"O'Neil"}]},"corrected":true},{"label":"embedded quote in identifier","input":{"column":"we\"ird","value":"A"},"expected":{"error":null,"values":[{"value":"A"}]},"corrected":true},{"label":"empty identifier prohibited","input":{"column":"","value":"A"},"expected":{"error":"empty-identifier","values":[]},"corrected":true}];
for(const test of cases){
  const actual=run(test.input,test.corrected);
  assert.deepEqual(actual,test.expected,test.label);
  console.log(test.label,actual);
}
Download runnable example ↓

Check boundaries before the next load

A quoted embedded-name quote is accepted. The explicit empty-name gate refuses to create a column.

Editable boundary records and expected outputs
CaseInput JSONExpected output JSON
Embedded identifier quote{"column":"we\"ird","value":"A"}{"error":null,"values":[{"value":"A"}]}
Empty identifier rejected{"column":"","value":"A"}{"error":"empty-identifier","values":[]}
Download editable CSV ↓

Can a parameter placeholder stand in for a destination column name?

Show the worked answer

No. Bind data values; construct identifiers using the permitted identifier-quoting rule. Here order is quoted and O'Neil is bound.

Related resources