Commit graph

326 commits

Author SHA1 Message Date
Suraj Shetty
ed72fc5a0e
Merge pull request #17003 from netchampfaris/db-query-child-table-syntax-sugar 2022-05-30 12:21:35 +05:30
Faris Ansari
87ec6d4fb9 fix: initialize link_tables in constructor 2022-05-30 10:50:16 +05:30
Faris Ansari
507a45d8f2 fix: dot syntax support for link fields
 test
2022-05-28 13:57:44 +05:30
Faris Ansari
96b30e714c feat: table_field.fieldname field syntax for db_query 2022-05-27 16:04:22 +05:30
gavin
6dedf899ff
Merge pull request #16899 from ChillarAnand/imports
refactor: Removed unused imports & added flake8 check in CI
2022-05-23 15:53:18 +05:30
chillaranand
1d763a6659 refactor: Fix flake8 issues 2022-05-19 15:34:35 +05:30
gavin
7c77bedbf2 refactor: Simplify logic + Add typing hints 2022-05-18 16:57:54 +05:30
phot0n
7ec5e88278 chore: remove unnecessary groups from search regex in cast_name 2022-05-05 21:31:13 +05:30
phot0n
aa6a21fc2c chore: add regex to consider space in cast_name 2022-05-05 21:31:13 +05:30
Ritwik Puri
b41379c78b
fix: misc fixes (integer primary keys) (#16307)
* fix: misc fixes

local.x gets resetted on every request so switched to a simple dict

simplified is_val_used in set_next_val function for sequences

* chore: use multisql for sequence methods

* fix: fields not updating on form

* minor(base_input): removed unnecessary branching in update_input

* chore: remove prints and rename autoincremented_status_map

* chore: added proper type hint + comment + formatting

* fix: added searching in cast_name rather than handling it manually

* fix: share condition query + test_build_match_conditions

* fix: add cast_name to more places

* test: test for sequence

* fix: sequence functions

* fix: inherit frappetestcase

* minor: attach sequence methods to db context local

* chore: update sequence function names in Database

use frappe.db for sequences in naming.py

* fix: convert filename to str (for autoincremented doctypes)

* chore: better regex for modifying values for postgres

* minor: allow changing name column type (if no data is present in the doctype)

* refactor: validate_autoname

converted it to a simple function
enabled changing autoincrement autoname from customize form

* fix: use sql_ddl for change_column_type in postgres

* fix: use not null constraint in postgres when changing name type

* fix(test): updated test_autoincremented_doctype_transition with transitioning when no data is present

* fix(test): updated test_cast_name

probably messed up during rebase

* fix(test): used rollback upon error in transaction for postgres

* chore: use frappe.db.x methods for sequences

* minor: use temporary sequences in test

* minor: use generate_hash for sequence naming in sequence tests

* chore: replace sequence imports with frappe.db.x

* chore: move out casting name fields to a separate method

* refactor: cast_name

more explicit cases for casts and added docstring

* fix: added space in test_cast_name

* chore: fix linter

* chore: better naming for can_change_name_column_type

* chore: add comment for autoincremented_site_status_map

* chore: update/add docstrings
2022-04-29 15:06:03 +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
phot0n
8296d6e84a fix: use backticks for fieldname while preparing filters 2022-03-31 18:12:09 +05:30
phot0n
906f671d9c fix(db_query): ordering in extract_tables
this will allow the fields to be casted first
2022-03-11 23:46:00 +05:30
phot0n
4ea87fd9cc chore: rename cast_autoincremented_name to cast_name 2022-03-11 23:46:00 +05:30
phot0n
bebc8058b6 feat: integer primary keys 2022-03-11 23:46:00 +05:30
barredterra
745297a49d refactor: a not in b
Search: if not ([\w\d]*?) in ([\w\d]*?)
Replace: if $1 not in $2
2022-02-21 19:54:34 +01:00
barredterra
b1383df15a refactor: use is None instead of == None 2022-01-17 10:37:51 +01:00
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
Conor
55392b64e7 fix: Revert changes made to fix collation differences
Due to collation differences in MariaDB and Postgres, tests gave
inconsistent results. This was to be handled in tests alone instead of
the application. It was unnecessary. Collation changes should be made at DBMS config
level only. Accomodating for those in the application will unnecessarily
degrade performance for everyone.

Other changes:
* use pluck in user_type
* revert ordering in nestedset
* revert parsing in order_field
* use preferred APIs & styling

Co-authored-by: gavin <gavin18d@gmail.com>
2022-01-07 10:45:10 +05:30
Conor
1c40881c41 fix: refactor postgres arg prep into its own function 2022-01-07 10:45:05 +05:30
Conor
40ba1ac9ba fix: Postgres Compatibility
* Handle inconsistencies in type handling in DatabaseQuery & Database
  APIs
* Update incompatible queries with frappe.qb notation
* Fixed use cases discovered by failing ERPNext CI tests

fix: db independent syntax for user_type

fix: handle postgres datetime values

feat: add ability to auto commit on db inserts

feat: add ability to escape underscore in postgres

fix: handle missing data in test runner bootstrapping

fix: db independent syntax for queries

fix: refactor to use qb

fix: update cache for language

fix: use pluck in email_queue

Co-authored-by: gavin <gavin18d@gmail.com>

fix: don't auto insert on tests for make_property_setter

fix: remove auto_commit in custom_field insertion

fix: remove auto_commit functionality

fix: review comments

fix: revert link validation

fix: style suggestion for readability

Co-authored-by: gavin <gavin18d@gmail.com>

fix: revert .lower() in link validation

fix: add rollback for setup_wizard

Revert "fix: add rollback for setup_wizard"

This reverts commit 83b3b0913db17718ccd5edae01858cff15603829.

Revert "feat: add ability to escape underscore in postgres"

This reverts commit 8ed9c2aa3306438e94bb813f60e65b416d0b947b.

fix: more concise representation of order fields

Co-authored-by: gavin <gavin18d@gmail.com>
2022-01-07 10:44:57 +05:30
Verequies
379342d0ca fix: Postgres Compatibility for Standard Views
Core/User DocType: Add 'group_by' for PostgreSQL

Signed-off-by: Verequies <hamishclaxton@gmail.com>

fix: Postgres Compatibility for Standard Views

Desk/Dashboard DocType: Fix lowercase table name

Signed-off-by: Verequies <hamishclaxton@gmail.com>

Desk/Page/Setup Wizard: Fix data not being commited to database

Signed-off-by: Verequies <hamishclaxton@gmail.com>

Model/db_query: Fix queries with order_by and group_by for PostgreSQL

Signed-off-by: Verequies <hamishclaxton@gmail.com>

Model/db_query: Fix order_by without table name for PostgreSQL

Signed-off-by: Verequies <hamishclaxton@gmail.com>
2022-01-06 14:02:23 +05:30
Gavin D'souza
0f71dd411b style: DatabaseQuery.execute's permission cond block 2021-12-24 14:01:26 +05:30
Gavin D'souza
33b7d7d74f fix: Handle custom child tables via check_parent_permission
Check `tabCustom Field` and `tabDocfield` for matching parent existence.
2021-12-24 13:28:40 +05:30
Aradhya
0ea0f7dfa3 fix: fixed default ordering in execute 2021-11-25 16:39:44 +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
ae59fd7c58 feat: added no_order to execute 2021-11-19 22:58:32 +05:30
Gavin D'souza
ccb53c0f5b fix: If column comparision is done, dont check for ifnull/coalesce 2021-10-29 14:19:28 +05:30
Gavin D'souza
9bf043eddf fix(db_query): Change fallback to min datetime 2021-10-29 13:24:28 +05:30
Gavin D'souza
9be8a0895d Merge branch 'develop' into between-formatting 2021-10-29 13:13:55 +05:30
Suraj Shetty
9189c62437 fix: Pass parent_doctype while checking permission for child_table in db_query 2021-10-27 13:52:34 +05:30
Suraj Shetty
64822df6ff
Merge branch 'develop' into fix-has-permission-for-child-doc 2021-10-27 13:07:44 +05:30
Suraj Shetty
0f98b4d174 fix: Make parent_doctype mandatory while accessing child doctype 2021-10-27 12:59:42 +05:30
Aradhya-Tripathi
94f2a6e275 feat: Added run kwarg to get_all, get_values 2021-10-23 15:08:02 +05:30
Mohammad Hasnain
08ac2eda0a Merge branch 'develop' into between-formatting 2021-10-20 19:37:43 +05:30
Mohammad Hasnain
d7b7afeb14 fix: format between for creation/ modified 2021-10-19 16:18:21 +05:30
Sagar Vora
5c86dc80c7
fix: if_owner constraint being applied wrongly (#14471)
* fix: `if_owner` constraint being applied wrongly

* test: check if owner on `frappe.get_list`

Co-authored-by: Pruthvi Patel <pruthvipatel145@gmail.com>
2021-10-19 15:03:17 +05:30
Gavin D'souza
09557ab8c7 fix(db_query): Add fallback value irrespective of operator 2021-09-16 15:22:37 +05:30
Gavin D'souza
6973a34828 Merge branch 'develop' into compare-columns-db_query 2021-09-16 11:40:33 +05:30
Gavin D'souza
ad5783b1c3 fix: Use PyPika's Column
also, Discard Data class. Since we're adding support for PyPika objects
to natively interact with the Frappe ORM, this PR brings us closer
toward that direction.
2021-09-16 11:38:23 +05:30
Gavin D'souza
ab7dee13cf chore: Added return type for DatabaseQuery.execute 2021-09-06 19:44:25 +05:30
Gavin D'souza
9f4f096bf1 Merge branch 'develop' into compare-columns-db_query 2021-09-06 11:38:55 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Gavin D'souza
77895bbcfc feat: Support for Column comparison in DatabaseQuery 2021-08-03 12:43:01 +05:30
Gavin D'souza
ffb2aceb43 fix: Logical bug in DatabaseQuery.extract_tables
Introduced via 888aa8ad84
2021-06-15 12:50:29 +05:30
Gavin D'souza
1b6c41cbfc fix: Don't re-define pluck bug
Introduced via 974bf463df
2021-06-11 19:44:22 +05:30
Gavin D'souza
f92c5d9898 refactor: Unnecessary/illogical check
because cint(False) gives 0
2021-06-11 19:34:34 +05:30
Gavin D'souza
888aa8ad84 refactor(minor): DatabaseQuery.extract_tables 2021-06-11 19:34:24 +05:30
Gavin D'souza
ee75fb38cc style: Restructured if blocks in db_query 2021-06-11 19:34:16 +05:30