Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register integer types limit correctly for postgresql adapter #26386

Merged
merged 1 commit into from
Aug 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class PostgreSQLAdapter < AbstractAdapter
primary_key: "bigserial primary key",
string: { name: "character varying" },
text: { name: "text" },
integer: { name: "integer" },
integer: { name: "integer", limit: 4 },
float: { name: "float" },
decimal: { name: "decimal" },
datetime: { name: "timestamp" },
Expand Down Expand Up @@ -439,9 +439,9 @@ def get_oid_type(oid, fmod, column_name, sql_type = "".freeze)
end

def initialize_type_map(m = type_map)
register_class_with_limit m, "int2", Type::Integer
register_class_with_limit m, "int4", Type::Integer
register_class_with_limit m, "int8", Type::Integer
m.register_type "int2", Type::Integer.new(limit: 2)
m.register_type "int4", Type::Integer.new(limit: 4)
m.register_type "int8", Type::Integer.new(limit: 8)
m.register_type "oid", OID::Oid.new
m.register_type "float4", Type::Float.new
m.alias_type "float8", "float4"
Expand Down Expand Up @@ -508,17 +508,6 @@ def initialize_type_map(m = type_map)
load_additional_types
end

def extract_limit(sql_type)
case sql_type
when /^bigint/i, /^int8/i
8
when /^smallint/i
2
else
super
end
end

# Extracts the value from a PostgreSQL column default definition.
def extract_value_from_default(default)
case default
Expand Down