Commit graph

153 commits

Author SHA1 Message Date
Devin Slauenwhite
160f0b65fb
Merge branch 'develop' into fix-ambigus-table-join 2023-03-03 09:44:29 -05:00
gavin
3406b6d752
fix(db_query): selecting linked fields as alias (#20085)
* fix(db_query): Don't track link_tables separately

Treat all joined tables the same, expand the fieldnames whether Table or
Link type with their respective table names

* fix(db_query): Add link join conditions for all relevant fields

* Revert "fix(db_query): Add link join conditions for all relevant fields"

This reverts commit 79622ab4cea5aa73a24f4ba7afde8e83510a79fb.

* Revert "fix(db_query): Don't track link_tables separately"

This reverts commit b8364f781e52e7ffaa7faa8878ef409b023f2288.

* fix: Check link field tables permissions in permlevel checks

* test: Fix, add for test_permlevel_fields

Previous assertion was wrong :')
added extra to check if access is fine
2023-02-22 22:14:15 +05:30
Gavin D'souza
c4544cb37e test: test_get_count 2023-02-03 20:53:53 +05:30
Gavin D'souza
3cd781e316 Merge branch 'develop' into get_all-virtual-dts 2023-02-02 13:55:24 +05:30
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
Gavin D'souza
9efe84a644 fix(reportview): Remove aggregate_on_field added in fields
Essentially reverts changes added via
https://github.com/frappe/frappe/pull/14424 but works just the same
without the additional column :thonk:

The added column's data in mariadb was essentially garbage data. Wasn't
meaningful from what I could tell - couldn't play well with postgres
either
2023-01-20 19:26:56 +05:30
gavin
4be74bc013
Merge branch 'develop' into permlevel-apis 2023-01-19 11:00:15 +05:30
Gavin D'souza
f0a282e941 test: Add test for linked table permission check 2023-01-16 14:28:13 +05:30
Gavin D'souza
7e38d7fe63 test: Make test_child_table_join more resilient 2023-01-16 13:56:37 +05:30
Devin Slauenwhite
1fa9c15240 fix(test): test no pymysql.err.OperationalError 2023-01-13 14:39:21 -05:00
Devin Slauenwhite
af579e3192 test: ambiguous linked tables 2023-01-13 14:09:09 -05:00
Gavin D'souza
9012b95a9a fix(postgres): group_by in reportview, tests
Add approporiate group_by, order_by clauses in reportview and tests for
featureset compatibility with postgres
2023-01-11 12:42:45 +05:30
Gavin D'souza
d2ad86d2fe test: Add tests for permlevel handing in get_list 2023-01-10 17:44:06 +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