MySQL dialect descendant of BasicJoin class
Class contructor. Takes a caller object as the first argument, JOIN type as the second argument, and a list of sources for the JOIN clause
# File lib/dialects/mysql-constructor.rb, line 192 def initialize ( _caller, type, *sources ) type = type.to_s if ! VALID_JOINS.include? type raise NoMethodError, ERR_UNKNOWN_METHOD + ": " + type end super end
Adds a USE/FORCE/IGNORE INDEX clause for the last objects in for_vals argument.
# File lib/dialects/mysql-constructor.rb, line 204 def _addIndexes ( type, *list ) type = type.to_s type.upcase!.gsub! /_/, ' ' @attr_index_hints ||= [ ] # set the attr_index_hints for the last object in for_vals last_ind = @join_sources.length - 1 @attr_index_hints[last_ind] = { :type => type, :list => SQLObject.get( list ) } @string = nil return self end
Handles INDEX hints or sends the call to the parent
# File lib/dialects/mysql-constructor.rb, line 229 def method_missing ( method, *args ) # Handle all valid *_index/*_key calls: return _addIndexes( method, *args ) if VALID_INDEX_HINTS.include? method super end
Export to string with index hints included
# File lib/dialects/mysql-constructor.rb, line 218 def to_s return @string if @string result = @type + " " + to_sWithAliasesIndexes( @join_sources ) result += @exporter.separator result += "ON " + @join_on.val.to_s if @join_on @string = result end
Returns a string of objects in list merged with @attr_index_hints
# File lib/dialects/mysql-constructor.rb, line 242 def to_sWithAliasesIndexes ( list ) list = [ list ] if ! [ Array, SQLValList, SQLAliasedList ].include? list.class arr = [ ] list.each_with_index do |item,i| _alias = item.alias ? " " + item.alias.to_s : "" str = item.to_s + _alias if @attr_index_hints index_hash = @attr_index_hints[i] str += " " + index_hash[:type] + " " + index_hash[:list].to_s end arr << str end return arr.join ',' end
Generated with the Darkfish Rdoc Generator 2.