siuying / NanoStoreInMotion

RubyMotion wrapper for NanoStore, a lightweight schema-less key-value document database based on sqlite.
Other
103 stars 24 forks source link

uninitialized constant NSFLessThan #31

Closed ofl closed 11 years ago

ofl commented 11 years ago

Hello, Some NanoStore finder options(NSFLessThan, NSFBeforeDate..) doesn't seem to work.

(main)> ar = Article.find(:is_checked => {NSFGreaterThan => 0})
=> [#<Article:0x1028e740>, #<Article:0x1028b780>]

(main)> ar = Article.find(:is_checked => {NSFLessThan => 1})
=> #<NameError: uninitialized constant NSFLessThan>

(main)> ar = Article.find(:created_at => {NSFBeforeDate => Time.now})
=> #<NameError: uninitialized constant NSFBeforeDate>

Have you any suggestions ? Thanks.

siuying commented 11 years ago

If you are trying that in REPL, this could happen if you only have NSFGreaterThan in your ruby source code but not NSFLessThan or NSFBeforeDate. RubyMotion will remove all symbols not referenced by your app.

As a work around, you may include all of those symbol in your app.

ofl commented 11 years ago

Thank you for a reply.

As a work around, you may include all of those symbol in your app.

it works. but

Article.create(created_at: Time.now)

ar = Article.find(:created_at => {NSFBeforeDate => Time.now})
=> []

or

ar = Article.find(:created_at => {NSFBeforeDate => NSDate.date})
=> []

Is it the wrong usage?

siuying commented 11 years ago

Would you please try to use NSDate for yuour created_at? The NSFBeforeDate is designed for NSDate not ruby Time.

In RubyMotion Time is not a NSDate. (this can be confirmed via REPL: Time.class.ancestors => [Class, Module, NSObject, Profiler::ObjectExt, Kernel] )

siuying commented 11 years ago

As this is not an issue of NanoStore, i'll close this issue.