Ken Stowell
Ken Stowell

Reputation: 11

Insert shows all empty values

I am rather new to this library (knex) and have run across a problem I have not been able to find a solution for on the interwebs.

Here is my Knex connection:

Knex({client: 'pg', connection: config.DB, searchPath:'syp,public', debug: true})

Here is my insert:

Knex('users')
    .returning('id')
    .insert(data)
    .then(function(user) {
      console.log(user);
    }, function(err) {
      console.log(err)
    });

This is my data from the above query:

{   
    "first_name": "Kenneth",
    "last_name": "Stowell",
    "email": "[email protected]" }

The resulting error is:

code:"42703"
file:"parse_target.c"
length:119
line:"943"
name:"error"
position:"230"
routine:"checkInsertTargets"
severity:"ERROR"

Which would make sense as the debugger is showing the following as the sql:

sql:"insert into "users" ("first_name", "last_name", "email") values (?, ?, ?) returning "id""

I hope I am just making a newbie mistake but I cannot for the life of me figure out why. It appears to be making the bindings correctly but never applying them.

Any help appreciated!

Upvotes: 1

Views: 1914

Answers (1)

Clintm
Clintm

Reputation: 4877

The code 42703 is a postgres error code that means you're trying to insert data into a column that doesn't exist.

Upvotes: 2

Related Questions