提交 b199012c 编写于 作者: R Ryuta Kamizono

An array type is a part of `sql_type`

`sql_type` is reused in `lookup_cast_type`. If making it a part of
`sql_type` when handled array option first, it isn't necessary to do
again.
上级 1492e83e
...@@ -28,7 +28,7 @@ def visit_AlterTable(o) ...@@ -28,7 +28,7 @@ def visit_AlterTable(o)
end end
def visit_ColumnDefinition(o) def visit_ColumnDefinition(o)
o.sql_type = type_to_sql(o.type, o.limit, o.precision, o.scale) o.sql_type ||= type_to_sql(o.type, o.limit, o.precision, o.scale)
column_sql = "#{quote_column_name(o.name)} #{o.sql_type}" column_sql = "#{quote_column_name(o.name)} #{o.sql_type}"
add_column_options!(column_sql, column_options(o)) unless o.type == :primary_key add_column_options!(column_sql, column_options(o)) unless o.type == :primary_key
column_sql column_sql
......
...@@ -4,16 +4,9 @@ module PostgreSQL ...@@ -4,16 +4,9 @@ module PostgreSQL
class SchemaCreation < AbstractAdapter::SchemaCreation class SchemaCreation < AbstractAdapter::SchemaCreation
private private
def column_options(o) def visit_ColumnDefinition(o)
column_options = super o.sql_type = type_to_sql(o.type, o.limit, o.precision, o.scale)
column_options[:array] = o.array o.sql_type << '[]' if o.array
column_options
end
def add_column_options!(sql, options)
if options[:array]
sql << '[]'
end
super super
end end
...@@ -24,14 +17,6 @@ def quote_default_expression(value, column) ...@@ -24,14 +17,6 @@ def quote_default_expression(value, column)
super super
end end
end end
def type_for_column(column)
if column.array
@conn.lookup_cast_type("#{column.sql_type}[]")
else
super
end
end
end end
module SchemaStatements module SchemaStatements
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册