Skip to content
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

No have paginate in session.query #22

Open
wilian746 opened this issue Jul 27, 2019 · 2 comments
Open

No have paginate in session.query #22

wilian746 opened this issue Jul 27, 2019 · 2 comments

Comments

@wilian746
Copy link

I use a method to paginate my queries but in the library I don't have this implementation whenever I use session.query(Model).paginate(page=1, per_page=10, max_per_page=100) returns an empty list. If this method is implemented I do not know how it should be applied!

In sqlalchemy we have here how the implementation is usually done in the library https://flask-sqlalchemy.palletsprojects.com/en/2.x/api/#flask_sqlalchemy.Pagination

@wilian746 wilian746 changed the title No have paginate in query No have paginate in session.query Jul 27, 2019
@wilian746
Copy link
Author

wilian746 commented Jul 27, 2019

Example how i use

    def test_check_length_is_two(self):
        self.session_unified = UnifiedAlchemyMagicMock()

        self.session_unified.add(PermissionModel(
            id="7de42c1b-7321-4042-84af-d9be3b3562f3",
            description="permission of xablau"
        ))

        self.session_unified.add(UserModel(
            id="19dc9999-9331-4212-9199-e8f2acdcbb3f",
            active=True,
            name="xablau1",
            email="[email protected]",
            password="@Xablau1",
            permission_id="7de42c1b-7321-4042-84af-d9be3b3562f3"
        ))

        self.session_unified.add(UserModel(
            id="29dc9999-9331-4212-9199-e8f2acdcbb3f",
            active=True,
            name="xablau2",
            email="[email protected]",
            password="@Xablau2",
            permission_id="7de42c1b-7321-4042-84af-d9be3b3562f3"
        ))

        self.session_unified.add(UserModel(
            id="39dc9999-9331-4212-9199-e8f2acdcbb3f",
            active=True,
            name="xablau3",
            email="[email protected]",
            password="@Xablau3",
            permission_id="7de42c1b-7321-4042-84af-d9be3b3562f3"
        ))

        data = self.session_unified.query(UserModel).paginate(page=1, per_page=2, max_per_page=100)

       # Broken because return an Empty List
        self.assertEqual(len(data), 2)

@shosca
Copy link
Collaborator

shosca commented Jul 28, 2019

@miki725, there's no paginate method on sqlalchemy's query, its only available on flask-sqlalchemy's query implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants