Search code examples
javascriptpg-promise

Pg promise suddenly complain about table name is unknown


console.log(columnsets.activites.forInsert)

gives me

ColumnSet {
table: "accounting"."activities"
columns: [
    Column {
        name: "note"
    }
    Column {
        name: "title"
    }
    Column {
        name: "context_id"
        prop: "contextId"
    }
    Column {
        name: "created_timestamp"
        prop: "createdTimestamp"
    }
    Column {
        name: "created_by_id"
        prop: "createdById"
    }
    Column {
        name: "object_id"
        prop: "objectId"
        cnd: true
    }
]

}

pgp.helpers.insert({ contextId: user.objectId, createdById: user.objectId, createdTimestamp: now, note: null, objectId: uuid.v4(), title: MESSAGE_SUCCESS_USER_AUTHENTICATE }, columnSets.activities.forInsert)

I could have sworn that it was working for me until recently. I am not sure what has changed. I have table name set but why is it complaining about Error: Table name is unknown.


Solution

  • It is not clear at which point you are calling console.log(columnsets.activites.forInsert), compared to the call into helpers.insert, but I'm guessing it happens afterwards.

    There is only one reason why you would get error Table name is unknown, and that's when your columnsets.activites.forInsert doesn't contain a ColumnSet with table information in it.

    There is no other scenario when you could get that error. You can debug the code to check that ;)