Class: SQLConstructor::BasicSelect_mysql

Inherits:
BasicSelect show all
Defined in:
lib/dialects/mysql-constructor.rb

Overview

MySQL dialect descendant of BasicSelect class

Constant Summary collapse

METHODS =
{
  :straight_join => SQLConstructor::QAttr.new( :name => 'attr_straight_join', 
                                               :text => 'STRAIGHT_JOIN' ),
  :sql_cache => SQLConstructor::QAttr.new( :name => 'attr_sql_cache', :text => 'SQL_CACHE'),
  :sql_no_cache => SQLConstructor::QAttr.new( :name => 'attr_sql_cache', :text => 'SQL_NO_CACHE'),
  :high_priority => SQLConstructor::QAttr.new( :name => 'attr_high_priority',:text => 'HIGH_PRIORITY' ),
  :sql_calc_found_rows  => SQLConstructor::QAttr.new( :name => 'attr_sql_calc_found_rows', 
                                                      :text => 'SQL_CALC_FOUND_ROWS' ),
  :sql_small_result     => SQLConstructor::QAttr.new( :name => 'attr_sql_result_size', 
                                                      :text => 'SQL_SMALL_RESULT' ),
  :sql_big_result       => SQLConstructor::QAttr.new( :name => 'attr_sql_result_size', 
                                                      :text => 'SQL_BIG_RESULT' ),
  :sql_buffer_result    => SQLConstructor::QAttr.new( :name => 'attr_sql_result_size', 
                                                      :text => 'SQL_BUFFER_RESULT' ),
  :limit                => SQLConstructor::QAttr.new( :name => 'attr_limit', 
                                                      :text => 'LIMIT', :val => SQLObject ),
  :group_by_with_rollup => SQLConstructor::QAttr.new( :name => 'attr_group_by_with_rollup', 
                                                      :text => "WITH ROLLUP" ),
}

Instance Attribute Summary collapse

Attributes inherited from BasicSelect

#attr_distinction, #attr_expression, #attr_first, #attr_from, #attr_group_by, #attr_group_by_order, #attr_having, #attr_index_hints, #attr_joins, #attr_order_by, #attr_order_by_order, #attr_skip, #attr_unions, #attr_where

Attributes inherited from GenericQuery

#attr_index_hints, #caller, #child_caller, #dialect, #exporter, #string, #tidy, #type

Attributes inherited from SQLObject

#alias, #inline, #name, #separator

Instance Method Summary collapse

Methods inherited from BasicSelect

#select_more

Methods inherited from GenericQuery

#_get, #_remove, #to_s, #to_str

Methods inherited from SQLObject

#_name, #_string, #_string=, get, #to_s

Constructor Details

#initialize(_caller, *list) ⇒ BasicSelect_mysql

Class constructor.

_caller     - the caller object
*list       - list of sources for the FROM clause


38
39
40
# File 'lib/dialects/mysql-constructor.rb', line 38

def initialize ( _caller, *list )
    super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

Send missing methods calls to the @caller object, and also handle

JOINs, UNIONs and INDEX hints


46
47
48
49
50
51
52
# File 'lib/dialects/mysql-constructor.rb', line 46

def method_missing ( method, *args )
     # Handle all [*_]join calls:
    return _addJoin( method, *args )  if method.to_s =~ /^[a-z_]*join$/
      # Handle all valid *_index/*_key calls:
    return _addIndexes( method, *args )  if VALID_INDEX_HINTS.include? method 
    super
end

Instance Attribute Details

#attr_group_by_with_rollupObject (readonly)

Returns the value of attribute attr_group_by_with_rollup.



10
11
12
# File 'lib/dialects/mysql-constructor.rb', line 10

def attr_group_by_with_rollup
  @attr_group_by_with_rollup
end

#attr_high_priorityObject (readonly)

Returns the value of attribute attr_high_priority.



10
11
12
# File 'lib/dialects/mysql-constructor.rb', line 10

def attr_high_priority
  @attr_high_priority
end

#attr_limitObject (readonly)

Returns the value of attribute attr_limit.



10
11
12
# File 'lib/dialects/mysql-constructor.rb', line 10

def attr_limit
  @attr_limit
end

#attr_sql_cacheObject (readonly)

Returns the value of attribute attr_sql_cache.



10
11
12
# File 'lib/dialects/mysql-constructor.rb', line 10

def attr_sql_cache
  @attr_sql_cache
end

#attr_sql_calc_found_rowsObject (readonly)

Returns the value of attribute attr_sql_calc_found_rows.



10
11
12
# File 'lib/dialects/mysql-constructor.rb', line 10

def attr_sql_calc_found_rows
  @attr_sql_calc_found_rows
end

#attr_sql_result_sizeObject (readonly)

Returns the value of attribute attr_sql_result_size.



10
11
12
# File 'lib/dialects/mysql-constructor.rb', line 10

def attr_sql_result_size
  @attr_sql_result_size
end

#attr_straight_joinObject (readonly)

Returns the value of attribute attr_straight_join.



10
11
12
# File 'lib/dialects/mysql-constructor.rb', line 10

def attr_straight_join
  @attr_straight_join
end