I would like to use a SQL function when inserting a new value into a dataset. However, I keep getting TypeError: can't convert Sequel::SQL::Function into String
errors. The Sequel docs explain how to select using functions, but not insert.
Ideally I would like to avoid DB.run
since I am inserting dynamically and raw SQL is messy and inflexible.
This is what I'm trying to do:
INSERT INTO dataset (col1, col2, col3) VALUES ('something', 3, func(value))
This is what I have in Sequel:
x = 'something'
y = 3
func_value = Sequel.function(:func, value)
DB[:dataset].insert (:col1 => x, :col2 => y, :col3 => func_value)
Is this possible? If so, what am I missing?