Commit graph

108 commits

Author SHA1 Message Date
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
Ankush Menat
3e2d2a703a test: Use FrappeTestCase everywhere 2022-08-17 16:39:42 +05:30
Gavin D'souza
d1fbab1c45 test(db): Add tests for untested db methods 2022-07-22 13:30:47 +05:30
Gavin D'souza
2bef29bb46 chore: Deprecate backup script + minor refactors 2022-07-22 13:21:29 +05:30
Gavin D'souza
bcfa8c276e fix: Set default port attribute for Database classes
db.default_port wil be available as a class attribute to hold defaults
for DB types.

Usage: frappe.conf.db_port or frappe.db.default_port
Why: I couldn't run the mariadb command because the defaults aren't set
for my system. server is remote / containerized. Setting port in
equivalent mysql command fixes this.
2022-07-22 13:16:26 +05:30
Gavin D'souza
63e618c709 test: More resilient tests for sequences 2022-07-22 12:11:01 +05:30
Gavin D'souza
71b5c77e6e Merge branch 'develop' of github.com:frappe/frappe into mariadb-client-refactor 2022-07-05 14:55:02 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
gavin
574f160d3c
Merge branch 'develop' into mariadb-client-refactor 2022-06-23 16:13:03 +05:30
phot0n
5e1007940c refactor(minor): move test_modify_query and test_modify_values to TestDB class 2022-06-18 10:55:40 +05:30
phot0n
215507a742 test: add list value in test_modify_values 2022-06-18 10:45:40 +05:30
Gavin D'souza
71ed8417d3 test: frappe.db.describe returns List[Tuple] through mariadb 2022-06-16 16:23:27 +05:30
Ankush Menat
359c7768f5 fix: multiple postgres transaction abort issues
- wrap setup fixtures in savepoint
- wrap scheduled_job_type in savepoint
- ignore duplicates where it's ignored by exc
- dont attempt to delete from deleted table
- delete custom field and commit - stale meta causes future inserts to
  insert unknown field.
2022-06-05 00:26:15 +05:30
Ankush Menat
8861752675 fix: restart transaction after commit 2022-06-05 00:26:12 +05:30
Aradhya Tripathi
7a0dc40693
feat!: Added support for IS in frappe qb (#16877)
Fixes #16869
Using 53148c3f90
2022-05-18 09:09:22 +00:00
Ritwik Puri
968343b302
Merge branch 'develop' into autoinc-customize-form-fix 2022-05-13 00:41:58 +05:30
phot0n
b1d61906d1 test: update and rename test_change_autoname
* chore: remove unnecessary decorators for skiprun
2022-05-13 00:03:19 +05:30
saxenabhishek
0450a25822 test: get_count 2022-04-28 17:10:31 +05:30
phot0n
6405b0510a chore: fix linter 2022-04-20 17:56:48 +05:30
phot0n
c516357027 test(get_value): test for multiple order bys 2022-04-20 17:56:48 +05:30
Pruthvi Patel
8b010e1732
refactor: make frappe.db.bulk_insert work as expected (#16527)
## Issue

`frappe.db.bulk_insert` is not working as expected:
 - It will not insert any row if there are less than 3 values
 - It will not add 1st row at all. e.g if I'm adding 5 values, it will only add 4.
 - It will add values one by one after 2 values, instead it should have inserted items (in db) in chunk of 10000 (as per the code written before).

## Changes Made
 - Solved above issues 
 - use better way to chunk list
 - Added Postgres support for bulk_insert API
 
And now `bulk_insert` will only do **1 db call for each 10000** values.

Note: For testing purpose I made `Test Bulk Insert` doctype and keep chunk size of 100.

## Before
![image](https://user-images.githubusercontent.com/43115036/161979365-c1100745-7602-47d2-a9b8-62d797d2039f.png)

## After
![image](https://user-images.githubusercontent.com/43115036/161978344-3c17d56b-2195-40f4-b00c-e9478d4083f1.png)

nodocs
2022-04-19 14:47:22 +00:00
Gavin D'souza
70a8a49c9c fix: new_doctype API testing util
Use kwargs instead of mapping defined kwargs to single actions
2022-04-12 19:06:35 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Ankush Menat
c4ca58fedf refactor: query stripping 2022-03-28 10:56:55 +05:30
barredterra
512c622487 test: make sure exists doesn't eat the doctype key 2022-03-21 20:51:35 +01:00
Karthikeyan Singaravelan
880832671a fix: use assertEqual instead of assertEquals for Python 3.11 compatibility 2022-03-21 11:05:43 +00:00
Ankush Menat
85428e817d test: get_value(s) with limits 2022-03-21 11:19:28 +05:30
mergify[bot]
f47331cd1d
Merge pull request #16200 from alyf-de/refactor-db-exists
refactor: `frappe.db.exists`
2022-03-21 05:47:27 +00:00
barredterra
734d0b4fe8 test: frappe.db.exists 2022-03-17 01:35:46 +01:00
phot0n
bebc8058b6 feat: integer primary keys 2022-03-11 23:46:00 +05:30
Ankush Menat
d3f768fef9 feat(db/pg): ability to ignore pk colission 2022-02-09 16:25:36 +05:30
mergify[bot]
819202f5da
Merge pull request #15560 from gavindsouza/set_value-refactor
refactor: frappe.db.set_value
2022-02-02 06:41:58 +00:00
Saqib Ansari
bd8ac90286
fix(ux): show report button on too many writes error (#15614)
* feat: log errors on too many writes to ease debugging

* fix(ux): extract and show which app/file/function caused too many writes

* fix: postgres error checking assumes exception is postgres exception

* fix: better default for skipping frames

Typically stack is like: some_app -> your_function -> this function. So last 2 frames need to be skipped.

* fix: postgres error checking assumes exception is postgres exception

* fix: better default for skipping frames

Typically stack is like: some_app -> your_function -> this function. So last 2 frames need to be skipped.

* refactor: show Report button instead of logging

* revert: unnecessary new functionality

* test: assert exact exception

Co-authored-by: Ankush Menat <ankush@frappe.io>
2022-01-31 18:57:32 +05:30
Gavin D'souza
9f1503c582 test: Postgres compatible db tests 2022-01-11 12:54:18 +05:30
Gavin D'souza
202145f0ec test: Add tests for frappe.db.set_value 2022-01-10 21:01:02 +05:30
Ankush Menat
e08b41964c feat: savepoint contextmanager
syntactic sugar around frappe.db.savepoint and rollback
2022-01-03 22:20:39 +05:30
Ankush Menat
1c0de77634 feat: SQL savepoints 2021-12-20 23:07:53 +05:30
Aradhya
7faa843e97 feat: Added distinct in get_value 2021-12-17 15:01:24 +05:30
Aradhya
e1360a3770 test: Added tests for distinct in get values 2021-12-17 13:45:57 +05:30
Aradhya
e862ae83da fix: fixed list of Field objects as fields in get_values
tests: added test for list of field objects
2021-12-03 14:24:19 +05:30