Commit graph

60 commits

Author SHA1 Message Date
Ankush Menat
1a1dc0a62c
fix: more bad migrations and sanity test (#33112)
* test: prevent unnecessary migrations

* fix: Avoid resyncing JSON repeatedly

* fix: Varchar not nullable defaults should be casted

* fix: force cast to float before

Bad default values cause it to break.
2025-06-26 10:31:55 +00:00
Ankush Menat
40b465ee0d
fix: Avoid unnecessary syncing defaults (#33108)
When default is `'0.0000'` (string) it gets synced again and again even
though it will end up being 0 again.
2025-06-26 06:49:44 +00:00
Ankush Menat
2a1d3dd474
fix: Unnecessary migration from hard-coded not-nullable fields (#33107) 2025-06-26 06:25:14 +00:00
Akhil Narang
ed8191047e
fix(add_column): adjust for sqlite
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-04-15 13:59:16 +05:30
Akhil Narang
ad32216040
fix: support sqlite
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-04-15 13:59:16 +05:30
Ankush Menat
fdba41c682
perf: misc client cache improvements (#29070)
* perf: Reduce penalty for lack of redis connection

If redis isn't running than this client cache is slower than default
implementation because of the extra locking overhead.

* test: update perf redis counts

* perf: cache table columns in client-cache

* fix: race condition on cache-client_cache init

Rare but apparant in synthetic benchmarks.

Cache is set but client cache is still being initialized then request
will fail.

* perf: Don't run notifications when loading document

WHAT?

* fix: use cached doc to repopulate

* perf: reduce get_meta calls
2025-01-07 16:14:43 +05:30
Ankush Menat
23b5b0c7ae
perf: speedup QB field sanitization (#28818) 2024-12-18 05:47:02 +00:00
Ankush Menat
fb27368a53
feat: Link fields with UUID datatype in DB (#26625)
Link fields that refer to doctypes with UUID naming will also be UUID.
2024-05-31 09:17:09 +00:00
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Ankush Menat
4350f94616
refactor: add_column (#24867)
- Skip cache which can be invalid
- Do check at db level
2024-02-12 07:45:18 +00:00
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
Akhil Narang
fbc88a4d24
refactor(treewide): code cleanup
Drop redundant bool conversion

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-23 13:57:51 +05:30
Akhil Narang
5c023d238d
fix: get correct column definition
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 16:14:50 +05:30
Akhil Narang
e1bbcd73ab
fix: 0 is falsy, set correct defaults
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 16:14:50 +05:30
Akhil Narang
75c8445b6a
refactor: cleanup column definition
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
12a0afd91f
refactor: cleanup DbColumn.get_definition()
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
5e6be19fe3
chore(DbColumn): force constructor arguments to be kwargs
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
e41fa2dfc7
feat: migrate columns to be non-nullable if required
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
4f9ee8b633
feat(DbColumn): set non_nullable attribute and make use of it for column definition
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
barredterra
88c8baa9ee refactor: for append to extend, merge list extend
Replace a for append loop with list extend.
Create the list with values instead of creating
an empty list and extending it with another list.
2023-08-09 13:25:39 +02:00
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
Ritwik Puri
e277b94714
fix: allow default for text and long text when altering table (#21109) 2023-05-26 11:09:28 +05:30
Ritwik Puri
c5e62cac26
fix: allow setting default in longtext and text columns (#21089) 2023-05-25 12:29:20 +05:30
Ankush Menat
8df845ca35 fix: duplicate unique index when column is altered 2022-12-15 13:36:28 +05:30
Ankush Menat
d27ea5e6da test: unique index on install and alter
There should always be 1 unique index.
2022-12-15 13:36:28 +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
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
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
Gavin D'souza
0482f1362a Merge branch 'develop' of github.com:frappe/frappe into dynamic-docfields 2022-02-08 16:50:58 +05:30
phot0n
266e1f95ed chore: adding back idx column
This is needed for ordering in display of links as it keeps
track of the clicks on a particular link item
2022-02-07 16:40:01 +05:30
phot0n
b31f3c24f6 refactor: remove parent, parenttype, parentfield, idx columns from non-child table doctypes
* feat: add parent, parenttype, idx, parentfield columns to doctypes when transitioning from normal -> child table

* fix: remove parent, parenttype, parentfield, idx from DocType DocType
2022-02-07 15:12:37 +05:30
Gavin D'souza
66b09afda6 fix: Don't create DB column for Virtual DocFields 2022-02-01 17:48:02 +05:30
Ankush Menat
e5eca8232f
fix: dont auto drop manually created index on text types (#15739) 2022-01-26 17:47:30 +05:30
Suraj Shetty
4d384f308b fix: Unique and Index constraints 2022-01-23 22:57:33 +05:30
Suraj Shetty
39031d18ed fix: Check if index exists with specific key_name 2022-01-23 17:44:07 +05:30
Saif Ur Rehman
063cc293a9 fix(Migrate): add unique and index for new columns 2021-12-31 13:37:40 +05:00
leela
a76445bcf5 fix: use decimal digits precision 9 instead of 6 while creating schema
Currently we use DECIMAL(18, 6) datatype for float, currency and
percent. But in the system settings we provide a configuration to change the
precision up to 9 digits. This obviously does not work because we do not
store 9 digit precision in database. Fixed by changing the decimal
datatype scale.
2021-09-22 16:07:06 +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
Chinmay Pai
a02d2fb694
chore: change an instance of virtual_doctype to is_virtual 2020-12-29 10:55:55 +05:30
Shridhar Patil
86f9747925
chore: clean up database schema sync for virtual doctype
Co-authored-by: Chinmay D. Pai <chinmay.pai@zerodha.com>
Signed-off-by: Chinmay D. Pai <chinmay.pai@zerodha.com>
2020-12-29 10:55:55 +05:30
Shridhar
7b16837f88
fix: handle virtual doctype flag for existing doctypes 2020-12-29 10:55:55 +05:30
Shridhar
04d63159f1
fix: skip table creation for virtual doctype 2020-12-29 10:55:54 +05:30
Rushabh Mehta
8a198f363b fix(default): cast as string as required 2020-10-26 10:02:04 +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
651109bb00 fix: Translatable string 2020-04-29 14:07:51 +05:30
Suraj Shetty
031aad0d85 perf: Cache get_tables values
- To avoid redundant db calls
2020-04-29 12:28:08 +05:30
Suraj Shetty
1599fc0751 fix: Get latest meta while building table 2020-03-25 12:48:21 +05:30
Suraj Shetty
8f8e361766 style: Fix formatting issues 2020-03-21 17:45:39 +05:30