On Sun, Sep 11, 2016 at 10:02:11PM -0700, Jeremy Evans wrote:
> On Sunday, September 11, 2016 at 7:12:24 PM UTC-7, Matt Palmer wrote:
> >
> > 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)
> >
>
> Actually, it's not. You are selecting a string expression (single quotes)
> without an alias, so the ?column? is expected, and there are no rows
> because you just created the table.
Sorry, I wasn't clear: that example was given on a PostgreSQL 9.4 server.
It demonstrates that the query generated by Sequel (that I executed) is
valid syntax *for PostgreSQL*; thus, if the same query fails with `ERROR:
relation "users" does not exist` in redshift, then that is a
redshift-specific quirk.
- 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.