The query SELECT COALESCE(username, '') FROM radcheck was causing the exception below:
Unhandled exception: not supported read (Exception)
from lib/mysql/src/mysql/types.cr:86:5 in 'read'
from lib/mysql/src/mysql/result_set.cr:85:10 in 'read'
from lib/db/src/db/result_set.cr:79:15 in 'read'
from src/user_radius.cr:37:8 in 'read'
from src/user.cr:32:11 in 'read'
from src/command_auth_copy.cr:9:13 in 'run'
from src/crystalville.cr:48:3 in '__crystal_main'
from /snap/crystal/600/share/crystal/src/crystal/main.cr:110:5 in 'main_user_code'
from /snap/crystal/600/share/crystal/src/crystal/main.cr:96:7 in 'main'
from /snap/crystal/600/share/crystal/src/crystal/main.cr:119:3 in 'main'
from __libc_start_main
from _start
from ???
The same query without COALESCE worked: SELECT username FROM radcheck.
Copying the block in types.cr decl_type Blob to the decl_type MediumBlob made it work:
decl_type MediumBlob, 0xfau8, ::Bytes do
def self.write(packet, v : ::Bytes)
packet.write_blob v
end
def self.write(packet, v : ::StaticArray(T, N)) forall T, N
packet.write_blob v.to_slice
end
def self.read(packet)
packet.read_blob
end
def self.parse(str : ::String)
str.to_slice
end
end
The query
SELECT COALESCE(username, '') FROM radcheck
was causing the exception below:The same query without COALESCE worked:
SELECT username FROM radcheck
.Copying the block in types.cr
decl_type Blob
to thedecl_type MediumBlob
made it work:Versions:
I'm new to Crystal and don't know anything about the MySQL protocol, but why only type
Blob
has that block?