It is working nicely!! Thank you so much! On Tuesday, September 27, 2022 at 4:38:01 PM UTC-4 Jeremy Evans wrote:
> On Tue, Sep 27, 2022 at 12:46 PM 'Maria Fradkin' via sequel-talk < > [email protected]> wrote: > >> Hello, >> >> I have recently came across a problem with foreign_key_list not working >> correctly with partitioned tables on Postgres. >> My table is partitioned by hash on some_id column, I have few partitions >> attached >> some_table_p_hash_p1 >> some_table_p_hash_p2 >> ... >> some_table_p_hash_p16 >> >> the table has few foreign keys , e.g. fk_tab1, fk_tab2, ... >> When i try SomeTable.db.foreign_key_list(SomeTable.table_name) on a main >> table I am getting an empty array [] >> when I use an actual partition everything is working as expected: >> SomeTable.db.foreign_key_list(:some_table_p_hash_p1) >> [{:name=>:some_table_tab1_id_fkey, :columns=>[:tab1_id], :key=>[:id], >> :on_update=>:no_action, :on_delete=>:cascade, :deferrable=>false, >> :table=>:tab1, :schema=>:public}, >> {:name=>:some_table_tab2_id_fkey, :columns=>[:tab2_id, :org_id], >> :key=>[:id], :on_update=>:no_action, :on_delete=>:cascade, >> :deferrable=>false, :table=>:tab2, :schema=>:public},..] >> >> Can you please advise how to fix this issue with an actual model table? >> > > Thanks for reporting this issue. Can you let me know if the following > patch fixes it: > > diff --git a/lib/sequel/adapters/shared/postgres.rb > b/lib/sequel/adapters/shared/postgres.rb > index c2f354f16..148a466ff 100644 > --- a/lib/sequel/adapters/shared/postgres.rb > +++ b/lib/sequel/adapters/shared/postgres.rb > @@ -586,7 +586,7 @@ module Sequel > join(Sequel[:pg_namespace].as(:nsp), > :oid=>Sequel[:cl2][:relnamespace]). > order{[co[:conname], cpos]}. > where{{ > - cl[:relkind]=>'r', > + cl[:relkind]=>%w'r p', > co[:contype]=>'f', > cl[:oid]=>oid, > cpos=>rpos > > 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 view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/062b5e1f-124a-4da8-bff6-c0212a57b469n%40googlegroups.com.
