File tree Expand file tree Collapse file tree 2 files changed +27
-27
lines changed
activerecord/lib/active_record/connection_adapters/postgresql Expand file tree Collapse file tree 2 files changed +27
-27
lines changed Original file line number Diff line number Diff line change @@ -9,35 +9,23 @@ module ArrayParser
9
9
BRACKET_OPEN = '{'
10
10
BRACKET_CLOSE = '}'
11
11
12
- private
13
- # Loads pg_array_parser if available. String parsing can be
14
- # performed quicker by a native extension, which will not create
15
- # a large amount of Ruby objects that will need to be garbage
16
- # collected. pg_array_parser has a C and Java extension
17
- begin
18
- require 'pg_array_parser'
19
- include PgArrayParser
20
- rescue LoadError
21
- def parse_pg_array ( string )
22
- parse_data ( string )
12
+ def parse_pg_array ( string )
13
+ local_index = 0
14
+ array = [ ]
15
+ while ( local_index < string . length )
16
+ case string [ local_index ]
17
+ when BRACKET_OPEN
18
+ local_index , array = parse_array_contents ( array , string , local_index + 1 )
19
+ when BRACKET_CLOSE
20
+ return array
23
21
end
22
+ local_index += 1
24
23
end
25
24
26
- def parse_data ( string )
27
- local_index = 0
28
- array = [ ]
29
- while ( local_index < string . length )
30
- case string [ local_index ]
31
- when BRACKET_OPEN
32
- local_index , array = parse_array_contents ( array , string , local_index + 1 )
33
- when BRACKET_CLOSE
34
- return array
35
- end
36
- local_index += 1
37
- end
25
+ array
26
+ end
38
27
39
- array
40
- end
28
+ private
41
29
42
30
def parse_array_contents ( array , string , index )
43
31
is_escaping = false
Original file line number Diff line number Diff line change @@ -29,8 +29,20 @@ def text?
29
29
30
30
# :stopdoc:
31
31
class << self
32
- include ConnectionAdapters ::PostgreSQLColumn ::Cast
33
- include ConnectionAdapters ::PostgreSQLColumn ::ArrayParser
32
+ include PostgreSQLColumn ::Cast
33
+
34
+ # Loads pg_array_parser if available. String parsing can be
35
+ # performed quicker by a native extension, which will not create
36
+ # a large amount of Ruby objects that will need to be garbage
37
+ # collected. pg_array_parser has a C and Java extension
38
+ begin
39
+ require 'pg_array_parser'
40
+ include PgArrayParser
41
+ rescue LoadError
42
+ require 'active_record/connection_adapters/postgresql/array_parser'
43
+ include PostgreSQLColumn ::ArrayParser
44
+ end
45
+
34
46
attr_accessor :money_precision
35
47
end
36
48
# :startdoc:
You can’t perform that action at this time.
0 commit comments