Commit graph

74 commits

Author SHA1 Message Date
gavin
6db1038501 refactor(qb): Rename term subqry to SubQuery
"SubQuery" conforms with terms naming in PyPika. Kept subqry that points
to same def for maintaining APIs.
2022-05-27 16:55:54 +05:30
saxenabhishek
1df3e8f5e7 test: test agg funtions 2022-05-16 15:20:23 +05:30
saxenabhishek
846b89a703 test: test cast funtion 2022-05-16 15:20:23 +05:30
saxenabhishek
e59c2f7b04 test: match edge case 2022-05-16 15:20:23 +05:30
Gavin D'souza
66655eb8ed Merge branch 'develop' of github.com:frappe/frappe into bg-rename_doc 2022-04-14 13:41:56 +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
Abhishek Saxena
5c8856d66e
refactor: db.sql calls to frappe.qb (#16107)
# Changes

- Introduces `subqry` class to use in where clause when there is a non-column condition. eg.
> .where(subqry(no_of_roles) == 0)
- Convert SQL queries to frappe.qb 

# Testing

Functions with query refactors
- frappe.boot.get_user_pages_or_reports() -> Same output of `get_bootinfo()` as develop
- frappe.boot.get_unseen_notes() -> Forms the same query as develop 
```sql
SELECT `name`,`title`,`content`,`notify_on_every_login`
FROM `tabNote` WHERE `notify_on_every_login`=1
AND `expire_notification_on`>'2022-03-30 01:10:53.393874'
AND (SELECT `nsb`.`user` FROM `tabNote Seen By` `nsb` WHERE `nsb`.`parent`=`tabNote`.`name`) NOT IN ('Administrator')
```
- frappe.installer._delete_doctypes() -> installed and uninsalled a dummy app to drop tables

### Not tested
- frappe.make_property_setter()
- frappe.realtime.get_pending_tasks_for_doc() [whitelist method]
- frappe.sessions.Session.start()
- frappe.twofactor.cache_2fa_data()
2022-04-12 05:07:25 +00:00
Gavin D'souza
2d806b5d6d fix: Ported subqry to branch for compatibility
Via https://github.com/frappe/frappe/pull/16107
2022-03-31 13:41:08 +05:30
Gavin D'souza
71d3f1c0d1 feat(minor): Add DateFormat function util for qb 2022-03-31 13:39:06 +05:30
Ritwik Puri
0d16c20f93
test: tests for Cast_ Function in qb (#16399)
* test: tests for Cast_ Function in qb

* test: remove unneeded sync

Co-authored-by: Mohammad Hasnain <hasnain2808@gmail.com>
2022-03-25 14:46:08 +05:30
Mohammad Hasnain Mohsin Rajan
fda544f424
refactor!: make automatically following documents optional (#16030)
* fix: make automatically following documents optional

* fix: optimize email triggers for document followed

* test: add tests for document follow settings

* test: sync global search before testing

* fix: extend pypika's cast function to mimic varchar cast in MariaDB

Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
Co-authored-by: phot0n <ritwikpuri5678@gmail.com>
2022-03-25 02:01:15 +05:30
Ankush Menat
b029b255fe refactor: code duplication for sql whitelisting 2022-03-24 17:49:28 +05:30
Gavin D'souza
f92f77dab7 fix(qb): Make Table importable 2022-03-22 20:31:37 +05:30
Ankush Menat
1a0fb21645 feat: MySQL TIMESTAMP functionality for QB 2022-03-16 15:13:04 +05:30
Ankush Menat
496e5b513b fix: executing non-select qb code from whitelisted methods
Co-Authored-By: Gavin D'souza <gavin18d@gmail.com>
2022-02-08 13:06:24 +05:30
saxenabhishek
44d7940746 fix: missing param_wrapper in recursive calls 2022-02-03 12:32:47 +05:30
Gavin D'souza
229e259bd2 fix: Format timedelta object accurately 2022-01-31 11:56:09 +05:30
saxenabhishek
97d6a96419 fix: timedelta parsing in pypika 2022-01-25 13:28:11 +05:30
saxenabhishek
02bdc35490 fix: make parameters for strings only 2022-01-15 14:55:28 +05:30
saxenabhishek
9121014f48 fix: ignore copy of getattr methods 2022-01-11 16:53:42 +05:30
saxenabhishek
ece1564e4d fix: replace the field method with a column 2022-01-11 15:32:07 +05:30
saxenabhishek
471c0bd697 docs: Working of NamedParameters in qb 2022-01-11 01:01:44 +05:30
saxenabhishek
e2d49c17ff refactor: remove reduandant func call 2022-01-11 01:01:44 +05:30
saxenabhishek
0f75394720 refactor: pythonic NamedParameterWrapper 2022-01-11 01:01:44 +05:30
Gavin D'souza
f6fba91fd2 chore(typing): Add type hints in qb builder classes 2022-01-10 13:44:23 +05:30
Gavin D'souza
04e79eb075 fix(qb:ValueWrapper): Use get_value_sql only for str values 2022-01-10 13:25:47 +05:30
Gavin D'souza
6aa9a0bef5 style: Sorted imports & whitespace consistency 2022-01-07 20:44:51 +05:30
Gavin D'souza
34a6f7adb5 fix(qb): Patch ParameterizedValueWrapper as wrapper_cls 2022-01-07 20:43:50 +05:30
Suraj Shetty
e8ced74901
Merge branch 'develop' into aks-feat-sanitise_qb_2 2021-12-12 10:16:26 +05:30
saxenabhishek
a71795afec docs: ConstantColumn 2021-12-08 15:46:30 +05:30
saxenabhishek
9a393e5654 fix: postgres compatibility 2021-12-08 15:43:22 +05:30
Suraj Shetty
5c34405d8a
Merge branch 'develop' into aks-feat-constCol 2021-12-08 09:33:50 +05:30
saxenabhishek
4f7c8d066a feat: build constant value cols 2021-12-07 20:55:38 +05:30
Suraj Shetty
99defea410
fix: Explicitly ignore semgrep warning 2021-12-07 16:40:45 +05:30
saxenabhishek
6120b4b3c1 fix: extend named parameters to frappe.qb.function 2021-12-06 14:32:55 +05:30
saxenabhishek
9fdacedfc8 feat: sanitise frappe.qb 2021-12-06 14:29:57 +05:30
saxenabhishek
a574c1ba88 chore: patching ValueWrapper 2021-12-06 14:27:42 +05:30
Aradhya
3243fb2083 fix: misc fixes 2021-12-06 13:04:27 +05:30
Aradhya
69108c4c86 Merge branch 'develop' of github.com:Aradhya-Tripathi/frappe into at/aggregations 2021-11-27 17:52:30 +05:30
Aradhya
b5c73648dc refactor: made DRY-er functions 2021-11-26 15:44:14 +05:30
Aradhya
e3bdf11006 refactor: moved aggregation functions to Query Builder 2021-11-26 14:19:59 +05:30
Aradhya
22434d065c feat: Added aggregation functions to qb functions
refactor: changed args to aggregation funcs to match db level aggregation funcs
2021-11-26 13:19:26 +05:30
Aradhya-Tripathi
008954aed8 feat: added Pseudocolumn to qb utils 2021-11-16 15:12:18 +05:30
Aradhya-Tripathi
4eabb7129e feat: Added concat_ws in frappe.qb 2021-11-08 13:55:17 +05:30
mergify[bot]
00d137d1cb
Merge pull request #14454 from Aradhya-Tripathi/at/patch/builder
feat: prepending `tab` to doctypes in query builder
2021-10-14 11:09:42 +00:00
Aradhya-Tripathi
c6542749cd feat: prepending tab to table name for UPDATE and INSERT 2021-10-14 15:00:01 +05:30
Gavin D'souza
2622f3398e style: Black-ish queries
* feat(minor): Added DocType to frappe.query_builder namespace
2021-10-11 19:00:52 +05:30
Aradhya-Tripathi
5362d367d1 fix(minor): fixed execute_query patch 2021-10-11 14:15:01 +05:30
Aradhya-Tripathi
fe7b45c068 fix: fixing safeqb in server scripts 2021-10-11 14:01:17 +05:30
Gavin D'souza
cfa2d65394 refactor(safe_exec): Manage in-safe frappe.db.sql
* Check if flag in_safe_exec to check if SELECT query in frappe.db.sql
* Get rid of read_sql...refactor logic
* Enable frappe.qb just like that ;)
* Add support fro *args in .run
2021-10-11 12:28:36 +05:30