-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
sqlite3.create_collation() doesn't get called for custom types #92742
Comments
TL;DR: The adapter function returns a
This is because $ python2
WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.
Python 2.7.18 (default, Jan 4 2022, 17:47:56)
[GCC Apple LLVM 13.0.0 (clang-1300.0.29.10) [+internal-os, ptrauth-isa=deployme on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> type(pickle.dumps(1))
<type 'str'>
>>> ^D
$ python3
Python 3.11.0b1 (v3.11.0b1:8d32a5c8c4, May 6 2022, 22:45:29) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> type(pickle.dumps(1))
<class 'bytes'> Collations only work on strings. Quoting the SQLite docs:
If you force
This is probably because the collation function was not run. Suggesting closing this as not-a-bug. |
Ah ha! Indeed using the following
does indeed work. Thanks!
Agreed |
@erlend-aasland, on a related note the https://docs.python.org/3/library/sqlite3.html documentation for
However, you can see from the output above that
and not:
Do you agree the the documentation is incorrect? If so I'll raise a new issue for that |
Yeah, I believe the docs can be improved; please open a new issue. Thanks! |
Bug report
The following example demonstrates that
sqlite3.create_collation()
works for a basic type such asint
but doesn't for a custom type. It used to work in python 2.7.18 but hasn't worked since v3.0.0 on Windows 10 x64.Your environment
Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)] on win32
produces the following output:Python 3.0 (r30:67507, Dec 3 2008, 19:44:23) [MSC v.1500 64 bit (AMD64)] on win32
through toPython 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
produce:Note:
reverse_collation_func
for theMyObj
objectsobj
values is not reversed as it was for python v2.7Operating system and architecture:
The text was updated successfully, but these errors were encountered: