github simonw/sqlite-utils 4.2.2

one hour ago

Fixes for upsert() and upsert_all():

  • table.upsert_all() no longer overwrites existing values with NULL when records in the same batch have different keys. Each record now only updates the columns it provides. (#873)
  • table.upsert() and table.upsert_all() no longer raise IntegrityError when updating an existing row with a record that omits a NOT NULL column that has no default. An upsert that would create a new row without that column still raises the error. (#878)
  • SQL conversions= are now applied once when an upsert updates an existing row. Previously they were applied twice, so a conversion such as ? * 100 stored the wrong value. Thanks, Sanidhya Saluja. (#946, #947)

Fixes for full-text search:

  • table.enable_fts(..., fts_version="FTS4", create_triggers=True) now creates triggers that work. Previously any update or delete of an indexed row raised sqlite3.OperationalError: SQLlogic error. Existing FTS4 tables keep their old triggers until you run table.enable_fts(...,replace=True) or sqlite-utils enable-fts ... --replace. With the new FTS4 triggers a row that is skipped by UPDATE OR IGNORE is removed from the search index. Thanks, Caldera. (#922, #923)
  • table.detect_fts() no longer treats _ and % in a table name as wildcards, which could cause table.search() to use the search index belonging to a different table. Thanks, Ilya Khalafi. (#930, #931)
  • table.enable_fts(), table.search() and table.search_sql() now accept an iterator or generator of column names. Thanks, Syed Ahnaf Raza. Thanks, Pengyi Peng. (#902, #903, #942, #943)

Other fixes:

  • Carriage returns inside quoted CSV and TSV fields are now preserved on import. Previously \r\nand \r inside a quoted value were stored as \n. This affects sqlite-utils insert --csv, --tsv, sqlite-utils memory and rows_from_file(). Thanks, Agustin Saiz. (#895, #897)
  • table.transform() now preserves COLLATE clauses on columns. Previously a TEXT COLLATENOCASE column silently became case-sensitive after any transform. Thanks, Yewan Moon. (#954, #955)
  • table.transform(not_null={"column": False}) no longer adds a NOT NULL constraint to a column that was already nullable. (#944)
  • Calling table.convert() more than once with different callables that share a name, such as two dict.get methods, now runs the correct callable each time. Thanks, Zihan Dai. (#910, #911)
  • numpy integer and floating point scalars such as np.int64(5) are now stored as SQLite integers and floats. Previously they were stored as BLOB values. Thanks, Tanbir Hossain Ramim. (#876, #877)
  • table.analyze_column() and sqlite-utils analyze-tables now handle columns containing NULLvalues correctly. They previously reported wrong counts, could raise TypeError when counts were tied and could omit values from the results. analyze-tables --save now stores a JSON null for a null value where it used to store the string "None". (#887)
  • rows_from_file() now respects ignore_extras= and extras_key= for TSV files and for files where the format is detected automatically. (#892)
  • table.insert_all(..., truncate=True) and sqlite-utils insert --truncate now delete the existing rows when the new input is empty, for example a JSON [] or a CSV file with only a header row. Previously the existing rows were left in place. Thanks, Peter Olkhovets. (#935, #936)
  • sqlite-utils rows --limit 0 now returns no rows. Previously it returned every row in the table. Thanks, LucioLiu. (#964, #965)
  • rows_from_file() now closes the buffered reader it creates when detecting the format of a JSON file, avoiding a ResourceWarning.

Don't miss a new sqlite-utils release

NewReleases is sending notifications on new releases.