Commit graph

289 commits

Author SHA1 Message Date
Sagar Vora
a93530e221 Merge branch 'develop' into computed_child_table 2025-10-14 12:53:32 +05:30
Sagar Vora
a084f5a2f3 refactor: separate only computed CTs, with new include_computed flag 2025-10-14 12:31:47 +05:30
Sagar Vora
2c9c6c0fd5 fix: correct table_fields references 2025-10-01 12:25:00 +05:30
Ejaaz Khan
03ac6e2f75 refactor: fetch mask field from cache instead of meta 2025-09-21 19:09:32 +05:30
Sagar Vora
dddfe7a02f fix: more foolproof implementation for virtal ct 2025-09-10 13:27:35 +05:30
barredterra
76c04fef27 refactor: move virtual child table check into get_table_fields 2025-09-10 12:07:47 +05:30
Ejaaz Khan
c2544f9096 refactor: change approach of masking fields 2025-08-18 23:38:18 +05:30
mergify[bot]
0312cb7eb4
Merge branch 'develop' into 32489-role-perm-based-masking 2025-06-25 17:17:30 +00:00
Sagar Vora
18dde69ab0 perf: dont serialize caches 2025-06-21 20:54:11 +05:30
Sagar Vora
d9fc9f21f9 perf: faster meta serialisation 2025-06-21 20:12:39 +05:30
Ejaaz Khan
4613129c4c fix: don't mask fields in patch, install or in migrate state 2025-06-11 20:38:29 +05:30
Ejaaz Khan
aba7f29aa6 refactor: remove debugging statement 2025-06-10 19:54:13 +05:30
Ejaaz Khan
1d96a933cb
Merge branch 'develop' into 32489-role-perm-based-masking 2025-06-10 19:46:20 +05:30
Ejaaz Khan
ed0071df9e feat: export encrypted data and add system setting 2025-06-10 19:42:49 +05:30
Ankush Menat
e4bc7f361b
Revert: DocRef (#32866)
- Hardly used anywhere
- Too many hardcoded `__value__` calls without which it's not usable.
- Another type to worry about
2025-06-10 05:20:56 +00:00
Ankush Menat
7d7d77d762
perf: misc small cruft (#32778)
* perf: cache docstatus check for invalid links

* perf: avoid querying if doctype is single

* perf: cache is_single
2025-06-04 19:18:19 +05:30
Ejaaz Khan
a4fbe0160e feat: show mask data in form, list and report view 2025-05-27 13:16:27 +05:30
Sagar Vora
beeeed4160 revert: meta signature 2025-04-12 18:29:25 +05:30
Sagar Vora
7421ffa79a feat: use cached_property without locks on all supported Python versions 2025-04-11 13:21:27 +05:30
Sagar Vora
628ddfd494 perf: remove repeated calls to get_permitted_fieldnames 2025-03-16 23:39:46 +05:30
Sagar Vora
32ff002c32 fix: revert valid columns cache
it is used only once when initialising doc
2025-03-16 01:10:29 +05:30
Sagar Vora
aae5860efc perf: faster init_valid_columns 2025-02-25 13:20:35 +05:30
Ankush Menat
7721fdb054
fix: clear cache using client_cache (#31420)
It's faster than relying on indirect invalidations. This was avoided
before only because delete_keys didn't exist on client_cache.
2025-02-25 06:43:39 +00:00
Sagar Vora
26b5d8de15 perf: better _table_fieldnames cache 2025-02-24 17:41:00 +05:30
Ankush Menat
7f0394bf86
fix: short-circuit large table checks (#31223)
This can become super slow on child tables, so first check if it's worth "checking" data.
2025-02-11 10:09:29 +00:00
Ankush Menat
ef3b0ef008
perf: Only filter last 3 months of data by default on large tables (#31216)
Applying something basic like `order id like xyz` filter can result in
full table scan on years of data. This isn't necessary most of the time.

Interactive queries are usually done on recent data, so add this filter
to ensure only recent data is checked first.

Users can remove this filter if they want to.
2025-02-11 09:24:08 +00:00
Sandeep Kakde
165968714d
fix: update cache key for table_columns to new format (#31179) 2025-02-07 17:19:02 +05:30
Ankush Menat
8eafe67805 feat: share table size heuristic with meta 2025-02-03 09:29:31 +05:30
Ankush Menat
4e4972fe2d
refactor: Use @cached_property (#29212) 2025-01-17 06:09:05 +00:00
Ankush Menat
e6bad301b8 refactor: Use @cached_property instead of implmenting it 2025-01-16 19:19:56 +05:30
Ankush Menat
b3859d9fa3 fix: Don't assume homogeneous data in meta tables
Steps to reproduce:
- enable developer mode (doesn't happen in prod)
- Save a document with set only once fields
- Reload the page (requests meta again which is now polluted)

This is new category of bug surfaced because meta objects now live
longer than request and all kinds of weird `self._cached_property`
starts getting serialized.

Co-Authored-By: ruthra kumar <ruthra@erpnext.com>
2025-01-16 19:10:16 +05:30
Ankush Menat
55ae5615d0 fix: clear all meta cache only when doctype is not specified 2025-01-06 18:57:57 +05:30
Ankush Menat
e7139a1395 perf: store meta in client cache 2025-01-06 18:57:57 +05:30
Akhil Narang
84ef6ec677
refactor: fixup with ruff 0.8.1
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-04 13:18:04 +05:30
David Arnold
3c1392c8fd
fix: meta signature (#28526)
* 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.
2024-11-20 04:17:38 +00:00
David Arnold
15d122025f
feat: get_meta can derive meta from dict (#28525) 2024-11-20 01:36:04 +00:00
David Arnold
d5fd8d7c20
chore(docref): fix circular imports (#28282) 2024-10-24 22:31:12 +02:00
David Arnold
7348572af8
feat: docref identifier / proxy (#27973)
* feat: add DocRef

* feat: Add comprehensive test cases for DocRef functionality

* chore(db): add field type hints

* fix: ensure document stringer fulfills the DocRef contract
2024-10-19 09:40:26 +05:30
David Arnold
5d3697500e
refactor: improve maintainability with a simple dispatcher (#27975)
* 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
2024-10-06 16:56:40 +00:00
David
d05f70f9ba
fix: return correct types for owner and modified_by 2024-10-03 23:25:11 +02:00
David
2de43f7797
feat: improve placement for custom field sections and columns 2024-09-26 12:54:30 +02:00
Raffael Meyer
b91cacdd18
feat!: enhance Language to become more of a Locale (#27178) 2024-09-21 16:02:58 +02:00
marination
a893341f95 fix: get_valid_fields excludes show_on_timeline, breaking migrations
Co-authored-by: Gavin <gavin.dsouza@switchup.de>
2024-09-02 17:27:50 +02:00
Gavin D'souza
074da5c553
fix: Separate meta.get_valid_fields from *columns 2024-08-28 18:12:42 +02:00
Gavin D'souza
151de897f1
fix: Use doc.get to safely check for attr
This bypasses the bungle during site creations when meta isn't present in
the database yet
2024-08-28 11:59:25 +02:00
Gavin D'souza
12e3cee4a6
fix!: Skip virtual fields in meta.get_valid_columns 2024-08-28 11:42:43 +02:00
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Corentin Flr
f8ff2308e2
Merge branch 'frappe:develop' into fix-fieldlevel-access-to-shared-document-list 2024-01-15 01:32:51 +01:00