Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add string concatenation support. #173

Closed
wants to merge 1 commit into from

2 participants

@whitequark

This PR adds an infix operator ||. I didn't find any tests for specific
infix operators, so I didn't write any.

@ernie
Collaborator

@whitequark This is db-specific -- better to use the existing support for infix operations.

@whitequark

@ernie Could you elaborate? I believe the || operator is SQL-92, 4.2.2.1.

@ernie
Collaborator

@whitequark it's SQL-92 but not supported by all db engines (read, LOL MYSQL)

@ernie
Collaborator

In any case, since ARel already supports all manner of infix operations without this patch, I'm not sure I see the point in adding a specific implementation for concat.

@whitequark

@ernie I see. Am I correct that you are suggesting to manually create the relevant nodes, and are opposed to the shortcut (like for arithmetic operations) because || is not supported by MySQL?

@ernie
Collaborator

@whitequark Partly. Also because I'm not really sure concatenation is in the same category as the stuff in Arel::Math.

@whitequark

@ernie Well I guess that counts as a reason. Feel free to close the PR or delegate it to an arel maintainer (not sure if you are one)

@ernie
Collaborator

Sorry :(

@ernie ernie closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 14, 2013
  1. @whitequark
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 1 deletion.
  1. +5 −0 lib/arel/expression.rb
  2. +7 −1 lib/arel/nodes/infix_operation.rb
View
5 lib/arel/expression.rb
@@ -1,5 +1,10 @@
module Arel
module Expression
include Arel::OrderPredications
+
+ def concat other
+ Nodes::Concatenation.new self, other
+ end
+
end
end
View
8 lib/arel/nodes/infix_operation.rb
@@ -40,5 +40,11 @@ def initialize left, right
end
end
+ class Concatenation < InfixOperation
+ def initialize left, right
+ super(:"||", left, right)
+ end
+ end
+
end
-end
+end
Something went wrong with that request. Please try again.