Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f48703e8
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,发现更多精彩内容 >>
提交
f48703e8
编写于
10月 09, 2008
作者:
H
Hongli Lai (Phusion)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the final MySQL unit test failure that's related to savepoint support.
上级
47b594cc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
28 deletion
+39
-28
activerecord/test/cases/defaults_test.rb
activerecord/test/cases/defaults_test.rb
+39
-28
未找到文件。
activerecord/test/cases/defaults_test.rb
浏览文件 @
f48703e8
...
...
@@ -20,34 +20,7 @@ def test_nil_defaults_for_not_null_columns
if
current_adapter?
(
:MysqlAdapter
)
#MySQL 5 and higher is quirky with not null text/blob columns.
#With MySQL Text/blob columns cannot have defaults. If the column is not null MySQL will report that the column has a null default
#but it behaves as though the column had a default of ''
def
test_mysql_text_not_null_defaults
klass
=
Class
.
new
(
ActiveRecord
::
Base
)
klass
.
table_name
=
'test_mysql_text_not_null_defaults'
klass
.
connection
.
create_table
klass
.
table_name
do
|
t
|
t
.
column
:non_null_text
,
:text
,
:null
=>
false
t
.
column
:non_null_blob
,
:blob
,
:null
=>
false
t
.
column
:null_text
,
:text
,
:null
=>
true
t
.
column
:null_blob
,
:blob
,
:null
=>
true
end
assert_equal
''
,
klass
.
columns_hash
[
'non_null_blob'
].
default
assert_equal
''
,
klass
.
columns_hash
[
'non_null_text'
].
default
assert_equal
nil
,
klass
.
columns_hash
[
'null_blob'
].
default
assert_equal
nil
,
klass
.
columns_hash
[
'null_text'
].
default
assert_nothing_raised
do
instance
=
klass
.
create!
assert_equal
''
,
instance
.
non_null_text
assert_equal
''
,
instance
.
non_null_blob
assert_nil
instance
.
null_text
assert_nil
instance
.
null_blob
end
ensure
klass
.
connection
.
drop_table
(
klass
.
table_name
)
rescue
nil
end
end
if
current_adapter?
(
:PostgreSQLAdapter
,
:SQLServerAdapter
,
:FirebirdAdapter
,
:OpenBaseAdapter
,
:OracleAdapter
)
...
...
@@ -73,8 +46,46 @@ def test_multiline_default_text
if
current_adapter?
(
:MysqlAdapter
)
class
DefaultsTestWithoutTransactionalFixtures
<
ActiveRecord
::
TestCase
# ActiveRecord::Base#create! (and #save and other related methods) will
# open a new transaction. When in transactional fixtures mode, this will
# cause ActiveRecord to create a new savepoint. However, since MySQL doesn't
# support DDL transactions, creating a table will result in any created
# savepoints to be automatically released. This in turn causes the savepoint
# release code in AbstractAdapter#transaction to fail.
#
# We don't want that to happen, so we disable transactional fixtures here.
self
.
use_transactional_fixtures
=
false
# MySQL 5 and higher is quirky with not null text/blob columns.
# With MySQL Text/blob columns cannot have defaults. If the column is not
# null MySQL will report that the column has a null default
# but it behaves as though the column had a default of ''
def
test_mysql_text_not_null_defaults
klass
=
Class
.
new
(
ActiveRecord
::
Base
)
klass
.
table_name
=
'test_mysql_text_not_null_defaults'
klass
.
connection
.
create_table
klass
.
table_name
do
|
t
|
t
.
column
:non_null_text
,
:text
,
:null
=>
false
t
.
column
:non_null_blob
,
:blob
,
:null
=>
false
t
.
column
:null_text
,
:text
,
:null
=>
true
t
.
column
:null_blob
,
:blob
,
:null
=>
true
end
assert_equal
''
,
klass
.
columns_hash
[
'non_null_blob'
].
default
assert_equal
''
,
klass
.
columns_hash
[
'non_null_text'
].
default
assert_equal
nil
,
klass
.
columns_hash
[
'null_blob'
].
default
assert_equal
nil
,
klass
.
columns_hash
[
'null_text'
].
default
assert_nothing_raised
do
instance
=
klass
.
create!
assert_equal
''
,
instance
.
non_null_text
assert_equal
''
,
instance
.
non_null_blob
assert_nil
instance
.
null_text
assert_nil
instance
.
null_blob
end
ensure
klass
.
connection
.
drop_table
(
klass
.
table_name
)
rescue
nil
end
# MySQL uses an implicit default 0 rather than NULL unless in strict mode.
# We use an implicit NULL so schema.rb is compatible with other databases.
def
test_mysql_integer_not_null_defaults
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录