go-sqlite3
go-sqlite3 copied to clipboard
Trying to use maths function (from SQLite v3.35) does not work
Since this PR the underlying version of SQLite should be >=3.35 (and it is). The PR even mentions the new maths function added.
However, when I try to use math functions (like SELECT power(2,2)
) I get this error no such function: power
.
Is there something more I need to do than use the latest version of the go-sqlite3 library?
As per the SQLite docs, in order to leverage the built-in math functions, you must compile with -DSQLITE_ENABLE_MATH_FUNCTIONS
https://www.sqlite.org/lang_mathfunc.html
However, currently there is no way to include that option with this library. Please add a build tag for it, as was done for -DSQLITE_DEFAULT_FOREIGN_KEYS
. https://github.com/mattn/go-sqlite3/blob/master/sqlite3_opt_foreign_keys.go
You'll also want to add an entry to the table in the README. https://github.com/mattn/go-sqlite3#feature--extension-list
I didn't understand: is it possible to use pow and sqrt or not? If not, when will it be fixed? I spent a couple of days trying to figure out why sqllite works differently in different applications!
is it possible to use pow and sqrt or not?
It is not currently possible to use the built-in math functions, because to do so requires the -DSQLITE_ENABLE_MATH_FUNCTIONS
flag to be passed to the C library at compile-time.
If not, when will it be fixed?
You need to raise a PR with the aforementioned changes.
Hi, I came across this issue when trying to use SQRT function in an application. I added the changes @rittneje mentioned and create a PR, I hope it is correctly implemented. At least on my local test system I can successfully use the scalar math functions afterwards