SQL scripts fail with "TypeError: dict is not a sequence"

Bug #1947400 reported by Evan Ward
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
sqlalchemy-migrate
New
Undecided
Unassigned

Bug Description

When using SQL scripts if the script has a "%" in it then it will fail to execute with the error "TypeError: dict is not a sequence". This seems to be due to sqlalchemy passing through Python % string formatting before executing it. The correct solution appears to be to escape any characters that offend sqlalchemy using `sqlalchemy.text`. For example the following statement runs in `psql` but fails when run with `migrate`.

do
$$
begin
    execute format('select text(''%I'')', current_database());
end
$$;

Perhaps the right place to make the change is in migrate/versioning/script/sql.py before the statement is passed to sqlalchemy.

Workaround: Double the "%" as this escapes the character for Python's formatting.

Tested with Version: 0.13.0-0ubuntu1 from
http://us.archive.ubuntu.com/ubuntu hirsute/main amd64 Packages

Evan Ward (evanward1)
description: updated
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.