我無法檢查我的表的jsonb列是否爲空。如何檢查jsonb列是否爲空Postgres
我列方向當空已值「{}」
試過以下
Model.where("directions != '{}'") <- brings all
Model.where("directions <@ '{}'") <- brings all
是那裏,我不知道任何其他方式?使用PostgreSQL 9.6
我無法檢查我的表的jsonb列是否爲空。如何檢查jsonb列是否爲空Postgres
我列方向當空已值「{}」
試過以下
Model.where("directions != '{}'") <- brings all
Model.where("directions <@ '{}'") <- brings all
是那裏,我不知道任何其他方式?使用PostgreSQL 9.6
Model.where.not(directions: '{}')
嘗試否定查詢與.not
:
Model.where.not("directions = '{}'")
對不起,這種語法不起作用 –
我同意佩特羅斯,這是截至2017年和Rails 4無效的語法。 – user478798
'Model.where( 「!=方向 '{}'」)'應該工作,但是'Model.where.not(方向:'{}')'感覺更有價值(但相當於)。如果這些查詢返回所有數據,那麼您確定您有任何實際路線數據的實例嗎? – Frost
@Frost工作的唯一語法是'Model.where.not(方向:'{}')'。回答你的問題是,我有兩種情況的記錄。 –