Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clash between independent registered functions #331

Closed
aplavin opened this issue Sep 2, 2023 · 0 comments · Fixed by #333
Closed

Clash between independent registered functions #331

aplavin opened this issue Sep 2, 2023 · 0 comments · Fixed by #333

Comments

@aplavin
Copy link
Contributor

aplavin commented Sep 2, 2023

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:

function $(nm)(

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant