-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow extended from_kwargs calls & small fixes (#218)
Changes: - from_kwargs supports now complex kwargs like in queryset - failure querying when using proxy model table and kwargs - proxy and main model use now the same tables - model_class in query is always not a proxy model - fix stacklevel of performance warning - deprecate passing an object for from_kwargs - add dedicated warning for unconnected databases - document and test the performance warning - bump version
- Loading branch information
Showing
14 changed files
with
450 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -275,10 +275,10 @@ For this there is an extension of edgy's `and_` and `or_` which takes a model or | |
matches kwargs against: | ||
|
||
```python | ||
users = await User.query.filter(and_.from_kwargs(User, name="foo", email="[email protected]")) | ||
users = await User.query.filter(and_.from_kwargs(name="foo", email="[email protected]")) | ||
# or | ||
|
||
users = await User.query.filter(and_.from_kwargs(User, **my_dict)) | ||
users = await User.query.filter(and_.from_kwargs(**my_dict)) | ||
``` | ||
|
||
#### OR | ||
|
@@ -1126,8 +1126,36 @@ sql types because otherwise some features are not supported or cause warnings. | |
|
||
## Debugging | ||
|
||
### Getting the SQL query | ||
|
||
QuerySet contains a cached debug property named `sql` which contains the QuerySet as query with inserted blanks. | ||
|
||
### Performance warnings | ||
|
||
Edgy issues a `DatabaseNotConnectedWarning` when using edgy without a connected database. To silence it, wrap the affected | ||
code in a database scope | ||
|
||
``` python | ||
await model.save() | ||
# becomes | ||
async with model.database: | ||
await model.save() | ||
``` | ||
|
||
If the warning is completely unwanted despite the performance impact, you can filter: | ||
|
||
``` python | ||
import warnings | ||
from edgy.exceptions import DatabaseNotConnectedWarning | ||
with warnings.catch_warnings(action="ignore", category=DatabaseNotConnectedWarning): | ||
await model.save() | ||
``` | ||
|
||
It inherits from `UserWarning` so it is possible to filter UserWarnings. | ||
|
||
However the silencing way is not recommended. | ||
|
||
|
||
[model]: ../models.md | ||
[managers]: ../managers.md | ||
[lambda statements](https://docs.sqlalchemy.org/en/20/core/sqlelement.html#sqlalchemy.sql.expression.lambda_stmt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = "0.21.0" | ||
__version__ = "0.21.1" | ||
|
||
from .cli.base import Migrate | ||
from .conf import settings | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.