Francois Gouget : testbot/orm: Turn Itemrefs into virtual properties.

Alexandre Julliard julliard at winehq.org
Wed Jun 8 15:39:29 CDT 2022


Module: tools
Branch: master
Commit: b1a19b109f4faa7e33aaea5bea2f656c1a367ff0
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=b1a19b109f4faa7e33aaea5bea2f656c1a367ff0

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Wed Jun  8 16:41:23 2022 +0200

testbot/orm: Turn Itemrefs into virtual properties.

Itemref properties are used to map foreign key columns to the object
corresponding to the target table row. However so far adding an
Itemref property meant hiding the underlying table column(s) with
annoying side-effects:
* The type of the underlying property is unknown which is not an issue
  for strings and integers but rules out using booleans and timestamps
  in foreign keys since they need conversion from / to the database
  format.
* Filtering on an Itemref property is possible by passing the target
  object, but not by using the underlying property(s). This makes
  inequality filters (e.g. >= JobId) awkward or impossible.
* This also makes it impossible to filter on a partial foreign key.
  For instance if one had a TaskFailures table matching known failures
  to the tasks (JobId, TaskNo) they appear in, one would be unable to
  get a collection with all the entries for a given job since it's
  impossible to filter on just the JobId column.

So this modifies Itemref properties to come in addition to the
underlying column instead of replacing them.
This means declaring all the underlying columns, with their proper
property descriptors, which makes it possible to access them the
normal way and to use them in filters, while still being able to
access the corresponding object using the extra Itemref 'virtual'
property.
It also means filtering out the new properties if they should not be
shown in the GUI.
Another consequence is that Itemref properties cannot be keys: only
the underlying columns can.
Finally the underlying columns should not be modified directly as
that would cause them to be inconsistent with the corresponding Itemref
property but this is not enforced.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/lib/ObjectModel/DBIBackEnd.pm              | 26 ++++++++++++++--------
 testbot/lib/ObjectModel/Item.pm                    | 25 ++++++---------------
 .../lib/ObjectModel/ItemrefPropertyDescriptor.pm   | 17 +++++++++-----
 testbot/lib/WineTestBot/CGI/Sessions.pm            |  1 +
 testbot/lib/WineTestBot/Jobs.pm                    |  3 +++
 testbot/lib/WineTestBot/PendingPatches.pm          |  1 +
 testbot/lib/WineTestBot/StepsTasks.pm              |  1 +
 testbot/lib/WineTestBot/Tasks.pm                   |  1 +
 testbot/lib/WineTestBot/UserRoles.pm               |  3 ++-
 testbot/web/JobDetails.pl                          |  6 ++---
 testbot/web/index.pl                               | 11 +++------
 11 files changed, 50 insertions(+), 45 deletions(-)

Diff:   https://source.winehq.org/git/tools.git/?a=commitdiff;h=b1a19b109f4faa7e33aaea5bea2f656c1a367ff0



More information about the wine-cvs mailing list