refinery icon indicating copy to clipboard operation
refinery copied to clipboard

Missing math functions for SQLite

Open Pamplemousse opened this issue 3 months ago • 3 comments

One of my migration file that uses the SQLite function FLOOR fails to be applied by refinery, with the following error:

$ refinery migrate -c ./refinery.toml -p ./data/migrations/
current version: 1
applying migration: V2__update_spendings
Error: `error applying migration V2__update_spendings`, `no such function: FLOOR in 

[...]
  CAST(FLOOR(price) as INT),
[...]

Caused by:
    0: no such function: FLOOR in 
       
[...]
         CAST(FLOOR(price) as INT),
[...]
        at offset 103
    1: Error code 1: SQL error or missing database

The function is listed here https://www.sqlite.org/lang_mathfunc.html, which specifies that the -SQLITE_ENABLE_MATH_FUNCTIONS compilation option needs to be applied when building the library.

I suspect that the issue probably comes from a dependency, particularly rusqlite, and could be fixed by adding

[env]
LIBSQLITE3_FLAGS = { value = "-DSQLITE_ENABLE_MATH_FUNCTIONS", force=true }

in a .cargo/config.toml as proposed in https://github.com/rusqlite/rusqlite/issues/1211#issuecomment-1656027096 .


$ refinery --version
refinery_cli 0.8.10

Pamplemousse avatar May 20 '24 10:05 Pamplemousse