flask-sqlalchemy
flask-sqlalchemy copied to clipboard
Implemented first and last property for pagination
Added first and last property to the pagination class and relevant tests.
Relevant issue: #567
Travis failed because of python 2.6 no longer being supported by SQLAlchemy see #587.
This will need to get rebased on #687 once it gets merged. Then, assuming tests still pass, I think this PR is GTG.
Unfortunately, after rebasing this PR onto the 2.x maintenance branch and running tox locally, I periodically see an exception thrown from the 2.7-lowest tox run:
Traceback (most recent call last):
File "/home/rsyring/projects/flask-sqlalchemy/tests/test_sessions.py", line 33, in test_session_scoping_changing
assert fb not in db.session # because a new scope is generated on each call
AssertionError: assert <FOOBar (transient 140174734162512)> not in <sqlalchemy.orm.scoping.scoped_session object at 0x7f7cf943bd10>
+ where <sqlalchemy.orm.scoping.scoped_session object at 0x7f7cf943bd10> = <SQLAlchemy engine=<sqlalchemy.engine.url.URL object at 0x7f7cf93c76d0>>.session
I've not had time to look into it further and don't think this should hold up the 2.4 release. If it ends up being a quick fix, I'm happy to release it with 2.4. But if not, I'm going to bump the milestone to 2.x.
For what it's worth I am able to locally reproduce that intermittently-failing test on latest master 42d40b3f7e11d58b05d42ee172464a782ca8ec92/(3.0.0.dev) on Python 3.7 and 2.7, so perhaps not related to the PR?
Unfortunately that's about all I bring to the table right now as I just stumbled in here from a google search and cloned/ran the tests, but hopefully a useful as a datapoint at least.
platform darwin -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
=================================================== FAILURES ===================================================
________________________________________ test_session_scoping_changing _________________________________________
tests/test_sessions.py:33: in test_session_scoping_changing
assert fb not in db.session # because a new scope is generated on each call
E assert <FOOBar (transient 4469726008)> not in <sqlalchemy.orm.scoping.scoped_session object at 0x10a305860>
E + where <sqlalchemy.orm.scoping.scoped_session object at 0x10a305860> = <SQLAlchemy engine=sqlite:///:memory:>.session
I ended up implementing this a little differently in #1098 to account for a few other things such as the last page not having a full page of items.