Closed aplavin closed 1 year ago
Registering different UDF functions in different databases but with the same name doesn't work and silently gives a wrong result:
using SQLite using DBInterface: execute db_a = SQLite.DB(":memory:") db_b = SQLite.DB(":memory:") SQLite.register(db_a, x -> 2x, name="myfunc") SQLite.register(db_b, x -> 10x, name="myfunc") @show first(execute(db_a, """select myfunc(1) as x""")) # shows 10 (should be 2) @show first(execute(db_b, """select myfunc(1) as x""")) # shows 10 (as it should)
As I understand, it's due to this line: https://github.com/JuliaDatabases/SQLite.jl/blob/4b22cc449555bea223b7b5814840f03da671aee3/src/UDF.jl#L54
Definitions with the function keyword are global in Julia, and SQLite.jl defines function myfunc(x) in both cases above. Can this be an anonymous function instead? I think it would fix the bug.
function
function myfunc(x)
Registering different UDF functions in different databases but with the same name doesn't work and silently gives a wrong result:
As I understand, it's due to this line: https://github.com/JuliaDatabases/SQLite.jl/blob/4b22cc449555bea223b7b5814840f03da671aee3/src/UDF.jl#L54
Definitions with the
function
keyword are global in Julia, and SQLite.jl definesfunction myfunc(x)
in both cases above. Can this be an anonymous function instead? I think it would fix the bug.