Commit graph

299 commits

Author SHA1 Message Date
artykbasar
2739385184
fix(estimate_count): scope to site db (#35481)
* Fix large-table heuristics: scope estimate_count and guard recency

* fix(estimate_count): scope to site database

Incase some setups don't have per-db-users

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

---------

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
Co-authored-by: artykbasar <artykbasar@users.noreply.github.com>
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
2025-12-29 14:11:34 +05:30
Akhil Narang
42d8cae26e
fix(meta): use raw SQL to avoid recursively querying meta in some cases
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-17 11:21:22 +05:30
Hussain Nagaria
0891a69bda
fix: bring back currency precision fix #34886 (#35015)
* fix: use number format from currency if defined

* refactor: extract out function
2025-12-02 07:16:17 +00:00
Akhil Narang
c7dcc0e097
Revert "fix: use number format from currency document if defined (#34886)" (#34906)
This reverts commit a8c835190d.
2025-11-26 10:50:28 +00:00
Hussain Nagaria
a8c835190d
fix: use number format from currency document if defined (#34886)
* fix: use number format from currency if defined

* refactor: extract out function
2025-11-25 12:44:18 +00:00
Ankush Menat
81bc61fe97
chore: remove dead code 2025-11-19 21:15:58 +05:30
Akhil Narang
7ad6f7e2c6
refactor: ensure no meta recursion
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-11-19 21:15:58 +05:30
Akhil Narang
7183caf871
fix(query_builder): default sorting based on doctype meta
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-11-19 21:15:57 +05:30
Saqib Ansari
f687f2a457 Merge branch 'develop' of https://github.com/frappe/frappe into custom-perm-types 2025-10-30 13:08:14 +05:30
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
Saqib Ansari
e184fc4148 feat: extend permission type fields to DocPerm 2025-08-06 12:36:17 +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