Actually, most of this seems solvable by liberal use of `primary_key` and `left_primary_key` on the associations. Whilst I can now read from the database there are still the odd things related to PKs:
``` Sequel::Error: No primary key is associated with this model ``` etc. On Fri, Mar 6, 2015 at 8:04 PM, Neil Middleton <[email protected]> wrote: > No cigar. Setting this with: > > ``` > set_primary_key :id > ``` > > yields the same error. > > Neil > > On Fri, Mar 6, 2015 at 7:50 PM, Jeremy Evans <[email protected]> > wrote: > >> On Friday, March 6, 2015 at 9:35:20 AM UTC-8, Neil Middleton wrote: >>> >>> Hey, >>> >>> We're trying to use sequel against a view in Postgres which goes cross >>> schema (select * from schema.table basically). There's a relationship in >>> one model 'tickets' (based on the view) which links to another table via a >>> `many_to_many`: >>> >>> ``` >>> many_to_many :tags, left_key: :ticket_id, right_key: :tag_id >>> ``` >>> >>> (tickets is a view on a table in another schema, tags is just >>> public.tags) >>> >>> However, on application boot, this causes an error: >>> >>> ``` >>> 17:25:23 web.1 | [32073] ! Unable to load application: Sequel::Error: >>> mismatched number of left keys: [:ticket_id] vs [] >>> 17:25:24 web.1 | /Users/neil/.rbenv/versions/2. >>> 2.0/lib/ruby/gems/2.2.0/gems/sequel-4.19.0/lib/sequel/model/associations.rb:1806:in >>> `def_many_to_many': mismatched number of left keys: [:ticket_id] vs [] >>> (Sequel::Error) >>> ``` >>> >>> Everything is fine and working in postgres-land and behaving as it >>> should, but Sequel is blocking us by causing this error. I assume this is >>> something to do with the schema change in the view? >>> >> >> It's probably because Sequel can't determine the primary key for the >> model if you use a view instead of a table, since views do not have primary >> keys. You can probably use set_primary_key for the appropriate model that >> is backed by the view to work around it. >> >> Thanks, >> Jeremy >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "sequel-talk" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/sequel-talk/WamdFeH0wGQ/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/sequel-talk. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > - N > -- - N -- 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 http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
