FieldQuery#

class beets.dbcore.query.FieldQuery(field_name: str, pattern: P, fast: bool = True)[source]#

Bases: Query, Generic[P]

An abstract query that searches in a specific field for a pattern. Subclasses must provide a value_match class method, which determines whether a certain pattern string matches a certain value string. Subclasses may also provide col_clause to implement the same matching functionality in SQLite.

__init__(field_name: str, pattern: P, fast: bool = True)[source]#

Public methods summary

clause()

Generate an SQLite expression implementing the query.

col_clause()

match(obj)

Check whether this query matches a given Model.

value_match(pattern, value)

Determine whether the value matches the pattern.

Methods definition

property field_names: set[str]#

Return a set with field names that this query operates on.

clause() tuple[str | None, Sequence[str | bytes | float | int | memoryview | None]][source]#

Generate an SQLite expression implementing the query.

Return (clause, subvals) where clause is a valid sqlite WHERE clause implementing the query and subvals is a list of items to be substituted for ?s in the clause.

The default implementation returns None, falling back to a slow query using match().

classmethod value_match(pattern: P, value: Any)[source]#

Determine whether the value matches the pattern.

match(obj: Model) bool[source]#

Check whether this query matches a given Model. Can be used to perform queries on arbitrary sets of Model.