seitime-frappe/frappe/database
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
..
mariadb feat: added support for data type json (#16187) 2022-04-14 04:21:41 +00:00
postgres feat: added support for data type json (#16187) 2022-04-14 04:21:41 +00:00
__init__.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
database.py refactor: make frappe.db.bulk_insert work as expected (#16527) 2022-04-19 14:47:22 +00:00
db_manager.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
query.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
schema.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30
sequence.py style: format all python files using black (#16453) 2022-04-12 10:59:25 +05:30