Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
563c16c7
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,发现更多精彩内容 >>
提交
563c16c7
编写于
6月 02, 2017
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add JSON attribute test cases for SQLite3 adapter
上级
214dc7d8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
1 deletion
+33
-1
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
...lib/active_record/connection_adapters/abstract_adapter.rb
+2
-0
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
...tive_record/connection_adapters/abstract_mysql_adapter.rb
+0
-1
activerecord/test/cases/adapters/sqlite3/json_test.rb
activerecord/test/cases/adapters/sqlite3/json_test.rb
+29
-0
activerecord/test/cases/json_shared_test_cases.rb
activerecord/test/cases/json_shared_test_cases.rb
+2
-0
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
浏览文件 @
563c16c7
...
...
@@ -478,6 +478,8 @@ def initialize_type_map(m = type_map)
m
.
alias_type
%r(number)i
,
"decimal"
m
.
alias_type
%r(double)i
,
"float"
m
.
register_type
%r(^json)i
,
Type
::
Json
.
new
m
.
register_type
(
%r(decimal)i
)
do
|
sql_type
|
scale
=
extract_scale
(
sql_type
)
precision
=
extract_precision
(
sql_type
)
...
...
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
浏览文件 @
563c16c7
...
...
@@ -563,7 +563,6 @@ def initialize_type_map(m = type_map)
m
.
register_type
%r(longblob)i
,
Type
::
Binary
.
new
(
limit:
2
**
32
-
1
)
m
.
register_type
%r(^float)i
,
Type
::
Float
.
new
(
limit:
24
)
m
.
register_type
%r(^double)i
,
Type
::
Float
.
new
(
limit:
53
)
m
.
register_type
%r(^json)i
,
Type
::
Json
.
new
register_integer_type
m
,
%r(^bigint)i
,
limit:
8
register_integer_type
m
,
%r(^int)i
,
limit:
4
...
...
activerecord/test/cases/adapters/sqlite3/json_test.rb
0 → 100644
浏览文件 @
563c16c7
# frozen_string_literal: true
require
"cases/helper"
require
"cases/json_shared_test_cases"
class
SQLite3JSONTest
<
ActiveRecord
::
SQLite3TestCase
include
JSONSharedTestCases
def
setup
super
@connection
.
create_table
(
"json_data_type"
)
do
|
t
|
t
.
column
"payload"
,
:json
,
default:
{}
t
.
column
"settings"
,
:json
end
end
def
test_default
@connection
.
add_column
"json_data_type"
,
"permissions"
,
column_type
,
default:
{
"users"
:
"read"
,
"posts"
:
[
"read"
,
"write"
]
}
klass
.
reset_column_information
assert_equal
({
"users"
=>
"read"
,
"posts"
=>
[
"read"
,
"write"
]
},
klass
.
column_defaults
[
"permissions"
])
assert_equal
({
"users"
=>
"read"
,
"posts"
=>
[
"read"
,
"write"
]
},
klass
.
new
.
permissions
)
end
private
def
column_type
:json
end
end
activerecord/test/cases/json_shared_test_cases.rb
浏览文件 @
563c16c7
...
...
@@ -30,6 +30,7 @@ def test_column
end
def
test_change_table_supports_json
skip
unless
@connection
.
supports_json?
@connection
.
change_table
(
"json_data_type"
)
do
|
t
|
t
.
public_send
column_type
,
"users"
end
...
...
@@ -40,6 +41,7 @@ def test_change_table_supports_json
end
def
test_schema_dumping
skip
unless
@connection
.
supports_json?
output
=
dump_table_schema
(
"json_data_type"
)
assert_match
(
/t\.
#{
column_type
}
\s+"settings"/
,
output
)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录