diff --git a/Appraisals b/Appraisals index d186324..21f9d75 100644 --- a/Appraisals +++ b/Appraisals @@ -1,5 +1,6 @@ appraise "activerecord-6.0" do gem "activerecord", "~> 6.0.0" + gem "activerecord-trilogy-adapter", "~> 3.0.0" gem "mysql2", "~> 0.4.10" gem "pg", ">= 0.18", "< 2.0" gem "sqlite3", "~> 1.4.0" @@ -7,6 +8,7 @@ end appraise "activerecord-6.1" do gem "activerecord", "~> 6.1.0" + gem "activerecord-trilogy-adapter", "~> 3.0.0" gem "mysql2", "~> 0.5" gem "pg", ">= 0.18", "< 2.0" gem "sqlite3", "~> 1.4.0" @@ -14,6 +16,7 @@ end appraise "activerecord-7.0" do gem "activerecord", "~> 7.0.0" + gem "activerecord-trilogy-adapter", "~> 3.0.0" gem "mysql2", "~> 0.5" gem "pg", ">= 0.18", "< 2.0" gem "sqlite3", "~> 1.4.0" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1acc64b..b258884 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## 1.0.x +## 1.1.x + +## 1.1.0 + +- Add support for trilogy adapter ([PR 115](https://github.com/jenseng/hair_trigger/pulls) ### 1.0.0 diff --git a/gemfiles/activerecord_6.0.gemfile b/gemfiles/activerecord_6.0.gemfile index 4064fd5..b925be9 100644 --- a/gemfiles/activerecord_6.0.gemfile +++ b/gemfiles/activerecord_6.0.gemfile @@ -3,6 +3,7 @@ source "https://rubygems.org" gem "activerecord", "~> 6.0.0" +gem "activerecord-trilogy-adapter" gem "mysql2", "~> 0.4.10" gem "pg", ">= 0.18", "< 2.0" gem "sqlite3", "~> 1.4.0" diff --git a/gemfiles/activerecord_6.1.gemfile b/gemfiles/activerecord_6.1.gemfile index a31243f..b6fa822 100644 --- a/gemfiles/activerecord_6.1.gemfile +++ b/gemfiles/activerecord_6.1.gemfile @@ -3,6 +3,7 @@ source "https://rubygems.org" gem "activerecord", "~> 6.1.0" +gem "activerecord-trilogy-adapter" gem "mysql2", "~> 0.5" gem "pg", ">= 0.18", "< 2.0" gem "sqlite3", "~> 1.4.0" diff --git a/gemfiles/activerecord_7.0.gemfile b/gemfiles/activerecord_7.0.gemfile index 921e018..5a31a32 100644 --- a/gemfiles/activerecord_7.0.gemfile +++ b/gemfiles/activerecord_7.0.gemfile @@ -3,6 +3,7 @@ source "https://rubygems.org" gem "activerecord", "~> 7.0.0" +gem "activerecord-trilogy-adapter", "~> 3.0.0" gem "mysql2", "~> 0.5" gem "pg", ">= 0.18", "< 2.0" gem "sqlite3", "~> 1.4.0" diff --git a/lib/hair_trigger/adapter.rb b/lib/hair_trigger/adapter.rb index 77619fc..1b9e594 100644 --- a/lib/hair_trigger/adapter.rb +++ b/lib/hair_trigger/adapter.rb @@ -31,7 +31,7 @@ def triggers(options = {}) select_rows("SELECT name, sql FROM sqlite_master WHERE type = 'trigger' #{name_clause ? " AND name " + name_clause : ""}").each do |(name, definition)| triggers[name] = quote_table_name_in_trigger(definition) + ";\n" end - when :mysql + when :mysql, :trilogy select_rows("SHOW TRIGGERS").each do |(name, event, table, actions, timing, created, sql_mode, definer)| definer = normalize_mysql_definer(definer) next if options[:only] && !options[:only].include?(name) diff --git a/lib/hair_trigger/builder.rb b/lib/hair_trigger/builder.rb index 9e4f52a..c8bbe64 100644 --- a/lib/hair_trigger/builder.rb +++ b/lib/hair_trigger/builder.rb @@ -162,7 +162,7 @@ def set_#{method}(*args, &block) chainable_methods :name, :on, :for_each, :before, :after, :where, :security, :timing, :events, :all, :nowrap, :of, :declare def create_grouped_trigger? - adapter_name == :mysql + adapter_name == :mysql || adapter_name == :trilogy end def prepare! @@ -224,7 +224,7 @@ def generate(validate = true) [case adapter_name when :sqlite generate_trigger_sqlite - when :mysql + when :mysql, :trilogy generate_trigger_mysql when :postgresql, :postgis generate_trigger_postgresql @@ -407,7 +407,7 @@ def supports_of? def generate_drop_trigger case adapter_name - when :sqlite, :mysql + when :sqlite, :mysql, :trilogy "DROP TRIGGER IF EXISTS #{prepared_name};\n" when :postgresql, :postgis "DROP TRIGGER IF EXISTS #{prepared_name} ON #{adapter.quote_table_name(options[:table])};\nDROP FUNCTION IF EXISTS #{adapter.quote_table_name(prepared_name)}();\n" diff --git a/spec/adapter_spec.rb b/spec/adapter_spec.rb index 18fd4d2..b4c2db6 100644 --- a/spec/adapter_spec.rb +++ b/spec/adapter_spec.rb @@ -55,6 +55,11 @@ it_behaves_like "mysql" end if ADAPTERS.include? :mysql2 + context "trilogy" do + let(:adapter) { :trilogy } + it_behaves_like "mysql" + end if ADAPTERS.include? :trilogy + context "postgresql" do let(:adapter) { :postgresql }