[sqlalchemy] delete of polymorphic objects leaves orphaned parent objects

2019-10-11 Thread natsjoo sodillepa
Hi all, We have a list of polymorphic objects from which delete object does not work, not matter what we try. The situation: class ItemGroup(Base): __tablename__ = 'item_group' __table_args__ = ( UniqueConstraint('model_id', 'item_group_color_id', name='unique_model_id_item_grou

Re: [sqlalchemy] Slow entities pickling for caching purposes

2019-10-11 Thread Александр Егоров
Thank you very much for your answers! Some more questions 1) I see you use sa.inspect(self).dict in __getstate__. Is it safe to replace it with self.__dict__? I didn't find any difference in the result, but __dict__ works 30 times faster. 2) I'm going to implement __getstate__ and __setstate__ i

Re: [sqlalchemy] delete of polymorphic objects leaves orphaned parent objects

2019-10-11 Thread Simon King
You haven't given a complete script to reproduce the problem, so I'm not certain what happened. The following is just a guess You are using query(...).delete() with joined-table inheritance, which has a lot of caveats in the docs: https://docs.sqlalchemy.org/en/13/orm/query.html#sqlalchemy.o

Re: [sqlalchemy] delete of polymorphic objects leaves orphaned parent objects

2019-10-11 Thread natsjoo sodillepa
Hi Simon, Thank you for your reply. I've tried all the variant I could think of, also eg for item in items: session.delete(it), with and without remove on the list of items, all known mapper and relation params but nothing. However, I've tried a similar structure from examples from the web and

Re: [sqlalchemy] Slow entities pickling for caching purposes

2019-10-11 Thread Mike Bayer
On Fri, Oct 11, 2019, at 5:23 AM, Александр Егоров wrote: > Thank you very much for your answers! > > Some more questions > 1) I see you use sa.inspect(self).dict in __getstate__. Is it safe to replace > it with self.__dict__? I didn't find any difference in the result, but > __dict__ works 30

Re: [sqlalchemy] boud parameter to NCHAR column in Oracle

2019-10-11 Thread Victor Olex
A bit of advocacy from my side on cx_Oracle: https://github.com/oracle/python-cx_Oracle/issues/365 Mike, there's something you might want to look at. We have this monkey patch on SQLAlchemy in our recent code, which was necessary to get the correct behavior for NCHAR columns. from sqlalchemy.d

Re: [sqlalchemy] boud parameter to NCHAR column in Oracle

2019-10-11 Thread Mike Bayer
On Fri, Oct 11, 2019, at 3:56 PM, Victor Olex wrote: > A bit of advocacy from my side on cx_Oracle: > https://github.com/oracle/python-cx_Oracle/issues/365 > > Mike, there's something you might want to look at. We have this monkey patch > on SQLAlchemy in our recent code, which was necessary t

Re: [sqlalchemy] Slow entities pickling for caching purposes

2019-10-11 Thread Alexander Egorov
I've considered manual queries and building classes by myself. This option is good in terms of performance, but it requires a lot of code duplication and kills code reuse. So I want to use the same mapper classes for both read and modify operations. Also, I want to have the same query descripti