← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 813974] Re: Could we deprecate passing a single id to ORM methods

 

The present situation is indeed something we want to change.

But some details about what you propose, or given in the linked mailing
list thread, are not right to me. The mail says that some methods are
changed to accept a single id *instead* of a list of ids. The example
commit doesn't say that. The real purpose of the commit is to bring a
uniform API: accept *both* forms: either a single id, or a list of ids.

The fact is that the de facto API is to allow both. So this uniformity
is brought back to some methods because there is no real reason to favor
one or the other form for those methods.

It is clear for a large part of the community and core developers that
allowing both form was a mistake. But having something uniform, without
braking existing code was deemed more important than changing things. I
don't think that we have an incoherent API, or that this flexibility is
hardly used. But indeed it is an unfortunate flexibility and make the
code harder to read and write than necessary.

One of the good reasons to think the situation is bad, is that in some
situation, there is no reason to allow a list of ids, and thus the API
seems inconsistent.

We do plan to change the situation. It is planned to bring a new API (in
a broader sense, not just this id vs ids problem) and we will make sure
to make clear when methods accept a single id or a list of ids, and that
they don't accept both (i.e. most of the methods will only accept a list
of ids, and when necessary, some will only accept a single id). The
argument names will thus be in sync with the actual accepted argument
types.

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/813974

Title:
  Could we deprecate passing a single id to ORM methods

Status in OpenERP Server:
  Confirmed

Bug description:
  Most ORM methods accept an "ids" argument which can be either an integer or a list of integers.
  This is supported and well documented, and fixes have been accepted to support single integers (Bug #740202, Bug #812723 and probably others).

  Unfortunately this is very badly known even among the core developers.
  This regularly leads people to talk at cross purposes (as in Bug #740202) and it's also a bit controversial (as in https://lists.launchpad.net/openerp-expert-framework/msg00397.html).

  As a consequence it may break in some new standard feature, and has never worked in numerous third-party modules.
  Almost all the code in OpenERP passes "ids" as lists, even for only one element.
  So, this feature is confusing and of little use.

  Could it just be deprecated in the next version ?
  A warning would be issued when an ORM method is called with a single int.
  The documentation would be updated to indicate that "ids" should be a list, and a footnote would be added to explain that single integers are deprecated.

  Then we could drop the feature completely in some later version.

  Lionel Sausin.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/813974/+subscriptions


References