You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The create_function() support exists, and was added in order to implement the REGEX() callback function. It would be very useful to have a documented Crystal interface to sqlite3_create_function_v2() that could be used similar to this:
@db.create_function returning: Int32.class do |param1, param2|
# ... do something, returning an Int32
end
Syntax to support returning an array, handling aggregate functions, and handling window functions would be (hopefully) similar.
In addition, for my uses, it doesn't need to be exposed through DB; this is obviously for use cases that are very specific to SQLite and not portable, so having a different interface than Database::DB would be perfectly acceptable, though obviously a lot of the functionality would have to be duplicated.
The text was updated successfully, but these errors were encountered:
db =DB.open(DB_URL)
db.setup_connection do |connection|
connection = connection.as(SQLite3::Connection)
# .. use custom method of SQLite3::Connection
connection.create_fun ...
end
I think the sqlite3_create_function_v2 would require a proc with fixed arguments, similar to REGEXP_FN.
On top of that, for convenience, there could be a macro that translate a proc with crystal arguments to the variadic argc/argv as REGEXP_FN. But you won't be able to have a proc like the one to propose since the param1 & param2 are not typed and there would be no clue on how to translate it to the variadic one.
So, the story can be divided in two. Getting binding to sqlite3_create_function_v2 and some example/spec for it seems reasonable. Having a macro for the translation might require a bit more advance crystal stuff and it can be done initially per project basis until it's battle tested enough I think.
The
create_function()
support exists, and was added in order to implement the REGEX() callback function. It would be very useful to have a documented Crystal interface tosqlite3_create_function_v2()
that could be used similar to this:Syntax to support returning an array, handling aggregate functions, and handling window functions would be (hopefully) similar.
In addition, for my uses, it doesn't need to be exposed through DB; this is obviously for use cases that are very specific to SQLite and not portable, so having a different interface than
Database::DB
would be perfectly acceptable, though obviously a lot of the functionality would have to be duplicated.The text was updated successfully, but these errors were encountered: