Fork me on GitHub
#clojure
<
2021-11-29
>
m2i3k200019:11:51

I am querying a mySQL db table using next.jdbc and honeySQL. The table has a column that stores URLs. In the query result this field appears as a vector of ints e.g. [104 116 116 112 58 47 47 115 114 118 49 46 109 121 99 111 109 112 97 110 121 46 99 111 109 47 108 111 103], which is the list of chars that make up the URL string. Other string fields appear correctly. If I query the same table from Kotlin or Golang the URL field correctly appears as a string. What should I do to get this read correctly in clojure? I also tried with clojure.java.jdbc with the same result.

seancorfield19:11:30

What is the actual column type in MySQL?

seancorfield19:11:06

(also, there's a #sql channel where folks can get help with database-related stuff and are more likely to see Qs like this since it is lower traffic)

seancorfield19:11:06

As part of debugging this, I'd also suggest trying the query directly with next.jdbc/execute! without using HoneySQL and println the direct result without any further processing, just to verify that you really are getting that back from JDBC rather than it being an issue in your post-processing @U0DV4USKH

m2i3k200006:11:27

The column type is blob. That explains it. Thank you for responding, as well as for the pointer to the #sql channel. Since the documentation says that there is no equivalent for blob similar to clob->string, I am simply updating the fields with #(->> % (map char) (string/join "")

seancorfield06:11:17

But that would mean you would get strings, even for images etc.

seancorfield06:11:39

I guess my question would be: why on earth did someone declare URL columns as Blob???

seancorfield06:11:43

Oh, MySQL returns Blob as byte[] -- my bad. Yeah, that sucks. So, even more of a reason that declaring a URL column as Blob is a dumb idea.

seancorfield06:11:28

BTW (string/join) would be shorter and equivalent there.

m2i3k200006:11:34

Inherited 12 year old db at work 😪. Migrating to MariaDB soon, so will try to get this fixed. This column only contains URL strings pointing to log files.

m2i3k200006:11:15

Thank you for the tip on (string/join)

Alex Miller (Clojure team)23:11:03

Does anyone have some public code that has known perf characteristics and uses primarily normal long (checked) math ops? I'm trying to evaluate actual benefits of https://clojure.atlassian.net/browse/CLJ-2670 in a non-synthetic benchmark