mirror of
https://github.com/beetbox/beets.git
synced 2026-01-08 00:45:55 +01:00
remove superfluous py_type field from Type
This commit is contained in:
parent
00829c1a6c
commit
1cdb30fd56
3 changed files with 13 additions and 14 deletions
|
|
@ -66,7 +66,7 @@ def format_for_path(value, key=None):
|
|||
# Abstract base for model classes and their field types.
|
||||
|
||||
|
||||
Type = namedtuple('Type', 'py_type sql_type query')
|
||||
Type = namedtuple('Type', 'sql query')
|
||||
|
||||
|
||||
class Model(object):
|
||||
|
|
@ -637,7 +637,7 @@ class Database(object):
|
|||
# No table exists.
|
||||
columns = []
|
||||
for name, typ in fields.items():
|
||||
columns.append('{0} {1}'.format(name, typ.sql_type))
|
||||
columns.append('{0} {1}'.format(name, typ.sql))
|
||||
setup_sql = 'CREATE TABLE {0} ({1});\n'.format(table,
|
||||
', '.join(columns))
|
||||
|
||||
|
|
@ -648,7 +648,7 @@ class Database(object):
|
|||
if name in current_fields:
|
||||
continue
|
||||
setup_sql += 'ALTER TABLE {0} ADD COLUMN {1} {2};\n'.format(
|
||||
table, name, typ.sql_type
|
||||
table, name, typ.sql
|
||||
)
|
||||
|
||||
with self.transaction() as tx:
|
||||
|
|
|
|||
|
|
@ -79,13 +79,13 @@ class SingletonQuery(dbcore.Query):
|
|||
|
||||
# Common types used in field definitions.
|
||||
TYPES = {
|
||||
int: Type(int, 'INTEGER', dbcore.query.NumericQuery),
|
||||
float: Type(float, 'REAL', dbcore.query.NumericQuery),
|
||||
datetime: Type(datetime, 'REAL', dbcore.query.NumericQuery),
|
||||
unicode: Type(unicode, 'TEXT', dbcore.query.SubstringQuery),
|
||||
bool: Type(bool, 'INTEGER', dbcore.query.BooleanQuery),
|
||||
int: Type('INTEGER', dbcore.query.NumericQuery),
|
||||
float: Type('REAL', dbcore.query.NumericQuery),
|
||||
datetime: Type('REAL', dbcore.query.NumericQuery),
|
||||
unicode: Type('TEXT', dbcore.query.SubstringQuery),
|
||||
bool: Type('INTEGER', dbcore.query.BooleanQuery),
|
||||
}
|
||||
PATH_TYPE = Type(bytes, 'BLOB', PathQuery)
|
||||
PATH_TYPE = Type('BLOB', PathQuery)
|
||||
|
||||
# Fields in the "items" database table; all the metadata available for
|
||||
# items in the library. These are used directly in SQL; they are
|
||||
|
|
@ -96,7 +96,7 @@ PATH_TYPE = Type(bytes, 'BLOB', PathQuery)
|
|||
# - Is the field writable?
|
||||
# - Does the field reflect an attribute of a MediaFile?
|
||||
ITEM_FIELDS = [
|
||||
('id', Type(int, 'INTEGER PRIMARY KEY', dbcore.query.NumericQuery),
|
||||
('id', Type('INTEGER PRIMARY KEY', dbcore.query.NumericQuery),
|
||||
False, False),
|
||||
('path', PATH_TYPE, False, False),
|
||||
('album_id', TYPES[int], False, False),
|
||||
|
|
@ -167,8 +167,7 @@ ITEM_KEYS = [f[0] for f in ITEM_FIELDS]
|
|||
# The third entry in each tuple indicates whether the field reflects an
|
||||
# identically-named field in the items table.
|
||||
ALBUM_FIELDS = [
|
||||
('id', Type(int, 'INTEGER PRIMARY KEY', dbcore.query.NumericQuery),
|
||||
False),
|
||||
('id', Type('INTEGER PRIMARY KEY', dbcore.query.NumericQuery), False),
|
||||
('artpath', PATH_TYPE, False),
|
||||
('added', TYPES[datetime], True),
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ from beets import dbcore
|
|||
# Fixture: concrete database and model classes. For migration tests, we
|
||||
# have multiple models with different numbers of fields.
|
||||
|
||||
ID_TYPE = dbcore.Type(int, 'INTEGER PRIMARY KEY', dbcore.query.NumericQuery)
|
||||
INT_TYPE = dbcore.Type(int, 'INTEGER', dbcore.query.NumericQuery)
|
||||
ID_TYPE = dbcore.Type('INTEGER PRIMARY KEY', dbcore.query.NumericQuery)
|
||||
INT_TYPE = dbcore.Type('INTEGER', dbcore.query.NumericQuery)
|
||||
|
||||
class TestModel1(dbcore.Model):
|
||||
_table = 'test'
|
||||
|
|
|
|||
Loading…
Reference in a new issue