Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
0cfa4966
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,发现更多精彩内容 >>
提交
0cfa4966
编写于
8月 06, 2015
作者:
S
Sean Griffin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20459
上级
6caeec53
7f2037a9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
132 addition
and
0 deletion
+132
-0
activerecord/CHANGELOG.md
activerecord/CHANGELOG.md
+15
-0
activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb
...cord/connection_adapters/postgresql/schema_definitions.rb
+24
-0
activerecord/test/cases/migration/postgresql_geometric_types_test.rb
...d/test/cases/migration/postgresql_geometric_types_test.rb
+93
-0
未找到文件。
activerecord/CHANGELOG.md
浏览文件 @
0cfa4966
*
Added methods for PostgreSQL geometric data types to use in migrations
Example:
create_table :foo do |t|
t.line :foo_line
t.lseg :foo_lseg
t.box :foo_box
t.path :foo_path
t.polygon :foo_polygon
t.circle :foo_circle
end
*Mehmet Emin İNAÇ*
*
Add
`cache_key`
to ActiveRecord::Relation.
Example:
...
...
activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb
浏览文件 @
0cfa4966
...
...
@@ -103,6 +103,30 @@ def point(*args, **options)
args
.
each
{
|
name
|
column
(
name
,
:point
,
options
)
}
end
def
line
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:line
,
options
)
}
end
def
lseg
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:lseg
,
options
)
}
end
def
box
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:box
,
options
)
}
end
def
path
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:path
,
options
)
}
end
def
polygon
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:polygon
,
options
)
}
end
def
circle
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:circle
,
options
)
}
end
def
serial
(
*
args
,
**
options
)
args
.
each
{
|
name
|
column
(
name
,
:serial
,
options
)
}
end
...
...
activerecord/test/cases/migration/postgresql_geometric_types_test.rb
0 → 100644
浏览文件 @
0cfa4966
require
'cases/helper'
module
ActiveRecord
class
Migration
class
PostgreSQLGeometricTypesTest
<
ActiveRecord
::
TestCase
attr_reader
:connection
,
:table_name
def
setup
super
@connection
=
ActiveRecord
::
Base
.
connection
@table_name
=
:testings
end
if
current_adapter?
(
:PostgreSQLAdapter
)
def
test_creating_column_with_point_type
connection
.
create_table
(
table_name
)
do
|
t
|
t
.
point
:foo_point
end
assert_column_exists
(
:foo_point
)
assert_type_correct
(
:foo_point
,
:point
)
end
def
test_creating_column_with_line_type
connection
.
create_table
(
table_name
)
do
|
t
|
t
.
line
:foo_line
end
assert_column_exists
(
:foo_line
)
assert_type_correct
(
:foo_line
,
:line
)
end
def
test_creating_column_with_lseg_type
connection
.
create_table
(
table_name
)
do
|
t
|
t
.
lseg
:foo_lseg
end
assert_column_exists
(
:foo_lseg
)
assert_type_correct
(
:foo_lseg
,
:lseg
)
end
def
test_creating_column_with_box_type
connection
.
create_table
(
table_name
)
do
|
t
|
t
.
box
:foo_box
end
assert_column_exists
(
:foo_box
)
assert_type_correct
(
:foo_box
,
:box
)
end
def
test_creating_column_with_path_type
connection
.
create_table
(
table_name
)
do
|
t
|
t
.
path
:foo_path
end
assert_column_exists
(
:foo_path
)
assert_type_correct
(
:foo_path
,
:path
)
end
def
test_creating_column_with_polygon_type
connection
.
create_table
(
table_name
)
do
|
t
|
t
.
polygon
:foo_polygon
end
assert_column_exists
(
:foo_polygon
)
assert_type_correct
(
:foo_polygon
,
:polygon
)
end
def
test_creating_column_with_circle_type
connection
.
create_table
(
table_name
)
do
|
t
|
t
.
circle
:foo_circle
end
assert_column_exists
(
:foo_circle
)
assert_type_correct
(
:foo_circle
,
:circle
)
end
end
private
def
assert_column_exists
(
column_name
)
columns
=
connection
.
columns
(
table_name
)
assert
columns
.
map
(
&
:name
).
include?
(
column_name
.
to_s
)
end
def
assert_type_correct
(
column_name
,
type
)
columns
=
connection
.
columns
(
table_name
)
column
=
columns
.
select
{
|
c
|
c
.
name
==
column_name
.
to_s
}.
first
assert_equal
type
.
to_s
,
column
.
sql_type
end
end
end
end
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录