Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] use single-quotes for string literals in sqlite queries #5419

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions beets/dbcore/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
return unicodedata.normalize("NFC", s)

@classmethod
def string_match(cls, pattern: Pattern, value: str) -> bool:

Check failure on line 306 in beets/dbcore/query.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "Pattern"
return pattern.search(cls._normalize(value)) is not None


Expand Down Expand Up @@ -465,7 +465,7 @@
"""Return a set with field names that this query operates on."""
return reduce(or_, (sq.field_names for sq in self.subqueries))

def __init__(self, subqueries: Sequence = ()):

Check failure on line 468 in beets/dbcore/query.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "Sequence"
self.subqueries = subqueries

# Act like a sequence.
Expand All @@ -476,7 +476,7 @@
def __getitem__(self, key):
return self.subqueries[key]

def __iter__(self) -> Iterator:

Check failure on line 479 in beets/dbcore/query.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "Iterator"
return iter(self.subqueries)

def __contains__(self, subq) -> bool:
Expand Down Expand Up @@ -525,7 +525,7 @@
"""Return a set with field names that this query operates on."""
return set(self.fields)

def __init__(self, pattern, fields, cls: Type[FieldQuery]):

Check failure on line 528 in beets/dbcore/query.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "FieldQuery"
self.pattern = pattern
self.fields = fields
self.query_class = cls
Expand Down Expand Up @@ -563,7 +563,7 @@
query is initialized.
"""

subqueries: MutableSequence

Check failure on line 566 in beets/dbcore/query.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "MutableSequence"

def __setitem__(self, key, value):
self.subqueries[key] = value
Expand Down Expand Up @@ -908,7 +908,7 @@
"""
return None

def sort(self, items: List) -> List:

Check failure on line 911 in beets/dbcore/query.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "List"
"""Sort the list of objects and return a list."""
return sorted(items)

Expand Down Expand Up @@ -1002,7 +1002,7 @@
self.ascending = ascending
self.case_insensitive = case_insensitive

def sort(self, objs: Collection):

Check failure on line 1005 in beets/dbcore/query.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "Collection"
# TODO: Conversion and null-detection here. In Python 3,
# comparisons with None fail. We should also support flexible
# attributes with different types without falling over.
Expand Down Expand Up @@ -1040,8 +1040,8 @@
if self.case_insensitive:
field = (
"(CASE "
'WHEN TYPEOF({0})="text" THEN LOWER({0}) '
'WHEN TYPEOF({0})="blob" THEN LOWER({0}) '
"WHEN TYPEOF({0})='text' THEN LOWER({0}) "
"WHEN TYPEOF({0})='blob' THEN LOWER({0}) "
"ELSE {0} END)".format(self.field)
)
else:
Expand All @@ -1061,7 +1061,7 @@
class NullSort(Sort):
"""No sorting. Leave results unsorted."""

def sort(self, items: List) -> List:

Check failure on line 1064 in beets/dbcore/query.py

View workflow job for this annotation

GitHub Actions / Check types with mypy

Missing type parameters for generic type "List"
return items

def __nonzero__(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def order_clause(self):
collate = "COLLATE NOCASE" if self.case_insensitive else ""
return (
"(CASE {0}_sort WHEN NULL THEN {0} "
'WHEN "" THEN {0} '
"WHEN '' THEN {0} "
"ELSE {0}_sort END) {1} {2}"
).format(field, collate, order)

Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Bug fixes:
as a numpy array. Update ``librosa`` dependency constraint to prevent similar
issues in the future.
:bug:`5289`
* Fixed changed double to single quotes in two queries to work with DSQLITE_DQS=0.

For packagers:

Expand Down
Loading