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

Filtering and pagination return no results #97

Open
PaulWaldo opened this issue May 28, 2021 · 1 comment
Open

Filtering and pagination return no results #97

PaulWaldo opened this issue May 28, 2021 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@PaulWaldo
Copy link

Describe the bug
using limit or offset causes results to be empty

To Reproduce
Code to reproduce the error.

def test_working():
    Base = declarative_base()
    class SomeClass(Base):
        __tablename__ = "some_table"
        pk1 = Column(String, primary_key=True)
        name = Column(String(50))

    def __repr__(self):
        return str(self.pk1)

    mock_session = UnifiedAlchemyMagicMock()
    sc = SomeClass(pk1="123", name="test")
    mock_session.add(sc)
    result = mock_session.query(SomeClass).all()
    assert len(result) == 1
    result = mock_session.query(SomeClass).limit(10).all()
    assert len(result) == 1

    # This fails "assert 0 == 1"
    result = mock_session.query(SomeClass).filter(SomeClass.pk1 == "123")
    assert len(result) == 1

    # This fails "assert 0 == 1"
    result = mock_session.query(SomeClass).offset(0).all()
    assert len(result) == 1

Expected behavior
See tests

Screenshots
NA

Desktop (please complete the following information):

  • OS: macOS Big Sur
  • Version mock-alchemy==0.2.2

Additional context
Add any other context about the problem here.

@PaulWaldo PaulWaldo added the bug Something isn't working label May 28, 2021
@rajivsarvepalli rajivsarvepalli added the enhancement New feature or request label May 29, 2021
@rajivsarvepalli
Copy link
Owner

As of right now, this is one of the many features missing from mock-alchemy. Both limit and offset are not supported features of this library. This is something worth adding, so I will work at some point to add these features. If you have a good idea of how to add this, feel free to open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants