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
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
Ankush Menat
b162c0d6ec
fix!: Don't update document from keyword args ( #32898 )
...
Right now if you do this:
`get_doc(doctype, name, field=value)` then it loads document from DB and
then updates field to value.
This is absurd API and I don't think it was ever done intentionally.
2025-06-11 10:15:35 +00:00
Ankush Menat
44681433c9
fix: for_update for lazy loaded documents ( #32897 )
...
* fix: Support for_update on lazy documents
* fix: Pop for_update from arguments
* fix: Don't init empty child tables
2025-06-11 10:02:36 +00:00
Sagar Vora
a6b2f7c991
perf: dont override doc.extend ( #32890 )
2025-06-11 07:26:46 +00:00
Ankush Menat
893a87df86
fix: append and extend without touching attributes
2025-06-11 10:07:48 +05:30
Ankush Menat
10c3c9ea9b
fix: Limit getattr to lazy loaded child tables only
2025-06-11 09:55:45 +05:30
Ankush Menat
5c886ef091
test: test internal implementation of LazyChildTable
2025-06-11 09:55:45 +05:30
Ankush Menat
26cf77562c
refactor: rearrange checks, inline and cast super args
...
Co-authored-by: Sagar Vora <16315650+sagarvora@users.noreply.github.com>
2025-06-11 09:55:45 +05:30
Ankush Menat
e69f79e2ae
fix: Support dict as key ~ filters
...
Triggers full fetch indirectly, but there's no other option for this.
2025-06-11 09:55:45 +05:30
Ankush Menat
bebabc3211
fix: Handle support for DocType and virtual
...
By falling back to original impl with warning.
This is just to allow "fearless usage".
2025-06-11 09:55:45 +05:30
Ankush Menat
49f582ae57
perf: Use lazy doc in a lot more places
2025-06-11 09:55:45 +05:30
Ankush Menat
4d7348d3c0
refactor: avoid code duplication
2025-06-11 09:55:36 +05:30
Ankush Menat
5b8f7bba2b
fix: Ensure some basic checks are present to prevent misuse
2025-06-11 09:55:01 +05:30
Ankush Menat
3e4e944ae9
fix: dont db_update what hasn't changed
2025-06-11 09:55:01 +05:30
Ankush Menat
022dbf444d
fix: make doc.save work and empty tables
2025-06-11 09:55:01 +05:30
Ankush Menat
eb77ddab69
feat: Lazy loaded documents
...
https://docs.python.org/3/howto/descriptor.html#invocation-from-an-instance
After first invokation, object's __dict__ will be used... then we can
assume rest of the code works as expected (?)
2025-06-11 09:55:01 +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
47a47a9b5d
refactor!: Change internal datastructure of db.value_cache
...
It's now a defaultdictionary of `[doctype][name/filters][fieldname]`
This allows us to implement granular clearing and improve usage of this cache.
2025-06-05 14:46:03 +05:30
Ankush Menat
bc63c17287
perf: don't load doc before save for child tables ( #32770 )
...
Consider this:
```python
for row in doc.get_children():
row.db_set("amount", 0)
```
This sounds like it will do one write query for each row but it does 2
because of this unnecessary locking of child tables.
2025-06-04 07:52:37 +00:00
Ankush Menat
78f7fa1429
perf: hoist constant computations for child table column order ( #32677 )
...
These don't/shouldn't change during execution of the function.
2025-05-26 19:39:29 +05:30
Ankush Menat
e2d619504f
perf: batch bulk_insert ( #32675 )
...
* fix: reduce bulk insert batch size
Back when this feature was added it used to lazily evaluate the input.
Now the iterator is consumed upfront so large batch sizes == huge memory usage.
* perf: bring back iterator for bulk_insert
Bulk insert used to support iterator for consuming arbitrarily large
amount of data and inserting it. Since child table support was added, it
can't do it anymore because that requires collecting values.
This change now brings back iterators by batching input iterator (by
default 1000) documents.
This is almost as good as original change from design POV. Performance
is still meh for flat documents.
2025-05-26 13:36:53 +00:00
Ankush Menat
9920c8d033
fix: duplicate follow
...
This exists in `doc.insert()` not need to add it here too
2025-05-26 14:43:06 +05:30
Ankush Menat
c2d2fda212
perf: avoid clearing cache for newly imported documents
2025-05-26 14:42:54 +05:30
Ankush Menat
d3c88556bc
perf: Skip version checking on new docs
2025-05-26 14:38:26 +05:30
Ankush Menat
cc1e843260
perf: Skip realtime notifications while importing
2025-05-26 14:31:46 +05:30
Akhil Narang
33dbf97db2
fix(document): don't try to overwrite name if a string is already set
...
This allows us to pass `name` in via API when creating documents.
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-05-05 12:24:58 +05:30
Sagar Vora
f93b87ddd8
fix(Document): improve __onload implementation
2025-05-03 20:35:52 +05:30
Ankush Menat
266ec9f76e
perf: Fix child table queries for int-PK parent ( #32293 )
...
Lessen but not eliminate impact of https://github.com/frappe/frappe/issues/32287
2025-04-25 05:33:07 +00:00
Ankush Menat
d998d520fb
perf: use raw query for reading int-pk docs too ( #32286 )
...
Currently only string PK is supported but that wasn't the intention,
isinstance check is only there to avoid dicts/filters.
2025-04-24 13:11:07 +00:00
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
ad32216040
fix: support sqlite
...
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-04-15 13:59:16 +05:30
Ankush Menat
eb79ecaca9
chore: Revert document read only mode ( #32102 )
...
We can trust mappers to do the right thing, restricting few methods
doesn't prevent anything real anyway, unnecessary overhead and breakages.
2025-04-12 18:27:16 +05:30
Sagar Vora
bd844579d2
refactor: trim frappe.__init__
2025-04-06 10:30:23 +05:30
gavin
554c76aa13
Merge pull request #31706 from gavindsouza/fix-add_viewed
...
refactor: doc.add_viewed
2025-03-17 09:07:47 +01:00
Sagar Vora
09d0abcb54
fix: simplify load_from_db logic
2025-03-15 16:14:55 +05:30
Gavin D'souza
dc807832fe
refactor: doc.add_viewed
...
* Don't check for unique_views if not needed - one less query/table scan
* Remove unnecessary indents
* Fix docstring
2025-03-13 11:11:47 +01:00
Sagar Vora
146d50e5d4
chore: fix typo in new DocStatus constant
2025-03-05 08:29:47 +05:30
Sagar Vora
99574a74e2
Merge pull request #31400 from sagarvora/better-table-fieldnames
2025-02-25 10:43:29 +05:30
Ankush Menat
efee329adf
fix: Unlock old locks automatically ( #31411 )
2025-02-24 13:49:08 +00:00
Sagar Vora
26b5d8de15
perf: better _table_fieldnames cache
2025-02-24 17:41:00 +05:30