Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
5d0dece6
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,发现更多精彩内容 >>
提交
5d0dece6
编写于
3月 23, 2009
作者:
R
Raimonds Simanovskis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Oracle adapter gets Time or DateTime value already with timezone
上级
ee654e54
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
17 deletion
+46
-17
activerecord/test/cases/migration_test.rb
activerecord/test/cases/migration_test.rb
+46
-17
未找到文件。
activerecord/test/cases/migration_test.rb
浏览文件 @
5d0dece6
...
...
@@ -446,18 +446,22 @@ def test_native_types
assert_equal
Date
,
bob
.
favorite_day
.
class
end
# Test DateTime column and defaults, including timezone.
# FIXME: moment of truth may be Time on 64-bit platforms.
if
bob
.
moment_of_truth
.
is_a?
(
DateTime
)
with_env_tz
'US/Eastern'
do
assert_equal
DateTime
.
local_offset
,
bob
.
moment_of_truth
.
offset
assert_not_equal
0
,
bob
.
moment_of_truth
.
offset
assert_not_equal
"Z"
,
bob
.
moment_of_truth
.
zone
# US/Eastern is -5 hours from GMT
assert_equal
Rational
(
-
5
,
24
),
bob
.
moment_of_truth
.
offset
assert_match
/\A-05:?00\Z/
,
bob
.
moment_of_truth
.
zone
#ruby 1.8.6 uses HH:MM, prior versions use HHMM
assert_equal
DateTime
::
ITALY
,
bob
.
moment_of_truth
.
start
# Oracle adapter stores Time or DateTime with timezone value already in _before_type_cast column
# therefore no timezone change is done afterwards when default timezone is changed
unless
current_adapter?
(
:OracleAdapter
)
# Test DateTime column and defaults, including timezone.
# FIXME: moment of truth may be Time on 64-bit platforms.
if
bob
.
moment_of_truth
.
is_a?
(
DateTime
)
with_env_tz
'US/Eastern'
do
assert_equal
DateTime
.
local_offset
,
bob
.
moment_of_truth
.
offset
assert_not_equal
0
,
bob
.
moment_of_truth
.
offset
assert_not_equal
"Z"
,
bob
.
moment_of_truth
.
zone
# US/Eastern is -5 hours from GMT
assert_equal
Rational
(
-
5
,
24
),
bob
.
moment_of_truth
.
offset
assert_match
/\A-05:?00\Z/
,
bob
.
moment_of_truth
.
zone
#ruby 1.8.6 uses HH:MM, prior versions use HHMM
assert_equal
DateTime
::
ITALY
,
bob
.
moment_of_truth
.
start
end
end
end
...
...
@@ -571,7 +575,7 @@ def test_rename_nonexistent_column
ActiveRecord
::
Base
.
connection
.
create_table
(
:hats
)
do
|
table
|
table
.
column
:hat_name
,
:string
,
:default
=>
nil
end
exception
=
if
current_adapter?
(
:PostgreSQLAdapter
)
exception
=
if
current_adapter?
(
:PostgreSQLAdapter
,
:OracleAdapter
)
ActiveRecord
::
StatementInvalid
else
ActiveRecord
::
ActiveRecordError
...
...
@@ -625,7 +629,13 @@ def test_remove_column_with_multi_column_index
table
.
column
:hat_size
,
:integer
table
.
column
:hat_style
,
:string
,
:limit
=>
100
end
ActiveRecord
::
Base
.
connection
.
add_index
"hats"
,
[
"hat_style"
,
"hat_size"
],
:unique
=>
true
# Oracle index names should be 30 or less characters
if
current_adapter?
(
:OracleAdapter
)
ActiveRecord
::
Base
.
connection
.
add_index
"hats"
,
[
"hat_style"
,
"hat_size"
],
:unique
=>
true
,
:name
=>
'index_hats_on_hat_style_size'
else
ActiveRecord
::
Base
.
connection
.
add_index
"hats"
,
[
"hat_style"
,
"hat_size"
],
:unique
=>
true
end
assert_nothing_raised
{
Person
.
connection
.
remove_column
(
"hats"
,
"hat_size"
)
}
ensure
...
...
@@ -783,7 +793,12 @@ def test_change_column_quotes_column_names
assert_nothing_raised
{
Person
.
connection
.
change_column
:testings
,
:select
,
:string
,
:limit
=>
10
}
assert_nothing_raised
{
Person
.
connection
.
execute
"insert into testings (
#{
Person
.
connection
.
quote_column_name
(
'select'
)
}
) values ('7 chars')"
}
# Oracle needs primary key value from sequence
if
current_adapter?
(
:OracleAdapter
)
assert_nothing_raised
{
Person
.
connection
.
execute
"insert into testings (id,
#{
Person
.
connection
.
quote_column_name
(
'select'
)
}
) values (testings_seq.nextval, '7 chars')"
}
else
assert_nothing_raised
{
Person
.
connection
.
execute
"insert into testings (
#{
Person
.
connection
.
quote_column_name
(
'select'
)
}
) values ('7 chars')"
}
end
ensure
Person
.
connection
.
drop_table
:testings
rescue
nil
end
...
...
@@ -799,7 +814,12 @@ def test_keeping_default_and_notnull_constaint_on_change
person_klass
.
reset_column_information
assert_equal
99
,
person_klass
.
columns_hash
[
"wealth"
].
default
assert_equal
false
,
person_klass
.
columns_hash
[
"wealth"
].
null
assert_nothing_raised
{
person_klass
.
connection
.
execute
(
"insert into testings (title) values ('tester')"
)}
# Oracle needs primary key value from sequence
if
current_adapter?
(
:OracleAdapter
)
assert_nothing_raised
{
person_klass
.
connection
.
execute
(
"insert into testings (id, title) values (testings_seq.nextval, 'tester')"
)}
else
assert_nothing_raised
{
person_klass
.
connection
.
execute
(
"insert into testings (title) values ('tester')"
)}
end
# change column default to see that column doesn't lose its not null definition
person_klass
.
connection
.
change_column_default
"testings"
,
"wealth"
,
100
...
...
@@ -1054,7 +1074,12 @@ def test_migrator_interleaved_migrations
end
def
test_migrator_db_has_no_schema_migrations_table
ActiveRecord
::
Base
.
connection
.
execute
(
"DROP TABLE schema_migrations;"
)
# Oracle adapter raises error if semicolon is present as last character
if
current_adapter?
(
:OracleAdapter
)
ActiveRecord
::
Base
.
connection
.
execute
(
"DROP TABLE schema_migrations"
)
else
ActiveRecord
::
Base
.
connection
.
execute
(
"DROP TABLE schema_migrations;"
)
end
assert_nothing_raised
do
ActiveRecord
::
Migrator
.
migrate
(
MIGRATIONS_ROOT
+
"/valid"
,
1
)
end
...
...
@@ -1412,6 +1437,8 @@ def test_remove_timestamps_creates_updated_at_and_created_at
def
string_column
if
current_adapter?
(
:PostgreSQLAdapter
)
"character varying(255)"
elsif
current_adapter?
(
:OracleAdapter
)
'VARCHAR2(255)'
else
'varchar(255)'
end
...
...
@@ -1420,6 +1447,8 @@ def string_column
def
integer_column
if
current_adapter?
(
:MysqlAdapter
)
'int(11)'
elsif
current_adapter?
(
:OracleAdapter
)
'NUMBER(38)'
else
'integer'
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录