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
479f637f76
fix(single:set_value): Cast using sbool instead of str for all
2022-01-10 20:59:50 +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
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
mergify[bot]
96a45473ab
Merge pull request #15492 from resilient-tech/fix-clear-cache-in-set-value
...
fix: clear cache for all docs matched with the filters passed as `dn` param in `set_value`
2022-01-05 07:06:07 +00:00
Ankush Menat
80d456ef7e
fix: avoid cached results for table_exists during install
2022-01-05 11:54:46 +05:30
Ankush Menat
08464553f3
fix: define check_transaction_status for postgres
...
To implement repeatable reads it has to respect transactions.
2022-01-04 13:59:22 +05:30
Ankush Menat
0fddbafd09
fix(postgres)!: dont silently rollback on db exception
2022-01-04 11:25:08 +05:30
Ankush Menat
3c83043301
chore: sort imports
...
also fix `time` import
2022-01-04 10:53:31 +05:30
Ankush Menat
e08b41964c
feat: savepoint contextmanager
...
syntactic sugar around frappe.db.savepoint and rollback
2022-01-03 22:20:39 +05:30
Pruthvi Patel
289d7e7afa
fix: clear cache when filters passed as dn param in set_value
2022-01-01 17:49:59 +05:30
Aditya Hase
d334379b02
fix(restore): Repopulate db_tables cache after database restore
...
This takes care of the following scenario.
During restore, before tabDefaultValue is created if a request/command executes frappe.db.get_tables, then the cached value db_tables is populated with partial list of tables.
bootstrap_database then checks if this partial list contains tabDefaultValue (as a sanity test to see if the restore worked). This check fails even though the database is correctly restored.
2021-12-22 10:58:17 +05:30
Ankush Menat
1c0de77634
feat: SQL savepoints
2021-12-20 23:07:53 +05:30
Aradhya
7faa843e97
feat: Added distinct in get_value
2021-12-17 15:01:24 +05:30
Aradhya
e1360a3770
test: Added tests for distinct in get values
2021-12-17 13:45:57 +05:30
Aradhya
33b4ff0a84
fix(db): fixed distinct in get_values
...
refactor: remove redundant imports
2021-12-17 13:30:07 +05:30
Aradhya
3243fb2083
fix: misc fixes
2021-12-06 13:04:27 +05:30
mergify[bot]
23e5505923
Merge pull request #15170 from Aradhya-Tripathi/at/fixes
...
fix: fixed list of Field objects as fields in get_values
2021-12-03 14:36:36 +00:00
Saqib Ansari
6f7d030e82
fix: IndexError while handling sql timeout error
2021-12-03 16:06:23 +05:30
Aradhya
e862ae83da
fix: fixed list of Field objects as fields in get_values
...
tests: added test for list of field objects
2021-12-03 14:24:19 +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
fc65c2cd36
fix: fixed pluck in execute
2021-11-25 16:20:06 +05:30
Aradhya
f04b2157f1
refactor: getting rid of kwargs
2021-11-25 13:07:38 +05:30
Aradhya
47367fc107
Merge branch 'at/aggregations' of github.com:Aradhya-Tripathi/frappe into at/aggregation
2021-11-24 19:01:29 +05:30
Aradhya
c9b05f7d95
fix: fixed as_dict in get_values
2021-11-24 16:10:29 +05:30
Aradhya
303edc8c04
refactor: added get_sql function to query class (encapsulation++)
2021-11-24 15:53:03 +05:30
Aradhya
7a0c06b46a
fix: fixed semgrep issues
2021-11-23 15:56:55 +05:30
Aradhya
d55d19ea50
refactor: using throw instead of raise
2021-11-23 15:46:44 +05:30
Aradhya
59f54aa60c
refactor: changed default_ordering to keep_default_ordering
2021-11-23 15:26:15 +05:30
Aradhya
c4f76c0568
fix: fixed order_by arg in get_value
2021-11-23 14:21:20 +05:30
Aradhya
30278a3939
refactor: removed no_order to support order_by None as valid input
2021-11-23 13:29:59 +05:30
Aradhya
ae68ad53a7
feat: Added permissions to database API
2021-11-20 23:51:06 +05:30
Aradhya
ae59fd7c58
feat: added no_order to execute
2021-11-19 22:58:32 +05:30
Aradhya
d37aa55607
fix: fixed merged conflicts
2021-11-18 18:13:10 +05:30
Aradhya-Tripathi
b081496912
fix: added additional conditions when filters are None
2021-11-16 22:44:51 +05:30
Aradhya-Tripathi
6a8515af85
feat: Added pluck to get_values
2021-11-16 15:12:39 +05:30
Aradhya-Tripathi
952921ef79
fix: fixed list filters in get_values
2021-11-12 14:32:24 +05:30
Aradhya-Tripathi
b8340fff58
feat: Added support for Criterion objects as fieldnames
2021-11-08 15:56:20 +05:30
Gavin D'souza
c755df29bd
Merge branch 'develop' of github.com:frappe/frappe into mask-sql-errors
2021-10-26 15:37:03 +05:30
mergify[bot]
ebc29efae5
Merge pull request #14499 from ankush/configurable_max_writes
...
refactor: move max_writes constant to a class var
2021-10-25 07:01:13 +00:00
Aradhya-Tripathi
ca1d9b4514
fix: fixed sider issues
2021-10-23 16:03:29 +05:30
Aradhya-Tripathi
33775b5373
style: reverting erroneous formatting
2021-10-23 15:17:40 +05:30
Aradhya-Tripathi
94f2a6e275
feat: Added run kwarg to get_all, get_values
2021-10-23 15:08:02 +05:30
Aradhya-Tripathi
23c3079433
fix: set_value now takes for_update for pypika objects
2021-10-22 23:43:47 +05:30
Aradhya-Tripathi
e46b1d1116
feat: Added pluck in sql to mirror sql_list
2021-10-22 12:44:33 +05:30
Saqib Ansari
4f288db878
refactor: handle exception messages on client side
2021-10-19 20:00:35 +05:30