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

Can mock-alchemy or alchemy-mock be used to mock session.execute(selectObject).where(...).scalars.fetchAll? #160

Open
RobertHana opened this issue Oct 12, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@RobertHana
Copy link

https://stackoverflow.com/q/69546839/6429049?sem=2

Can mock-alchemy or alchemy-mock be used to mock the following:

def fetch() -> List[MyEntity]:
  selectObject = sqlalchemy.select(MyEntity)
  with sqlalchemy.orm.Session(engine) as session:
    results = session.execute(selectObject)
    instances = results.scalars().fetchall()
    return instances
@RobertHana RobertHana added the bug Something isn't working label Oct 12, 2021
@RobertHana RobertHana changed the title Can mock-alchemy or alchemy-mock be used to mock the following: def fetch() -> List[MyEntity]: selectObject = sqlalchemy.select(MyEntity) with sqlalchemy.orm.Session(engine) as session: results = session.execute(selectObject) instances = results.scalars().fetchall() return instances Can mock-alchemy or alchemy-mock be used to mock session.execute(selectObject).where(...).scalars.fetchAll? Oct 12, 2021
@rajivsarvepalli
Copy link
Owner

No, this is not supported as of yet.

I can look into adding fetchall() natively on all returned scalars, but I am not sure of the effort required and interest in such a feature. The unified core is also a request feature that I will look into: #134 .

@rajivsarvepalli rajivsarvepalli added enhancement New feature or request and removed bug Something isn't working labels Oct 18, 2021
@kentbull
Copy link

I would like this feature.

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

No branches or pull requests

3 participants