Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
numpy: [0, 1]
os: [ubuntu-latest, macos-latest, windows-latest, macos-14]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
Expand Down
8 changes: 4 additions & 4 deletions sqlite_utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -3047,10 +3047,10 @@ def fk_with_renamed_columns(fk: ForeignKey) -> ForeignKey:
for key, value in not_null.items():
# Column may have been renamed
key = rename.get(key) or key
if value is False and key in create_table_not_null:
create_table_not_null.remove(key)
else:
if value:
create_table_not_null.add(key)
else:
create_table_not_null.discard(key)
elif isinstance(not_null, set):
create_table_not_null.update((rename.get(k) or k) for k in not_null)
elif not not_null:
Expand Down Expand Up @@ -4789,7 +4789,7 @@ def insert_all(
raise ValueError(
"When using list-based iteration, the first yielded value must be a list of column name strings"
)
column_names = cast(list[str], list(first_record))
column_names = list(first_record)
all_columns = column_names
num_columns = len(column_names)
# Get the actual first data record
Expand Down
16 changes: 16 additions & 0 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,22 @@ def test_transform_remove_a_not_null(fresh_db):
)


def test_transform_not_null_false_leaves_nullable_column_nullable(fresh_db):
# not_null={"col": False} on a column that was already nullable
# used to add NOT NULL to it
dogs = fresh_db["dogs"]
dogs.insert({"id": 1, "name": "Cleo", "age": None}, pk="id")
dogs.transform(not_null={"age": False})
assert dogs.schema == (
'CREATE TABLE "dogs" (\n'
' "id" INTEGER PRIMARY KEY,\n'
' "name" TEXT,\n'
' "age" TEXT\n'
")"
)
assert list(dogs.rows) == [{"id": 1, "name": "Cleo", "age": None}]


@pytest.mark.parametrize("not_null", [{"age"}, {"age": True}])
def test_transform_add_not_null_with_rename(fresh_db, not_null):
dogs = fresh_db.table("dogs")
Expand Down
Loading