On Wednesday, October 19, 2016 at 12:26:19 PM UTC-7, [email protected]
wrote:
>
> Hi all,
> We are currently using Sequel on Rails, some of the classes are CTI and I
> need to eager_graph some of the tables.
>
> class A
> plugin :class_table_inheritance, key: :foo, table_map: {:B => b_tables
> }
> one_to_many :names, class: "name"
> end
>
> class B < A
> end
>
> By default, all of our tables have default :created_at, :updated_at
> columns.
> I am trying to eager_graph B class with associated join table of names
> from the parent class
> basically, I do B.eager_graph(:names).first will throw an error that is
> caused we have multiple ambiguous columns of :created_at and :updated_at on
> both classes.
>
> error thrown: Sequel::DatabaseError: PG::AmbiguousColumn: ERROR: column
> reference "created_at" is ambiguous
>
> Greatly appreciate anybody could help me looking for the best way to solve
> this.
>
Please provide a self contained example showing this issue. I tried to
create one, but I'm not able to reproduce:
DB.create_table(:as) do
primary_key :id
String :kind
Time :created_at, :default=>Sequel::CURRENT_TIMESTAMP
end
DB.create_table(:bs) do
foreign_key :id, :as, :primary_key=>true
String :foo
end
DB.create_table(:names) do
primary_key :id
foreign_key :a_id, :as
Time :created_at, :default=>Sequel::CURRENT_TIMESTAMP
end
class Name < Sequel::Model
end
class A < Sequel::Model
plugin :class_table_inheritance, key: :kind
one_to_many :names
end
class B < A
end
a = A.create
p a
p a.add_name({})
p A.eager_graph(:names).all
b = B.create
p b.add_name({})
p B.eager_graph(:names).all
Note if that you have created_at in both the tables for A and B, an error
is expected, CTI is not supported when any subclass tables have column
names that overlap with column names in any superclass tables. There
shouldn't be a need for the duplicate columns anyway, so if that is the
reason it is failing for you, you could probably just drop the column from
the subclass table, as it should be the same as the column in the
superclass table.
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.