Skip to content

Commit b1c10f8

Browse files
committed
Removes encoding patches from PostgreSQLAdapter
Depends on pg_array_parser to handle the encoding
1 parent b4a51b9 commit b1c10f8

File tree

3 files changed

+2
-29
lines changed

3 files changed

+2
-29
lines changed

Gemfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,3 @@ unless ENV['CI']
1010
end
1111
end
1212
gem 'fivemat'
13-
14-
group :test, :development do
15-
gem 'debugger'
16-
end

lib/postgres_ext/active_record/connection_adapters/postgres_adapter.rb

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ def string_to_array(value)
5959
value
6060
else
6161
string_array = parse_pg_array value
62-
if type == :string || type == :text
63-
force_character_encoding(string_array)
64-
else
65-
type_cast_array(string_array)
66-
end
62+
type_cast_array(string_array)
6763
end
6864
end
6965

@@ -178,12 +174,6 @@ def extract_range(value, &conversion)
178174

179175
private
180176

181-
def force_character_encoding(string_array)
182-
string_array.map do |item|
183-
item.respond_to?(:force_encoding) ? item.force_encoding(ActiveRecord::Base.connection.encoding_for_ruby) : item
184-
end
185-
end
186-
187177
def simplified_type_with_extended_types(field_type)
188178
case field_type
189179
when 'uuid'
@@ -287,19 +277,6 @@ def #{column_type}(*args) # def string(
287277

288278
NATIVE_DATABASE_TYPES.merge!(EXTENDED_TYPES)
289279

290-
# Translate from the current database encoding to the encoding we
291-
# will force string array components into on retrievial.
292-
def encoding_for_ruby
293-
@database_encoding ||= case ActiveRecord::Base.connection.encoding
294-
when 'UTF8'
295-
'UTF-8'
296-
when 'SQL_ASCII'
297-
'ASCII'
298-
else
299-
ActiveRecord::Base.connection.encoding
300-
end
301-
end
302-
303280
def supports_extensions?
304281
postgresql_version > 90100
305282
end

postgres_ext.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
1616
gem.version = PostgresExt::VERSION
1717

1818
gem.add_dependency 'activerecord', '~> 3.2.0'
19-
gem.add_dependency 'pg_array_parser', '~> 0.0.8'
19+
gem.add_dependency 'pg_array_parser', '~> 0.0.9'
2020

2121
gem.add_development_dependency 'rails', '~> 3.2.0'
2222
gem.add_development_dependency 'rspec-rails', '~> 2.12.0'

0 commit comments

Comments
 (0)