Created
February 26, 2009 22:23
-
-
Save maxlapshin/71161 to your computer and use it in GitHub Desktop.
Sqlite group_concat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
module ConnectionAdapters | |
class SQLite3Adapter | |
def initialize(*args) | |
Rails.logger.debug "Adding group_concat to SQLite database" | |
super | |
raw_connection.create_aggregate("group_concat", 2) do | |
step do |func, value, separator| | |
if String(func[:concat]).empty? then | |
func[:concat] = String(value) | |
else | |
func[:concat] = String(func[:concat]) + "#{separator}" + String(value) | |
end | |
end | |
finalize do |func| | |
func.result = func[:concat] | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment