benji icon indicating copy to clipboard operation
benji copied to clipboard

MySQL compatability problem

Open elemental-lf opened this issue 3 years ago • 1 comments

Thanks for your reply.

Using mysql I found

sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1170, "BLOB/TEXT column 'checksum' used in key specification without a key length")
[SQL: CREATE INDEX ix_blocks_checksum ON blocks (checksum)]

solved by

	--- /usr/local/lib/python3.8/dist-packages/benji/database.py.orig	2022-06-20 19:39:16.450627651 +0000
+++ /usr/local/lib/python3.8/dist-packages/benji/database.py	2022-06-20 19:39:28.657846049 +0000
@@ -786,7 +786,7 @@
         sqlalchemy.Index(None, 'uid_left', 'uid_right'),
         # Maybe using an hash index on PostgeSQL might be beneficial in the future
         # Index(None, 'checksum', postgresql_using='hash'),
-        sqlalchemy.Index(None, 'checksum'),
+        sqlalchemy.Index(None, 'checksum',mysql_length=64),
     )
 
     def deref(self) -> DereferencedBlock:

I do not know if mysql_length is ignored on postgres but i assume it is...

Also are benji using any specific sqlalchemy features not present in 1.3.19 or 1.3.22? I could not find any issue with light testing on 1.3.19 so why is the version bumped in v.0.16.1 this high in https://github.com/elemental-lf/benji/commit/69bb667e493f2542887038800a7955b6f966ac44 Thanks

Originally posted by @jsm222 in https://github.com/elemental-lf/benji/issues/143#issuecomment-1160369364

elemental-lf avatar Jul 29 '22 10:07 elemental-lf

Specifying cache_ok on a TypeDecorator is only supported in 1.4.14 or higher. See https://docs.sqlalchemy.org/en/14/core/custom_types.html#sqlalchemy.types.TypeDecorator.cache_ok. If a remember correctly I was getting warnings because cache_ok was not specified and so I added it in the relevant places.

Thanks for the patch to fix the problem with MySQL, I will have a look at it soon.

elemental-lf avatar Jul 29 '22 10:07 elemental-lf