Gavin D'souza
8ccc0d039b
fix: Database._transform_query
...
* Don't try to convert None to sequence
* Skip transforming values that mariadb~=1.1 can handle - only worry
about sequences for now
2022-07-07 15:59:48 +05:30
Gavin D'souza
41b93392b1
fix: Database._transform_result
...
Transform data not already casted by mariadb client
2022-07-06 15:58:45 +05:30
Gavin D'souza
6a76f8ad5f
fix(pg): Transform Falsy values as None
...
ref: https://github.com/frappe/frappe/runs/7208763442
2022-07-06 11:47:43 +05:30
Gavin D'souza
1faa2fd1e2
fix: Format string instead of % to avoid TypeError
2022-07-06 10:52:48 +05:30
Gavin D'souza
dbb37acedf
fix: Transform queries with all types of values
2022-07-05 17:47:14 +05:30
Gavin D'souza
71b5c77e6e
Merge branch 'develop' of github.com:frappe/frappe into mariadb-client-refactor
2022-07-05 14:55:02 +05:30
Ankush Menat
c12b52a259
refactor: use frappe.get_system_settings
...
Not sure why this needs YET ANOTHER separate cache.
2022-07-04 11:25:47 +05:30
Aradhya Tripathi
ebd1d5b48c
Merge branch 'develop' into get-all-mod
2022-07-01 13:25:32 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features ( #17367 )
...
refactor: clean up code to py39+ supported syntax
- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes
Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Gavin D'souza
fddd624a7c
Merge branch 'develop' of github.com:frappe/frappe into mariadb-client-refactor
2022-06-30 14:31:52 +05:30
Ankush Menat
813dcc1848
Revert "feat: Adding support to Query engine"
2022-06-29 23:30:23 +05:30
Aradhya
4da5fdcd02
fix: fixed spaces in args
...
fix: lint
2022-06-29 17:37:49 +05:30
Gavin D'souza
cf699fe40b
Merge branch 'develop' of github.com:frappe/frappe into mariadb-client-refactor
2022-06-29 13:49:18 +05:30
Ankush Menat
181833848f
Merge pull request #17337 from ankush/lint_cleanup
...
fix: remove bare exception catching
2022-06-29 11:39:05 +05:30
gavin
91e76ff874
Merge branch 'develop' into get-all-mod
2022-06-28 19:47:20 +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
7732accded
feat: Attached Engine object to qb & added dynamic type hints
2022-06-28 19:43:23 +05:30
Aradhya
fca026927e
refactor: moved all query logic to query class
2022-06-28 19:41:32 +05:30
Ankush Menat
d35d7ffbe2
fix: remove bare exception catching
...
A bare except catches lots of things (like generator iteration end) and should never be used.
2022-06-28 18:05:00 +05:30
Gavin D'souza
b8d2c195a6
fix: Disable connection pooling via bench commands unless specified
2022-06-23 19:42:12 +05:30
Gavin D'souza
ef078a4ab5
refactor(db-read_only): Track conn type in Database instance
2022-06-23 19:40:17 +05:30
Gavin D'souza
a58a5bb848
fix: Improve _transform_query unique key identification
2022-06-20 13:10:13 +05:30
Gavin D'souza
9b6a048bcd
refactor(minor): Use db.db_type instead of conf.db_type
2022-06-17 12:49:12 +05:30
Gavin D'souza
3af8d5caea
fix: Add fallbacks for values
...
Psycopg seems to like None over () and MariaDB - PyMySQL can't seem to
agree on anything - so this seems to keep everyone happy...a very
delicate balance :crie:
2022-06-17 12:47:44 +05:30
Gavin D'souza
a03bf6b0bb
fix(db): Transform values only if not None
2022-06-17 11:31:55 +05:30
Gavin D'souza
1a772e304c
fix(db): Store result of last executed query under frappe.db.last_result
2022-06-16 16:01:38 +05:30
Gavin D'souza
25b87a9d49
chore: NoneType alias for < PY310
2022-06-16 15:04:35 +05:30
Gavin D'souza
bc3780560e
perf: Use lazy mogrified query for logging
...
For parameterized queries, there's an improvement of ~30% in query
execution via frappe.db.sql - from 58.6 µs ± 2.37 µs to 44.6 µs ± 1.56 µs
2022-06-16 14:26:34 +05:30
Gavin D'souza
effa942f4c
refactor: frappe.db.log_query
...
* Mogrify queries and set them as frappe.db.last_query instead of
directly interfacing with the clients
* This is required for now as the MariaDB client uses binary protocol to
talk to the server and doesn't build the queries itself
* Add typing hints
* Imported Query object as FilterEngine - Query is too ambiguous lol
ref: https://jira.mariadb.org/browse/CONPY-208?focusedCommentId=226873&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-226873
2022-06-16 13:28:54 +05:30
Gavin D'souza
889ced3035
refactor: frappe.db.sql
...
* Move everything except _cursor.execute outside try-except block - This
caused multiple traceback printing (by recursion of db.sql)
* Include values mogrifying & executing via client alone in execution
time for query
* Reduce indentations lol
2022-06-16 12:39:30 +05:30
Gavin D'souza
0adf5e127a
fix(db): Track query engine under db._filter_engine
2022-06-16 12:31:14 +05:30
Gavin D'souza
5a29177e6b
fix(db): Log queried tables through generated query
2022-06-15 17:42:52 +05:30
Gavin D'souza
b4578dc632
Merge branch 'develop' of github.com:frappe/frappe into mariadb-client-refactor
2022-06-15 16:40:29 +05:30
Gavin D'souza
57bd1b6031
fix(db): Import cast as cast_fieldtype to manevour ambiguity
2022-06-15 10:54:48 +05:30
Gavin D'souza
bbc90e6578
refactor!: frappe.db.get_singles_dict
...
* Don't cast values by default - only if cast kwarg is set
* Reverts breaking behaviour added via f74dc5023d
2022-06-15 10:33:06 +05:30
Gavin D'souza
f74dc5023d
refactor!: frappe.db.get_singles_dict
...
* Cast single's values as their fieldtypes before returning
* Support previously dead debug parameter
* Consider single with no meta as non-existent; skip query
Decided to go ahead with the breaking change given the nature of the
existing usages of get_singles_dict :crie:
2022-06-13 18:39:56 +05:30
Gavin D'souza
13cf4964a6
perf: Check query type via is_query_type
2022-06-13 18:39:56 +05:30
Gavin D'souza
b696fa6da5
perf: Pre-compile and re-use regexp pattern
...
Converted all possible usages of re.* that weren't compiling the regex
separately and re-using it. Separated out the compiled patterns as
global variables. Repetitive patterns could be made DRY-er.
Would be nicer to have all regexes in a single module so that we could
re-use better, keep track of outdated, and keep checks for possible
reDos' etc
2022-06-08 14:07:38 +05:30
gavin
44dba28159
Merge branch 'develop' into refactor-file
2022-06-08 12:43:35 +05:30
Ankush Menat
94920ab4ae
Merge pull request #16727 from ankush/pg_transaction_management
...
fix: explicitly start a new transaction
2022-06-07 12:46:23 +05:30
Gavin D'souza
50b0eb8cca
perf: Initialize Query engine only if used
2022-06-06 15:42:59 +05:30
Ankush Menat
8861752675
fix: restart transaction after commit
2022-06-05 00:26:12 +05:30
Ankush Menat
654ded1a05
chore: print full stack on postgres DB errors
2022-06-04 22:42:03 +05:30
Gavin D'souza
5ec2690160
Merge branch 'develop' into refactor-file
2022-06-01 15:47:55 +05:30
gavin
ff9c89450e
feat(db): _transform_query to convert args passed to db.cursor
...
Transform query & parameters based on client requirements. Eg: MariaDB
client doesn't behave similar to PyMySQL or Psycopg2.
ref: https://jira.mariadb.org/projects/CONPY/issues/CONPY-205
2022-05-25 13:58:23 +05:30
gavin
958fc2b0b2
refactor: Database
...
* Change query notations - QB > raw
* Update logic of DB APIs - simplify & perf improvements
2022-05-25 12:26:24 +05:30
gavin
4f72eb9eac
refactor: Base Database class
...
* DRY, explicit > implicit usages
* Don't re-compute and do multiple calls for errprint, log, mogrify, etc
* Use consistent logging methods
* Simplify logic / Use newer APIs where applicable
2022-05-25 11:44:08 +05:30
gavin
dae57d0de2
fix(db)!: Base methods should throw NotImplementedError
2022-05-24 19:19:53 +05:30
gavin
d3900485a6
refactor: Use mariadb client for creating connections
...
Move to use MariaDB's official Python client written in C instead of
the PyMySQL library. This change doesn't rid Frappe of the PyMySQL
library. Instead, it continues to utilize it for the ER module and
converter methods until the MariaDB library adds support for the same.
Ticket: https://jira.mariadb.org/projects/CONPY/issues/CONPY-203
2022-05-24 19:19:53 +05:30
gavin
7c77bedbf2
refactor: Simplify logic + Add typing hints
2022-05-18 16:57:54 +05:30