Skip to content

Failed Table.convert() leaves newly created columns behind #993

Backlog

Description

@0xeriiic
from sqlite_utils import Database
from sqlite_utils.utils import sqlite3

table = Database(memory=True, execute_plugins=False)["example"].insert(
    {"value": "not a number"},
)
try:
    table.convert("value", int, output="converted", output_type=int)
except sqlite3.OperationalError:
    pass
print(table.columns_dict)

On main at 74c0b6c, the conversion raises and leaves converted in the schema. multi=True also leaves new columns when updating a row fails a constraint. Since both conversion paths already use a transaction for writing rows, it would be useful to include adding output columns in that transaction so a failed conversion leaves the original schema intact.

OpenAI Codex assisted with investigation, testing, and this draft.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions