mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-16 21:44:10 +02:00
transform=True for differing column types, refs #467
This commit is contained in:
parent
1ac5d4e39d
commit
6d4efd2949
2 changed files with 8 additions and 1 deletions
|
|
@ -912,7 +912,7 @@ class Database:
|
||||||
if missing_columns:
|
if missing_columns:
|
||||||
for col_name, col_type in missing_columns.items():
|
for col_name, col_type in missing_columns.items():
|
||||||
table.add_column(col_name, col_type)
|
table.add_column(col_name, col_type)
|
||||||
if missing_columns or columns_to_drop:
|
if missing_columns or columns_to_drop or columns != existing_columns:
|
||||||
should_transform = True
|
should_transform = True
|
||||||
# Do we need to change the column order?
|
# Do we need to change the column order?
|
||||||
if (
|
if (
|
||||||
|
|
|
||||||
|
|
@ -1176,6 +1176,13 @@ def test_create_if_no_columns(fresh_db):
|
||||||
'CREATE TABLE "demo" (\n [id] INTEGER PRIMARY KEY,\n [name] TEXT,\n [age] INTEGER\n)',
|
'CREATE TABLE "demo" (\n [id] INTEGER PRIMARY KEY,\n [name] TEXT,\n [age] INTEGER\n)',
|
||||||
True,
|
True,
|
||||||
),
|
),
|
||||||
|
# Change a column type
|
||||||
|
(
|
||||||
|
{"id": int, "name": bytes},
|
||||||
|
{"pk": "id"},
|
||||||
|
'CREATE TABLE "demo" (\n [id] INTEGER PRIMARY KEY,\n [name] BLOB\n)',
|
||||||
|
True,
|
||||||
|
),
|
||||||
# Change the primary key
|
# Change the primary key
|
||||||
(
|
(
|
||||||
{"id": int, "name": str},
|
{"id": int, "name": str},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue