* chore(typing): type filters
* chore(typing): type filters for get_list et al
* fix: dashboard chart filter expression
* test: fix case with new-style right hand object to equality check
* chore: place new typed filter under typing verification
* chore: remove debug print statment
* chore: inverse logic of type guard
* fix: add float to filter value types
* chore: clarify value naming
* fix: meta
* fix: test case
save is required:
1. Fetch values
```python
def get_invalid_links(self, is_submittable=False):
"""Return list of invalid links and also update fetch values if not set."""
...
```
2. Is triggered by
```python
def _validate_links(self):
if self.flags.ignore_links or self._action == "cancel":
return
...
```
3. Which is triggered by either `_save` or `insert`
----
`reload` does not trigger link fetch
```python
def reload(self) -> "Self":
"""Reload document from database"""
return self.load_from_db()
```
Neither does the new calling path which does not excempt Document
from caching when initializing meta.
It can be proven that this revert would be an alternative fix. But this
seems design by accident and there's no preceivable reason to excempt
Document args from being cached normally.
diff --git a/frappe/model/meta.py b/frappe/model/meta.py
index c4321f0128..87452c812c 100644
--- a/frappe/model/meta.py
+++ b/frappe/model/meta.py
@@ -70,11 +70,10 @@ def get_meta(doctype: str | dict | DocRef, cached=True) -> "_Meta":
Returns:
Meta object for the given doctype.
"""
- if cached and (
- doctype_name := getattr(doctype, "doctype", doctype)
- if not isinstance(doctype, dict)
- else doctype.get("doctype")
- ):
+ if cached and not isinstance(doctype, Document):
+ doctype_name = (
+ getattr(doctype, "doctype", doctype) if not isinstance(doctype, dict) else doctype.get("doctype")
+ )
if meta := frappe.cache.hget("doctype_meta", doctype_name):
return meta
Therefore, we comply the test.
* fix: Apply read_only_method decorator to Document methods
* fix: update tests for read-only document context manager
* refactor: place mappers into read-only mode
Reapply "refactor: place mappers into read-only mode"
This reverts commit a8208d57069c63f0982bf2881bcad28a4b349f3c.
read-only mode is now thread safe
Because of large common prefix hash naming becomes "too sequential" when
doing a lot of concurrent writes.
I don't know a good tradeoff between both use cases:
1. Lots of reads - prefers large shared prefix.
2. Lots of writes - prefers small shared prefix.
But as of now this punishes writes too badly in form of excessive
locking. Until a better fix is found, it's better to keep it prefix free.
---
A better fix would be a tradeoff of between these two:
1. Reads - temporal locality should result in spatial locality on disk.
2. Writes - temporal locality should NOT result in spatial locality.
temporal locality = data inserted around same time
spatial locality = data sits next to each other in DB pages.
This can be achieved by adding a small request/job specific part to
prefix so each concurrent request has it's own different locality when
writing data.
* refactor: prefer staticmethod decorator
* refactor: add cm register utility and keep cms in one file
* refactor: enter safe_exec enabled context (treewide)
* refactor: move trace fields to the other test context managers
* chore: marke all test_runner functions for deprecation
* chore: mark some tests.utils functions for deprecation (moved)
* chore: mark traced_field_conext for deprecation (moved)
* chore: placate semgrep in dumpster
* fix: show deprecation warnings per module in tests (incl. from dumpster)
* chore: remove use of deprecated functions from tests
* refactor: improve maintainability with a simple dispatcher
* refactor: improve maintainability with a init dispatcher on Document
* refactor: improve maintainability with an init dispatcher on meta