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

Fix count with eager_load #9

Merged
merged 3 commits into from Mar 15, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion activerecord-mysql-index-hint.gemspec
Expand Up @@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake'
spec.add_development_dependency 'appraisal'
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'mysql2', '= 0.4.1'
spec.add_development_dependency 'mysql2', '>= 0.3.18', '< 0.5'
end
2 changes: 1 addition & 1 deletion lib/activerecord-mysql-index-hint.rb
Expand Up @@ -17,7 +17,7 @@ def ignore_index(*args)
def from_with_index_hint(hint_type, *args)
return self if args.blank?
indexes = args.map {|index| connection.quote_column_name index }
self.from("#{quoted_table_name} #{hint_type} INDEX(#{indexes.join(', ')})")
self.from([Arel.sql("#{quoted_table_name} #{hint_type} INDEX(#{indexes.join(', ')})")])
end
end

Expand Down
35 changes: 22 additions & 13 deletions spec/activerecord-mysql-index-hint_spec.rb
@@ -1,21 +1,30 @@
require 'active_record'
require 'mysql2'
require 'active_record/connection_adapters/mysql2_adapter'
require 'activerecord-mysql-index-hint'

#module Mysql2
# class Client
# def initialize(opts={})
# @query_options = @@default_query_options.dup.merge opts
# end
# end
#end

ActiveRecord::ConnectionAdapters::Mysql2Adapter.class_eval do
def quote_string(string)
string
module ActiveRecord
module ConnectionHandling
prepend Module.new {
def mysql2_connection(config)
ConnectionAdapters::Mysql2Adapter.new(nil, logger, nil, config)
end
}
end
def configure_connection

module ConnectionAdapters
class Mysql2Adapter
prepend Module.new {
def quote_string(string)
string
end

def reconnect!
end

def configure_connection
end
}
end
end
end

Expand Down