Ticket #4064 (new defect)

Opened 21 months ago

Last modified 20 months ago

find() has weird API

Reported by: bert Owned by: tomeu
Priority: high Milestone: Future Release
Component: sugar-datastore Version:
Keywords: dbus Cc: marco, tomeu, smcv
Action Needed: Verified: no
Deployments affected: Blocked By:
Blocking:

Description

datastore.find() was recently changed to not only take the query dict but an array of property names to return, too. That property name list should instead be made into a query parameter. Not only does it streamline the API, but it is actually invalid to send the default value (None) via DBus to get all the properties without listing them.

Change History

  Changed 21 months ago by jg

  • cc marco added
  • milestone changed from Never Assigned to First Deployment, V1.0

Marco, opinion?

follow-up: ↓ 3   Changed 21 months ago by tomeu

  • cc tomeu added

Bert, sending an empty list would return all the properties an entry has.

in reply to: ↑ 2 ; follow-up: ↓ 4   Changed 21 months ago by bert

Replying to tomeu:

Bert, sending an empty list would return all the properties an entry has.

Maybe, although that is counter-intuitive (the default parameter in the source is None not an empty list). Anyway, sending in a useless empty list is arguably not as nice as just not adding a parameter to the query.

And what if we want to add an option to exclude specific properties? Add another argument? IMHO having all these things as query parameters makes a whole lot more sense, is easier to document etc. Like, why is limiting the number of items a query parameter, but not the number of properties? And, what do you actually gain by that extra parameter? You can easily use a keyword argument at the calling side if I am not misreading the code.

in reply to: ↑ 3   Changed 21 months ago by tomeu

Replying to bert:

Replying to tomeu:

Bert, sending an empty list would return all the properties an entry has.

Maybe, although that is counter-intuitive (the default parameter in the source is None not an empty list). Anyway, sending in a useless empty list is arguably not as nice as just not adding a parameter to the query.

I would prefer to do like you say, but you cannot send None through dbus...

And what if we want to add an option to exclude specific properties? Add another argument? IMHO having all these things as query parameters makes a whole lot more sense, is easier to document etc. Like, why is limiting the number of items a query parameter, but not the number of properties? And, what do you actually gain by that extra parameter?

I agree on that.

You can easily use a keyword argument at the calling side if I am not misreading the code.

Not when calling through dbus, AFAIK. Anyway, passing a dictionary like the query param is the same thing.

  Changed 21 months ago by smcv

This appears to have been fixed in Datastore git as of snapshot cb0acdf653 (which caused #4440 in Sugar). Joyride builds from at least 90 onwards have a newer snapshot, so this bug can probably be closed.

  Changed 21 months ago by tomeu

  • milestone changed from First Deployment, V1.0 to V1.1

Have reverted that commit, as it's too late for API changes for FRS. Retargeting for 1.1, when we hope to review the DS API.

  Changed 20 months ago by smcv

  • cc smcv added
  • keywords dbus added
  • summary changed from find() incompatible with DBus to find() has weird API

Keywording, I'd like to keep track of D-Bus API issues.

Note: See TracTickets for help on using tickets.