Commit graph

165 commits

Author SHA1 Message Date
Ankush Menat
1ec4d658fc fix: Allow setting UUID to application code 2024-03-29 19:02:28 +05:30
Ankush Menat
6c79a13641 feat: UUID naming support 2024-03-29 19:02:28 +05:30
Ankush Menat
adf24b24d4
perf: use base32 space for random names instead of base16 (#25497) 2024-03-17 20:02:57 +05:30
Ankush Menat
495273dcf9 fix: faster change of hash prefix 2024-03-10 21:48:56 +05:30
Ankush Menat
665f1fdf79 perf: optimize hash naming for MySQL storage
Random names can send rows all over the place, typically documents
created closer in time should live closer on mysql pages too.
2024-03-10 21:22:36 +05:30
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +05:30
Ankush Menat
730e906dfd
refactor!: remove implicit primary key from logs (#22209) 2023-08-26 16:01:47 +05:30
Ankush Menat
79392260d4
fix: autoincr caching and clear site cache after restore (#22079)
* fix: remove hazardous cache for autoincr

* fix: move cache to redis

* fix: clear all redis cache after restoring a site
2023-08-17 11:11:27 +05:30
mergify[bot]
fd10ab25cc
Merge pull request #22003 from gavindsouza/refactor-doc-bits
refactor: Use single query to delete child rows on doc.save
2023-08-11 06:45:07 +00:00
Gavin D'souza
84f134a683
fix: Add "better" typing hints 2023-08-11 11:45:47 +05:30
barredterra
b553ed98d8 refactor: inline immediately returned variable
Inline a variable to a return in the case when the
variable being declared is immediately returned
2023-08-08 18:09:49 +02:00
Ankush Menat
8817c228a2 fix: filter schema name on mariadb 2023-08-04 14:33:17 +05:30
Ankush Menat
fd15ab5329 fix: revert pg incompatible change 2023-08-04 14:13:36 +05:30
Ankush Menat
c4230f8760
fix: autoincr status per doctype (#21918)
* fix: autoincr status per doctype

closes https://github.com/frappe/frappe/issues/21386

* chore: Check autoincremented on the database currently being used.

* refactor: Styling and space fix

---------

Co-authored-by: Athul Cyriac Ajay <athul8720@gmail.com>
2023-08-04 13:59:39 +05:30
Deepesh Garg
e32e74f2f1
feat: Custom naming series parser via hooks (#21690)
* feat: Custom naming series parser via hooks

* chore: use assignment operatot

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>

* test: Unit test for custom parser

* test: Unit test for custom parser

---------

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2023-07-16 12:57:40 +05:30
Ankush Menat
adf30693a9 ci: update pyupgrade 2023-07-14 14:24:08 +05:30
Sagar Vora
b4f1a2328b
fix: ignore naming series validation when generating repeated address name (#21568) 2023-07-10 10:51:55 +05:30
Dany Robert
4f3c0f6e99
feat: configurable amended document naming (#21414)
* feat: configurable amendment naming

* patch: set default amend naming

* chore: linters and document filter

* test: amended document naming

* refactor: use set_single_value

* chore: typo, fix copy

* fix(UX): move action button below table

* refactor: Series Counter -> Default Naming

The behaviour in this PR doesn't necessarily mean to apply naming series
it can be:
- Naming Series
- hash
- Naming Rule
- Some code

So the name was misleading.

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-06-20 21:37:08 +05:30
Ritwik Puri
2e2c8316c6
fix: use sentinel value for checking existence of key in doc while parsing naming series (#20994) 2023-05-15 14:58:14 +05:30
Ritwik Puri
4bd32bcf04
fix: naming part should be empty if field is empty (#20978) 2023-05-14 00:41:12 +05:30
Ankush Menat
5348dd1f29 fix: Migration fails while inserting docfield
When migrating base doctypes we need to insert docfield which triggers
 document naming rule code and document naming rule doesn't yet exists
 cause that's what we are trying to migrate.

Fix: skip naming rule on bootstrapped doctypes.
2023-02-03 13:28:59 +05:30
Anand Baburajan
6554919f1e
fix: improve invalid naming series message (#19711)
* fix: show the invalid naming series in special chars error msg

* chore: translations

[skip ci]
2023-01-23 15:00:04 +05:30
Ankush Menat
f34f7030a3 refactor: remove txt param from generate_hash use 2022-11-10 11:56:48 +05:30
Daizy
78d30905ac refactor: get_doctype_map() using single query and use generator for caching 2022-11-02 09:58:34 +00:00
Daizy
28a124ca47 perf: cache document naming rule to avoid multiple db call 2022-11-02 09:58:34 +00:00
Ankush Menat
8cca50bf26
refactor: remove naming case feature (#18672)
This has never worked since 2016... which can mean two things:
- No one really uses this.
- If I fix this now suddenly people will find different behaviour in
  naming because `name_case` is selected in some doctypes (but never
  tested)
2022-10-31 11:23:49 +05:30
Anand Baburajan
feb198a019
docs: fix make_autoname example (#18354) 2022-10-10 21:04:35 +05:30
Ritwik Puri
66a31917f7
refactor(minor): reorder and remove unnecessary branches in set_new_name (#18243) 2022-09-29 16:23:55 +05:30
Ankush Menat
95f67b8de8
fix: ignore empty part in naming series (#17508)
on v13 doc.get("") returns entire doc dictionary, this gets strigified
and becomes a problem for naming.
2022-07-14 13:14:58 +05:30
Ankush Menat
111060224b fix: naming series tool doesn't load if missing numbers 2022-07-07 17:38:52 +05:30
Ankush Menat
60c4819373
refactor: safer binding of outer scope in closures (#17389) 2022-07-04 13:39:56 +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
vishdha
27f2cdf016 chore: remove unused code 2022-06-17 13:59:21 +05:30
vishdha
ea18460cc2 fix: date_field not able to fetch in _format_naming autoname 2022-06-17 13:59:21 +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
Ankush Menat
462aa20386
fix: naming using doc fields (#17040) 2022-05-31 19:55:34 +05:30
Ankush Menat
45604a7f3f refactor: move all naming series related logic 2022-05-31 14:48:14 +05:30
Ankush Menat
b7a032e7e8 refactor: generate naming series preview without DB calls 2022-05-31 12:59:49 +05:30
Ankush Menat
5590cb0be8 feat: NamingSeries class
Single class to group together everything required related to naming
series
2022-05-31 11:53:58 +05:30
Ankush Menat
5c35aae876 fix: accurate prefix parsing
Previous version of prefix parsing relied on partial reimplemntation of
naming series logic which was outdated and often incorrect.
2022-05-31 11:53:58 +05:30
Ankush Menat
15dbcacd56 refactor: split transaction and prefix functions
refactor: fetching transaction list

refactor: get default naming series

refactor: simplify naming series option scrubbing

fix: remove dead code related to insert series

This code is dead in many ways
- Creates map but it's never evaluated, so it doesn't actually run :D
- Just randomly splits naming series parts to create prefix... makes no
  sense.

fix: deduplicate prefix list
2022-05-31 11:53:40 +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
Rushabh Mehta
fca6c3d305 fix(minor): circular imports? 2022-04-18 17:29:03 +05:30
Gavin D'souza
03d542edce fix!: Allow child table naming 2022-04-13 17:32:58 +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
f21f526ae6 fix: sider 2022-03-15 16:49:33 +05:30
phot0n
86c9791813 fix: use next sequence number for ammended doc
* chore: use meta
2022-03-15 16:07:08 +05:30