Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
9bd21b17
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,发现更多精彩内容 >>
提交
9bd21b17
编写于
4月 25, 2020
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use `supports_datetime_with_precision?` rather than `subsecond_precision_supported?`
上级
4c5e4ea4
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
21 addition
and
24 deletion
+21
-24
activerecord/test/cases/ar_schema_test.rb
activerecord/test/cases/ar_schema_test.rb
+1
-1
activerecord/test/cases/base_test.rb
activerecord/test/cases/base_test.rb
+1
-1
activerecord/test/cases/date_time_precision_test.rb
activerecord/test/cases/date_time_precision_test.rb
+1
-1
activerecord/test/cases/date_time_test.rb
activerecord/test/cases/date_time_test.rb
+1
-1
activerecord/test/cases/defaults_test.rb
activerecord/test/cases/defaults_test.rb
+1
-1
activerecord/test/cases/dirty_test.rb
activerecord/test/cases/dirty_test.rb
+1
-1
activerecord/test/cases/helper.rb
activerecord/test/cases/helper.rb
+1
-4
activerecord/test/cases/integration_test.rb
activerecord/test/cases/integration_test.rb
+2
-2
activerecord/test/cases/primary_keys_test.rb
activerecord/test/cases/primary_keys_test.rb
+1
-1
activerecord/test/cases/quoting_test.rb
activerecord/test/cases/quoting_test.rb
+1
-1
activerecord/test/cases/time_precision_test.rb
activerecord/test/cases/time_precision_test.rb
+1
-1
activerecord/test/cases/type/date_time_test.rb
activerecord/test/cases/type/date_time_test.rb
+1
-1
activerecord/test/schema/mysql2_specific_schema.rb
activerecord/test/schema/mysql2_specific_schema.rb
+1
-1
activerecord/test/schema/schema.rb
activerecord/test/schema/schema.rb
+7
-7
未找到文件。
activerecord/test/cases/ar_schema_test.rb
浏览文件 @
9bd21b17
...
...
@@ -160,7 +160,7 @@ def test_timestamps_without_null_set_null_to_false_on_add_timestamps
assert
@connection
.
column_exists?
(
:has_timestamps
,
:updated_at
,
null:
false
)
end
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
def
test_timestamps_sets_precision_on_create_table
ActiveRecord
::
Schema
.
define
do
create_table
:has_timestamps
do
|
t
|
...
...
activerecord/test/cases/base_test.rb
浏览文件 @
9bd21b17
...
...
@@ -221,7 +221,7 @@ def test_preserving_time_objects
)
# For adapters which support microsecond resolution.
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
assert_equal
11
,
Topic
.
find
(
1
).
written_on
.
sec
assert_equal
223300
,
Topic
.
find
(
1
).
written_on
.
usec
assert_equal
9900
,
Topic
.
find
(
2
).
written_on
.
usec
...
...
activerecord/test/cases/date_time_precision_test.rb
浏览文件 @
9bd21b17
...
...
@@ -3,7 +3,7 @@
require
"cases/helper"
require
"support/schema_dumping_helper"
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
class
DateTimePrecisionTest
<
ActiveRecord
::
TestCase
include
SchemaDumpingHelper
self
.
use_transactional_tests
=
false
...
...
activerecord/test/cases/date_time_test.rb
浏览文件 @
9bd21b17
...
...
@@ -62,7 +62,7 @@ def test_assign_in_local_timezone
end
def
test_date_time_with_string_value_with_subsecond_precision
skip
unless
su
bsecond_precision_supported
?
skip
unless
su
pports_datetime_with_precision
?
string_value
=
"2017-07-04 14:19:00.5"
topic
=
Topic
.
create
(
written_on:
string_value
)
assert_equal
topic
,
Topic
.
find_by
(
written_on:
string_value
)
...
...
activerecord/test/cases/defaults_test.rb
浏览文件 @
9bd21b17
...
...
@@ -113,7 +113,7 @@ class MysqlDefaultExpressionTest < ActiveRecord::TestCase
end
end
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
test
"schema dump datetime includes default expression"
do
output
=
dump_table_schema
(
"datetime_defaults"
)
assert_match
%r/t
\.
datetime
\s
+"modified_datetime",
\s
+default: -> { "CURRENT_TIMESTAMP(?:
\(\)
)?" }/i
,
output
...
...
activerecord/test/cases/dirty_test.rb
浏览文件 @
9bd21b17
...
...
@@ -596,7 +596,7 @@ def test_field_named_field
end
def
test_datetime_attribute_can_be_updated_with_fractional_seconds
skip
"Fractional seconds are not supported"
unless
su
bsecond_precision_supported
?
skip
"Fractional seconds are not supported"
unless
su
pports_datetime_with_precision
?
in_time_zone
"Paris"
do
target
=
Class
.
new
(
ActiveRecord
::
Base
)
target
.
table_name
=
"topics"
...
...
activerecord/test/cases/helper.rb
浏览文件 @
9bd21b17
...
...
@@ -40,10 +40,6 @@ def in_memory_db?
ActiveRecord
::
Base
.
connection_pool
.
db_config
.
database
==
":memory:"
end
def
subsecond_precision_supported?
ActiveRecord
::
Base
.
connection
.
supports_datetime_with_precision?
end
def
mysql_enforcing_gtid_consistency?
current_adapter?
(
:Mysql2Adapter
)
&&
"ON"
==
ActiveRecord
::
Base
.
connection
.
show_variable
(
"enforce_gtid_consistency"
)
end
...
...
@@ -66,6 +62,7 @@ def supports_default_expression?
supports_insert_on_duplicate_update?
supports_insert_conflict_target?
supports_optimizer_hints?
supports_datetime_with_precision?
]
.
each
do
|
method_name
|
define_method
method_name
do
ActiveRecord
::
Base
.
connection
.
public_send
(
method_name
)
...
...
activerecord/test/cases/integration_test.rb
浏览文件 @
9bd21b17
...
...
@@ -154,7 +154,7 @@ def test_cache_key_for_newer_updated_on
end
def
test_cache_key_format_is_precise_enough
skip
(
"Subsecond precision is not supported"
)
unless
su
bsecond_precision_supported
?
skip
(
"Subsecond precision is not supported"
)
unless
su
pports_datetime_with_precision
?
dev
=
Developer
.
first
key
=
dev
.
cache_key
travel_to
dev
.
updated_at
+
0.000001
do
...
...
@@ -171,7 +171,7 @@ def test_cache_key_format_is_not_too_precise
end
def
test_cache_version_format_is_precise_enough
skip
(
"Subsecond precision is not supported"
)
unless
su
bsecond_precision_supported
?
skip
(
"Subsecond precision is not supported"
)
unless
su
pports_datetime_with_precision
?
with_cache_versioning
do
dev
=
Developer
.
first
version
=
dev
.
cache_version
.
to_param
...
...
activerecord/test/cases/primary_keys_test.rb
浏览文件 @
9bd21b17
...
...
@@ -316,7 +316,7 @@ def test_any_type_primary_key
assert_no_match
%r{t
\.
index
\[
"code"
\]
}
,
schema
end
if
current_adapter?
(
:Mysql2Adapter
)
&&
su
bsecond_precision_supported
?
if
current_adapter?
(
:Mysql2Adapter
)
&&
su
pports_datetime_with_precision
?
test
"schema typed primary key column"
do
@connection
.
create_table
(
:scheduled_logs
,
id: :timestamp
,
precision:
6
,
force:
true
)
schema
=
dump_table_schema
(
"scheduled_logs"
)
...
...
activerecord/test/cases/quoting_test.rb
浏览文件 @
9bd21b17
...
...
@@ -267,7 +267,7 @@ def test_type_cast_returns_frozen_value
end
end
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
class
QuoteARBaseTest
<
ActiveRecord
::
TestCase
class
DatetimePrimaryKey
<
ActiveRecord
::
Base
end
...
...
activerecord/test/cases/time_precision_test.rb
浏览文件 @
9bd21b17
...
...
@@ -3,7 +3,7 @@
require
"cases/helper"
require
"support/schema_dumping_helper"
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
class
TimePrecisionTest
<
ActiveRecord
::
TestCase
include
SchemaDumpingHelper
self
.
use_transactional_tests
=
false
...
...
activerecord/test/cases/type/date_time_test.rb
浏览文件 @
9bd21b17
...
...
@@ -7,7 +7,7 @@ module ActiveRecord
module
Type
class
DateTimeTest
<
ActiveRecord
::
TestCase
def
test_datetime_seconds_precision_applied_to_timestamp
skip
"This test is invalid if subsecond precision isn't supported"
unless
su
bsecond_precision_supported
?
skip
"This test is invalid if subsecond precision isn't supported"
unless
su
pports_datetime_with_precision
?
p
=
Task
.
create!
(
starting:
::
Time
.
now
)
assert_equal
p
.
starting
.
usec
,
p
.
reload
.
starting
.
usec
end
...
...
activerecord/test/schema/mysql2_specific_schema.rb
浏览文件 @
9bd21b17
# frozen_string_literal: true
ActiveRecord
::
Schema
.
define
do
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
create_table
:datetime_defaults
,
force:
true
do
|
t
|
t
.
datetime
:modified_datetime
,
default:
->
{
"CURRENT_TIMESTAMP"
}
t
.
datetime
:precise_datetime
,
precision:
6
,
default:
->
{
"CURRENT_TIMESTAMP(6)"
}
...
...
activerecord/test/schema/schema.rb
浏览文件 @
9bd21b17
...
...
@@ -294,7 +294,7 @@
t
.
integer
:salary
,
default:
70000
t
.
references
:firm
,
index:
false
t
.
integer
:mentor_id
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
t
.
datetime
:created_at
,
precision:
6
t
.
datetime
:updated_at
,
precision:
6
t
.
datetime
:created_on
,
precision:
6
...
...
@@ -420,7 +420,7 @@
create_table
:invoices
,
force:
true
do
|
t
|
t
.
integer
:balance
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
t
.
datetime
:updated_at
,
precision:
6
else
t
.
datetime
:updated_at
...
...
@@ -611,7 +611,7 @@
create_table
:owners
,
primary_key: :owner_id
,
force:
true
do
|
t
|
t
.
string
:name
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
t
.
column
:updated_at
,
:datetime
,
precision:
6
else
t
.
column
:updated_at
,
:datetime
...
...
@@ -635,7 +635,7 @@
t
.
string
:parrot_sti_class
t
.
integer
:killer_id
t
.
integer
:updated_count
,
:integer
,
default:
0
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
t
.
datetime
:created_at
,
precision:
0
t
.
datetime
:created_on
,
precision:
0
t
.
datetime
:updated_at
,
precision:
0
...
...
@@ -652,7 +652,7 @@
t
.
string
:catchphrase
t
.
integer
:parrot_id
t
.
integer
:non_validated_parrot_id
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
t
.
datetime
:created_on
,
precision:
6
t
.
datetime
:updated_on
,
precision:
6
else
...
...
@@ -847,7 +847,7 @@
create_table
:ship_parts
,
force:
true
do
|
t
|
t
.
string
:name
t
.
integer
:ship_id
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
t
.
datetime
:updated_at
,
precision:
6
else
t
.
datetime
:updated_at
...
...
@@ -927,7 +927,7 @@
t
.
string
:title
,
limit:
250
,
**
case_sensitive_options
t
.
string
:author_name
,
**
case_sensitive_options
t
.
string
:author_email_address
if
su
bsecond_precision_supported
?
if
su
pports_datetime_with_precision
?
t
.
datetime
:written_on
,
precision:
6
else
t
.
datetime
:written_on
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录