remove explicit b' from sql query dict key names

This commit is contained in:
Johnny Robeson 2016-05-30 03:03:36 -04:00
parent 32d4545b5e
commit cd1f79340f
4 changed files with 8 additions and 8 deletions

View file

@ -562,13 +562,13 @@ class Results(object):
'SELECT * FROM {0} WHERE entity_id=?'.format(
self.model_class._flex_table
),
(row[b'id'],)
(row['id'],)
)
cols = dict(row)
values = dict((k, v) for (k, v) in cols.items()
if not k[:4] == 'flex')
flex_values = dict((row[b'key'], row[b'value']) for row in flex_rows)
flex_values = dict((row['key'], row['value']) for row in flex_rows)
# Construct the Python object
obj = self.model_class._awaken(self.db, values, flex_values)

View file

@ -85,7 +85,7 @@ def _print_keys(query):
returned row, with identation of 2 spaces.
"""
for row in query:
print_(' ' * 2 + row[b'key'])
print_(' ' * 2 + row['key'])
def fields_func(lib, opts, args):

View file

@ -214,7 +214,7 @@ class ModelTest(unittest.TestCase):
model.field_one = 123
model.store()
row = self.db._connection().execute('select * from test').fetchone()
self.assertEqual(row[b'field_one'], 123)
self.assertEqual(row['field_one'], 123)
def test_retrieve_by_id(self):
model = TestModel1()

View file

@ -63,7 +63,7 @@ class StoreTest(_common.LibTestCase):
self.i.store()
new_year = self.lib._connection().execute(
'select year from items where '
'title="the title"').fetchone()[b'year']
'title="the title"').fetchone()['year']
self.assertEqual(new_year, 1987)
def test_store_only_writes_dirty_fields(self):
@ -72,7 +72,7 @@ class StoreTest(_common.LibTestCase):
self.i.store()
new_genre = self.lib._connection().execute(
'select genre from items where '
'title="the title"').fetchone()[b'genre']
'title="the title"').fetchone()['genre']
self.assertEqual(new_genre, original_genre)
def test_store_clears_dirty_flags(self):
@ -91,7 +91,7 @@ class AddTest(_common.TestCase):
self.lib.add(self.i)
new_grouping = self.lib._connection().execute(
'select grouping from items '
'where composer="the composer"').fetchone()[b'grouping']
'where composer="the composer"').fetchone()['grouping']
self.assertEqual(new_grouping, self.i.grouping)
def test_library_add_path_inserts_row(self):
@ -101,7 +101,7 @@ class AddTest(_common.TestCase):
self.lib.add(i)
new_grouping = self.lib._connection().execute(
'select grouping from items '
'where composer="the composer"').fetchone()[b'grouping']
'where composer="the composer"').fetchone()['grouping']
self.assertEqual(new_grouping, self.i.grouping)