AttributeError: 'SQLLeaguePosition' object has no attribute 'delete'
Closed this issue · 4 comments
Hi,
While storing some matches + league position data I encountered the following exception. It looks like the code is trying to clean out old data from the sql store but the delete method is not implemented. I can't seem to find any other references to a delete()
call.
I'm happy to make a pull to fix this, but I'm not sure what the desired behavior is.
> Exception in thread Thread-1:
Traceback (most recent call last):
File "/Users/brendanroy/.pyenv/versions/3.6.5/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/Users/brendanroy/git/rito-nn/worker.py", line 54, in run
for league in part.summoner.league_positions:
File "/Users/brendanroy/.pyenv/versions/3.6.5/lib/python3.6/site-packages/merakicommons/container.py", line 354, in __iter__
yield next(self)
File "/Users/brendanroy/.pyenv/versions/3.6.5/lib/python3.6/site-packages/merakicommons/container.py", line 365, in __next__
value = next(self._generator)
File "/Users/brendanroy/.pyenv/versions/3.6.5/lib/python3.6/site-packages/cassiopeia/datastores/ghost.py", line 569, in league_entries_generator
data = context[context.Keys.PIPELINE].get(LeaguePositionsData, query)
File "/Users/brendanroy/.pyenv/versions/3.6.5/lib/python3.6/site-packages/datapipelines/pipelines.py", line 459, in get
return handler.get(query, context)
File "/Users/brendanroy/.pyenv/versions/3.6.5/lib/python3.6/site-packages/datapipelines/pipelines.py", line 190, in get
sink.put(result, context)
File "/Users/brendanroy/.pyenv/versions/3.6.5/lib/python3.6/site-packages/datapipelines/pipelines.py", line 140, in put
self._sink.put(self._store_type, item, context)
File "/Users/brendanroy/.pyenv/versions/3.6.5/lib/python3.6/site-packages/datapipelines/sinks.py", line 62, in wrapper
return call(self, items, context=context)
File "/Users/brendanroy/git/rito-nn/src/cassiopeia-sqlstore/cassiopeia-sqlstore/cassiopeia_sqlstore/SQLStore.py", line 499, in put_league_positions
old_positions[i].delete()
AttributeError: 'SQLLeaguePosition' object has no attribute 'delete'
League/LeaguePosition data is pretty weird to work with. There are some edge cases that need to be handled correctly. Hopefully me, you, or @Satrium can think about this when one of us gets a chance. I don't know off the top of my head what we need to do because I haven't thought about it in a while. We'll also need to be careful not to be modifying the list we are iterating over in the line of code you linked (right now it looks like it will skip some elements in the list if something is deleted).
@Satrium cool sounds good if you get some time later on! In the mean time I'll try to think about it a bit. Enjoy and talk to you when you get back!
Because I'm currently on vacation i don't have a development environment setup, so can't test if this is working, but i think this
should be
self._session().delete(old_positions[i])
would be nice if someone could test that.