From 9680a0291c7f5692076c468985c71f7fc6f5f199 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 8 Sep 2020 15:24:39 -0700 Subject: [PATCH] 'Soundness check' is better --- sqlite_utils/db.py | 8 ++++---- tests/test_cli.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index c03530f..f535f6b 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -286,7 +286,7 @@ class Database: foreign_keys_by_column[extract_column] = ForeignKey( name, extract_column, extract_table, "id" ) - # Sanity check not_null, and defaults if provided + # Soundness check not_null, and defaults if provided not_null = not_null or set() defaults = defaults or {} assert all( @@ -308,7 +308,7 @@ class Database: if hash_id: column_items.insert(0, (hash_id, str)) pk = hash_id - # Sanity check foreign_keys point to existing tables + # Soundness check foreign_keys point to existing tables for fk in foreign_keys: if not any( c for c in self[fk.other_table].columns if c.name == fk.other_column @@ -792,7 +792,7 @@ class Table(Queryable): if other_column is None: other_column = self.guess_foreign_column(other_table) - # Sanity check that the other column exists + # Soundness check that the other column exists if ( not [c for c in self.db[other_table].columns if c.name == other_column] and other_column != "rowid" @@ -996,7 +996,7 @@ class Table(Queryable): conversions = conversions or {} if not isinstance(pk_values, (list, tuple)): pk_values = [pk_values] - # Sanity check that the record exists (raises error if not): + # Soundness check that the record exists (raises error if not): self.get(pk_values) if not updates: return self diff --git a/tests/test_cli.py b/tests/test_cli.py index 964b6a2..77efc56 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -475,7 +475,7 @@ def test_optimize(db_path): assert 0 == result.exit_code size_after_optimize = os.stat(db_path).st_size assert size_after_optimize < size_before_optimize - # Sanity check that --no-vacuum doesn't throw errors: + # Soundness check that --no-vacuum doesn't throw errors: result = CliRunner().invoke(cli.cli, ["optimize", "--no-vacuum", db_path]) assert 0 == result.exit_code @@ -724,7 +724,7 @@ def test_insert_alter(db_path, tmpdir): input='{"foo": "bar", "baz": 5}', ) assert 0 == result.exit_code, result.output - # Sanity check the database itself + # Soundness check the database itself db = Database(db_path) assert {"foo": str, "n": int, "baz": int} == db["from_json_nl"].columns_dict assert [