Skip to content

use a decorator to automatically commit after public methods #64

@dlqqq

Description

@dlqqq

Problem

Forgetting to call self.con.commit() imperatively can be the source of a lot of silly bugs, as seen in #63.

Setting autocommit=True is bad for performance, as a single batched commit is significantly faster than multiple commits. The way this is currently being managed is that private methods never commit, and public methods should always commit right before returning the value. However, this currently needs to be done imperatively at every possible return point in each public method, which is fragile.

Proposed Solution

There should be a @commit decorator that wraps every public method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions