flask-sqlalchemy icon indicating copy to clipboard operation
flask-sqlalchemy copied to clipboard

get_bind does not check the instance of its "mapper" attribute

Open nikoskaragiannakis opened this issue 7 years ago • 0 comments

I've been using sqlalchemy in the past and recently I've been experimenting with flask-sqlalchemy (using sqlalchemy's declarative system for my models).

When I make a raw sql query, I have to get the mapper for my declarative class (let's call it MyModel in the example) via inspect function in order to get a binding

        response = session.execute(my_raw_sql_query,
                                   ...,
                                   bind=session.get_bind(inspect(MyModel)))

because get_bind in flask-sqlalchemy expects a Mapper object https://github.com/mitsuhiko/flask-sqlalchemy/blob/f465142ea1643b4f0fe50540780ef9a6bf2c7e53/flask_sqlalchemy/init.py#L157

However, I didn't need to do that with base method sqlalchemy.orm.session.get_bind which does the inspection.

My question is why doesn't the flask-sqlalchemy's get_bind follow the flexibility of the base method?

nikoskaragiannakis avatar Jan 29 '18 00:01 nikoskaragiannakis