Skip to main content
`Ctrl`+`K`

# FieldQuery

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

  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)

  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

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

    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().

  property field_names: set[str]

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

  match(obj: Model) → bool

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

  classmethod value_match(pattern: P, value: Any)

    Determine whether the value matches the pattern.