Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-26 Thread Антонио Антуан
Yes, it works. I'm grateful for your help :) ср, 25 окт. 2017 г. в 16:56, Mike Bayer : > On Wed, Oct 25, 2017 at 9:25 AM, Антонио Антуан > wrote: > > As I said befire, sqlalchemy version: 1.0.19 and code is here: > > https://gist.github.com/aCLr/113ac292c05bdb01e964d8e9884d6e5f > > I apologize,

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-25 Thread Mike Bayer
On Wed, Oct 25, 2017 at 9:25 AM, Антонио Антуан wrote: > As I said befire, sqlalchemy version: 1.0.19 and code is here: > https://gist.github.com/aCLr/113ac292c05bdb01e964d8e9884d6e5f I apologize, did not see that link. Use the execute_and_instances() implemenation from lib/sqlalchemy/orm/query.

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-25 Thread Антонио Антуан
As I said befire, sqlalchemy version: 1.0.19 and code is here: https://gist.github.com/aCLr/113ac292c05bdb01e964d8e9884d6e5f Currently I can't use another version. In that case, I think that here is the right decision: "Looks like I have to check if "_mapper_zero()" returns real mapper. Otherwise

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-25 Thread Mike Bayer
On Wed, Oct 25, 2017 at 6:52 AM, Антонио Антуан wrote: > Any news here? We would require a self-contained demonstration case that illustrates your error as well as complete information on what specific SQLAlchemy version you are targeting. As mentioned in a different reply, _mapper_zero has been

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-25 Thread Mike Bayer
On Wed, Oct 25, 2017 at 8:02 AM, Антонио Антуан wrote: > Looks like I have to check if _mapper_zero() returns real mapper. _mapper_zero() in the 1.1 and 1.2 series will never return a non-mapper (see https://bitbucket.org/zzzeek/sqlalchemy/issues/3608). I would strongly advise working with the

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-25 Thread Simon King
This is complete guesswork - I haven't examined this code in detail so I could be wrong. Also, I don't know what version of SQLAlchemy you are using, so this may not apply. Session.connection takes separate "mapper" and "clause" parameters: https://bitbucket.org/zzzeek/sqlalchemy/src/f34b180ca905

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-25 Thread Антонио Антуан
Looks like I have to check if _mapper_zero() returns real mapper. Otherwise I should pass None to "_connection_from_session()" as value of "mapper" argument. Right? ср, 25 окт. 2017 г. в 15:00, Антонио Антуан : > As I mentioned before, " group_getter>". > > ср, 25 окт. 2017 г. в 14:19, Simon King

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-25 Thread Антонио Антуан
As I mentioned before, "". ср, 25 окт. 2017 г. в 14:19, Simon King : > What does self._mapper_zero() return in your > RoutingQuery._execute_and_instances method? > > Simon > > On Wed, Oct 25, 2017 at 11:52 AM, Антонио Антуан > wrote: > > Any news here? > > > > суббота, 21 октября 2017 г., 18:42:

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-25 Thread Simon King
What does self._mapper_zero() return in your RoutingQuery._execute_and_instances method? Simon On Wed, Oct 25, 2017 at 11:52 AM, Антонио Антуан wrote: > Any news here? > > суббота, 21 октября 2017 г., 18:42:47 UTC+3 пользователь Антонио Антуан > написал: >> >> I see that it is not happened when

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-25 Thread Антонио Антуан
Any news here? суббота, 21 октября 2017 г., 18:42:47 UTC+3 пользователь Антонио Антуан написал: > > I see that it is not happened when "bind" passed directly to > "sessionmaker" > > сб, 21 окт. 2017 г. в 18:33, Антонио Антуан : > >> >> >> пятница, 20 октября 2017 г., 20:50:52 UTC+3 пользователь

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-21 Thread Антонио Антуан
I see that it is not happened when "bind" passed directly to "sessionmaker" сб, 21 окт. 2017 г. в 18:33, Антонио Антуан : > > > пятница, 20 октября 2017 г., 20:50:52 UTC+3 пользователь Mike Bayer > написал: > >> On Fri, Oct 20, 2017 at 11:05 AM, Simon King >> wrote: >> > The "is not None" is imp

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-21 Thread Антонио Антуан
пятница, 20 октября 2017 г., 20:50:52 UTC+3 пользователь Mike Bayer написал: > > On Fri, Oct 20, 2017 at 11:05 AM, Simon King > wrote: > > The "is not None" is important when checking a variable that may > > contain a ClauseElement, precisely because ClauseElement defines that > > __bool__ me

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-20 Thread Mike Bayer
On Fri, Oct 20, 2017 at 11:05 AM, Simon King wrote: > The "is not None" is important when checking a variable that may > contain a ClauseElement, precisely because ClauseElement defines that > __bool__ method. > > However, in Session.get_bind(), "mapper" is not supposed to contain a > ClauseElemen

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-20 Thread Simon King
The "is not None" is important when checking a variable that may contain a ClauseElement, precisely because ClauseElement defines that __bool__ method. However, in Session.get_bind(), "mapper" is not supposed to contain a ClauseElement. It should either be an instance of sqlalchemy.orm.mapper.Mapp

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-20 Thread Антонио Антуан
Really, `mapper` contains this: . But does it changes something? I already encountered this problem in my code, when I checked sqla-objects existance without "is not None", project was broken. Is it normal to omit that condition in sqlalchemy code? I use: >>> sqlalchemy.__version__ '1.0.19' пя

Re: [sqlalchemy] mapper existance checks possibly wrong

2017-10-20 Thread Simon King
On Fri, Oct 20, 2017 at 2:15 PM, Антонио Антуан wrote: > Hi. > I use my own `RoutingSession` and `RoutingQuery` implementation, most of it > inspired by `sqlalchemy.ext.horizontal_shard`: > > class RoutingSession(Session): > def get_bind(self, mapper=None, clause=None, shard_id=None, **kwargs)