Saqib Ansari
326406d139
fix: avoid false cache misses by ensuring string keys for linked fields
2026-02-17 12:21:19 +05:30
Ayaan Ahmad
614bb642ef
refactor(model): simplify prefetch per szufisher's suggestion
...
- Remove fetch_if_empty check from prefetch phase
- Fetch ALL fields, let base_document.py handle fetch_if_empty
- Avoids DRY violation (same logic in two places)
- Efficiency difference is negligible
2026-01-17 21:29:48 +05:30
Ayaan Ahmad
6197b73d52
fix(model): resolve CI failures in bulk link validation
...
- Remove cache-check-before-get_all due to recursive_defaultdict edge cases
- Fix ruff-format (multi-line to single-line function call)
- Keep cache population after fetch (addresses maintainer request)
- Preserve core N+1 optimization (bulk fetching via get_all)
2026-01-15 00:21:04 +05:30
Ayaan Ahmad
f37890c31f
fix(model): address PR feedback for bulk link validation
...
- Replace **kwargs with explicit link_value_cache parameter
- Check db.value_cache before get_all for cross-document caching
- Populate db.value_cache after fetching for subsequent documents
- Add sorted() for deterministic cache key matching
- Add isinstance guard for integer docnames (MariaDB)
- Fix linting issues (RUF005, slice spacing)
2026-01-14 22:31:22 +05:30
Ayaan Ahmad
3f86d478e8
perf(validation): optimize link validation with bulk pre-fetching
...
Implements a _prefetch_link_values method that bulk-fetches all link values
before validation, eliminating N+1 queries when saving documents with many
child rows containing Link/Dynamic Link fields.
Performance Impact:
- 50 child rows: 51 queries → 3 queries (94% reduction)
- 500 child rows: 501 queries → 3 queries (99.4% reduction)
Implementation:
- Uses instance-level cache (garbage collected after validation)
- Sentinel pattern to distinguish cache miss from cached-None
- DB-conditional case handling (MariaDB vs Postgres)
- Chunking at 1000 items for safety
- Backward compatible via **kwargs
Edge Cases Handled:
- Empty name lists (skip query)
- Invalid docname types (preserves existing assertions)
- Virtual doctypes (individual fetch)
- Single doctypes (special handling)
- Dynamic links with doctype changes (cache miss fallback)
Closes #35794
2026-01-12 20:23:54 +05:30
Sagar Vora
fc3a85b93a
fix: check perms before validating links
2025-12-29 16:08:27 +05:30
Akhil Narang
f7feeea0a0
fix: ruff "unsafe" fixes
...
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-22 21:06:48 +05:30
Akhil Narang
8723a2b6ee
fix: ruff fixes
...
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-22 21:06:48 +05:30
Akhil Narang
ef6a0bffc2
fix: update overloaded get_doc() signature
...
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-10 16:52:37 +05:30
Akhil Narang
2dcfe07ca8
refactor: make use of check_permission parameter for get_lazy_doc
...
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-10 16:52:26 +05:30
Akhil Narang
75b91f44ce
feat(get_lazy_doc): add in check_permission parameter
...
So as to avoid manually calling doc.check_permission() often
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-10 15:40:58 +05:30
Akhil Narang
40ebe6b97a
feat(get_doc): add in check_permissions parameter
...
If a string, we'll try to check for that permission
Otherwise, we'll just check for `read`
2025-12-09 19:31:14 +05:30
Raffael Meyer
afefeb5dc1
refactor: allow defer_insert in doc.log_error ( #34631 )
2025-11-07 12:35:50 +01:00
Sagar Vora
a93530e221
Merge branch 'develop' into computed_child_table
2025-10-14 12:53:32 +05:30
Sagar Vora
2a42f0688f
chore: update docstring
2025-10-14 12:41:58 +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
3264fb0f12
fix: missing flag
2025-10-01 12:59:48 +05:30
Sagar Vora
4ba6855fff
fix: reset virtual ct cache on save/insert
2025-10-01 12:28:45 +05:30
Sagar Vora
2c9c6c0fd5
fix: correct table_fields references
2025-10-01 12:25:00 +05:30
Ejaaz Khan
335c0d5f36
fix: refactor code and change field type
2025-09-30 12:38:39 +05:30
Ejaaz Khan
e69b607aab
feat: add validation to prevent changing values on save
2025-09-19 11:21:40 +05:30
Ejaaz Khan
54b34c9535
Merge branch 'develop' into 32489-role-perm-based-masking
2025-09-17 16:17:30 +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
Raffael Meyer
ee93a01106
Merge branch 'develop' into computed_child_table
2025-09-10 08:34:36 +02:00
Akhil Narang
5b26db7265
Merge pull request #33685 from AMR-Mannesmann/fix(document)-is_child_table_same-for-new-docs
...
fix(document): is_child_table_same for new docs
2025-09-02 11:37:06 +05:30
Ejaaz Khan
590fe7e520
Merge branch 'develop' into 32489-role-perm-based-masking
2025-09-02 10:48:06 +05:30
Akhil Narang
719af6e722
Merge pull request #33815 from raizasafeel/fix/translation-trailing-spaces
...
fix: remove trailing spaces in translatable strings
2025-08-28 16:31:45 +05:30
Raizaaa
aa3bb0e4d7
fix: remove trailing spaces in translatable strings
2025-08-27 13:23:17 +03:00
Mihir Kandoi
c24bda0481
feat: enable non negative validation for Percent type fields
2025-08-26 22:12:23 +05:30
Daniel Radl
99d6e1b381
fix(document): is_child_table_same for new docs
2025-08-20 09:30:26 +00:00
Ejaaz Khan
c2544f9096
refactor: change approach of masking fields
2025-08-18 23:38:18 +05:30
mergify[bot]
c0aa39ee9a
Merge branch 'develop' into 32489-role-perm-based-masking
2025-08-01 05:57:54 +00:00
Raffael Meyer
93b4700899
fix: make labels in error message translatable ( #33166 )
2025-07-23 18:11:51 +05:30
P-Froggy
00a5fde3ad
feat: Enable _doc_before_save for child documents ( #33279 )
...
* Initial Commit
* Apply suggestion from @ankush
* refactor: move unrelated code out of try-except block
* test: child table level value change detection
---------
Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
2025-07-11 12:33:00 +00:00
Ankush Menat
b74b8f16b7
refactor: slim down init.py further ( #33284 )
...
* refactor: move document utils
* test: rewrite init.py test
The LOC is 1000 less than what it used to be.
2025-07-11 15:34:50 +05:30
Sagar Vora
71428b7dcb
feat: utility to commit certain queries after sending response ( #32978 )
...
* feat: utility to commit certain queries after sending response
* fix: add error handling
* refactor: subclass CallbackManager
2025-07-08 05:02:27 +00:00
Akhil Narang
ad948c9b98
Revert "Merge pull request #32327 from akhilnarang/allow-passing-name-in-api"
...
This reverts commit 1e30db26dc , reversing
changes made to 8da72e91e3 .
2025-07-03 17:23:48 +05:30
Sagar Vora
406aae7432
chore: fix typo
2025-07-01 19:43:04 +05:30
Ejaaz Khan
cbcf16440a
refactor: remove masking setting from System Settings
2025-06-26 13:06:44 +05:30
mergify[bot]
0312cb7eb4
Merge branch 'develop' into 32489-role-perm-based-masking
2025-06-25 17:17:30 +00:00
Ankush Menat
3d50221762
fix: Don't lazy load virtual tables
2025-06-25 17:59:48 +05:30
Ankush Menat
bb58e7aebe
fix: Don't update computed tables
2025-06-25 17:24:38 +05:30
Ankush Menat
17324982b5
fix: force virtual field too
2025-06-25 17:24:38 +05:30
Ankush Menat
388d8b2bc7
feat: Computed/virtual child-tables
...
- They need to be a non-data descriptor i.e. cached_property or
equivalent
- When "loading from DB", we will trigger the descriptor
- The descriptor can return dict or docs for better DX.
- We initialize docs as normal child tables
2025-06-25 17:24:37 +05:30
Faris Ansari
09ae9ad086
fix: rename method typing
2025-06-18 15:51:13 +05:30
Sagar Vora
b3e1eda4c8
feat: global frappe.in_test flag ( #32960 )
...
* feat: global `frappe.in_test` flag
* feat: helper utility to toggle `frappe.in_test`
* fix: use `toggle_test_mode` util
* fix: use `frappe.in_test`
* chore: add comment explaining global `in_test`
* chore: ignore commit replacing flag usage
* test: temporarily disable `frappe.in_test`
this worked earlier because flag was set in werkzeug.local which was separate for API test client
* test: add comment explaining change
2025-06-17 19:19:31 +05:30
Sagar Vora
5210348322
perf: assume key to be table fieldname
2025-06-14 01:49:07 +05:30
Sagar Vora
d79ca9560b
chore: revert _init_* methods of document
2025-06-13 22:24:03 +05:30
Ejaaz Khan
2ad1217fb0
Merge branch 'develop' into 32489-role-perm-based-masking
2025-06-11 19:47:48 +05:30