Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for mysql2rgeo DB adapter #121

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/hair_trigger/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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, :trilogy
when :mysql, :trilogy, :mysql2rgeo
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)
Expand Down
6 changes: 3 additions & 3 deletions lib/hair_trigger/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 == :trilogy
adapter_name == :mysql || adapter_name == :trilogy || adapter_name == :mysql2rgeo
end

def prepare!
Expand Down Expand Up @@ -224,7 +224,7 @@ def generate(validate = true)
[case adapter_name
when :sqlite
generate_trigger_sqlite
when :mysql, :trilogy
when :mysql, :trilogy, :mysql2rgeo
generate_trigger_mysql
when :postgresql, :postgis
generate_trigger_postgresql
Expand Down Expand Up @@ -407,7 +407,7 @@ def supports_of?

def generate_drop_trigger
case adapter_name
when :sqlite, :mysql, :trilogy
when :sqlite, :mysql, :trilogy, :mysql2rgeo
"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"
Expand Down
5 changes: 5 additions & 0 deletions spec/adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
it_behaves_like "mysql"
end if ADAPTERS.include? :trilogy

context "mysql2rgeo" do
let(:adapter) { :mysql2rgeo }
it_behaves_like "mysql"
end if ADAPTERS.include? :mysql2rgeo

context "postgresql" do
let(:adapter) { :postgresql }

Expand Down