Skip to content

Fix TypeError when working with nested maps [JIRA: CLIENTS-417] - #402

Merged
hazen merged 1 commit into
basho:masterfrom
nrvnrvn:CLIENTS-349
Dec 21, 2015
Merged

Fix TypeError when working with nested maps [JIRA: CLIENTS-417]#402
hazen merged 1 commit into
basho:masterfrom
nrvnrvn:CLIENTS-349

Conversation

@nrvnrvn

@nrvnrvn nrvnrvn commented Apr 16, 2015

Copy link
Copy Markdown
Contributor

Fixes #401 (CLIENTS-349)

@hazen

hazen commented Apr 16, 2015

Copy link
Copy Markdown

@nicorevin Could you please add a test case for your change? That would help me to verify. Thanks!

@nrvnrvn

nrvnrvn commented Apr 16, 2015

Copy link
Copy Markdown
Contributor Author

@javajolt I've added. See riak/tests/test_datatypes.py

@hazen

hazen commented Apr 16, 2015

Copy link
Copy Markdown

Sorry, I missed it. Thanks!

@hazen

hazen commented Apr 16, 2015

Copy link
Copy Markdown

👍 4dca64c

borshop added a commit that referenced this pull request Apr 16, 2015
Fix TypeError when working with nested maps

Reviewed-by: javajolt
@hazen

hazen commented Apr 16, 2015

Copy link
Copy Markdown

Looks like make lint failed. I'm guessing this is a newer version of pep8. I'll create a new PR to address that.

@hazen

hazen commented Apr 16, 2015

Copy link
Copy Markdown

@borshop: merge

@nrvnrvn

nrvnrvn commented Apr 17, 2015

Copy link
Copy Markdown
Contributor Author

By the way, is it ok that modified attribute does not correspond with _updates and to_op() is None?
Even without this PR we have the following picture:

In [1]: from riak import RiakClient
In [2]: c = RiakClient()
In [3]: b = c.bucket_type('maps').bucket('wow')
In [4]: m = b.get('key')
In [5]: m.__dict__
Out[5]: 
{'_context': None,
 '_removes': set(),
 '_updates': {},
 '_value': {},
 'bucket': <RiakBucket 'maps'/'wow'>,
 'key': 'key'}

In [6]: m.maps['a']
Out[6]: <riak.datatypes.map.Map at 0x7fad9a294c50>
In [7]: m.flags['b']
Out[7]: <riak.datatypes.flag.Flag at 0x7fad99be8668>
In [8]: m.registers['c']
Out[8]: <riak.datatypes.register.Register at 0x7fad99be8278>
In [9]: m.counters['d']
Out[9]: <riak.datatypes.counter.Counter at 0x7fad99be8630>

In [10]: m._updates
Out[10]: 
{('a', 'map'): <riak.datatypes.map.Map at 0x7fad9a294c50>,
 ('b', 'flag'): <riak.datatypes.flag.Flag at 0x7fad99be8668>,
 ('c', 'register'): <riak.datatypes.register.Register at 0x7fad99be8278>,
 ('d', 'counter'): <riak.datatypes.counter.Counter at 0x7fad99be8630>}

In [11]: m.to_op()
# None

In [12]: m.modified
Out[12]: True

In [13]: m.context
# None

Of course if we call m.update() we catch No operation to send exception.
It means we know we have nothing to commit but we set the modified flag to true and keep the stack of local changes that will never ever be commited. Why?
P.S. Other datatypes meet the self.modified == (self.to_op() is not None) rule.

@nrvnrvn

nrvnrvn commented Apr 21, 2015

Copy link
Copy Markdown
Contributor Author

Updated pull request regarding my last comment.

@nrvnrvn

nrvnrvn commented May 27, 2015

Copy link
Copy Markdown
Contributor Author

Hi! Any updates?

@hazen

hazen commented May 27, 2015

Copy link
Copy Markdown

Hmmm... Looks like it tried to get merged on April 16th, but I see no successful merge messages. Looks like our merge tool does not work on other repos. Let me look at your subsequent changes now, too.

@Basho-JIRA Basho-JIRA changed the title Fix TypeError when working with nested maps Fix TypeError when working with nested maps [JIRA: CLIENTS-417] May 27, 2015
@nrvnrvn

nrvnrvn commented Dec 21, 2015

Copy link
Copy Markdown
Contributor Author

We've been successfully using this patch for more than half a year.
Any chances for this to be merged into upstream?

@Basho-JIRA Basho-JIRA assigned lukebakken and hazen and unassigned lukebakken Dec 21, 2015
hazen pushed a commit that referenced this pull request Dec 21, 2015
Fix TypeError when working with nested maps [JIRA: CLIENTS-417]
@hazen
hazen merged commit cc77cba into basho:master Dec 21, 2015
@nrvnrvn
nrvnrvn deleted the CLIENTS-349 branch December 23, 2015 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Updating nested maps raises TypeError [JIRA: CLIENTS-349]

4 participants