On Mon, Jun 9, 2014 at 3:00 PM, Ivailo Bardarov <[email protected]>
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 [email protected].
To post to this group, send email to [email protected].
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