Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Hstore operators in update don't seem to work #225

@ericeslinger

Description

@ericeslinger

I think, at least.

Basically, what I want to do is: update foo set bar = bar || 'baz=>bam' where id=1 to add the baz=>bam keyword to the hstore entry. It looks like I'm stuck with update foo set bar = $1 and $1 binding to 'bar || "baz=>bam", which errors out (parse error coming back from postgres). I haven't completely isolated the error, but I'm 90% sure it's because the column name shouldn't be inside quotes there.

IOW: Knex.DB('foos').update('hstore_col', 'hstore_col || '+hstore.stringify(hstore_obj)) doesn't really do what I want.

This isn't a real huge blocker - most (maybe even all) of the time when I'm writing an hstore column to the database, I've already loaded it from the database, so I probably don't really need to worry about the situation where I set one key->value and accidentally delete all the other keys in the column. That said, it's definitely a gotcha in my ORM code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions