Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Use db.set_single_value #35668

Merged
merged 1 commit into from
Jun 13, 2023
Merged

refactor: Use db.set_single_value #35668

merged 1 commit into from
Jun 13, 2023

Conversation

ankush
Copy link
Member

@ankush ankush commented Jun 13, 2023

I just applied semgrep autofix. Untested completely, review before merging.

- id: frappe-set-value-semantics
  patterns:
    - pattern-either:
      - pattern: frappe.db.set_value($DOCTYPE, None, $...AFTER)
      - pattern: frappe.db.set_value($DOCTYPE, $DOCTYPE, $...AFTER)
  fix: frappe.db.set_single_value($DOCTYPE, $...AFTER)
  message: |
    If $DOCTYPE is a single doctype then using `frappe.db.set_value` is discouraged for setting values in DB. Use db.set_single_value for single doctype instead.
  languages: [python]
  severity: ERROR

I just applied semgrep autofix. Untested completed, review before merging.

```yaml
- id: frappe-set-value-semantics
  patterns:
    - pattern-either:
      - pattern: frappe.db.set_value($DOCTYPE, None, $...AFTER)
      - pattern: frappe.db.set_value($DOCTYPE, $DOCTYPE, $...AFTER)
  fix: frappe.db.set_single_value($DOCTYPE, $...AFTER)
  message: |
    If $DOCTYPE is a single doctype then using `frappe.db.set_value` is discouraged for setting values in DB. Use db.set_single_value for single doctype instead.
  languages: [python]
  severity: ERROR
```
@codecov
Copy link

codecov bot commented Jun 13, 2023

Codecov Report

Merging #35668 (8b5b4ec) into develop (e3802d1) will increase coverage by 0.02%.
The diff coverage is 88.63%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #35668      +/-   ##
===========================================
+ Coverage    63.92%   63.94%   +0.02%     
===========================================
  Files          812      811       -1     
  Lines        61785    61856      +71     
===========================================
+ Hits         39495    39554      +59     
- Misses       22290    22302      +12     
Impacted Files Coverage Δ
...rpnext/accounts/doctype/fiscal_year/fiscal_year.py 56.00% <0.00%> (ø)
...xt/accounts/doctype/journal_entry/journal_entry.py 69.17% <0.00%> (-0.10%) ⬇️
erpnext/setup/install.py 23.00% <0.00%> (+0.45%) ⬆️
erpnext/stock/stock_balance.py 56.96% <0.00%> (ø)
...e/payment_reconciliation/payment_reconciliation.py 94.20% <100.00%> (+0.09%) ⬆️
...x_withholding_category/tax_withholding_category.py 85.65% <100.00%> (+0.94%) ⬆️
.../report/accounts_receivable/accounts_receivable.py 72.24% <100.00%> (+0.29%) ⬆️
erpnext/stock/doctype/item/item.py 85.66% <100.00%> (ø)

... and 7 files with indirect coverage changes

@ankush ankush merged commit a3ea985 into frappe:develop Jun 13, 2023
@ankush ankush deleted the set_value branch June 14, 2023 05:57
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

replace set_value usage with set_single_value
1 participant