Replies: 2 comments 5 replies
-
Then we would need to check for every logged SQL whether the |
Beta Was this translation helpful? Give feedback.
-
For rodauth-rails, I've decided to generate Sequel initialization directly inside the Rodauth configuration, which is autoloaded and thus isn't automatically loaded when the Rails app boots (unlike initializers). I set class RodauthMain < Rodauth::Auth
configure do
# ...
db Sequel.postgres(extensions: [:activerecord_connection, :sql_log_normalizer], keep_reference: false)
# ...
end
end For other use cases where it would make sense to create a database object in an initializer, I will probably recommend something like: DB = Sequel.postgres(extensions: :activerecord_connection)
begin
DB.extension :sql_log_normalizer
rescue ActiveRecord::NoDatabaseError
end The |
Beta Was this translation helpful? Give feedback.
-
When using the sequel-activerecord_connection extension in an Active Record app, I'm recommending people to use the
sql_log_normalizer
extension if they want Sequel's SQL logs to be normalized like Active Record's.I'm recommending initializing a Sequel database object in an initializer, and the
activerecord_connection
extension prevents the connection to be checked out (by settingdb.opts[:test]
tofalse
), because the Rails apps needs to remain bootable without a database connection in order for rake tasks such asdb:create
anddb:drop
to work.However, the
sql_log_normalizer
connection callsSequel::Database#literal
as soon as it's loaded, which checks out a connection and thus errors when the database doesn't exist. Would it be possible to somehow delay setting the SQL string escape type to when the connection would naturally be checked out?Beta Was this translation helpful? Give feedback.
All reactions