On Sun, Sep 11, 2016 at 11:05:17AM -0700, Will Koffel wrote:
> I have the following:
>
> (byebug) puts DB.from(:users).select("email").sql
>
> SELECT 'email' FROM "users"
>
> The problem is that the DB doesn't accept that SQL, because the table name
> is quoted.
>
> (byebug) DB[DB.from(:users).select("email").sql].each { |r| puts r }
>
> *** Sequel::DatabaseError Exception: PG::UndefinedTable: ERROR: relation
> "users" does not exist
>
> The query works just fine manually if the table name is bare.
Does the query fail as expected when you quote the table name?
> The DB is RedShift. I don't have a PG database hooked up to test with, but
> maybe this is a quirk of Redshift that the redshift adapter doesn't handle
> properly?
I'd say this is a quirk of redshift:
=> create table users (id int);
CREATE TABLE
=> select 'email' from "users";
?column?
----------
(0 rows)
http://docs.aws.amazon.com/redshift/latest/dg/r_names.html suggests this
*should* be supported, at least in some way. I'm a bit leery of the
sentence, "If you use a delimited identifier, you must use the double
quotation marks for every reference to that object.", which suggests that
you would need create the table as being named `"users"`, rather than just
`users`, if you wanted it to work with quotes later, but that might be an
imprecision in the phrasing, rather than what is literally meant.
- Matt
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.