Methods
Public Instance
Constants
CAST_TYPES | = | {String=>:CStr, Integer=>:CLng, Date=>:CDate, Time=>:CDate, DateTime=>:CDate, Numeric=>:CDec, BigDecimal=>:CDec, File=>:CStr, Float=>:CDbl, TrueClass=>:CBool, FalseClass=>:CBool}.freeze | ||
EXTRACT_MAP | = | {:year=>"'yyyy'", :month=>"'m'", :day=>"'d'", :hour=>"'h'", :minute=>"'n'", :second=>"'s'"}.freeze | ||
OPS | = | {:'%'=>' Mod '.freeze, :'||'=>' & '.freeze}.freeze |
Public Instance methods
Access
doesn’t support CASE, so emulate it with nested IIF function calls.
# File lib/sequel/adapters/shared/access.rb 103 def case_expression_sql_append(sql, ce) 104 literal_append(sql, ce.with_merged_expression.conditions.reverse.inject(ce.default){|exp,(cond,val)| Sequel::SQL::Function.new(:IIF, cond, val, exp)}) 105 end
Access
doesn’t support CAST, it uses separate functions for type conversion
# File lib/sequel/adapters/shared/access.rb 109 def cast_sql_append(sql, expr, type) 110 sql << CAST_TYPES.fetch(type, type).to_s 111 sql << '(' 112 literal_append(sql, expr) 113 sql << ')' 114 end
# File lib/sequel/adapters/shared/access.rb 116 def complex_expression_sql_append(sql, op, args) 117 case op 118 when :ILIKE 119 complex_expression_sql_append(sql, :LIKE, args) 120 when :'NOT ILIKE' 121 complex_expression_sql_append(sql, :'NOT LIKE', args) 122 when :'!=' 123 sql << '(' 124 literal_append(sql, args[0]) 125 sql << ' <> ' 126 literal_append(sql, args[1]) 127 sql << ')' 128 when :'%', :'||' 129 sql << '(' 130 c = false 131 op_str = OPS[op] 132 args.each do |a| 133 sql << op_str if c 134 literal_append(sql, a) 135 c ||= true 136 end 137 sql << ')' 138 when :** 139 sql << '(' 140 literal_append(sql, args[0]) 141 sql << ' ^ ' 142 literal_append(sql, args[1]) 143 sql << ')' 144 when :extract 145 part = args[0] 146 raise(Sequel::Error, "unsupported extract argument: #{part.inspect}") unless format = EXTRACT_MAP[part] 147 sql << "datepart(" << format.to_s << ', ' 148 literal_append(sql, args[1]) 149 sql << ')' 150 else 151 super 152 end 153 end
Use Date(), Now(), and Time() for CURRENT_DATE, CURRENT_TIMESTAMP, and CURRENT_TIME
# File lib/sequel/adapters/shared/access.rb 156 def constant_sql_append(sql, constant) 157 case constant 158 when :CURRENT_DATE 159 sql << 'Date()' 160 when :CURRENT_TIMESTAMP 161 sql << 'Now()' 162 when :CURRENT_TIME 163 sql << 'Time()' 164 else 165 super 166 end 167 end
Emulate cross join by using multiple tables in the FROM clause.
# File lib/sequel/adapters/shared/access.rb 170 def cross_join(table) 171 clone(:from=>@opts[:from] + [table]) 172 end
Access
uses [] to escape metacharacters, instead of backslashes.
# File lib/sequel/adapters/shared/access.rb 175 def escape_like(string) 176 string.gsub(/[\\*#?\[]/){|m| "[#{m}]"} 177 end
Specify a table for a SELECT … INTO query.
# File lib/sequel/adapters/shared/access.rb 180 def into(table) 181 clone(:into => table) 182 end
Access
uses [] for quoting identifiers, and can’t handle ] inside identifiers.
# File lib/sequel/adapters/shared/access.rb 186 def quoted_identifier_append(sql, v) 187 sql << '[' << v.to_s << ']' 188 end
Access
does not support derived column lists.
# File lib/sequel/adapters/shared/access.rb 191 def supports_derived_column_lists? 192 false 193 end
Access
doesn’t support INTERSECT or EXCEPT
# File lib/sequel/adapters/shared/access.rb 196 def supports_intersect_except? 197 false 198 end
Access
does not support IS TRUE
# File lib/sequel/adapters/shared/access.rb 201 def supports_is_true? 202 false 203 end
Access
doesn’t support JOIN USING
# File lib/sequel/adapters/shared/access.rb 206 def supports_join_using? 207 false 208 end
Access
does not support multiple columns for the IN/NOT IN operators
# File lib/sequel/adapters/shared/access.rb 211 def supports_multiple_column_in? 212 false 213 end
Access
doesn’t support truncate, so do a delete instead.
# File lib/sequel/adapters/shared/access.rb 216 def truncate 217 delete 218 nil 219 end