seitime-frappe/frappe/tests
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
..
data test: Add tests for optimize_file 2021-08-25 17:17:39 +05:30
__init__.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_api.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_assign.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_auth.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_background_jobs.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_base_document.py fix: use assertEqual instead of assertEquals for Python 3.11 compatibility 2022-03-21 11:05:43 +00:00
test_boilerplate.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_bot.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_child_table.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_client.py test: dict and JSON filters in client.get 2022-04-16 06:03:40 +05:30
test_commands.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_cors.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_db.py refactor: make frappe.db.bulk_insert work as expected (#16527) 2022-04-19 14:47:22 +00:00
test_db_query.py fix: new_doctype API testing util 2022-04-12 19:06:35 +05:30
test_db_update.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_defaults.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_docstatus.py feat: utility methods for docstatus (#15515) 2022-02-04 07:41:25 +00:00
test_document.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_document_locks.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_domainification.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_dynamic_links.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_email.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_exporter_fixtures.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_fixture_import.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_fmt_datetime.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_fmt_money.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_form_load.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_formatter.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_frappe_client.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_geo_ip.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_global_search.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_goal.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_hooks.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_linked_with.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_listview.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_monitor.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_naming.py test: naming on child tables 2022-04-14 16:33:23 +05:30
test_nestedset.py test: Added tests for nestedset 2022-04-12 19:06:01 +05:30
test_oauth20.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_password.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_patches.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_pdf.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_permissions.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_printview.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_query_builder.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_query_report.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_rate_limiter.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_recorder.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_redis.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_rename_doc.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_safe_exec.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_scheduler.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_search.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_seen.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_sitemap.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_translate.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_twofactor.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
test_utils.py test: set name to create client script 2022-04-13 18:36:44 +05:30
test_webform.py test: test hook to get website_list_context 2021-09-03 16:55:44 +05:30
test_website.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
tests_geo_utils.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
translation_test_file.txt feat: allow splitting _() function call on multiple lines 2022-03-26 16:18:35 +05:30
ui_test_helpers.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
utils.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30