Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
5777f0bf
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5777f0bf
编写于
1月 03, 2015
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18283 from kamipo/refactor_postgresql_column
Prefer `array?` rather than `array`
上级
217e5f6e
3225ebfa
变更
18
显示空白变更内容
内联
并排
Showing
18 changed file
with
29 addition
and
30 deletion
+29
-30
activerecord/lib/active_record/connection_adapters/column.rb
activerecord/lib/active_record/connection_adapters/column.rb
+2
-2
activerecord/lib/active_record/connection_adapters/postgresql/column.rb
...ib/active_record/connection_adapters/postgresql/column.rb
+4
-5
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
...b/active_record/connection_adapters/postgresql_adapter.rb
+1
-1
activerecord/test/cases/adapters/postgresql/array_test.rb
activerecord/test/cases/adapters/postgresql/array_test.rb
+3
-3
activerecord/test/cases/adapters/postgresql/bit_string_test.rb
...erecord/test/cases/adapters/postgresql/bit_string_test.rb
+2
-2
activerecord/test/cases/adapters/postgresql/citext_test.rb
activerecord/test/cases/adapters/postgresql/citext_test.rb
+1
-1
activerecord/test/cases/adapters/postgresql/composite_test.rb
...verecord/test/cases/adapters/postgresql/composite_test.rb
+2
-2
activerecord/test/cases/adapters/postgresql/domain_test.rb
activerecord/test/cases/adapters/postgresql/domain_test.rb
+1
-1
activerecord/test/cases/adapters/postgresql/enum_test.rb
activerecord/test/cases/adapters/postgresql/enum_test.rb
+1
-1
activerecord/test/cases/adapters/postgresql/full_text_test.rb
...verecord/test/cases/adapters/postgresql/full_text_test.rb
+1
-1
activerecord/test/cases/adapters/postgresql/geometric_test.rb
...verecord/test/cases/adapters/postgresql/geometric_test.rb
+1
-1
activerecord/test/cases/adapters/postgresql/hstore_test.rb
activerecord/test/cases/adapters/postgresql/hstore_test.rb
+1
-1
activerecord/test/cases/adapters/postgresql/json_test.rb
activerecord/test/cases/adapters/postgresql/json_test.rb
+1
-1
activerecord/test/cases/adapters/postgresql/ltree_test.rb
activerecord/test/cases/adapters/postgresql/ltree_test.rb
+1
-1
activerecord/test/cases/adapters/postgresql/money_test.rb
activerecord/test/cases/adapters/postgresql/money_test.rb
+1
-1
activerecord/test/cases/adapters/postgresql/network_test.rb
activerecord/test/cases/adapters/postgresql/network_test.rb
+3
-3
activerecord/test/cases/adapters/postgresql/uuid_test.rb
activerecord/test/cases/adapters/postgresql/uuid_test.rb
+1
-1
activerecord/test/cases/migration/change_schema_test.rb
activerecord/test/cases/migration/change_schema_test.rb
+2
-2
未找到文件。
activerecord/lib/active_record/connection_adapters/column.rb
浏览文件 @
5777f0bf
...
...
@@ -30,13 +30,13 @@ module Format
# <tt>company_name varchar(60)</tt>.
# It will be mapped to one of the standard Rails SQL types in the <tt>type</tt> attribute.
# +null+ determines if this column allows +NULL+ values.
def
initialize
(
name
,
default
,
cast_type
,
sql_type
=
nil
,
null
=
true
)
def
initialize
(
name
,
default
,
cast_type
,
sql_type
=
nil
,
null
=
true
,
default_function
=
nil
)
@name
=
name
@cast_type
=
cast_type
@sql_type
=
sql_type
@null
=
null
@default
=
default
@default_function
=
nil
@default_function
=
default_function
end
def
has_default?
...
...
activerecord/lib/active_record/connection_adapters/postgresql/column.rb
浏览文件 @
5777f0bf
...
...
@@ -2,18 +2,17 @@ module ActiveRecord
module
ConnectionAdapters
# PostgreSQL-specific extensions to column definitions in a table.
class
PostgreSQLColumn
<
Column
#:nodoc:
attr_accessor
:array
attr_reader
:array
alias
:array?
:array
def
initialize
(
name
,
default
,
cast_type
,
sql_type
=
nil
,
null
=
true
,
default_function
=
nil
)
if
sql_type
=~
/\[\]$/
@array
=
true
s
uper
(
name
,
default
,
cast_type
,
sql_type
[
0
..
sql_type
.
length
-
3
],
null
)
s
ql_type
=
sql_type
[
0
..
sql_type
.
length
-
3
]
else
@array
=
false
super
(
name
,
default
,
cast_type
,
sql_type
,
null
)
end
@default_function
=
default_function
super
end
def
serial?
...
...
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
浏览文件 @
5777f0bf
...
...
@@ -144,7 +144,7 @@ def column_spec_for_primary_key(column)
# AbstractAdapter
def
prepare_column_options
(
column
)
# :nodoc:
spec
=
super
spec
[
:array
]
=
'true'
if
column
.
respond_to?
(
:array
)
&&
column
.
array
spec
[
:array
]
=
'true'
if
column
.
array?
spec
[
:default
]
=
"
\"
#{
column
.
default_function
}
\"
"
if
column
.
default_function
spec
end
...
...
activerecord/test/cases/adapters/postgresql/array_test.rb
浏览文件 @
5777f0bf
...
...
@@ -35,13 +35,13 @@ def setup
def
test_column
assert_equal
:string
,
@column
.
type
assert_equal
"character varying"
,
@column
.
sql_type
assert
@column
.
array
assert
@column
.
array
?
assert_not
@column
.
number?
assert_not
@column
.
binary?
ratings_column
=
PgArray
.
columns_hash
[
'ratings'
]
assert_equal
:integer
,
ratings_column
.
type
assert
ratings_column
.
array
assert
ratings_column
.
array
?
assert_not
ratings_column
.
number?
end
...
...
@@ -74,7 +74,7 @@ def test_change_column_with_array
assert_equal
:text
,
column
.
type
assert_equal
[],
PgArray
.
column_defaults
[
'snippets'
]
assert
column
.
array
assert
column
.
array
?
end
def
test_change_column_cant_make_non_array_column_to_array
...
...
activerecord/test/cases/adapters/postgresql/bit_string_test.rb
浏览文件 @
5777f0bf
...
...
@@ -28,7 +28,7 @@ def test_bit_string_column
assert_equal
"bit(8)"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_bit_string_varying_column
...
...
@@ -37,7 +37,7 @@ def test_bit_string_varying_column
assert_equal
"bit varying(4)"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_default
...
...
activerecord/test/cases/adapters/postgresql/citext_test.rb
浏览文件 @
5777f0bf
...
...
@@ -34,7 +34,7 @@ def test_column
assert_equal
'citext'
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_change_table_supports_json
...
...
activerecord/test/cases/adapters/postgresql/composite_test.rb
浏览文件 @
5777f0bf
...
...
@@ -52,7 +52,7 @@ def test_column
assert_equal
"full_address"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_composite_mapping
...
...
@@ -113,7 +113,7 @@ def test_column
assert_equal
"full_address"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_composite_mapping
...
...
activerecord/test/cases/adapters/postgresql/domain_test.rb
浏览文件 @
5777f0bf
...
...
@@ -31,7 +31,7 @@ def test_column
assert_equal
"custom_money"
,
column
.
sql_type
assert
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_domain_acts_like_basetype
...
...
activerecord/test/cases/adapters/postgresql/enum_test.rb
浏览文件 @
5777f0bf
...
...
@@ -33,7 +33,7 @@ def test_column
assert_equal
"mood"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_enum_defaults
...
...
activerecord/test/cases/adapters/postgresql/full_text_test.rb
浏览文件 @
5777f0bf
...
...
@@ -23,7 +23,7 @@ def test_tsvector_column
assert_equal
"tsvector"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_update_tsvector
...
...
activerecord/test/cases/adapters/postgresql/geometric_test.rb
浏览文件 @
5777f0bf
...
...
@@ -28,7 +28,7 @@ def test_column
assert_equal
"point"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_default
...
...
activerecord/test/cases/adapters/postgresql/hstore_test.rb
浏览文件 @
5777f0bf
...
...
@@ -56,7 +56,7 @@ def test_column
assert_equal
"hstore"
,
@column
.
sql_type
assert_not
@column
.
number?
assert_not
@column
.
binary?
assert_not
@column
.
array
assert_not
@column
.
array
?
end
def
test_default
...
...
activerecord/test/cases/adapters/postgresql/json_test.rb
浏览文件 @
5777f0bf
...
...
@@ -36,7 +36,7 @@ def test_column
assert_equal
column_type
.
to_s
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_default
...
...
activerecord/test/cases/adapters/postgresql/ltree_test.rb
浏览文件 @
5777f0bf
...
...
@@ -32,7 +32,7 @@ def test_column
assert_equal
"ltree"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_write
...
...
activerecord/test/cases/adapters/postgresql/money_test.rb
浏览文件 @
5777f0bf
...
...
@@ -27,7 +27,7 @@ def test_column
assert_equal
2
,
column
.
scale
assert
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_default
...
...
activerecord/test/cases/adapters/postgresql/network_test.rb
浏览文件 @
5777f0bf
...
...
@@ -25,7 +25,7 @@ def test_cidr_column
assert_equal
"cidr"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_inet_column
...
...
@@ -34,7 +34,7 @@ def test_inet_column
assert_equal
"inet"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_macaddr_column
...
...
@@ -43,7 +43,7 @@ def test_macaddr_column
assert_equal
"macaddr"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_network_types
...
...
activerecord/test/cases/adapters/postgresql/uuid_test.rb
浏览文件 @
5777f0bf
...
...
@@ -51,7 +51,7 @@ def test_data_type_of_uuid_types
assert_equal
"uuid"
,
column
.
sql_type
assert_not
column
.
number?
assert_not
column
.
binary?
assert_not
column
.
array
assert_not
column
.
array
?
end
def
test_treat_blank_uuid_as_nil
...
...
activerecord/test/cases/migration/change_schema_test.rb
浏览文件 @
5777f0bf
...
...
@@ -82,7 +82,7 @@ def test_add_column_with_array
columns
=
connection
.
columns
(
:testings
)
array_column
=
columns
.
detect
{
|
c
|
c
.
name
==
"foo"
}
assert
array_column
.
array
assert
array_column
.
array
?
end
def
test_create_table_with_array_column
...
...
@@ -93,7 +93,7 @@ def test_create_table_with_array_column
columns
=
connection
.
columns
(
:testings
)
array_column
=
columns
.
detect
{
|
c
|
c
.
name
==
"foo"
}
assert
array_column
.
array
assert
array_column
.
array
?
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录