Commit graph

411 commits

Author SHA1 Message Date
gavin
d29641f734
Merge branch 'develop' into aks-feat-dbquery_update 2022-05-09 12:02:36 +05:30
Ritwik Puri
b41379c78b
fix: misc fixes (integer primary keys) (#16307)
* fix: misc fixes

local.x gets resetted on every request so switched to a simple dict

simplified is_val_used in set_next_val function for sequences

* chore: use multisql for sequence methods

* fix: fields not updating on form

* minor(base_input): removed unnecessary branching in update_input

* chore: remove prints and rename autoincremented_status_map

* chore: added proper type hint + comment + formatting

* fix: added searching in cast_name rather than handling it manually

* fix: share condition query + test_build_match_conditions

* fix: add cast_name to more places

* test: test for sequence

* fix: sequence functions

* fix: inherit frappetestcase

* minor: attach sequence methods to db context local

* chore: update sequence function names in Database

use frappe.db for sequences in naming.py

* fix: convert filename to str (for autoincremented doctypes)

* chore: better regex for modifying values for postgres

* minor: allow changing name column type (if no data is present in the doctype)

* refactor: validate_autoname

converted it to a simple function
enabled changing autoincrement autoname from customize form

* fix: use sql_ddl for change_column_type in postgres

* fix: use not null constraint in postgres when changing name type

* fix(test): updated test_autoincremented_doctype_transition with transitioning when no data is present

* fix(test): updated test_cast_name

probably messed up during rebase

* fix(test): used rollback upon error in transaction for postgres

* chore: use frappe.db.x methods for sequences

* minor: use temporary sequences in test

* minor: use generate_hash for sequence naming in sequence tests

* chore: replace sequence imports with frappe.db.x

* chore: move out casting name fields to a separate method

* refactor: cast_name

more explicit cases for casts and added docstring

* fix: added space in test_cast_name

* chore: fix linter

* chore: better naming for can_change_name_column_type

* chore: add comment for autoincremented_site_status_map

* chore: update/add docstrings
2022-04-29 15:06:03 +05:30
saxenabhishek
36de21c059 feat: left join tables by default 2022-04-28 17:10:31 +05:30
saxenabhishek
b1a0a3816b style: Applied Frappe linting 2022-04-28 17:10:31 +05:30
saxenabhishek
3498445733 test: multiple_tables_in_filters 2022-04-28 17:10:31 +05:30
saxenabhishek
d39e6a7890 refactor: new query engine in get_count() 2022-04-28 17:10:31 +05:30
saxenabhishek
c9df86f9ef feat: multi table queries 2022-04-28 17:10:31 +05:30
Suraj Shetty
ccc82e2c4c
Merge pull request #15538 from noahjacob/phone_field_control
feat: Phone Control Type
2022-04-28 10:27:52 +05:30
gavin
085900328b
Merge pull request #16688 from phot0n/multiple_order_by
fix: support for multiple order by in add_conditions
2022-04-26 16:09:29 +05:30
phot0n
4418c03237 fix: remove default null definition for name column in tabSeries
for postgres
2022-04-25 20:13:10 +05:30
gavin
2da85fa8da
Merge pull request #16698 from gavindsouza/traceback-with-context
feat: Traceback with context
2022-04-22 13:04:07 +05:30
Ankush Menat
dfef7192da
refactor: remove duplicate code from db.get_descendants (#16699) 2022-04-21 15:27:59 +05:30
Gavin D'souza
c691537e61 chore: Add typing for ease of development 2022-04-21 13:32:13 +05:30
phot0n
6405b0510a chore: fix linter 2022-04-20 17:56:48 +05:30
phot0n
da191390a5 fix: support for multiple order by in add_conditions 2022-04-20 17:56:48 +05:30
Gavin D'souza
35c606707e fix(bulk_insert): Cast values as list before subscripting 2022-04-20 16:43:19 +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
Suraj Shetty
6b7fda495b Merge branch 'develop' of https://github.com/frappe/frappe into phone_field_control 2022-04-14 14:19:35 +05:30
Shridhar Patil
39f8267a15
feat: added support for data type json (#16187)
> Please provide enough information so that others can review your pull request:

Added json support for postgres and mariadb



> Explain the **details** for making this change. What existing problem does the pull request solve?
https://github.com/frappe/frappe/projects/4#card-50160428


> Screenshots/GIFs
![json](https://user-images.githubusercontent.com/11792643/156367383-8f8492c2-3817-449d-a2dd-c983eeadbb48.gif)



---

**Previous attempts:** 

https://github.com/frappe/frappe/pull/8128
https://github.com/frappe/frappe/pull/7096


Docs: https://frappeframework.com/docs/v13/user/en/basics/doctypes/fieldtypes#json
2022-04-14 04:21:41 +00:00
Noah Jacob
c2f2fc10e7 Merge branch develop into phone_field_control 2022-04-12 20:40:29 +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
Noah Jacob
bf92b363e2
Merge branch 'develop' into phone_field_control 2022-04-07 15:04:47 +05:30
Gavin D'souza
ce5ac24b61 feat(db): Set frappe.db.debug to mass debug queries 2022-04-04 15:15:51 +05:30
gavin
278827cb18
Merge pull request #16468 from gavindsouza/misc-fixes-8
fix(utils): Misc fixes
2022-04-01 17:28:40 +05:30
gavin
3f6bbd6349
Merge pull request #16474 from resilient-tech/perf-get-doc-filters
perf: reduce query when calling `get_doc` with filters
2022-04-01 15:53:55 +05:30
Sagar Vora
e73c552632 fix: implement for_update for Single documents 2022-04-01 14:15:35 +05:30
Sagar Vora
493c7025f5 fix(get_value): make as_dict work for list-style filters 2022-04-01 00:33:15 +05:30
Gavin D'souza
69df3edba3 fix(query): Typo in OPERATOR_MAP 2022-03-31 16:24:03 +05:30
Gavin D'souza
10e4ed7c1e fix(query): Add human friendly operator oprions 2022-03-31 13:38:32 +05:30
Ankush Menat
c4ca58fedf refactor: query stripping 2022-03-28 10:56:55 +05:30
Ankush Menat
456cba71cd refactor: expand unreadable one-liner in get_value 2022-03-28 10:56:55 +05:30
Ankush Menat
3e1df641da fix: force keyword arguments in new ORM args 2022-03-28 10:56:55 +05:30
gavin
a7f1639e65
Merge branch 'develop' into log-settings 2022-03-23 13:20:33 +05:30
Gavin D'souza
300227ba71 fix(set_single_value): Make value parameter optional
Similar to set_value for accepting multiple columns ot be updated for
the same Table through a Dict as the second positional arg

Misc: Added type hints
2022-03-23 13:11:55 +05:30
Noah Jacob
579d0643c4 Merge branch 'develop' into phone_field_control 2022-03-22 15:05:45 +05:30
barredterra
44a7c0dd93 fix: copy dict before popping keys 2022-03-21 20:51:59 +01:00
Suraj Shetty
a1664330a7
Merge pull request #16344 from frappe/mergify/bp/develop/pr-16239 2022-03-21 20:49:33 +05:30
Shariq Ansari
5c6c9bb5c4
fix: resolved conflicts in database.py 2022-03-21 18:16:54 +05:30
Shariq Ansari
fbac6fbfb4 fix: only remove \n\t from start and end
(cherry picked from commit 7bb172365f2c9ae6cca98ccc4dfee7714b9c3f0c)

# Conflicts:
#	frappe/database/database.py
2022-03-21 05:50:58 +00:00
Shariq Ansari
b2c0bf7a4e fix: remove tab \t and newlines \n from start of query and remove from middle
(cherry picked from commit ac5effc7dd4d876d06daf945f0b8b77ecdd0c05f)

# Conflicts:
#	frappe/database/database.py
2022-03-21 05:50:57 +00:00
Ankush Menat
b97cfed6d7 perf: limit rows to 1 for get_value and exists 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
gavin
e696a8d73a
Merge pull request #16305 from gavindsouza/drop-site-pg
feat: Drop site support for postgres
2022-03-17 15:44:42 +05:30
barredterra
7e550e919c revert: don't check for doctype (861ff16) 2022-03-17 02:07:23 +01:00
Gavin D'souza
2558c6bee0 feat: Drop site support for postgres 2022-03-16 19:06:33 +05:30
phot0n
15ae019b12 fix: set_next_val function for sequences
postgres uses t & f, mariadb uses 0 & 1 for is_value_used
2022-03-11 23:46:01 +05:30
phot0n
bebc8058b6 feat: integer primary keys 2022-03-11 23:46:00 +05:30
Gavin D'souza
ad1e180666 feat(db): Alias is_missing_table for consistency in APIs 2022-03-11 14:03:21 +05:30
mergify[bot]
41ffb79828
Merge pull request #16250 from resilient-tech/typo-database-py
fix: typo in database file for v12 - latest
2022-03-11 08:27:43 +00:00
lapardnemihk1099
f4d3effaf2 fix: typo in database file for v12 - latest 2022-03-11 13:29:01 +05:30