I have following node.js + express code which is inserting data into postgres.
app.post('/register', function(request, response) {
pg.connect(connString, function(err, client, done) {
if(err) response.send("Could not connect to DB: " + err);
client.query('INSER INTO clients (client_id, params) VALUES ($1, $2)',
[request.query.client_id, request.query.params],
function(err, result) {
done();
if(err) return response.send(err);
response.send('OK');
});
});
});
The table structure is:
CREATE TABLE clients
(
client_id character varying NOT NULL,
params character varying[] NOT NULL,
id integer NOT NULL DEFAULT nextval('clients_id_seq1'::regclass),
CONSTRAINT clients_pkey PRIMARY KEY (id)
)
If I do a plain SELECT it works well. However on INSERT I get this HTTP 200 response:
{
"name": "error",
"length": 86,
"severity": "ERROR",
"code": "42601",
"position": "1",
"file": "scan.l",
"line": "1044",
"routine": "scanner_yyerror"
}
This error does not say too much for me.