我将Rails与PostgreSQL一起使用,它适用于这样的查询:
# Does hstore_column contain key?
scoped_users = User.where('hstore_column ? :key', key: 'name_of_key')
现在我的问题:如何反转此查询/如何找到不指定特定密钥的所有用户?
# I tried this query amongst others, but it does not work:
scoped_users = User.where('hstore_column ? :key = FALSE', key: 'name_of_key')
谢谢你的帮助!
答案 0 :(得分:2)
尝试:
where('NOT ( hstore_column ? :key )', key: 'name_of_key')