Discussion:
[Modeling-users] limiting the amount of objects retrieved
John Lenton
2004-02-06 11:35:06 UTC
Permalink
I need (or, rather, would like) to be able to use the 'splice
parameters' that I see commented out in Modeling.EditingContext to be
able to send feedback to the user as to how many objects have been
retrieved (and to let her cancel the operation if necessary). Is there
anything left to be done to be able to use these parameters?
--
John Lenton (***@vialibre.org.ar) -- Random fortune:
The shortest distance between two points is under construction.
-- Noelie Alito
Sebastien Bigaret
2004-02-06 14:16:12 UTC
Permalink
Post by John Lenton
I need (or, rather, would like) to be able to use the 'splice
parameters' that I see commented out in Modeling.EditingContext to be
able to send feedback to the user as to how many objects have been
retrieved (and to let her cancel the operation if necessary). Is there
anything left to be done to be able to use these parameters?
A patch was once made for using slice parameters; I was not able to
find it on sf.net, however if you're interested in testing it I can
make it available on sf tonite after I'm back home.

If the goal is simply to control that not too much objects are fetched
by a query, you may want to use ec.fetchCount() [same API as ec.fetch()]
which returns the number of objects fetched (without actually fetching
them).

-- Sébastien.
Sebastien Bigaret
2004-02-07 15:10:06 UTC
Permalink
Post by Sebastien Bigaret
Post by John Lenton
I need (or, rather, would like) to be able to use the 'splice
parameters' that I see commented out in Modeling.EditingContext to be
able to send feedback to the user as to how many objects have been
retrieved (and to let her cancel the operation if necessary). Is there
anything left to be done to be able to use these parameters?
A patch was once made for using slice parameters; I was not able to
find it on sf.net, however if you're interested in testing it I can
make it available on sf tonite after I'm back home.
I would be more than happy to do that, thank you.
Post by Sebastien Bigaret
If the goal is simply to control that not too much objects are fetched
by a query, you may want to use ec.fetchCount() [same API as ec.fetch()]
which returns the number of objects fetched (without actually fetching
them).
yes, but it's more than that: I want to give the user detailed
feedback as to the progress of the query, and the ability to cancel
it. The easyest way to do both is using fetchCount and then fetching
up to a number of objects.
Fine, so the patch is for you! Sorry for the delay, it took me some
time to retrieve it --it was hidden in a dark corner of my hard-disk :)
It also required some work since it was made quite a long time ago and
was completely out-of-sync.

The patch #892454 should be applied to v0.9pre16. It adds fetch slices
and, as an extra bonus, 'orderBy' parameter to ec.fetch().

It can be found at:
https://sourceforge.net/tracker/index.php?func=detail&aid=892454&group_id=58935&atid=489337

Sort orderings are strings like '<attribute path> [<operator>]', where
operator can be 'asc' (ascending, default), 'desc' (descending), and
'iasc' and 'idesc' (case-insensitive asc. and desc)


Here are some examples:

ec.fetch('Book', 'author.lastName != NULL',
orderBy='author.lastName desc, price desc, title iasc')

ec.fetch('Book', 'author.lastName != NULL', limit=2, offset=2)

ec.fetch('Book', limit=2, page=1)


Those examples are taken from test_EditingContext_Global.py (after patch
has been applied), methods test_17_fetchSpecWithSortOrderings(),
test_18/18b_fetchSpecWithFetchLimit() to which you can refer for further
details (you'll find there the full API for slices and
FetchSpecification as well).

About fetch slices: 'offset' begins at zero (zero is the first record
in the result set), while 'page' begins at one (page one is the first
page).


Current limitations are:

- it is available/tested for Postgresql and MySQL only

- parameter isDeep shouldn't be set w/ fetch slices and/or with sort
orderings,

- inserted (unsaved) objects will appear at the end of each result
set when limit and/or orderBy is set.


Last note, the patch contains all changes that have been made since
0.9pre16. This shouldn't be a problem, but I prefered to be explicit
about that; see CHANGES and MIGRATION for the details.


Enjoy ;) and thanks for your time testing this.

-- Sébastien.


PS: just before posting I wondered whether this hadn't been discussed
once. And true! see here:
https://sourceforge.net/mailarchive/forum.php?thread_id=1687932&forum_id=10674
https://sourceforge.net/mailarchive/forum.php?thread_id=1688402&forum_id=10674
https://sourceforge.net/mailarchive/forum.php?thread_id=1755269&forum_id=10674

The last url contains (at end) a post from me explaining the patch in
more details (forget about the cvs branch however, it is now
closed). Yes, this was one year ago...
John Lenton
2004-02-09 21:59:25 UTC
Permalink
Post by Sebastien Bigaret
Fine, so the patch is for you! Sorry for the delay, it took me some
time to retrieve it --it was hidden in a dark corner of my hard-disk :)
It also required some work since it was made quite a long time ago and
was completely out-of-sync.
The patch #892454 should be applied to v0.9pre16. It adds fetch slices
and, as an extra bonus, 'orderBy' parameter to ec.fetch().
https://sourceforge.net/tracker/index.php?func=detail&aid=892454&group_id=58935&atid=489337
should bugreports go to that page, or just discussed here?
--
John Lenton (***@vialibre.org.ar) -- Random fortune:
The only perfect science is hind-sight.
Sebastien Bigaret
2004-02-10 12:13:05 UTC
Permalink
Post by John Lenton
Post by Sebastien Bigaret
Fine, so the patch is for you! Sorry for the delay, it took me some
time to retrieve it --it was hidden in a dark corner of my hard-disk :)
It also required some work since it was made quite a long time ago and
was completely out-of-sync.
The patch #892454 should be applied to v0.9pre16. It adds fetch slices
and, as an extra bonus, 'orderBy' parameter to ec.fetch().
https://sourceforge.net/tracker/index.php?func=detail&aid=892454&group_id=58935&atid=489337
should bugreports go to that page, or just discussed here?
I'd prefer that bug reports are reported on that page, thanks. If you
have more general comments, for example about the API that you'd prefer
to be like this or that, this can be discussed here.

-- Sébastien.
Sebastien Bigaret
2004-02-17 19:43:14 UTC
Permalink
Hi,
Post by Sebastien Bigaret
The patch #892454 should be applied to v0.9pre16. It adds fetch slices
and, as an extra bonus, 'orderBy' parameter to ec.fetch().
https://sourceforge.net/tracker/index.php?func=detail&aid=892454&group_id=58935&atid=489337
At the same url, you'll find a brand new patch updated for 0.9pre17.

-- Sébastien.

Loading...