Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added generic support for all adapters to support the import function…
…ality. All tests pass with Mysql and PostgreSQL support. PostgreSQL support for the import functionality works, but it relies on single INSERT statement creation. By adding single INSERT statement creation and making it compatible with import all adapters should work flawlessly. All tests pass right now. git-svn-id: svn+ssh://rubyforge.org/var/svn/arext/trunk@41 5128a5ed-121c-0410-8d5c-98af306bc9be
- Loading branch information
zachdennis
committed
Dec 6, 2006
1 parent
b4fff3a
commit 141e872
Showing
12 changed files
with
206 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class ActiveRecord::Extensions::FullTextSearching::MySQLFullTextExtension < ActiveRecord::Extensions::AbstractExtension | ||
extend Forwardable | ||
|
||
class << self | ||
extend Forwardable | ||
|
||
def register( fulltext_key, options ) | ||
@fulltext_registry ||= ActiveRecord::Extensions::Registry.new | ||
@fulltext_registry.register( fulltext_key, options ) | ||
end | ||
|
||
def registry | ||
@fulltext_registry | ||
end | ||
|
||
def_delegator :@fulltext_registry, :registers?, :registers? | ||
end | ||
|
||
RGX = /^match_(.+)/ | ||
|
||
def process( key, val, caller ) | ||
match_data = key.to_s.match( RGX ) | ||
return nil unless match_data | ||
fulltext_identifier = match_data.captures[0].to_sym | ||
if self.class.registers?( fulltext_identifier ) | ||
fields = self.class.registry[fulltext_identifier][:fields] | ||
str = "MATCH ( #{fields.join( ',' )} ) AGAINST (#{caller.connection.quote(val)})" | ||
return ActiveRecord::Extensions::Result.new( str, nil ) | ||
end | ||
nil | ||
end | ||
|
||
def_delegator 'ActiveRecord::Extensions::FullTextSupport::MySQLFullTextExtension', :register | ||
end | ||
ActiveRecord::Extensions.register ActiveRecord::Extensions::FullTextSearching::MySQLFullTextExtension.new, :adapters=>[:mysql] | ||
|
||
|
||
class ActiveRecord::ConnectionAdapters::MysqlAdapter | ||
include ActiveRecord::Extensions::FullTextSearching::FullTextSupport | ||
|
||
def register_fulltext_extension( fulltext_key, options ) | ||
ActiveRecord::Extensions::FullTextSearching::MySQLFullTextExtension.register( fulltext_key, options ) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.