MechanicalRabbit / FunSQL.jl

Julia library for compositional construction of SQL queries
https://mechanicalrabbit.github.io/FunSQL.jl
Other
144 stars 5 forks source link

Support for databases without parametrized queries #45

Open aplavin opened 7 months ago

aplavin commented 7 months ago

I wonder if it would be possible for FunSQL to support databases/engines that can execute SQL queries specified as regular strings, but don't have query parameter support. A specific example that I played with and it didn't work is so-called "Virtual Observatory Table Access Protocol" (https://www.ivoa.net/documents/TAP/). There's my VirtualObservatory.jl package that implements DBInterface for such databases.

This is what I tried:

using VirtualObservatory
using FunSQL

conn = TAPService(:simbad)

# queries work same as elsewhere in dbinterface
execute(conn, "select top 10 * from basic")

# not 100% correct, just put something here for now
FunSQL.SQLDialect(::Type{TAPService}) = FunSQL.SQLDialect(:sqlite)

catalog = FunSQL.reflect(conn)

but it throws MethodError: no method matching prepare(::VirtualObservatory.TAPService, ::String). Of course, prepare could be trivially implemented as a no-op, but I see that the next line in reflect (https://github.com/MechanicalRabbit/FunSQL.jl/blob/master/src/reflect.jl#L90) executes the prepared query together with some parameter values. This part isn't natively supported by TAP.

Would be nice to be able to use FunSQL here!