Skip to content

table.transform() drops column COLLATE #954

Done

Description

@Mo0nl19ht

On sqlite-utils 4.2.1 (and main at 9c66baf), table.transform() and sqlite-utils transform drop the COLLATE clause from column definitions. A column declared name TEXT COLLATE NOCASE comes out as plain name TEXT, so comparisons on it silently become case-sensitive.

import sqlite_utils

db = sqlite_utils.Database(memory=True)
db.execute("CREATE TABLE people (id INTEGER PRIMARY KEY, name TEXT COLLATE NOCASE)")
db["people"].insert({"id": 1, "name": "Alice"})
print(db.execute("select count(*) from people where name = 'alice'").fetchone())
db["people"].transform(types={"id": int})
print(db.execute("select count(*) from people where name = 'alice'").fetchone())
print(db["people"].schema)

Output:

(1,)
(0,)
CREATE TABLE "people" (
   "id" INTEGER PRIMARY KEY,
   "name" TEXT
)

Any transform triggers it, even one that does not touch the column. PRAGMA table_info does not report collations, so they need to be read from the schema SQL, as CHECK and UNIQUE constraints already are. A column-level UNIQUE does keep its collation today (it is rewritten as UNIQUE ("name" COLLATE "NOCASE")), but the column itself loses it.

Activity

  1. added
    bug
    on Nov 29, 2026
  2. simonw commented on Nov 29, 2026

    @simonw
    Owner
  3. added a commit that references this issue on Nov 29, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions