gpt4 book ai didi

ruby-on-rails - ActiveRecord belongs_to 关联中的 PostgreSQL jsonb 字段

转载 作者:行者123 更新时间:2023-11-29 11:19:39 24 4
gpt4 key购买 nike

我可以在 belongs_to 关联中使用 jsonb 字段作为 foreign_key 吗?类似的东西:

belongs_to :product, class_name: "Product",  foreign_key: "data ->'product_id'"

最佳答案

引用只能在列(或列组)之间定义,如 the documentation 中所述:

FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ]

关于ruby-on-rails - ActiveRecord belongs_to 关联中的 PostgreSQL jsonb 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32889252/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com