Symbols being treated as columns in VALUES clause #547

Closed
jc00ke opened this Issue Sep 11, 2012 · 2 comments

Comments

Projects
None yet
2 participants
Contributor

jc00ke commented Sep 11, 2012

This tripped us up for a bit 😉

When I pass a symbol in as a value, I expect it to be treated like a string, so single quotes. However, it is parsed as a double quoted/escaped string, which in Postgres causes

Sequel::Database Error: PG::Error: column "foos" does not exist

Here's an example of what we were working with

db[:targets].
  multi_insert_sql(
    [:x_target_id, :target_id, :target_type],
    [['@foo:asdf', 459, :foos]]
)
=> ["INSERT INTO \"targets\" (\"x_target_id\", \"target_id\", \"target_type\") VALUES ('@foo', 459, \"foos\")"]

I would expect that last "foos" to be 'foos'.

sequel 3.39.0, sequel_pg 1.6.0, and pg 0.14.1

Owner

jeremyevans commented Sep 11, 2012

This behavior is by design. In Sequel, symbols represent SQL identifiers, not SQL strings. Your expectation would break the case where you want to set a column value to the current value of another column, and would be inconsistent with the rest of Sequel.

Contributor

jc00ke commented Sep 11, 2012

OK, that's understandable. Simple fix for us too. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment