Skip to content

Commit 7a520bb

Browse files
committed
Avoid shape-related performance warning for Sequel::SQL::StringAgg
Making the order the same helps. This does define an unnecessary instance variable, but it makes the order consistent. This keeps the object to 2 shapes (one without @order_expr and @distinct, and one with both).
1 parent 0242c40 commit 7a520bb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/sequel/extensions/string_agg.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,16 @@ def is_distinct?
173173
# Return a modified StringAgg that uses distinct expressions
174174
def distinct
175175
self.class.new(@expr, @separator) do |sa|
176-
sa.instance_variable_set(:@order_expr, @order_expr) if @order_expr
176+
sa.instance_variable_set(:@order_expr, @order_expr)
177177
sa.instance_variable_set(:@distinct, true)
178178
end
179179
end
180180

181181
# Return a modified StringAgg with the given order
182182
def order(*o)
183183
self.class.new(@expr, @separator) do |sa|
184-
sa.instance_variable_set(:@distinct, @distinct) if @distinct
185184
sa.instance_variable_set(:@order_expr, o.empty? ? nil : o.freeze)
185+
sa.instance_variable_set(:@distinct, @distinct)
186186
end
187187
end
188188

0 commit comments

Comments
 (0)