提交 711af752 编写于 作者: Y Yves Senn

pg, map `char` and `name` types as string. [dark-panda & Yves Senn]

Closes #10802.
上级 4320b778
* Handle `name` and `"char"` column types in the PostgreSQL adapter.
`name` and `"char"` are special character types used internally by
PostgreSQL and are used by internal system catalogs. These field types
can sometimes show up in structure-sniffing queries that feature internal system
structures or with certain PostgreSQL extensions.
*J Smith*, *Yves Senn*
* Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
......
......@@ -409,6 +409,7 @@ def self.registered_type?(name)
register_type 'text', OID::Text.new
register_type 'varchar', OID::String.new
alias_type 'char', 'varchar'
alias_type 'name', 'varchar'
alias_type 'bpchar', 'varchar'
register_type 'bool', OID::Boolean.new
register_type 'bit', OID::Bit.new
......
require "cases/helper"
require 'support/ddl_helper'
class PostgresqlArray < ActiveRecord::Base
end
......@@ -315,3 +316,25 @@ def test_timestamp_with_zone_values_without_rails_time_zone_support
@connection.reconnect!
end
end
class PostgresqlInternalDataTypeTest < ActiveRecord::TestCase
include DdlHelper
setup do
@connection = ActiveRecord::Base.connection
end
def test_name_column_type
with_example_table @connection, 'ex', 'data name' do
column = @connection.columns('ex').find { |col| col.name == 'data' }
assert_equal :string, column.type
end
end
def test_char_column_type
with_example_table @connection, 'ex', 'data "char"' do
column = @connection.columns('ex').find { |col| col.name == 'data' }
assert_equal :string, column.type
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册