Browse Source

Remove decode call from db migrations script

This is a follow up on 'py3 only' changes. Previously in py2
current_name variable had unicode type, however in py3 it is
a str type which leads to an Attribute error when the code
is executed by py3 ('str' object has no attribute 'decode').

Now when refstack is py3 only, we don't need to be decoding
current_name variable, the patch removes this conversion.

More about str and unicode and their meaning in py2 and py3:
 * https://portingguide.readthedocs.io/en/latest/strings.html

Change-Id: Ibc76a8797b467d45b05c6e6e61d4bc703a5d701f
changes/34/772934/1
Martin Kopec 6 months ago
parent
commit
23fcee1239
  1. 2
      refstack/db/migrations/alembic/utils.py

2
refstack/db/migrations/alembic/utils.py

@ -80,7 +80,6 @@ def get_db_tables(conn):
current_name =\
next((table for table in result if table != "alembic_version"),
result[0])
current_name = current_name.decode('utf-8')
current_version = get_table_version(conn, current_name)
default_name =\
next((table for table in result
@ -93,7 +92,6 @@ def get_db_tables(conn):
current_name = next((table for table in result
if table != current_name),
result[0])
current_name = current_name.decode('utf-8')
elif current_name:
# this is the case where the current-named table
# exists, but is empty

Loading…
Cancel
Save