NoBrainerORM / nobrainer

Ruby ORM for RethinkDB
http://nobrainer.io/
Other
386 stars 49 forks source link

Enum querying not working? #226

Closed elithecho closed 8 years ago

elithecho commented 8 years ago

My enum queries aren't showing any results, am I doing something wrong here?

I even tried using .where(status: :pending)

My model field

  field :status, type: Enum, in: [:pending, :complete, :banned], default: :pending

My logs

[9] pry(main)> Model.pending.count
[   2.0ms] r.table("models").filter {|var_7| var_7[:status].eq(:pending)}.count -- perf: filtering without using an index
=> 0
[10] pry(main)> Model.first.pending?
[   2.7ms] r.table("models").order_by({"index" => r.asc(:id)}).limit(1)
=> true
[11] pry(main)>
jeroenvisser101 commented 8 years ago

If you added the enum later, it could be that the model you're retrieving doesn't have a status set yet (e.g. status is nil).

elithecho commented 8 years ago

Thanks for clearing that up! @jeroenvisser101, that's something I shall take note of, appreciate it.

Closing this issue.