Akhil Narang
7c756aa811
Merge pull request #35872 from czarflix/fix/perf-bulk-link-validation
...
perf(validation): optimize link validation with bulk pre-fetching
2026-02-16 16:14:21 +05:30
Sagar Vora
93065e6af4
fix: handle extended class unpickling when frappe is not initialised
...
Store __bases__ in pickle for reconstructing extended classes during unpickling.
This avoids dependency on get_controller() which requires frappe to be initialised.
Uses functools.cache on _create_extended_class to avoid recreating the class
for each unpickled object.
fixes frappe#35371
2026-02-09 18:00:42 +05:30
Ayaan Ahmad
ddc757dcc8
refactor(model): extract repeated DB query logic into helper function
...
Address @akhilnarang's code review feedback:
1. Extract _fetch_link_values helper function
- Encapsulates repeated DB query pattern (was duplicated 3 times)
- Handles cache=True fallback and virtual doctype logic
2. Sort values_to_fetch for cache key consistency
- Uses tuple(sorted({...})) to match prefetch sorting
- Prevents cache misses due to field order differences
2026-02-04 00:32:46 +05:30
Hussain Nagaria
d5dc81cf50
Revert "fix(BaseDocument): reset name when __islocal is set"
...
This reverts commit 8f3710cdec19da5918e3bf25cef38be693fdc5c2.
2026-01-26 15:59:56 +05:30
Ejaaz Khan
d124305323
Merge pull request #35278 from stephenBDT/fix-virtual-childtable-fields-not-in-pdf-2
...
fix: virtual childtable docfields value not in pdf childtable
2026-01-24 02:01:28 +05:30
Hussain Nagaria
0080ee6aae
fix(BaseDocument): reset name when __islocal is set ( #36080 )
2026-01-19 13:42:25 +00:00
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
Rohit Waghchaure
f30e1e9a1c
fix: better validation message for data too long error
2026-01-06 11:49:08 +05:30
Raizaaa
0a2ab6364c
fix: added 'autoname' to reserved keywords ( #35473 )
...
* fix: added 'autoname' to reserved keywords
* fix: prevent using autoname as DocField name
- Add validation for autoname in check_invalid_fieldnames()
- Treat Python keywords as reserved fieldnames
* fix: move autoname out of reserved keywords
* fix: move python keywords out of reserved keywords
* fix: skip reserved docfield name check for 'DocType'
---------
Co-authored-by: Raiza Safeel <raizasafeel@Raizas-MacBook-Air.local>
2025-12-31 12:00:49 +05:30
Sagar Vora
49d33a7b3a
fix: stricter link field assertion
2025-12-29 16:35:51 +05:30
Steffen Brennscheidt
d7f6f1f65c
fix: virtual childtable docfields value not in pdf childtable
2025-12-16 10:10:04 +00:00
Aarol D'Souza
15e59a3ba2
fix(postgres): add rollback to prevent crash on hash collision ( #34686 )
...
* fix(postgres): add rollback to prevent crash on hash collision
* fix(postgres): rollback to savepoint to prevent crash on hash collision
* fix(postgres): tighten bounds for a rollback to savepoint for a better perf
* fix(postgres): Handle hash collision efficiently with ON CONFLICT
* refactor: better naming
- Private methods
- "rows" is not a correct name for single record's name
* fix: Bad error handling
- Why raise postgres error?
- Let default error raising/handling happen
---------
Co-authored-by: Ankush Menat <ankush@frappe.io>
2025-12-05 12:02:10 +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
ae21d544a5
fix: add fallback when getting children in as_dict
2025-10-13 11:48:03 +05:30
Sagar Vora
e5a9e5bf74
fix: use ignore_virtual
2025-10-01 12:49:49 +05:30
Sagar Vora
66e187daa0
fix: dont pickle _parent_doc
2025-10-01 12:39:02 +05:30
Sagar Vora
2c9c6c0fd5
fix: correct table_fields references
2025-10-01 12:25:00 +05:30
Ejaaz Khan
4942cdc289
fix: add default value none
2025-09-19 14:43:45 +05:30
Ejaaz Khan
e69b607aab
feat: add validation to prevent changing values on save
2025-09-19 11:21:40 +05:30
Sagar Vora
dddfe7a02f
fix: more foolproof implementation for virtal ct
2025-09-10 13:27:35 +05:30
Sagar Vora
bdcd7c8eed
Merge pull request #33956 from sagarvora/extend_doctype_class
...
fix: minor improvements to extended class logic
2025-09-09 06:18:52 +00:00
Sagar Vora
c5bc3875df
fix: minor improvements to extended class logic
2025-09-09 11:15:17 +05:30
Sagar Vora
d81cf3856c
Merge pull request #33943 from sagarvora/extend_doctype_class
...
feat: new `extend_doctype_class` hook
2025-09-08 13:54:41 +00:00
Sagar Vora
b4bd4f756d
fix: set __module__ in extended class
2025-09-08 18:37:41 +05:30
Sagar Vora
18e2e61cad
feat: support pickling extended class
2025-09-08 18:25:18 +05:30
Sagar Vora
1ff85611ff
feat: new extend_doctype_class hook
2025-09-08 17:02:34 +05:30
barredterra
b1c7821911
feat: validate IBAN in backend
2025-08-29 15:21:56 +02:00
Maverjk Carter
a9562f6182
fix: check if df exist before accessing its properties
2025-07-31 12:04:15 +05:30
Raffael Meyer
93b4700899
fix: make labels in error message translatable ( #33166 )
2025-07-23 18:11:51 +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
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
22827056ce
fix: Assert type of link field values
2025-06-10 10:10:51 +05:30
Ankush Menat
8c1ee68ce6
perf: Skip order_by in link validation ( #32848 )
...
~10% faster because no QB overhead
2025-06-09 07:35:00 +00:00
Ankush Menat
515d9006a4
refactor: simplify link field checks
...
Also: perf: only fetch docstatus if required
This will let us do index-only scans.
2025-06-05 21:38:12 +05:30
Ankush Menat
4dd21f175e
perf: Avoid seprately fetching docstatus
2025-06-05 15:24:29 +05:30
Ankush Menat
c434f4ca14
Revert "Revert "perf: cache fetch from value too ( #32700 )" ( #32708 )"
...
This reverts commit 8a3f65338c .
2025-06-05 15:24:29 +05:30
Ankush Menat
a3d5b4af77
Revert "perf: cache docstatus check for invalid links" ( #32799 )
...
This reverts commit be5c96acf22f208c4ec8fbcde92a721b0e84d561.
2025-06-05 08:52:57 +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
Ankush Menat
8a3f65338c
Revert "perf: cache fetch from value too ( #32700 )" ( #32708 )
...
This reverts commit f8e9e82260 .
2025-05-28 13:31:07 +00:00
Ankush Menat
ba96408d23
fix: checkboxes can never be mandatory ( #32707 )
2025-05-28 13:24:49 +00:00
Ankush Menat
f8e9e82260
perf: cache fetch from value too ( #32700 )
...
Consider any "items" table in ERNext, same item and warehouses are used
10s of times in a single document, every one of them triggers fetch from
query, even though it can't possibly change during the DB transaction.
This change now caches the fetched value too.
2025-05-28 15:56:52 +05:30
Akhil Narang
9e6a73f7c2
Merge pull request #31156 from akhilnarang/sqlite
...
feat: sqlite support
2025-04-16 08:56:52 +05:30
Ankush Menat
56e2a9ad2d
Revert "fix(HTML Editor): extraction of images" ( #32129 )
2025-04-15 22:21:40 +05:30
Akhil Narang
9fa330c075
fix(sqlite): use correct check for unique/primary key constraint violations
...
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-04-15 13:59:17 +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
2a2700970d
perf: pre-create UnionType objects
2025-03-20 21:34:07 +05:30
Sagar Vora
36b2d47c14
Merge pull request #31750 from sagarvora/perf-as_dict-
...
perf: reduce repeated attribute access in `as_dict`
2025-03-17 09:26:01 +05:30
Sagar Vora
2414647964
perf: reduce repeated attribute access in as_dict
2025-03-17 09:15:55 +05:30