Commit graph

91 commits

Author SHA1 Message Date
Gavin D'souza
fdff6351cd test: Add test for DatabaseQuery for virtual doctypes 2023-02-02 13:45:35 +05:30
Gavin D'souza
c4061904da test: Split DBQuery & ReportView API tests into separate cases 2023-02-02 13:45:17 +05:30
Faris Ansari
be654eaa60
Merge branch 'develop' into refactor-qb-engine 2023-01-09 15:23:20 +05:30
Faris Ansari
726fcfdb79 refactor: qb.engine
- simplify
- qb.engine.get_query -> qb.get_query
- qb.engine.build_conditions -> qb.get_query
2022-12-25 23:19:11 +05:30
gavin
6062d812a1
fix(db_query): Disallow usage of certain functions in *_by (#18981)
* fix(db_query): Disallow blacklisted functions in (order|group)_by

Changes:
- allow only functions that are not blacklisted in *_by clause:
  currently just sleep
- perf improvemnts: lower, in, split, strip & other low hanging  micro optimizations

Handle the following use cases:
- upper/lower case function usages
- spaces between function name and brackets

* test(db_query): Add tests for *_by checks
2022-11-28 12:42:29 +05:30
Gavin D'souza
1a5e5f546b fix: Move function check inside subquery 2022-11-24 16:27:54 +05:30
Gavin D'souza
1f913248aa test: Add more tests for illegal subquery and fn usage 2022-11-24 15:36:31 +05:30
Shariq Ansari
235171796d
fix: coalesce not in queries (#18099)
* fix: get workspaces with empty module fields

* Revert "fix: get workspaces with empty module fields"

This reverts commit 1f194be2c3642e31ebe2165e461b2f24be8cda4c.

* fix: always coalesce `not in` queries

Co-authored-by: Ankush Menat <ankush@frappe.io>
2022-09-13 12:08:07 +05:30
Ankush Menat
cdb0732646
perf: avoid coalescing wherever possible (#17920) 2022-08-24 10:30:51 +05:30
Ankush Menat
2eec621e95 chore: db.get_all -> get_all
Reduces 1 pointless function call.
Function calls are also not "super cheap" in python.
2022-08-22 11:35:14 +05:30
Faris Ansari
82fef72ce1
fix(db-query): parenttype condition on child table left join (#17865)
joining only on name is incorrect because parent primary keys are not unique across tables

How was this working all this time? 🥲
2022-08-18 09:04:40 +00:00
Ankush Menat
3e2d2a703a test: Use FrappeTestCase everywhere 2022-08-17 16:39:42 +05:30
phot0n
a52483f110 Revert "fix: remove integration request check from test_is_set_is_not_set"
This reverts commit b3f57f0e7774928df90bdf84c7ec23b5d3be53c8.
2022-07-26 23:17:04 +05:30
phot0n
91b04c2154 test: fix test_set_field_tables
removed amount_field from groupby and fields
2022-07-26 23:17:04 +05:30
phot0n
5c2cfdd1e9 fix: remove integration request check from test_is_set_is_not_set 2022-07-26 15:11:56 +05:30
Aradhya
4da5fdcd02 fix: fixed spaces in args
fix: lint
2022-06-29 17:37:49 +05:30
Aradhya
6db6be1f3c refactor: frappe.qb.engine
* Small fixes in set_fields and clean code
* Optimize casefolds
* Fixed functions passed in List
* get_sql => get_query - more expressive, less confusion
* Updated tests
2022-06-28 19:43:57 +05:30
Aradhya
4af2e1e886 refactor: replaced frappe.db.query with frappe.qb.engine 2022-06-28 19:43:50 +05:30
Faris Ansari
87ec6d4fb9 fix: initialize link_tables in constructor 2022-05-30 10:50:16 +05:30
Faris Ansari
507a45d8f2 fix: dot syntax support for link fields
 test
2022-05-28 13:57:44 +05:30
Faris Ansari
96b30e714c feat: table_field.fieldname field syntax for db_query 2022-05-27 16:04:22 +05:30
Shariq Ansari
b4e43257c3
fix: bad query if user has ' in the email address (#16796) 2022-05-04 19:07:51 +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
Ritwik Puri
d1423f1517
test: use data fieldtype instead of int in test_fieldname_starting_with_int (#16771)
* fix(test): use data fieldtype instead of int

postgres doesn't allow using like operator on int/any non-text/varchar column
ref: https://github.com/frappe/frappe/issues/16722

* minor: updated test_fieldname_starting_with_int with child table filters
2022-04-28 13:46:09 +05:30
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
phot0n
7e1a0ed5de test: test for fieldname which start with int 2022-04-01 12:58:49 +05:30
phot0n
d032822093 fix: use backticks in test_cast_name 2022-03-31 22:59:46 +05:30
phot0n
4ea87fd9cc chore: rename cast_autoincremented_name to cast_name 2022-03-11 23:46:00 +05:30
phot0n
bebc8058b6 feat: integer primary keys 2022-03-11 23:46:00 +05:30
ChillarAnand
5ce3937d79 fix: Handle None filters in db query 2022-02-24 15:19:31 +05:30
cpdeethree
58f7b02c30 fix: add test_for prepare_select_args 2022-01-11 13:25:40 +05:30
Mohammad Hasnain
d7b7afeb14 fix: format between for creation/ modified 2021-10-19 16:18:21 +05:30
Suraj Shetty
18df0b0f8c test: Fix test 2021-10-12 13:46:06 +05:30
Suraj Shetty
74ec9657da test: Update aggregation test 2021-10-12 13:36:30 +05:30
Suraj Shetty
8febefae9c test: Add test case to validate aggregation
- based on child table field
2021-10-12 12:05:05 +05:30
Gavin D'souza
86fa811004 test: Add test for DatabaseQuery Column comparison 2021-09-16 13:04:25 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Gavin D'souza
c00a5003f4 refactor(tests): frappe.db.delete > frappe.db.sql
Use frappe.db.delete wherever possible. Get rid of all the frappe.db.sql
;)

This commit focuses on the frappe.tests module
2021-08-19 19:48:42 +05:30
Gavin D'souza
7e68fad061 fix: Add test for DatabaseQuery.extract_tables
Test for selecting field from another table and field that includes tab
2021-06-15 17:19:42 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
Rushabh Mehta
337bdc976c fix(reportview): test 2021-03-30 18:35:44 +05:30
Suraj Shetty
6f774d6d0c
fix: Check for fieldlevel permission for report query (#12163)
Co-authored-by: Prssanna Desai <prssud@gmail.com>
2021-01-28 17:14:47 +05:30
Aditya Hase
fa2c320c49
test(db_query): Test for pluck syntax 2020-10-06 18:27:19 +05:30
Chinmay Pai
e30161b222
fix: disallow global variable access through sql (#10875)
* fix: disallow global variable access through sql

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
Co-authored-by: Sahil Khan <sahilkhan28297@gmail.com>

* chore: add test for sql disallowed variable access

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>

Co-authored-by: Sahil Khan <sahilkhan28297@gmail.com>
2020-07-10 13:55:06 +00:00
Shivam Mishra
00d21a2ac5 fix: tests for db_query 2019-10-29 10:17:52 +05:30
Shivam Mishra
5f5202d360 fix: doctype in test 2019-10-27 17:34:39 +05:30
Shivam Mishra
e293ea2289 style: removed unused import 2019-10-25 11:35:11 +05:30
Shivam Mishra
c0d69a04c4 feat: added tests 2019-10-24 19:47:53 +05:30
Faris Ansari
2508ae1377 test: Set user Administrator 2019-09-18 11:04:34 +05:30