As described in #207, there is no support for when the config.active_record.table_name_prefix or config.active_record.table_name_suffix are defined. This PR fixes what's relevant to logidze.
What changes did you make? (overview)
I add the method full_table_name as suggested by @palkan in the issue #207.
Quoted all the references to table or triggers names, in order to safely handle prefixes or suffixes that include for instance a - (hyphen). I explore the idea of using the quote_table_name() method on the connection for it but was not sure what approach do you prefer? what I thought that maybe we can have something like:
def quote_db_object_name(object_name)
ActiveRecord::Base.connection.quote_table_name(object_name)
end
The idea of having a method like this, is so that we can pass for instance logidze_on_#{full_table_name} and not only table names. And also because this gem supports only PG not sure if make sense to have this in there.
On the Logidze::Model I tweak the method reload_log_data in order to prevent the raise of the ActiveRecord::Sanitization::ClassMethods#disallow_raw_sql!
Changes on the specs to properly match the " (quotes) on the object names
Is there anything you'd like reviewers to focus on?
It's important to have in mind that this changes did not addresses the issue with the naming of the fx functions or triggers. I open an issue over there in order to know if it's something that's in the scope of the gem
Also because there are multiline and onliners SQL sometimes we need a escaped quote and sometimes we don't not sure if you want to move everything to use the <<~SQL and in such the quotation can be more consistent.
Address the issue #207
What is the purpose of this pull request?
As described in #207, there is no support for when the
config.active_record.table_name_prefix
orconfig.active_record.table_name_suffix
are defined. This PR fixes what's relevant tologidze
.What changes did you make? (overview)
I add the method
full_table_name
as suggested by @palkan in the issue #207.Quoted all the references to table or triggers names, in order to safely handle prefixes or suffixes that include for instance a
-
(hyphen). I explore the idea of using thequote_table_name()
method on the connection for it but was not sure what approach do you prefer? what I thought that maybe we can have something like:The idea of having a method like this, is so that we can pass for instance
logidze_on_#{full_table_name}
and not only table names. And also because this gem supports only PG not sure if make sense to have this in there.On the
Logidze::Model
I tweak the methodreload_log_data
in order to prevent the raise of theActiveRecord::Sanitization::ClassMethods#disallow_raw_sql!
Changes on the specs to properly match the
"
(quotes) on the object namesIs there anything you'd like reviewers to focus on?
fx
functions or triggers. I open an issue over there in order to know if it's something that's in the scope of the gem<<~SQL
and in such the quotation can be more consistent.Checklist