Hi,
I'm tring to build a query with more than 1 table as fallows
ds =
DB.select("r.year,r.prod,r.type,r.amnt,r.ccur,r.dcnt,r.dbcr,r.rcdt,r.stat
,p.code as partner_code,p.desc as partner_desc,p.txid")
ds = ds.from("#{Rank.table_name.to_s} r","#{Partner.table_name.to_s} p")
ds = ds.where(Sequel.lit('r.ptid = p.id'))
ds.first returns an error "no such table: ranks r"
What should I do to fix this?
On Monday, September 12, 2016 at 12:25:58 AM UTC+3, Jeremy Evans wrote:
>
> On Sunday, September 11, 2016 at 2:22:32 PM UTC-7, 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.
>>
>> 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 feel like I'm missing something obvious here. Is there any way to get
>> the table name not to be quoted?
>>
>
> DB.quote_identifiers = false
>
> Thanks,
> Jeremy
>
--
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.