kiddouk / redisco

A Python Library for Simple Models and Containers Persisted in Redis
MIT License
438 stars 78 forks source link

Can't push an array when initializing a list of references to ListField;can only append #31

Open GorgeouslyHumble opened 11 years ago

GorgeouslyHumble commented 11 years ago

So if I do something like this:

dog = Dog(name="Daryl", breed="Construction worker", description="He told his wife that he liked her sister's cooking better.", current_doghouse=(couch), previous_doghouses=[silent_treatment, snide_comments])

I get this:

Traceback (most recent call last): File "redisco_reference_test.py", line 37, in dog.save() File "/usr/local/lib/python2.7/dist-packages/redisco/models/base.py", line 324, in save self._write(_new) File "/usr/local/lib/python2.7/dist-packages/redisco/models/base.py", line 581, in _write pipeline.execute() File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1987, in execute return execute(conn, stack, raise_on_error) File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1911, in _execute_transaction self.raise_first_error(response) File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1946, in raise_first_error raise r redis.exceptions.ResponseError: ERR wrong number of arguments for 'rpush' command

However, appending an element to that list (like exampled within Redisco's tests),

daryl.previous_doghouses.append([snide_comments, cold_shoulder]) print daryl.previous_doghouses

[<Doghouse:2 {'location': u'the cold side of the bed', 'id': '2'}>, [<Doghouse:7 {'location': 'kitchen table', 'id': '7'}>, <Doghouse:8 {'location': 'everywhere', 'id': '8'}>]]

Works perfectly!