Commit graph

36841 commits

Author SHA1 Message Date
cpdeethree
58f7b02c30 fix: add test_for prepare_select_args 2022-01-11 13:25:40 +05:30
Gavin D'souza
4e5f02aea5 Merge branch 'set_value-refactor' of github.com:gavindsouza/frappe into set_value-refactor 2022-01-11 13:00:40 +05:30
Gavin D'souza
f5072af00d fix: sbool before cint in cast for Check types
Noticed an issue when get_single_value wasn't returning the correct
values; by converting true to 0.

Tested it out. Here's the examples:

In [2]: sbool("2")
Out[2]: '2'

In [3]: cint(sbool("2"))
Out[3]: 2

In [4]: cint(sbool("-1"))
Out[4]: -1

In [5]: cint(sbool("0"))
Out[5]: 0

In [6]: cint(sbool("1000"))
Out[6]: 1000

In [7]: cint(sbool("10_000"))
Out[7]: 10000

In [8]: cint(sbool("true"))
Out[8]: 1
2022-01-11 12:57:23 +05:30
Gavin D'souza
9f1503c582 test: Postgres compatible db tests 2022-01-11 12:54:18 +05:30
Suraj Shetty
4b5e67e165
Merge pull request #15580 from surajshetty3416/fix-datetime-control 2022-01-11 11:16:35 +05:30
Pruthvi Patel
a87899c215 test: add test for limit 2022-01-11 11:12:53 +05:30
Suraj Shetty
3d77f544fd fix(datetime): Fix side-effect due to __run_link_triggers
- `__run_link_triggers` should only affect link fields
- Removed usage of `__run_link_triggers` from base control and introduce `force_set_value` for more explicit action.
2022-01-11 10:09:14 +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
saxenabhishek
15f3523c24 test: qb parameterization
where conditions
set update conditions
where with a function
2022-01-11 01:01:29 +05:30
Gavin D'souza
d81fe8699c feat: frappe.db.set_single_value
Alias to frappe.db.set_value without having to pass the doctype name
twice or teh second one as None

Other changes:
* set/get db APIs for single DocTypes
* Make use of redundant cache key in frappe.db.get_single_value
2022-01-10 21:03:14 +05:30
Gavin D'souza
202145f0ec test: Add tests for frappe.db.set_value 2022-01-10 21:01:02 +05:30
Gavin D'souza
479f637f76 fix(single:set_value): Cast using sbool instead of str for all 2022-01-10 20:59:50 +05:30
mergify[bot]
5feebe22b0
Merge pull request #15569 from ankush/drop_py37
fix!: drop py3.7 support for v14
2022-01-10 11:28:06 +00:00
mergify[bot]
2446c5e099
Merge pull request #15564 from Havenir/fix-communication-get-contacts
fix: communication method "get_contacts"
2022-01-10 11:22:35 +00:00
saxenabhishek
f7cb090c5a style: test_query_builder 2022-01-10 16:09:53 +05:30
Pruthvi Patel
d1852242a0 fix: limit in Document.get 2022-01-10 15:52:25 +05:30
Gavin D'souza
3052808048 fix: Don't cast to str if None or Falsy
* refactor: use get_single_value instead of set_value(blah, None, blah1)
* User.reload in test_home_page to combat what happens locally
2022-01-10 15:05:57 +05:30
Ankush Menat
3d474b5927 fix: drop py3.7 support for v14 2022-01-10 13:45:18 +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
5de0b5cd35 style: remove commented code, whitespaces test_file, added typing hint 2022-01-10 13:23:49 +05:30
Pruthvi Patel
000625038c fix: delete property setter 2022-01-10 10:41:51 +05:30
Pruthvi Patel
97edb8f267 fix: delete translation only if label is empty 2022-01-10 10:40:58 +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
Saqib Ansari
d7aa7ac762 refactor: format multiselect table fields based on fieldtype 2022-01-07 20:15:55 +05:30
Saqib Ansari
05d80e3b6d refactor: build_for_autosuggest 2022-01-07 18:43:09 +05:30
Ahmad
9ebfc1ced9 refactor: communication.py 2022-01-07 17:33:54 +05:00
Ahmad
6afa5c8da3 fix: email_string parsing when pulling email 2022-01-07 17:33:35 +05:00
Rohan Bansal
10c5e732a5 fix: allow longer authorization URIs 2022-01-07 17:54:28 +05:30
Saqib Ansari
2b80cabaea chore: remove unused parameter 2022-01-07 16:46:49 +05:30
Saqib Ansari
f760aa1de2 perf: use get_value instead of get_cached_value
get_cached_value internally calls get_doc which is much slower than fetching a value from db
2022-01-07 16:43:58 +05:30
Saqib Ansari
74276ef69b chore: undo changes to link ui test 2022-01-07 16:22:15 +05:30
Saqib Ansari
e6a87332f8 chore: make label concise 2022-01-07 16:09:39 +05:30
Saqib Ansari
06b00e8e01 Merge branch 'develop' of https://github.com/frappe/frappe into link_title_refactor 2022-01-07 16:01:44 +05:30
ruthra
bf68f76405 fix: data exporter throwing exception 2022-01-07 15:49:05 +05:30
Saqib Ansari
1bde3b48bd fix: parsing exception from traceback 2022-01-07 14:56:25 +05:30
Saqib Ansari
307c7ced69 chore: check custom exception handlers only for json response 2022-01-07 14:55:54 +05:30
Gavin D'souza
31cc658e6d fix(typing): Add type hints for frappe.cache 2022-01-07 14:17:28 +05:30
Gavin D'souza
123bcc9509 fix: Clear cache on set_value 2022-01-07 14:16:45 +05:30
Gavin D'souza
b0c30363cf fix: Cast values as str for all single doctypes
Re-arranged block for simplicity. Type casting doesn't change anything
it seems. On get_value, values are casted properly.
2022-01-07 11:49:49 +05:30
Gavin D'souza
697d6f2d7a fix: Run query even if no documents found for_update
If no docnames are found, then use NULL as fallback. I tested this on PostgreSQL & MariaDB and it seems to work as expected

    In [1]: from frappe.query_builder import Field

    In [2]: frappe.db.set_value('ToDo', Field("creation") > Field("modified"), 'description', 'change 2', for_update=True, debug=True)
    SELECT "name" FROM "tabToDo" WHERE "creation">"modified"
    Execution time: 0.0 sec
    UPDATE "tabToDo" SET "description"='change 2',"modified"='2021-10-22 09:38:40.110481',"modified_by"='Administrator' WHERE "name" IN (NULL)
    Execution time: 0.0 sec
2022-01-07 11:47:49 +05:30
Gavin D'souza
aefb8e3b06 fix: Expand iterable to get rid of extra brackets
Although valid SQL, MariaDB didn't like double brackets on VALUES. It
raised ERROR 1241: Operand should contain 1 column(s)
2022-01-07 11:46:56 +05:30
Gavin D'souza
44f603fc6e refactor: frappe.db.set_value
* Simplified logic
* Perf enhancements (removed unnecessary conditional computations)
* Use query builder and ORM to build queries instead of juggling
2022-01-07 11:45:27 +05:30
Gavin D'souza
981564e544 Merge branch 'develop' into frappe-postgres-changes 2022-01-07 11:37:28 +05:30
Gavin D'souza
d9b571cf43 refactor(minor): DatabaseQuery.prepare_select_args
* Used regex to replace instead of re-iteration (for-loop)
* Used f-strings for better readability
* Renamed and re-ordered vars, code block
2022-01-07 11:35:52 +05:30
Suraj Shetty
b64cab6867
Merge pull request #15543 from alyf-de/white-space-unset 2022-01-07 11:16:58 +05:30
mergify[bot]
7f74a3164d
Merge pull request #15551 from hrwX/custom_translations
feat: add translations to datatable
2022-01-07 05:25:03 +00:00