Skip to content

Commit 79913af

Browse files
committed
Handle different SQLite version error messages
Refs #653 (comment)
1 parent fa6ae2b commit 79913af

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sqlite_utils/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,9 @@ def insert_upsert_implementation(
10981098
if (
10991099
isinstance(e, OperationalError)
11001100
and e.args
1101-
and "has no column named" in e.args[0]
1101+
and (
1102+
"has no column named" in e.args[0] or "no such column" in e.args[0]
1103+
)
11021104
):
11031105
raise click.ClickException(
11041106
"{}\n\nTry using --alter to add additional columns".format(

tests/test_cli.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,10 +1116,8 @@ def test_upsert_alter(db_path, tmpdir):
11161116
cli.cli, ["upsert", db_path, "dogs", json_path, "--pk", "id"]
11171117
)
11181118
assert result.exit_code == 1
1119-
assert (
1120-
"Error: table dogs has no column named age\n\n"
1121-
"Try using --alter to add additional columns"
1122-
) == result.output.strip()
1119+
# Could be one of two errors depending on SQLite version
1120+
assert ("Try using --alter to add additional columns") in result.output.strip()
11231121
# Should succeed with --alter
11241122
result = CliRunner().invoke(
11251123
cli.cli, ["upsert", db_path, "dogs", json_path, "--pk", "id", "--alter"]

0 commit comments

Comments
 (0)