By virtual we mean that we don't have the 'type' column in the DB at all. 
We determine it runtime via scope from the query.

Here is an example https://gist.github.com/gudata/7ff43e3b6600408b1c1e

multi_table_inheritance 
<https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fninjudd%2Fmulti_table_inheritance&sa=D&sntz=1&usg=AFQjCNEOoIsa4h8OtebcAb119NEEy0wPAw>
 is 
very old and probably is not addressing the same problem.


On Tuesday, June 10, 2014 11:59:54 AM UTC+3, Xavier Noria wrote:
>
> On Mon, Jun 9, 2014 at 3:00 PM, Ivailo Bardarov <i.bar...@gmail.com 
> <javascript:>> wrote:
>
> I have a case when I want to use postgres table inheritance. I want my 
>> STI inheritance_column to be virtual. What is the reason to check 
>> for inheritance_column in the columns_hash?
>>
>>
>> https://github.com/rails/rails/blob/4-2-release_notes/activerecord/lib/active_record/inheritance.rb#L151
>>
>> If we check only in the record (from the query result), then it would be 
>> possible to have STI based on virtual columns.
>>
>
> Virtual in what sense?
>
> AR assumes the type column exists in some queries. For example if you have
>
>     Square < Polygon < AR::Base
>
> then Square.count triggers
>
>     SELECT COUNT(*) FROM "polygons"  WHERE "polygons"."type" IN ('Square')
>
> Can you make that work with your table definitions?
>
> I have never used table inheritance in Postgres, but my understanding is 
> that that kind of logic is builtin. I mean, if I understand it correctly
>
>     SELECT COUNT(*) FROM "squares";
>
> would count squares and all their descendants. You need to pass ONLY to 
> opt-out.
>
> My first impression (modulus, again, I have not used it) is that Postgres 
> table inheritance is fundamentally incompatible with STI, and could maybe 
> deserve its own plugin. I have seen
>
>     https://github.com/ninjudd/multi_table_inheritance
>
> but does not seem to have much activity.
>
>  
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to