Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
4025efb5
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,发现更多精彩内容 >>
提交
4025efb5
编写于
5月 16, 2012
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6349 from erichmenge/patch-raise-type-errors
Integer limit out of range should be allowed to raise. Closes #6272
上级
2ee8ed4e
56cef492
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
7 deletion
+34
-7
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
...record/connection_adapters/abstract/schema_definitions.rb
+1
-1
activerecord/test/cases/migration/change_schema_test.rb
activerecord/test/cases/migration/change_schema_test.rb
+0
-4
activerecord/test/cases/migration/column_attributes_test.rb
activerecord/test/cases/migration/column_attributes_test.rb
+10
-0
activerecord/test/cases/migration_test.rb
activerecord/test/cases/migration_test.rb
+23
-2
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
浏览文件 @
4025efb5
...
...
@@ -23,7 +23,7 @@ def string_to_binary(value)
end
def
sql_type
base
.
type_to_sql
(
type
.
to_sym
,
limit
,
precision
,
scale
)
rescue
type
base
.
type_to_sql
(
type
.
to_sym
,
limit
,
precision
,
scale
)
end
def
to_sql
...
...
activerecord/test/cases/migration/change_schema_test.rb
浏览文件 @
4025efb5
...
...
@@ -83,7 +83,6 @@ def test_create_table_with_limits
t
.
column
:one_int
,
:integer
,
:limit
=>
1
t
.
column
:four_int
,
:integer
,
:limit
=>
4
t
.
column
:eight_int
,
:integer
,
:limit
=>
8
t
.
column
:eleven_int
,
:integer
,
:limit
=>
11
end
columns
=
connection
.
columns
(
:testings
)
...
...
@@ -94,20 +93,17 @@ def test_create_table_with_limits
one
=
columns
.
detect
{
|
c
|
c
.
name
==
"one_int"
}
four
=
columns
.
detect
{
|
c
|
c
.
name
==
"four_int"
}
eight
=
columns
.
detect
{
|
c
|
c
.
name
==
"eight_int"
}
eleven
=
columns
.
detect
{
|
c
|
c
.
name
==
"eleven_int"
}
if
current_adapter?
(
:PostgreSQLAdapter
)
assert_equal
'integer'
,
default
.
sql_type
assert_equal
'smallint'
,
one
.
sql_type
assert_equal
'integer'
,
four
.
sql_type
assert_equal
'bigint'
,
eight
.
sql_type
assert_equal
'integer'
,
eleven
.
sql_type
elsif
current_adapter?
(
:MysqlAdapter
)
or
current_adapter?
(
:Mysql2Adapter
)
assert_match
'int(11)'
,
default
.
sql_type
assert_match
'tinyint'
,
one
.
sql_type
assert_match
'int'
,
four
.
sql_type
assert_match
'bigint'
,
eight
.
sql_type
assert_match
'int(11)'
,
eleven
.
sql_type
elsif
current_adapter?
(
:OracleAdapter
)
assert_equal
'NUMBER(38)'
,
default
.
sql_type
assert_equal
'NUMBER(1)'
,
one
.
sql_type
...
...
activerecord/test/cases/migration/column_attributes_test.rb
浏览文件 @
4025efb5
...
...
@@ -183,6 +183,16 @@ def test_native_types
assert_instance_of
TrueClass
,
bob
.
male?
assert_kind_of
BigDecimal
,
bob
.
wealth
end
def
test_out_of_range_limit_should_raise
skip
(
"MySQL and PostgreSQL only"
)
unless
current_adapter?
(
:MysqlAdapter
,
:Mysql2Adapter
,
:PostgreSQLAdapter
)
assert_raise
(
ActiveRecordError
)
{
add_column
:test_models
,
:integer_too_big
,
:integer
,
:limit
=>
10
}
unless
current_adapter?
(
:PostgreSQLAdapter
)
assert_raise
(
ActiveRecordError
)
{
add_column
:test_models
,
:text_too_big
,
:integer
,
:limit
=>
0xfffffffff
}
end
end
end
end
end
activerecord/test/cases/migration_test.rb
浏览文件 @
4025efb5
...
...
@@ -375,6 +375,27 @@ def test_create_table_with_custom_sequence_name
end
end
def
test_out_of_range_limit_should_raise
skip
(
"MySQL and PostgreSQL only"
)
unless
current_adapter?
(
:MysqlAdapter
,
:Mysql2Adapter
,
:PostgreSQLAdapter
)
Person
.
connection
.
drop_table
:test_limits
rescue
nil
assert_raise
(
ActiveRecord
::
ActiveRecordError
,
"integer limit didn't raise"
)
do
Person
.
connection
.
create_table
:test_integer_limits
,
:force
=>
true
do
|
t
|
t
.
column
:bigone
,
:integer
,
:limit
=>
10
end
end
unless
current_adapter?
(
:PostgreSQLAdapter
)
assert_raise
(
ActiveRecord
::
ActiveRecordError
,
"text limit didn't raise"
)
do
Person
.
connection
.
create_table
:test_text_limits
,
:force
=>
true
do
|
t
|
t
.
column
:bigtext
,
:text
,
:limit
=>
0xfffffffff
end
end
end
Person
.
connection
.
drop_table
:test_limits
rescue
nil
end
protected
def
with_env_tz
(
new_tz
=
'US/Eastern'
)
old_tz
,
ENV
[
'TZ'
]
=
ENV
[
'TZ'
],
new_tz
...
...
@@ -883,8 +904,8 @@ def test_copying_migrations_with_timestamps_to_destination_with_timestamps_in_fu
def
test_skipping_migrations
@migrations_path
=
MIGRATIONS_ROOT
+
"/valid_with_timestamps"
@existing_migrations
=
Dir
[
@migrations_path
+
"/*.rb"
]
sources
=
{}
sources
=
{}
sources
[
:bukkits
]
=
MIGRATIONS_ROOT
+
"/to_copy_with_timestamps"
sources
[
:omg
]
=
MIGRATIONS_ROOT
+
"/to_copy_with_name_collision"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录