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

Can not MultiByteStrDecoder is QueryItem #bug #82

Closed
bindi-mo opened this issue Jan 20, 2025 · 3 comments
Closed

Can not MultiByteStrDecoder is QueryItem #bug #82

bindi-mo opened this issue Jan 20, 2025 · 3 comments
Labels

Comments

@bindi-mo
Copy link

in execute_query method (core.py)

MultiByteStrDecoder(query) is ValueError

Please fix is MultiByteStrDecoder(str(query)).unicode_str

@bindi-mo bindi-mo changed the title Can not MultiByteStrDecoder is QueryItem Can not MultiByteStrDecoder is QueryItem #bug Jan 20, 2025
@thombashi
Copy link
Owner

@bindi-mo
Thank you for your report.
Unfortunately, I was not able to reproduce the error.
Could you provide some code to reproduce the error?

@bindi-mo
Copy link
Author

query is str or QueryItem.

MultiByteStrDecoder(QueryItem) is ValueError

Checking instances are str or byte in MultiByteStrDecoder

isinstance(self.__encoded_str, (str, bytes)):

>>> from mbstrdecoder import MultiByteStrDecoder
>>> from simplesqlite.query import Select
>>> query = Select('*', 'article')
>>> MultiByteStrDecoder(query)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bindi/.local/lib/python3.12/site-packages/mbstrdecoder/_mbstrdecoder.py", line 149, in __init__
    self.__validate_str()
  File "/home/bindi/.local/lib/python3.12/site-packages/mbstrdecoder/_mbstrdecoder.py", line 160, in __validate_str
    raise ValueError(f"value must be a string: actual={type(self.__encoded_str)}")
ValueError: value must be a string: actual=<class 'simplesqlite.query.Select'>
>>>

my fix code:

diff -ur simplesqlite/core.py /home/bindi/.local/lib/python3.12/site-packages/simplesqlite/core.py
--- simplesqlite/core.py        2025-02-18 22:45:25.619217434 +0900
+++ /home/bindi/.local/lib/python3.12/site-packages/simplesqlite/core.py        2025-01-20 22:10:13.084544748 +0900
@@ -353,13 +356,13 @@
             file_path, line_no, func_name = caller[:3]

             raise OperationalError(
-                message="\n".join(
+                "\n".join(
                     [
                         "failed to execute query at {:s}({:d}) {:s}".format(
                             file_path, line_no, func_name
                         ),
-                        f"  - query: {MultiByteStrDecoder(query).unicode_str}",
-                        f"  - msg:   {e}",
+                        f"  - query: {MultiByteStrDecoder(str(query)).unicode_str}",
+                        f"  - msg:   {str(e)}",
                         f"  - db:    {self.database_path}",
                     ]
                 )

thombashi added a commit that referenced this issue Feb 22, 2025
@thombashi thombashi added the bug label Feb 22, 2025
@thombashi
Copy link
Owner

Fixed at SimpleSQLite 1.5.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants