Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tryton
Tryton
Commits
dd9957790a47
Commit
dd995779
authored
Jan 17, 2023
by
Cédric Krier
Browse files
Rename ModelStorage.count into ModelStorage.estimated_count
count is too common name for a standard method like
#12016
reveals.
parent
d1475c50226f
Pipeline
#61573
passed with stages
in 23 minutes and 47 seconds
Changes
6
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
trytond/CHANGELOG
View file @
dd995779
* Rename ModelStorage.count into ModelStorage.estimated_count
* Add border type to images
* Lock table on transaction start
* Use EXISTS for search on O2M with many records
...
...
trytond/doc/ref/models.rst
View file @
dd995779
...
...
@@ -407,7 +407,7 @@
It is used for the global search.
.. classmethod:: ModelStorage.count()
.. classmethod:: ModelStorage.
estimated_
count()
Return an estimation of the number of records stored.
...
...
trytond/trytond/model/fields/many2one.py
View file @
dd995779
...
...
@@ -259,7 +259,7 @@
else
:
_
,
target_name
=
name
.
split
(
'.'
,
1
)
target_domain
=
[(
target_name
,)
+
tuple
(
domain
[
1
:])]
if
callable
(
Target
.
count
)
and
Target
.
count
()
<
_subquery_threshold
:
if
Target
.
estimated_
count
()
<
_subquery_threshold
:
query
=
Target
.
search
(
target_domain
,
order
=
[],
query
=
True
)
return
column
.
in_
(
query
)
else
:
...
...
trytond/trytond/model/fields/one2many.py
View file @
dd995779
...
...
@@ -337,8 +337,7 @@
origin_where
=
origin
.
like
(
Model
.
__name__
+
',%'
)
origin
=
origin_field
.
sql_id
(
origin
,
Target
)
use_in
=
(
callable
(
Target
.
count
)
and
Target
.
count
()
<
_subquery_threshold
)
use_in
=
Target
.
estimated_count
()
<
_subquery_threshold
if
'.'
not
in
name
:
if
value
is
None
:
if
use_in
:
...
...
trytond/trytond/model/modelsql.py
View file @
dd995779
...
...
@@ -1647,9 +1647,7 @@
main_table
,
_
=
tables
[
None
]
if
count
:
table
=
convert_from
(
None
,
tables
)
if
(
limit
is
not
None
and
callable
(
cls
.
count
)
and
limit
<
cls
.
count
())
or
offset
:
if
(
limit
is
not
None
and
limit
<
cls
.
estimated_count
())
or
offset
:
select
=
table
.
select
(
Literal
(
1
),
where
=
expression
,
limit
=
limit
,
offset
=
offset
).
select
(
Count
(
Literal
(
'*'
)))
...
...
@@ -1880,7 +1878,7 @@
'You can not update fields: "%s", "%s"'
%
(
field
.
left
,
field
.
right
))
if
callable
(
cls
.
count
)
and
len
(
ids
)
<
max
(
cls
.
count
()
/
4
,
4
):
if
len
(
ids
)
<
max
(
cls
.
estimated_
count
()
/
4
,
4
):
for
id_
in
ids
:
cls
.
_update_tree
(
id_
,
field_name
,
field
.
left
,
field
.
right
)
...
...
trytond/trytond/model/modelstorage.py
View file @
dd995779
...
...
@@ -609,7 +609,7 @@
return
process
(
domain
)
@
classmethod
def
count
(
cls
):
def
estimated_
count
(
cls
):
"Returns the estimation of the number of records."
count
=
cls
.
_count_cache
.
get
(
cls
.
__name__
)
if
count
is
None
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment