Activity log for bug #123592

Date Who What changed Old value New value Message
2007-07-02 17:21:07 Michael Hudson-Doyle bug added bug
2007-07-02 18:25:06 Diogo Matsubara launchpad: status New Confirmed
2007-07-02 18:25:06 Diogo Matsubara launchpad: statusexplanation
2007-07-03 08:41:38 Michael Hudson-Doyle description I've found at least 4 patterns for what the common SomeDatabaseObjectSet.get(id) methods do when the 'id' is not present: 1. nothing special, and thus raise SQLObjectNotFoundError. This doesn't seem that great an idea, though it's probably ok for methods that never expect to be called for a missing id (the id is never derived from user input, for example). 2. catch SQLObjectNotFoundError and reraise the launchpad specific NotFoundError. 3. return None. 4. ape the dictionary .get() method and return an optional second argument that defaults to None. This seems a bit of a mess. While 4 seems the most flexible, I think it's actually wasted effort: if you're after the database row with a particular id, it seems very unlikely that some other (non-None) object will do, and in my grepping I found exactly no code taking advantage of the flexibility of these methods (not even tests). Option 1 has clear disadvantages (exposing implementation details) and so the choice is between 2 and 3. I'd lean towards 2, following the 'making errors errors' Python tradition. I've found at least 4 patterns for what the common SomeDatabaseObjectSet.get(id) methods do when the 'id' is not present: 1. nothing special, and thus raise SQLObjectNotFoundError. This doesn't seem that great an idea, though it's probably ok for methods that never expect to be called for a missing id (the id is never derived from user input, for example). 2. catch SQLObjectNotFoundError and reraise the launchpad specific NotFoundError. 3. return None. 4. ape the dictionary .get() method and return an optional second argument that defaults to None. This seems a bit of a mess. While 4 seems the most flexible, I think it's actually wasted effort: if you're after the database row with a particular id, it seems very unlikely that some other (non-None) object will do, and in my grepping I found exactly no code taking advantage of the flexibility of these methods (not even tests). Option 1 has clear disadvantages (exposing implementation details) and so the choice is between 2 and 3. Steve asked for 3.
2007-07-03 08:41:38 Michael Hudson-Doyle title DatabaseClassSet.get methods have inconsistent interfaces DatabaseClassSet.get should return None when id not present
2007-07-10 11:41:27 Jeroen T. Vermeulen launchpad: assignee jtv
2009-10-19 10:55:56 Данило Шеган launchpad-foundations: assignee Jeroen T. Vermeulen (jtv)
2009-11-06 04:51:55 Curtis Hovey launchpad-foundations: status Confirmed Triaged
2009-11-06 04:51:59 Curtis Hovey launchpad-foundations: importance Undecided Low