ERROR: zero-length delimited IDentifIEr at or near """" liNE 1: DELETE FROM "regions" WHERE "regions"."" =
我知道问题是由于缺少区域表的主键而导致的.而且奇怪的是,如果我将主键添加回表,破坏工作正常,没有错误.但是,如果我从表中删除主键,则会出现错误.我知道这与postgres有关,但我不知道如何解决这个问题,而无需为我的region表添加一个主键列.
这是实际的查询
[DEBUG] [adminUser Load (0.4ms) SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."ID" = 1 ORDER BY "admin_users"."ID" ASC liMIT 1] (pID:29655)[DEBUG] [Province Load (0.2ms) SELECT "provinces".* FROM "provinces" WHERE "provinces"."ID" = liMIT 1 [["ID",5]]] (pID:29655)[DEBUG] [ (0.1ms) BEGIN] (pID:29655)[DEBUG] [Region Load (0.3ms) SELECT "regions".* FROM "regions" WHERE "regions"."province_ID" = [["province_ID",5]]] (pID:29655)[ERROR] [PG::SyntaxError: ERROR: zero-length delimited IDentifIEr at or near """"liNE 1: DELETE FROM "regions" WHERE "regions"."" =尝试设置依赖::delete_all代替.
示例(不完全确定您如何设置多对多关系).
# models/region.rb
…
has_many :provinces_regions,dependent: :delete_all
has_many :provinces,through: :provinces_regions
…
:destroy /:destroy_all将通过调用它们的destroy方法来删除关联的对象,从而回调(:before_destroy,after_destroy等)
:delete /:delete_all将删除关联对象而不调用其destroy方法.
总结以上是内存溢出为你收集整理的postgresql – ERROR:零长度分隔标识符在“”“或”附近“LINE 1:DELETE FROM”regions“WHERE”regions“.”“= $1全部内容,希望文章能够帮你解决postgresql – ERROR:零长度分隔标识符在“”“或”附近“LINE 1:DELETE FROM”regions“WHERE”regions“.”“= $1所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)