The constant_sql_override extension allows you to change the SQL generated for Sequel
constants.
One possible use-case for this is to have Sequel::CURRENT_TIMESTAMP use UTC time when you have Sequel.database_timezone = :utc, but the database uses localtime when generating CURRENT_TIMESTAMP.
You can set SQL overrides with Database#set_constant_sql:
DB.set_constant_sql(Sequel::CURRENT_TIMESTAMP, "CURRENT_TIMESTAMP AT TIME ZONE 'UTC'")
Now, using Sequel::CURRENT_TIMESTAMP will use your override instead:
Album.where(released_at: Sequel::CURRENT_TIMESTAMP).sql # => SELECT "albums.*" FROM "albums" WHERE ("released_at" = CURRENT_TIMESTAMP AT TIME ZONE 'UTC')
To use this extension, first load it into your Sequel::Database
instance:
DB.extension :constant_sql_override
Related module: Sequel::ConstantSqlOverride