Skip to content

Commit

Permalink
remove some duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
funny-falcon committed Jun 3, 2012
1 parent 1ad91b9 commit cd30e1c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/ar_pg_array/schema.rb
Expand Up @@ -218,13 +218,9 @@ def prepare_pg_string_array(value, base_type, column=nil)
"{#{ value.join(',')}}"
end

class CNULL; def inspect; 'NULL'; end; alias to_s inspect end
NULL = CNULL.new

TESCAPE_HASH={'\\'=>'\\\\', '"'=>'\\"'}
def prepare_pg_text_array(value)
value = value.map{|v|
v ? "\"#{v.to_s.gsub(/\\|"/){|s| TESCAPE_HASH[s]}}\"" : NULL
v ? "\"#{v.to_s.gsub(/\\|"/){|s| ESCAPE_HASH[s]}}\"" : 'NULL'
}.join(',')
"{#{value}}"
end
Expand Down

0 comments on commit cd30e1c

Please sign in to comment.