Commit graph

147 commits

Author SHA1 Message Date
Smit Vora
6b02484f1c
feat: bulk update docs using case when queries (#28483) 2024-12-06 11:34:25 +00:00
David Arnold
9f980e7475
test: add missing test case for get values on single (#28254) 2024-10-23 10:47:46 +02:00
Akhil Narang
e96ff7e65e
Merge pull request #28015 from marination/not-set-filter
fix: 'not set' equivalence in query conditions
2024-10-14 16:00:55 +05:30
David Arnold
e7776021aa
refactor: Structure frappe.test.utils (green to green) (#28038)
* docs: constitute frappe.test readme

* refactor: move utils to __init__

* refactor: move generators into generators.py

* refactor: move cm into context_managers.py

* refactor: move test classes into submodule

* refactor: reexport general purpose context managers

* refactor: adapt imports (treewide)
2024-10-08 15:10:24 +00:00
marination
42e7b9223f fix(test): test_is to check for coalesce as ifnull is legacy for a not set/set filter 2024-10-08 12:31:25 +02:00
David Arnold
c114e5fae8
refactor: unit vs integration treewide (#27992)
* 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
2024-10-06 09:43:36 +00:00
gruener
8a2aa92389
fix: Fixes mariadb orm to return list instead of tuple as the typisat… (#27179)
* fix: Fixes mariadb orm to return list instead of tuple as the typisation suggests it

* fix: inverted fix for pg: Expect tuple as data_type for _transform_result

* fix: Fixed failing upstream spec due to data_type change
2024-08-09 09:27:07 +05:30
Philipp Gruener
ffcd6d1ff5 fix: Added missing newlines after merge (for pre-commit checks) 2024-07-16 22:52:31 +02:00
gruener
efc9bdd4f6
Merge branch 'develop' into bugfix/postgres_schema_support 2024-07-16 22:47:01 +02:00
Philipp Gruener
7df4185f87 fix: removed TODO marks 2024-07-08 15:16:51 +02:00
Philipp Gruener
c19e844516 fix: Re-establish orig connection in tearDown for failing cases, that following specs dont rely on broken connection 2024-07-05 16:43:15 +02:00
Philipp Gruener
ea3d1365fe fix: Adjusted the retrieved dbms errors to also handle mariadb errors correctly in specs. 2024-07-05 16:26:51 +02:00
Philipp Gruener
1b56b4f3f7 fix: Reset to orig env vars in specs 2024-07-05 15:44:04 +02:00
Philipp Gruener
abba28be3b feat: Added env db options for db, password and pg_schema 2024-07-05 12:05:20 +02:00
Philipp Gruener
d3591c7170 fix: Added missing ruff adjustments 2024-07-04 23:13:14 +02:00
Philipp Gruener
afd95691e9 fix: Fixed schema isolation/support for postgres connectivity. 2024-07-04 22:40:47 +02:00
Philipp Gruener
442ad03d7b feat: Adds possibility of permitting DB credentials via ENV vars instead of persisting them on the volume. 2024-07-04 22:24:21 +02:00
Ankush Menat
5de5e25df6
fix: datetime comparison in QB (#26364)
closes https://github.com/frappe/frappe/issues/26363
2024-05-09 10:19:27 +00:00
Ankush Menat
de48dc2c04
fix: db explain (#25724)
This broke from some recent changes.

It's just a wrapper, so probably no one uses it.
Anyway, fixed and added test to prevent it.
2024-03-29 10:23:12 +00:00
Ankush Menat
23204c0c05
Merge pull request #25256 from ankush/no_commit_doc_events
fix: disable transaction commits during doc events
2024-03-28 12:28:12 +05:30
Ankush Menat
e5a64fd50c test: transaction control 2024-03-28 11:58:38 +05:30
Ankush Menat
b7bc5d3236
fix(round 3): switch to creation sorting (#25669) 2024-03-27 08:59:04 +00:00
Ankush Menat
0fff2755d6
test: separate out risky tests (#25179) 2024-02-29 16:10:08 +00:00
Ankush Menat
0c9cc2e6ce test: NOWAIT functionality 2024-02-29 17:46:30 +05:30
Ankush Menat
5116768a54 test: utils for simulating two connections 2024-02-29 17:31:46 +05:30
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Raffael Meyer
68eb2d978d
fix: keep order in get_values_from_single (#24907)
* fix: keep order in `get_values_from_single`

* fix: add test for destructuring

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2024-02-19 05:35:35 +00:00
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
a2525e545a
perf: Unbuffered cursors for large result sets (#24365)
If you're reading 1000s of rows from MySQL, the default behaviour is to
read all of them in memory at once.

One of the use case for reading large rows is reporting where a lot of
data is read and then processed in Python. The read row is hoever not
used again but still consumes memory until entire function exits.

SSCursor (Server Side Cursor) allows fetching one row at a time.

Note: This is slower than fetching everything at once AND has risk of
connection loss. So, don't use this as a crutch. If possible rewrite
code so processing is done in SQL.
2024-01-16 11:00:12 +05:30
Ankush Menat
588157df74 feat: frappe.db.sql results as iterator
- Also avoid self.last_result that holds on to large result set reference.
2024-01-15 12:32:02 +05:30
Ankush Menat
e45e313bfb
feat: Skip locked rows while selecting (#24298) 2024-01-13 09:49:27 +05:30
Ankush Menat
acd1b9d64e
fix: Don't run query if dn is None (#22475) 2023-09-19 15:11:15 +00:00
0xsaif
aa7ee1c6b9
refactor: force ipv4 localhost (#22394)
* reafctor: force ipv4 localhost

Replacing "localhost" with "127.0.0.1" in the codebase; sometimes the name localhost force-resolves to ipv6

* revert: leave localhost usage in oauth tests

Change not required.

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-09-13 16:23:23 +05:30
Ankush Menat
961585f1d9
fix: misc dx improvemnts (#22188)
* fix(dx): simplify adding callbacks

frappe.db.after_commit(func) == frappe.db.after_commit.add(func)

* fix: trace id missing

DB gets initted before request
2023-08-28 07:01:25 +00:00
Ankush Menat
fefd9ac2e2
fix: connect_replica and read_only should be idempotent (#21674)
* fix: `connect_replica` should be idempotent

Calling `connect_replica` twice ends up forgetting orginal writable
replica completely.

* test: replicas

closes https://github.com/frappe/frappe/issues/21619
2023-07-14 13:56:57 +05:30
Ankush Menat
c73d9fb783 test: add perf test helper for counting rows read 2023-06-28 19:51:18 +05:30
Ankush Menat
3f3ee12338 Revert: keep supporting set_value for singles
w/ explicit check for singles

This shouldn't have any performance impact as last function call only
happens if we THINK it's single doctype. use set_single_value to avoid
that extra function call.
2023-06-14 17:30:32 +05:30
Ankush Menat
3d0888a5d5 refactor: set_value usage 2023-06-13 16:00:43 +05:30
Ankush Menat
26722b1a1c fix: ignore ConnectionError in frappe.cache().exists() 2023-06-03 22:53:10 +05:30
Ankush Menat
0d056a3a2b test: fix broken tests
Fixture test:
This is broken cause it's trying to find doctype after it has been
deleted (wut?)
It was working so far because cache wasn't cleared correctly so you'd
still find it from cache.

db.set_value test:
converted to use last query instead of patching SQL
2023-06-03 22:53:10 +05:30
Ankush Menat
0b9dee4791 test: db callbacks 2023-06-03 18:44:19 +05:30
Faris Ansari
60febc9799 fix: list filter
filters as list must always be list of list
2023-01-09 19:44:11 +05:30
Ankush Menat
a7377d23fc
refactor!: Drop deprecated functionality (#18815) 2022-11-11 19:54:36 +05:30
Ankush Menat
b71d93ef9f test: db timeout computation 2022-11-09 15:55:31 +05:30
Ankush Menat
ce360b6fce feat: Set default SQL statement timeouts 2022-11-08 14:51:43 +05:30
Ankush Menat
64a0e19329 Revert "fix!: Dont update modified by default in db.set_value (#18301)"
This reverts commit 6aaefd6633.
2022-10-06 22:02:31 +05:30
Ankush Menat
bfa6a5fbdf fix: better cache validation
- Only delete a single doc if we know which doc changed
- Drop all docs other wise (kinda bad, but this isn't used frequently,
  will fix when visiting entire caching system again)
2022-10-06 19:46:58 +05:30
Ankush Menat
6aaefd6633
fix!: Dont update modified by default in db.set_value (#18301) 2022-10-06 16:01:20 +05:30
Ankush Menat
f96505fae0 feat: wrap read only mode SQL errors 2022-09-09 17:34:44 +05:30