New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update for new versions of SQLAlchemy #910
Comments
Possibly related. Test suites started failing on flask-sqlalchemy 2.4.4 Stack trace:
|
Finding issues also: File "/Users/daniel/workarea/preset/Flask-AppBuilder/venv/lib/python3.7/site-packages/Flask_AppBuilder-3.2.0-py3.7.egg/flask_appbuilder/security/sqla/manager.py", line 88, in create_db
engine = self.get_session.get_bind(mapper=None, clause=None)
File "<string>", line 2, in get_bind
File "/Users/daniel/workarea/preset/Flask-AppBuilder/venv/lib/python3.7/site-packages/sqlalchemy/orm/scoping.py", line 104, in _proxied
return self.registry()
File "/Users/daniel/workarea/preset/Flask-AppBuilder/venv/lib/python3.7/site-packages/sqlalchemy/util/_collections.py", line 1010, in __call__
return self.registry.setdefault(key, self.createfunc())
File "/Users/daniel/workarea/preset/Flask-AppBuilder/venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 4027, in __call__
return self.class_(**local_kw)
File "/Users/daniel/workarea/preset/Flask-AppBuilder/venv/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 138, in __init__
bind = options.pop('bind', None) or db.engine
File "/Users/daniel/workarea/preset/Flask-AppBuilder/venv/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 943, in engine
return self.get_engine()
File "/Users/daniel/workarea/preset/Flask-AppBuilder/venv/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 962, in get_engine
return connector.get_engine()
File "/Users/daniel/workarea/preset/Flask-AppBuilder/venv/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 555, in get_engine
options = self.get_options(sa_url, echo)
File "/Users/daniel/workarea/preset/Flask-AppBuilder/venv/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 570, in get_options
self._sa.apply_driver_hacks(self._app, sa_url, options)
File "/Users/daniel/workarea/preset/Flask-AppBuilder/venv/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 914, in apply_driver_hacks
sa_url.database = os.path.join(app.root_path, sa_url.database)
AttributeError: can't set attribute SQLAlchemy 1.4.0 just got released |
Just FYI, I would strongly suggest anyone to pin sqlalchemy to <1.4 - 1.x releases in SA are generally major/breaking releases. |
This is breaking with SQLAlchemy 1.4: from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.orm import joinedload
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
manager_id = db.Column(db.Integer, db.ForeignKey('user.id'))
manager = db.relationship('User', remote_side=[id])
db.create_all()
u = User()
db.session.add(u)
db.session.commit()
u2 = User()
db.session.add(u2)
db.session.commit()
paginate = db.session.query(User, User.manager).options(joinedload(User.manager)).paginate()
Issue created on SQLAlchemy: sqlalchemy/sqlalchemy#6052 EDIT: problem fixed with sqlalchemy/sqlalchemy@1c5ec1e |
Including errors/tracebacks would be useful, and if it's just for people googling their error to find this issue... |
for the URL stuff please note url is now immutable, there was unfortunately no reasonable deprecation path for this combined with the fact that I didn't think mutation of URLs was that prevalent anyway. if flask is trying to "fix up" the arguments when the engine is created it would better if they used the event hook to do so, that way you get the arguments that are going straight to dbapi.connect() and you can deal with sqlite3 or whatever directly there. |
Here's a trace for part of flask admin, separate project? they should not be accessing private API like that, if they need class regsitry access it would have been nice if we had been tasked to create a public API
|
yes, separate project: https://github.com/flask-admin/flask-admin |
Fixed the URL issue in #933, as far as I can tell that's the only incompatibility. Will release 2.5 soon. |
SQLAlchemy 1.4 made some changes that are currently incompatible with this extension. Identify failing tests and make changes to fix those. We should also pin to
SQLAlchemy<2
, since that will be a bigger change and will be more appropriate in Flask-SQLAlchemy 3.0.Here's some that I'm aware of so far:
URL
is immutableThe text was updated successfully, but these errors were encountered: