Every repository with this icon (
Every repository with this icon (
| Description: | ruby persistence layer for CouchDB. edit |
-
I have used previous version of couch_potato before its major rewrite, separating database operations do help ease on testing, but finger kinda hurts compare to the older version, i guess its a matter of judging how much automagic u need Vs. performance,
One of the thing that last major version works is using array as a key.. so you can do operations like following and it builds the map function as well as conversion of date range object into key.
Person.all(:key => [project.id, 10.days.ago .. 0.day.ago])It kinda stopped working, i start poke around specs (custom_view_spec) and added following, It failes along with couple other specs start to blow up..
describe "with array as key" do it "should create a map function with the composite key" do CouchPotato::View::ViewQuery.should_receive(:new).with(anything, anything, anything, string_matching(/emit\(\[doc\['time'\], doc\['state'\]\]/), anything).and_return(stub('view query').as_null_object) CouchPotato.database.view Build.key_array_timeline CouchPotato.database.save_document Build.new(:state => 'success', :time => Time.now-1000) CouchPotato.database.save_document Build.new(:state => 'success', :time => Time.now) result = CouchPotato.database.view(Build.timeline(:key => (Time.now-100000)..(Time.now), :descending => true)) result.length.should > 0 end endComments
-
If I have a property that is typed as something, like an Array, and the field is nil, then when I run a query against the database, I get a NoMethodError.
db.view Product.all NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/json-1.1.7/lib/json/add/rails.rb:12:in `json_create' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/langalex-couch_potato-0.2.7/lib/couch_potato/persistence/simple_property.rb:53:in `build' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/langalex-couch_potato-0.2.7/lib/couch_potato/persistence/json.rb:38:in `block in json_create' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/langalex-couch_potato-0.2.7/lib/couch_potato/persistence/json.rb:37:in `each' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/langalex-couch_potato-0.2.7/lib/couch_potato/persistence/json.rb:37:in `json_create' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/langalex-couch_potato-0.2.7/lib/couch_potato/persistence/properties.rb:31:in `json_create' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/langalex-couch_potato-0.2.7/lib/couch_potato/view/model_view_spec.rb:38:in `block in process_results' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/langalex-couch_potato-0.2.7/lib/couch_potato/view/model_view_spec.rb:37:in `map' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/langalex-couch_potato-0.2.7/lib/couch_potato/view/model_view_spec.rb:37:in `process_results' from /opt/local/lib/ruby1.9/gems/1.9.1/gems/langalex-couch_potato-0.2.7/lib/couch_potato/database.rb:19:in `view' from (irb):6 from /opt/local/bin/irb:12:in `<main>'I am normally pretty good at finding these errors, but I am running Ruby 1.9.1, so I don't have the luxury of ruby-debug.
Comments
-
allow something like
after_create :do_something, :if => :do_it?should also work with a lambda instead of a symbol as condition
Comments
-
0 comments Created about 1 month ago by langalexsupport boolean/numeric property typesfeaturexit should be possible to declare something like
property :age, :type => :integer, and then couch potato should convert passed in strings into integers. same with booleans.Comments
-
when changing the code of a map or reduce function couch potato should update the design document accordingly
Comments
-
1 comment Created 8 days ago by langalexundefined class/module error on load_documentbugxI
set up a model (User) with a simple CRUD controller and am trying to
get the basic CRUD functionality to work. The problem I had was that
attempting to load a User document form couchDB with this codeuser_document = CouchPotato.database.load_document params[:id]
resulted in the following error
undefined class/module User
...
When I dropped a breakpoint where the error was happened and
instantiated a new User in the debugger and then continued the
document was returned as expected. It seems that the User class is
lazy loaded and is not available when the json parser needs it. The
hacky fix is to instantiate a new user before the load_document call.
Is there a better way to deal with this?Comments
looks like this is a bug with rails and the json gem. the exception occurs not in couch potato but in json, which doesn't like the fact that rails has unloaded the classes in development mode. as this is not a couch potato issue couch potato should not fix this. i would like to provide a workaround though, but i don't have one yet. we would somehow have to reload the classes that have implemented the persistence module before trying to load an object from the database.
-
Persisting a property with a boolean false value doesn't work
0 comments Created about 5 hours ago by berndThe clean_hash method in database.rb removes keys with a false value from the hash.
The conditional in the build method in simple_property.rb to retrieve the value doesn't take false values into account.
Fix at: bernd/couch_potato@c099080
Regards,
BerndComments











The syntax of using range object as :key appears on the readme file, and test coverage of both array key and range object key are no where to be found
Can you update the current status on this one please ?
Great work by the way
for ranges please use the startkey and endkey parameters. if this is still in the readme then the readme is wrong and has to be updated. can you provide a test case for the array problem?