You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i was testing something out and came across something of which i think is unintended.
in the file litestar/contrib/sqlalchemy/repository/_async.py specifically the function exists()
the function eventually calls self.count method which accepts filters.
however the function exists() doesn't accept *args ( or *filters in this case). (this is the same for the sync variant).
I tested it out with overriding this function and the behaviour that i was expecting seems to work then with filters.
signature of the function count() that exists() calls
asyncdefexists(self, **kwargs: Any) ->bool:
"""Return true if the object specified by ``kwargs`` exists. Args: **kwargs: Identifier of the instance to be retrieved. Returns: True if the instance was found. False if not found.. """existing=awaitself.count(**kwargs)
returnexisting>0
overrided and working
asyncdefexists(self, *filters: FilterTypes, **kwargs: Any) ->bool:
"""Return true if the object specified by ``kwargs`` exists. Args: *filters: Types for specific filtering operations. **kwargs: Identifier of the instance to be retrieved. Returns: True if the instance was found. False if not found.. """existing=awaitself.count(*filters, **kwargs)
returnexisting>0
just wanted to know if was a bug/oversight for this functionality so that i can open a pull request.
URL to code causing the issue
No response
MCVE
# Your MCVE code here
Steps to reproduce
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
Screenshots
"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"
Logs
No response
Litestar Version
2.0
Platform
Linux
Mac
Windows
Other (Please specify in the description above)
Funding
If you would like to see an issue prioritized, make a pledge towards it!
We receive the pledge once the issue is completed & verified
The text was updated successfully, but these errors were encountered:
)
* fixed exists() method for sqlalchemy sync and async.
also changed the functions in the repository abc. and the generic_mock_repository.py. that one used get_one_or_none that doesn't seem right
* added tests that give a filter argument in the mock_repository and test_sqlalchemy.py.
---------
Co-authored-by: niels van hooij <niels.vanhooij@kpn.com>
Description
Hi There.
i was testing something out and came across something of which i think is unintended.
in the file litestar/contrib/sqlalchemy/repository/_async.py specifically the function exists()
the function eventually calls self.count method which accepts filters.
however the function exists() doesn't accept *args ( or *filters in this case). (this is the same for the sync variant).
I tested it out with overriding this function and the behaviour that i was expecting seems to work then with filters.
signature of the function count() that exists() calls
original code:
overrided and working
just wanted to know if was a bug/oversight for this functionality so that i can open a pull request.
URL to code causing the issue
No response
MCVE
# Your MCVE code here
Steps to reproduce
Screenshots
"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"
Logs
No response
Litestar Version
2.0
Platform
Funding
The text was updated successfully, but these errors were encountered: