Skip to content

transform(not_null={"col": False}) adds NOT NULL to a nullable column #944

Open

Description

@abhishekcpp007

transform() only removes a column from the NOT NULL set if it's already there. Otherwise False falls into the else branch and adds it:

db["dogs"].insert({"id": 1, "name": "Cleo", "age": None}, pk="id")
db["dogs"].transform(not_null={"age": False})
# sqlite3.IntegrityError: NOT NULL constraint failed: dogs_new_....age

If the column has no nulls yet, it silently becomes NOT NULL. The CLI does the same:

sqlite-utils transform b.db dogs --not-null-false age

gives "age" INTEGER NOT NULL.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions