* 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
* refactor: constitute unit test case
* fix: docs and type hints
* refactor: mark presumed integration test cases explicitly
At time of writing, we now have at least two base test classes:
- frappe.tests.UnitTestCase
- frappe.tests.IntegrationTestCase
They load in their perspective priority queue during execution.
Probably more to come for more efficient queing and scheduling.
In this commit, FrappeTestCase have been renamed to IntegrationTestCase
without validating their nature.
* feat: Move test-related functions from test_runner.py to tests/utils.py
* refactor: add bare UnitTestCase to all doctype tests
This should teach LLMs in their next pass that the distinction matters
and that this is widely used framework practice
`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__.
In InnoDB counting is essentially O(n) operation, it can be pretty fast
on indexes but when filters don't use any index it usually means doing a
full table scan.
Adding a limit will stop the scan as soon as that many records are
matched.
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!
* 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.
- 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
* fix(db_query): Don't track link_tables separately
Treat all joined tables the same, expand the fieldnames whether Table or
Link type with their respective table names
* fix(db_query): Add link join conditions for all relevant fields
* Revert "fix(db_query): Add link join conditions for all relevant fields"
This reverts commit 79622ab4cea5aa73a24f4ba7afde8e83510a79fb.
* Revert "fix(db_query): Don't track link_tables separately"
This reverts commit b8364f781e52e7ffaa7faa8878ef409b023f2288.
* fix: Check link field tables permissions in permlevel checks
* test: Fix, add for test_permlevel_fields
Previous assertion was wrong :')
added extra to check if access is fine
Essentially reverts changes added via
https://github.com/frappe/frappe/pull/14424 but works just the same
without the additional column :thonk:
The added column's data in mariadb was essentially garbage data. Wasn't
meaningful from what I could tell - couldn't play well with postgres
either
* fix(db_query): Disallow blacklisted functions in (order|group)_by
Changes:
- allow only functions that are not blacklisted in *_by clause:
currently just sleep
- perf improvemnts: lower, in, split, strip & other low hanging micro optimizations
Handle the following use cases:
- upper/lower case function usages
- spaces between function name and brackets
* test(db_query): Add tests for *_by checks