# File lib/arel/select_manager.rb, line 46 46: def as other 47: create_table_alias grouping(@ast), Nodes::SqlLiteral.new(other) 48: end
# File lib/arel/select_manager.rb, line 22 22: def constraints 23: @ctx.wheres 24: end
# File lib/arel/select_manager.rb, line 142 142: def distinct(value = true) 143: if value 144: @ctx.set_quantifier = Arel::Nodes::Distinct.new 145: else 146: @ctx.set_quantifier = nil 147: end 148: end
# File lib/arel/select_manager.rb, line 189 189: def except other 190: Nodes::Except.new ast, other.ast 191: end
Produces an Arel::Nodes::Exists node
# File lib/arel/select_manager.rb, line 42 42: def exists 43: Arel::Nodes::Exists.new @ast 44: end
# File lib/arel/select_manager.rb, line 91 91: def from table 92: table = Nodes::SqlLiteral.new(table) if String === table 93: # FIXME: this is a hack to support 94: # test_with_two_tables_in_from_without_getting_double_quoted 95: # from the AR tests. 96: 97: case table 98: when Nodes::Join 99: @ctx.source.right << table 100: else 101: @ctx.source.left = table 102: end 103: 104: self 105: end
# File lib/arel/select_manager.rb, line 107 107: def froms 108: @ast.cores.map { |x| x.from }.compact 109: end
# File lib/arel/select_manager.rb, line 80 80: def group *columns 81: columns.each do |column| 82: # FIXME: backwards compat 83: column = Nodes::SqlLiteral.new(column) if String === column 84: column = Nodes::SqlLiteral.new(column.to_s) if Symbol === column 85: 86: @ctx.groups.push Nodes::Group.new column 87: end 88: self 89: end
# File lib/arel/select_manager.rb, line 124 124: def having *exprs 125: @ctx.having = Nodes::Having.new(collapse(exprs, @ctx.having)) 126: self 127: end
# File lib/arel/select_manager.rb, line 12 12: def initialize_copy other 13: super 14: @ctx = @ast.cores.last 15: end
FIXME: this method should go away
# File lib/arel/select_manager.rb, line 266 266: def insert values 267: if $VERBOSE 268: warn insert (#{caller.first}) is deprecated and will be removed in ARel 4.0.0. Pleaseswitch to `compile_insert` 269: end 270: 271: im = compile_insert(values) 272: table = @ctx.froms 273: 274: primary_key = table.primary_key 275: primary_key_name = primary_key.name if primary_key 276: 277: # FIXME: in AR tests values sometimes were Array and not Hash therefore is_a?(Hash) check is added 278: primary_key_value = primary_key && values.is_a?(Hash) && values[primary_key] 279: im.into table 280: # Oracle adapter needs primary key name to generate RETURNING ... INTO ... clause 281: # for tables which assign primary key value using trigger. 282: # RETURNING ... INTO ... clause will be added only if primary_key_value is nil 283: # therefore it is necessary to pass primary key value as well 284: @engine.connection.insert im.to_sql, 'AREL', primary_key_name, primary_key_value 285: end
# File lib/arel/select_manager.rb, line 185 185: def intersect other 186: Nodes::Intersect.new ast, other.ast 187: end
# File lib/arel/select_manager.rb, line 111 111: def join relation, klass = Nodes::InnerJoin 112: return self unless relation 113: 114: case relation 115: when String, Nodes::SqlLiteral 116: raise if relation.blank? 117: klass = Nodes::StringJoin 118: end 119: 120: @ctx.source.right << create_join(relation, nil, klass) 121: self 122: end
# File lib/arel/select_manager.rb, line 231 231: def join_sources 232: @ctx.source.right 233: end
# File lib/arel/select_manager.rb, line 217 217: def join_sql 218: return nil if @ctx.source.right.empty? 219: 220: sql = visitor.dup.extend(Visitors::JoinSql).accept @ctx 221: Nodes::SqlLiteral.new sql 222: end
# File lib/arel/select_manager.rb, line 239 239: def joins manager 240: if $VERBOSE 241: warn "joins is deprecated and will be removed in 4.0.0" 242: warn "please remove your call to joins from #{caller.first}" 243: end 244: manager.join_sql 245: end
# File lib/arel/select_manager.rb, line 17 17: def limit 18: @ast.limit && @ast.limit.expr 19: end
# File lib/arel/select_manager.rb, line 58 58: def lock locking = Arel.sql('FOR UPDATE') 59: case locking 60: when true 61: locking = Arel.sql('FOR UPDATE') 62: when Arel::Nodes::SqlLiteral 63: when String 64: locking = Arel.sql locking 65: end 66: 67: @ast.lock = Nodes::Lock.new(locking) 68: self 69: end
# File lib/arel/select_manager.rb, line 71 71: def locked 72: @ast.lock 73: end
# File lib/arel/select_manager.rb, line 26 26: def offset 27: @ast.offset && @ast.offset.expr 28: end
# File lib/arel/select_manager.rb, line 75 75: def on *exprs 76: @ctx.source.right.last.right = Nodes::On.new(collapse(exprs)) 77: self 78: end
# File lib/arel/select_manager.rb, line 150 150: def order *expr 151: # FIXME: We SHOULD NOT be converting these to SqlLiteral automatically 152: @ast.orders.concat expr.map { |x| 153: String === x || Symbol === x ? Nodes::SqlLiteral.new(x.to_s) : x 154: } 155: self 156: end
# File lib/arel/select_manager.rb, line 224 224: def order_clauses 225: visitor = Visitors::OrderClauses.new(@engine.connection) 226: visitor.accept(@ast).map { |x| 227: Nodes::SqlLiteral.new x 228: } 229: end
# File lib/arel/select_manager.rb, line 158 158: def orders 159: @ast.orders 160: end
# File lib/arel/select_manager.rb, line 129 129: def project *projections 130: # FIXME: converting these to SQLLiterals is probably not good, but 131: # rails tests require it. 132: @ctx.projections.concat projections.map { |x| 133: [Symbol, String].include?(x.class) ? SqlLiteral.new(x.to_s) : x 134: } 135: self 136: end
# File lib/arel/select_manager.rb, line 138 138: def projections= projections 139: @ctx.projections = projections 140: end
# File lib/arel/select_manager.rb, line 30 30: def skip amount 31: if amount 32: @ast.offset = Nodes::Offset.new(amount) 33: else 34: @ast.offset = nil 35: end 36: self 37: end
# File lib/arel/select_manager.rb, line 235 235: def source 236: @ctx.source 237: end
# File lib/arel/select_manager.rb, line 205 205: def take limit 206: if limit 207: @ast.limit = Nodes::Limit.new(limit) 208: @ctx.top = Nodes::Top.new(limit) 209: else 210: @ast.limit = nil 211: @ctx.top = nil 212: end 213: self 214: end
# File lib/arel/select_manager.rb, line 174 174: def union operation, other = nil 175: if other 176: node_class = Nodes.const_get("Union#{operation.to_s.capitalize}") 177: else 178: other = operation 179: node_class = Nodes::Union 180: end 181: 182: node_class.new self.ast, other.ast 183: end
# File lib/arel/select_manager.rb, line 50 50: def where_clauses 51: if $VERBOSE 52: warn "(#{caller.first}) where_clauses is deprecated and will be removed in arel 4.0.0 with no replacement" 53: end 54: to_sql = Visitors::ToSql.new @engine.connection 55: @ctx.wheres.map { |c| to_sql.accept c } 56: end
# File lib/arel/select_manager.rb, line 167 167: def where_sql 168: return if @ctx.wheres.empty? 169: 170: viz = Visitors::WhereSql.new @engine.connection 171: Nodes::SqlLiteral.new viz.accept @ctx 172: end
# File lib/arel/select_manager.rb, line 162 162: def wheres 163: warn "#{caller[0]}: SelectManager#wheres is deprecated and will be removed in ARel 4.0.0 with no replacement" 164: Compatibility::Wheres.new @engine.connection, @ctx.wheres 165: end
# File lib/arel/select_manager.rb, line 194 194: def with *subqueries 195: if subqueries.first.is_a? Symbol 196: node_class = Nodes.const_get("With#{subqueries.shift.to_s.capitalize}") 197: else 198: node_class = Nodes::With 199: end 200: @ast.with = node_class.new(subqueries.flatten) 201: 202: self 203: end
# File lib/arel/select_manager.rb, line 291 291: def collapse exprs, existing = nil 292: exprs = exprs.unshift(existing.expr) if existing 293: exprs = exprs.compact.map { |expr| 294: if String === expr 295: # FIXME: Don't do this automatically 296: Arel.sql(expr) 297: else 298: expr 299: end 300: } 301: 302: if exprs.length == 1 303: exprs.first 304: else 305: create_and exprs 306: end 307: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.