Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#8895 closed defect (fixed)

sqlite backend EagerCursor.execute does not return self

Reported by: vince@… Owned by: vince@…
Priority: normal Milestone: 0.11.7
Component: database backend Version: 0.11-stable
Severity: normal Keywords: sqlite cursor null
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

In trac.db.sqlite_backend.py, EagerCursor inherits from PyFormatCursor, but does not return a value like PyFormatCursor does.

This seems to cause several problems with my Trac project due to inconsistent behavior. Namely, several places that use the chaining to call fetchone() or fetchall().

        def execute(self, *args):
            PyFormatCursor.execute(self, *args)
            self.rows = PyFormatCursor.fetchall(self)
            self.pos = 0

There appears to be a simple solution:

        def execute(self, *args):
            PyFormatCursor.execute(self, *args)
            self.rows = PyFormatCursor.fetchall(self)
            self.pos = 0
            return self

Attachments (0)

Change History (7)

comment:1 by Remy Blank, 15 years ago

Milestone: 0.11.7
Resolution: fixed
Status: newclosed

Slightly different patch applied to 0.11-stable (as that's where EagerCursor was introduced) in [8916]. Thanks!

comment:2 by Remy Blank, 15 years ago

Owner: set to vince@…

comment:3 by Christian Boos, 15 years ago

Too quick Remy, I would have closed that as wontfix, as we're following the dbapi2 (pep:0249) in which the result of Cursor.execute is explicitly said to be undefined.

Of course the change won't harm, but encouraging this use is not really a good idea, I think.

in reply to:  3 comment:4 by Remy Blank, 15 years ago

Replying to cboos:

Of course the change won't harm, but encouraging this use is not really a good idea, I think.

It's not documented, so we can hardly say that we're encouraging it. And technically, it's still undefined, as we return the value we get from Cursor.execute() instead of just self. I just re-established the previous undefined behavior ;-)

But feel free to revert if you think this gives a bad example.

comment:5 by osimons, 15 years ago

And, Christian: Remember the need to reset the version number on the branch after releases…? ;-)

comment:6 by Christian Boos, 15 years ago

Well, I should probably have told Remy about my desire to not commit anymore on 0.11-stable except if we have changes that would justify a new release…

in reply to:  6 comment:7 by Remy Blank, 15 years ago

Replying to cboos:

Well, I should probably have told Remy about my desire to not commit anymore on 0.11-stable except if we have changes that would justify a new release…

That would have helped, yes. However, see comment:6:ticket:8884. Not really critical, but quite serious, I would say.

OTOH, as long as everything is merged to trunk, I don't see the harm in having unreleased changesets on 0.11-stable.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain vince@….
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from vince@… to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.