kvesteri / sqlalchemy-continuum

Versioning extension for SQLAlchemy.
BSD 3-Clause "New" or "Revised" License
575 stars 127 forks source link

Fix close_all deprecation warning #279

Closed edhaz closed 2 years ago

edhaz commented 2 years ago

session.close_all() has been deprecated in favour of orm.close_all_sessions()

After: 659 passed, 99 skipped, 4090 warnings

Before: 659 passed, 99 skipped, 4745 warnings

edhaz commented 2 years ago

@marksteward Could do with a re-run of the CI when you get a chance on this and #277 as the issue with flaks-login has had a new version pushed out :)

marksteward commented 2 years ago

Going to need to dig into this, I'm not sure if it's due to flask-login changes or close_all_sessions:

=================================== FAILURES ===================================
________________ TestFlaskPlugin.test_versioning_inside_request ________________

self = <tests.plugins.test_flask.TestFlaskPlugin object at 0x7fde0ef38be0>

    def test_versioning_inside_request(self):
        user = self.User(name=u'Rambo')
        self.session.add(user)
        self.session.commit()
        self.login(user)
        self.client.get(url_for('.test_simple_flush'))

        article = self.session.query(self.Article).first()
        tx = article.versions[-1].transaction
>       assert tx.user.id == user.id
E       AttributeError: 'NoneType' object has no attribute 'id'
edhaz commented 2 years ago

Going to need to dig into this, I'm not sure if it's due to flask-login changes or close_all_sessions:

=================================== FAILURES ===================================
________________ TestFlaskPlugin.test_versioning_inside_request ________________

self = <tests.plugins.test_flask.TestFlaskPlugin object at 0x7fde0ef38be0>

    def test_versioning_inside_request(self):
        user = self.User(name=u'Rambo')
        self.session.add(user)
        self.session.commit()
        self.login(user)
        self.client.get(url_for('.test_simple_flush'))

        article = self.session.query(self.Article).first()
        tx = article.versions[-1].transaction
>       assert tx.user.id == user.id
E       AttributeError: 'NoneType' object has no attribute 'id'

Yeah looks like it's an issue with using flask-login 0.6.2, tried it on master and the test fails there. I'll have a little look to see if there's a workaround/actual issue there.

marksteward commented 2 years ago

Rebased and merged, thanks for this!