Commit graph

71 commits

Author SHA1 Message Date
Ankush Menat
8ed2c87e00
perf: fix unneneccsary clearing of db.value_cache 2021-08-06 13:02:23 +05:30
saxenabhishek
42dc8a180f refactor: get_table_name, run_only_if 2021-07-30 11:48:12 +05:30
saxenabhishek
45d1afe739 refactor: move rename, change_column_type, DESC to db 2021-07-30 11:00:35 +05:30
saxenabhishek
ee3c84beef style: typecast to string inside db.sql 2021-07-30 11:00:35 +05:30
Gavin D'souza
b40721de4b style: Remove extra whitespace 2021-07-29 12:53:43 +05:30
Gavin D'souza
3ca7fa7796 refactor(minor): Make frappe.db.delete DRY-er 2021-07-28 19:01:07 +05:30
Aradhya-Tripathi
2f3371d873 refactor: Moved raw queries to frappe orm 2021-07-23 23:14:24 +05:30
Gavin D'souza
36c4be9a8d feat: frappe.db.truncate
ORM wrapper for SQL DDL statement

* Alias frappe.db.clear_table to use truncate
* Support for __ tables is added here
2021-07-23 11:52:41 +05:30
Gavin D'souza
1c82b83be0 refactor: Simplify frappe.db.delete logic
* Rename conditions kwarg to filters. Handle conditions kwarg if passed
* Re-added exc raise for no filters...to risky. Thinking of having an
  extra kwarg like `force` or something...undecided
* Added Python type hints
* Accept and pass kwargs to frappe.db.sql...Now pass any kwarg db.sql
  accepts
* Pass debug from fn def if someone is still using it as a positional
  arg :thonk:
2021-07-23 11:30:02 +05:30
Aradhya-Tripathi
bc39fd869f fix: Fixed typos 2021-07-23 10:45:54 +05:30
Aradhya-Tripathi
931549ee05 refactor: changed delete to accept no conditions 2021-07-21 19:20:35 +05:30
Mitul David
64840aac6b
refactor(minor): Delete redundant imports 2021-07-06 14:13:27 +05:30
Mitul David
a1e84d2341
fix: Accurately cast fieldtype in frappe.db.get_single_value() 2021-07-06 13:28:18 +05:30
Gavin D'souza
c489846547 Merge branch 'develop' into unnecessary_comprehensions 2021-06-11 19:30:23 +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
Ankush Menat
4754ab71d1
perf(minor): remove unnecessary comprehensions
- remove several unnecessary comprehensions from functions that accept a generator.
- Using `[x for x in iter]` causes a list to be built first then passed to the outer function.
- `any` and `all` can take generator instead. This makes memory usage O(1) and actually makes these functions short-circuiting. E.g. if the first condition fails then `all` will immediately return false instead of evaluating all the entries.
- `sum`, `min`, `max` => memory usage become O(1)
- `list`, `set`, `.join()` => roughly halves memory usage, as list is not required to be built.
- lastly, it's two fewer characters to read/think about.
2021-05-12 20:38:18 +05:30
leela
72ca7e9753 refactor: remove six dependency 2021-05-07 07:42:04 +05:30
Aditya Hase
2b1458e3fb
fix: Include dropped and renamed tables in touched tables list 2021-04-12 22:29:49 +05:30
Suraj Shetty
e6ef907184 fix(virtual doctype): Avoid circular calls 2021-04-04 10:13:18 +05:30
Suraj Shetty
65b55f6a90 fix: Check if doctype is virtual doctype before getting value 2021-04-02 16:24:29 +05:30
Shridhar
056b8c0fc6 feat: added get value for virtual doctype 2021-04-01 10:04:11 +05:30
Aditya Hase
b0456503f2
perf: Remove frappe.utils.background_job from import tree 2021-02-21 09:42:04 +05:30
Rushabh Mehta
c873c36971 feat(minor): add before_commit methods 2020-12-17 18:46:06 +05:30
Rushabh Mehta
8707ed1f27 fix(minor): remove "Custom Link" and add patch 2020-10-26 10:02:04 +05:30
Rushabh Mehta
7f9284f3ef fix(tests): postgres gotcha, errors will rollback? 2020-10-26 10:02:04 +05:30
Rushabh Mehta
a0a3606a7f fix(tests): add test cases for custom_link and custom_action 2020-10-26 10:02:04 +05:30
Rushabh Mehta
0192bcf45f fix(minor): frappe.db.set_value to allow multiple values 2020-08-17 22:19:44 +05:30
Rushabh Mehta
56853a0533 fix(linting): sider 2020-08-17 11:10:48 +05:30
Rushabh Mehta
b71acfd5fa fix(minor): print query and values directly if mogrify fails 2020-08-17 10:45:58 +05:30
Rushabh Mehta
b09beb9147 fix(tests): cleanup 2020-08-17 09:41:54 +05:30
Rushabh Mehta
aad2375cf3 fix(major): make document events more efficient, fix bug in cache_manager.get_doctype_map 2020-08-17 09:41:54 +05:30
Rushabh Mehta
26a9230fdd fix(tests): more debugging 2020-08-17 09:41:54 +05:30
Rushabh Mehta
e262ef6add fix(minor): logging fix in document.py 2020-08-17 09:41:54 +05:30
Rushabh Mehta
ef1d1b0dc4 fix(minor): typo 2020-08-17 09:41:54 +05:30
Rushabh Mehta
c83a9a142b fix(minor): mogrify 2020-08-17 09:41:54 +05:30
Rushabh Mehta
eba6dfa12a fix(major): frappe.db.set_value will lock the row 2020-08-17 09:41:54 +05:30
Rushabh Mehta
e421bc19f6 fix(major): frappe.db.set_value will lock the row 2020-08-17 09:41:54 +05:30
Rushabh Mehta
4d97635ab4 fix(major): frappe.db.set_value will lock the row 2020-08-17 09:41:54 +05:30
Rushabh Mehta
14d9c28eb7 fix(test): try with print_sql 2020-08-17 09:41:54 +05:30
Suraj Shetty
ed105eb001 fix: Clear db_tables cache whenever a table is created or dropped 2020-04-30 14:16:29 +05:30
Chinmay D. Pai
2f821f9c2d
chore: fix deepsource issues
* use set comprehension instead of generator
* remove redundant else statement

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-04-29 21:58:00 +05:30
Suraj Shetty
a73be732fd
refactor: Fix redundant cache value set 2020-04-29 16:43:01 +05:30
Suraj Shetty
bf3a80f05d fix: Directly used set comprehension
As indicated by deepsource
2020-04-29 14:39:14 +05:30
Suraj Shetty
031aad0d85 perf: Cache get_tables values
- To avoid redundant db calls
2020-04-29 12:28:08 +05:30
Dinuka Salwathura
e3dfb148e3
Change mysql host from localhost to 127.0.0.1
Having localhost makes mandatory to connect via mysqld.sock
changing host to 127.0.0.1 makes it to connect via tcp
2020-03-16 19:32:24 +05:30
Faris Ansari
488c68df96
Merge branch 'develop' into refactor-scheduler 2019-12-02 13:16:45 +05:30
Faris Ansari
2dac4f8432
fix(db.sql): Print query in debug mode (#8767) 2019-11-07 17:12:11 +05:30
Rushabh Mehta
fea34e3f6b fix(tests): test_scheduler 2019-11-07 12:14:09 +05:30
Himanshu
bf57a1d79a Patch(Tags): Check if column exists (#8682)
* fix: tags patch

* fix: auto_commit_on_many_writes

* fix: check if tag exists

* fix: check if tag or tag link exists

* fix: check if column exists

* fix: set autocommit false

* fix: use ignore in insert query for bulk insert

* fix: add option to ignore duplicates
2019-10-29 09:52:38 +00:00
Suraj Shetty
86263e05f4 perf: Cache db columns to avoid redundant database calls (#8543)
* perf: Cache db columns to avoid redundant database calls

* fix: Move cache clearing code from doctype to schema.py

* fix: self.table_name instead of self.name

* fix: Cache columns in  "table_columns" key

`table_columns` was cached in meta but columns were also getting accessed
directly using frappe.db.get_table_columns. Now, it is cached at
`frappe.db` layer

Co-authored-by: Suraj Shetty <surajshetty3416@gmail.com>
2019-10-07 13:39:40 +00:00