File tree 2 files changed +15
-16
lines changed
2 files changed +15
-16
lines changed Original file line number Diff line number Diff line change 29
29
from types import TracebackType
30
30
from typing import (
31
31
Any ,
32
+ AnyStr ,
32
33
Callable ,
33
34
DefaultDict ,
34
35
Dict ,
@@ -1088,8 +1089,22 @@ def regexp(value, pattern):
1088
1089
value = value .decode ()
1089
1090
return re .search (pattern , str (value )) is not None
1090
1091
1092
+ def bytelower (bytestring : Optional [AnyStr ]) -> Optional [AnyStr ]:
1093
+ """A custom ``bytelower`` sqlite function so we can compare
1094
+ bytestrings in a semi case insensitive fashion.
1095
+
1096
+ This is to work around sqlite builds are that compiled with
1097
+ ``-DSQLITE_LIKE_DOESNT_MATCH_BLOBS``. See
1098
+ ``https://github.com/beetbox/beets/issues/2172`` for details.
1099
+ """
1100
+ if bytestring is not None :
1101
+ return bytestring .lower ()
1102
+
1103
+ return bytestring
1104
+
1091
1105
conn .create_function ("regexp" , 2 , regexp )
1092
1106
conn .create_function ("unidecode" , 1 , unidecode )
1107
+ conn .create_function ("bytelower" , 1 , bytelower )
1093
1108
1094
1109
def _close (self ):
1095
1110
"""Close the all connections to the underlying SQLite database
Original file line number Diff line number Diff line change @@ -1550,17 +1550,6 @@ def parse_query_string(s, model_cls):
1550
1550
return parse_query_parts (parts , model_cls )
1551
1551
1552
1552
1553
- def _sqlite_bytelower (bytestring ):
1554
- """A custom ``bytelower`` sqlite function so we can compare
1555
- bytestrings in a semi case insensitive fashion.
1556
-
1557
- This is to work around sqlite builds are that compiled with
1558
- ``-DSQLITE_LIKE_DOESNT_MATCH_BLOBS``. See
1559
- ``https://github.com/beetbox/beets/issues/2172`` for details.
1560
- """
1561
- return bytestring .lower ()
1562
-
1563
-
1564
1553
# The Library: interface to the database.
1565
1554
1566
1555
@@ -1585,11 +1574,6 @@ def __init__(
1585
1574
1586
1575
self ._memotable = {} # Used for template substitution performance.
1587
1576
1588
- def _create_connection (self ):
1589
- conn = super ()._create_connection ()
1590
- conn .create_function ("bytelower" , 1 , _sqlite_bytelower )
1591
- return conn
1592
-
1593
1577
# Adding objects to the database.
1594
1578
1595
1579
def add (self , obj ):
You can’t perform that action at this time.
0 commit comments