Thanks for the quick reply Jeremy.  

It appears that a set_dataset method in Message class affected the CTI 
plugin.  Didn't mention it in my code sample because I (incorrectly) 
assumed it wouldn't matter; that's what I get.  

Everything working now as expected, appreciate the sanity check.  Will look 
further into set_dataset issues I'm experiencing and see if I can get 
everything to play nicely, but I'm satisfied for now.

Thanks again,

--Chad

On Wednesday, August 8, 2012 1:09:33 PM UTC-4, Jeremy Evans wrote:
>
> On Wednesday, August 8, 2012 9:27:12 AM UTC-7, Miko wrote:
>>
>> Hello all, 
>>
>> Have been playing with the class table inheritance plugin and am getting 
>> some unexpected results.  Here's a simplified version of my schema:
>>
>>     create_table :messages do
>>       primary_key :id
>>       varchar  :kind, :size => 40, :null => false, :index => true
>>       text     :body
>>     end
>>
>>     create_table :phone_calls do
>>       foreign_key :id, :messages, :key => :id, :delete => :cascade, 
>> :primary_key => true
>>       DateTime :called_at, :timezone => false
>>     end
>>
>> And my classes snippet:
>>
>>     class Message
>>         plugin :class_table_inheritance, :key => :kind  
>>         # have also tried adding :table_map => { :Message => 
>> :messages, :PhoneCall => :phone_calls}  to the above, to no avail
>>     end
>>
>>     class PhoneCall < Message
>>
>>     end
>>
>> I seeded my Postgres db with data that looks like this (portions removed 
>> for brevity):
>>  
>>     Messages:
>>
>> id |   kind    
>> ----+-----------
>>   1 | Message
>>   2 | Message
>>   3 | Message
>>   4 | PhoneCall
>>
>>
>>     PhoneCall:
>>
>> id 
>> ----
>>   4
>>
>>
>> Based upon the documented example, my expectation was that running 
>> Message.all would yield:
>>
>>  # [ <#Message>, <#Message>, <#Message>, <#PhoneCall>]
>>
>>
>> However I'm instead receiving:
>>
>>  # [ <#Message>, <#Message>, <#Message>, <#Message>]
>>
>>
>> So attempts to call methods defined only on the PhoneCall class (i.e. 
>> when rendering the collection) lead to 'undefined method' errors. 
>>
>> Any insight on where I might be going wrong would be appreciated.  As 
>> always, thanks for the help!
>>
>
> Seems to work OK here:
>
>     DB.create_table :messages do
>           primary_key :id
>           varchar  :kind, :size => 40, :null => false, :index => true
>           text     :body
>         end
>     DB.create_table :phone_calls do
>           foreign_key :id, :messages, :key => :id, :delete => :cascade, 
> :primary_key => true
>           DateTime :called_at, :timezone => false
>         end
>     class Message < Sequel::Model
>       plugin :class_table_inheritance, :key => :kind
>     end
>     class PhoneCall < Message
>     end
>     DB[:messages].insert(:kind=>'PhoneCall')
>     Message.all
>     # => [#<PhoneCall @values={:id=>1, :kind=>"PhoneCall", :body=>nil}>]
>
> If it still isn't working for you, please reply with a self contained 
> example showing the problem.
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/ARgXwOlU02EJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to