Commit graph

456 commits

Author SHA1 Message Date
Ankush Menat
fdba41c682
perf: misc client cache improvements (#29070)
* perf: Reduce penalty for lack of redis connection

If redis isn't running than this client cache is slower than default
implementation because of the extra locking overhead.

* test: update perf redis counts

* perf: cache table columns in client-cache

* fix: race condition on cache-client_cache init

Rare but apparant in synthetic benchmarks.

Cache is set but client cache is still being initialized then request
will fail.

* perf: Don't run notifications when loading document

WHAT?

* fix: use cached doc to repopulate

* perf: reduce get_meta calls
2025-01-07 16:14:43 +05:30
David Arnold
75377aaaf5
refactor(typing): type filters (#28218)
* chore(typing): type filters

* chore(typing): type filters for get_list et al

* fix: dashboard chart filter expression

* test: fix case with new-style right hand object to equality check

* chore: place new typed filter under typing verification

* chore: remove debug print statment

* chore: inverse logic of type guard

* fix: add float to filter value types

* chore: clarify value naming
2024-12-04 23:18:53 +00:00
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
Ankush Menat
820a6edae8
fix: Skip virtual fields in all select queries (#26700) 2024-06-06 09:43:36 +00:00
Ankush Menat
005e74b20d
perf: Avoid coalesce for between filters (#26531)
- Avoid on `between` + date
- Avoid on timestamp fields
- Avoid on `>` and `>=` comparisons
2024-05-22 09:32:59 +00:00
Akhil Narang
306c923986
chore: minor code cleanup
- Use walrus operator where possible
- Drop redundant checks - we anyway can't iterate over an empty list

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-04-10 17:22:45 +05:30
Revant Nandgaonkar
7e16e902d9
feat: allow wildcard for doctype in permission hooks (#25729)
* feat: allow wildcard for doctype in permission hooks

* fix: pass doctype to permission query

* fix: combine methods instead of alternate

* test: wildcard has_permssion hook

* test: wildcard has_permssion make note public

* fix: fetch list of hooks once
2024-04-10 11:44:37 +05:30
Ankush Menat
432c8cf48c
Merge pull request #25624 from ankush/creation
fix!: Switch to `creation` as default sort order
2024-03-27 13:25:53 +05:30
Ankush Menat
ff1f8ddbda
fix: allow any sequence container (#25664) 2024-03-27 06:31:15 +00:00
Ankush Menat
dbcf7ad30c refactor: update usage of modified everywhere 2024-03-27 11:23:13 +05:30
Ankush Menat
071e269548 fix!: Switch to creation as default sort order 2024-03-27 11:18:28 +05:30
Dany Robert
6e02df7ea2
fix: ordered fields on get_list returning list (#25663)
* fix: ordered `fields` on get_list returning list

* chore: linters
2024-03-27 05:11:09 +00:00
Ankush Menat
a12fc118f4
perf: remove useless sorting on docstatus (#25571) 2024-03-21 06:17:23 +00:00
Ankush Menat
f642b1881f fix: invalid select star expansions 2024-03-20 16:31:02 +05:30
Ankush Menat
065674236c refactor: duplicate check for * 2024-03-20 12:29:58 +05:30
Ankush Menat
5eca52b2c7 fix: only trim tab if it starts with tab 2024-03-20 12:29:58 +05:30
Ankush Menat
ea193ecd48 Revert "Revert "fix: search_link fails when txt contains parentheses (#22892)""
This reverts commit c0cf13b8e8.
2024-03-20 12:29:57 +05:30
Ankush Menat
8a7beebf30
fix: handle distinct for fieldname (#25511)
`distinct count(fieldname)` is supported well but `count(distinct fieldname)` fails if fieldname contains full field with table name included. This PR just adds basic handling for it.

Needs to be rewritten entirely in QB __some day__.
2024-03-18 13:38:29 +00:00
Ankush Menat
a28921750d fix(DX): Avoid use of args in virtual doctype 2024-03-11 15:20:35 +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
Ankush Menat
3bea50d519
fix: Return empty result if no perm level access (#24591) 2024-01-29 19:48:19 +05:30
Suraj Shetty
0f4a1d8f10 fix: Handle invalid descendant filter 2024-01-19 15:49:02 +05:30
Ankush Menat
c0cf13b8e8 Revert "fix: search_link fails when txt contains parentheses (#22892)"
This reverts commit 642e9f4ec1.
2024-01-17 12:44:20 +05:30
Sambasiva Suda
642e9f4ec1
fix: search_link fails when txt contains parentheses (#22892)
* fix: search_link fails when txt contains parentheses

* fix: updating regex to replace number params also

* chore: replacing regex with sqlparse

* chore: not including fields like count(1) in asterisk_fields

* fix: owner/module not identified as column

* chore: lint fix and removing exception

* refactor: better function name

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2024-01-16 21:36:45 +05:30
Ankush Menat
b38199a3b3 fix: pass user to has_perm check 2024-01-11 12:34:15 +05:30
Ankush Menat
9f135e8c1d fix: print perm check logs from DB query
Doing has_permission and then manually raising exception erases the perm check messages.

This causes insane amounts of confusion when perm error says X not
permitted while user is trying to check Y.
2024-01-11 12:27:39 +05:30
Ankush Menat
64c221343e
perf: skip ifnull checks on modified field (#24042) 2023-12-30 06:39:32 +00:00
Ankush Menat
0fd6f5eed7
Merge pull request #23827 from frappe/api-docs
docs: add Python API missing docstrings / type hints
2023-12-21 12:13:05 +05:30
bourouffala
3015852ce1
fix: Error when displaying dashboard with number card using average and sum functions (#23883) 2023-12-20 11:13:20 +00:00
Ankush Menat
5deabdde21 fix: skip virtual fields in perm level checks during DB Query
DB Query can't access virtual fields so it should ignore all virtual
fields.
2023-12-20 12:00:08 +05:30
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +05:30
Ankush Menat
687752359d
perf: Primary key is never nullable (#23788)
People ususally write queries like these...

```
frappe.get_all(doctype, {"name": ("in", list_of_docs))
```

Ocassionally, the `list_of_docs` is empty because it's dynamically
generated and in this case we end up doing full table scan to find... nothing!
2023-12-14 15:01:19 +00:00
Smit Vora
f62f4472e6
fix: ignore if controller doesn't have get_list attr (#23736) 2023-12-11 23:24:00 +05:30
barredterra
c35476256f refactor: simplify conditional logic
Command: `sourcery review --fix --enable de-morgan .`
2023-12-05 11:14:41 +01:00
Akhil Narang
731c5c8cd5
refactor(db_query): check for docfield not_nullable
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
15c925ccc7
feat: check for docfield not_nullable property to decide whether a field can be nullable
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
390d4e1b13
chore: drop unused variables and parameters
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Ankush Menat
385fa8aaef
fix!: Correct between filtering (#22918)
* fix: Remove incorrect fallback

If you do +1 on date it will also start considering next date. This was
only done to accomodate date filter on datetime fields. Which also
doesn't really work.

* refactor: simplify fieldtype detection

* fix!: Correct datetime fallbacks for between filters

* chore: remove unncessary test

This is very specific and introduces flake when the job tests run before
it.
2023-10-26 06:23:14 +00:00
barredterra
88c8baa9ee refactor: for append to extend, merge list extend
Replace a for append loop with list extend.
Create the list with values instead of creating
an empty list and extending it with another list.
2023-08-09 13:25:39 +02:00
Shariq Ansari
e1c1e256ef
Merge pull request #21798 from pps190/frappe/fix/ambigus-table-join 2023-07-28 12:28:04 +05:30
Ankush Menat
8930d4b5e1
perf: drop ifnull from IS SET filter (#21822)
- Kinda confuses query planner (idk why it's not smart enough to
  understand but there are probably edge cases where it can't be done)
- `null != null` and `'' != null` both yield `null` which is falsy and
  won't be shown in results.

Alternate fix to https://github.com/frappe/frappe/pull/21817
2023-07-27 10:58:20 +05:30
Devin Slauenwhite
7a3e7b7eb2 Merge remote-tracking branch 'frappe/develop' into frappe/fix/ambigus-table-join 2023-07-24 14:23:28 -04:00
Ankush Menat
2c99583247 perf: Lazily fetch shared documents
We eagerly fetch shared documents for ANY `get_list` query, even when
user has full read acess doctype, where it's moot to consider adding
shared document as separately.

This eliminates one entire db call from get_list and in most cases
get_list will translate to single DB call, hence probably worth the
additional complexity.
2023-07-22 18:04:35 +05:30
Devin Slauenwhite
b9b3a250f8
Merge branch 'develop' into fix-ambigus-table-join 2023-06-06 10:29:59 -04:00
Ankush Menat
3df13ca392 feat: new operator - descendants of (inclusive)
Co-Authored-By: Faris Ansari <netchamp.faris@gmail.com>
2023-05-29 16:59:57 +05:30
Gavin D'souza
63a605876f fix: Pass current dt as fallback parent_doctype 2023-04-27 14:37:15 +05:30
Gavin D'souza
a22cbe8ae5 fix: Setup permission_map & use get_permitted_fields 2023-04-22 14:58:28 +05:30
Devin Slauenwhite
f17e52088f chore: linter 2023-03-03 11:59:05 -05:00
Devin Slauenwhite
1c86d6431f fix: don't join on parenttype 2023-03-03 11:46:57 -05:00