Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
b10fb7e7
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,发现更多精彩内容 >>
提交
b10fb7e7
编写于
4月 20, 2009
作者:
J
Jeremy Kemper
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of git@github.com:rails/rails
上级
164a94d0
de0ea386
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
38 addition
and
35 deletion
+38
-35
actionpack/lib/action_dispatch/middleware/rewindable_input.rb
...onpack/lib/action_dispatch/middleware/rewindable_input.rb
+8
-17
actionpack/test/controller/dispatcher_test.rb
actionpack/test/controller/dispatcher_test.rb
+1
-1
actionpack/test/dispatch/request/multipart_params_parsing_test.rb
...ck/test/dispatch/request/multipart_params_parsing_test.rb
+2
-2
actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
.../test/dispatch/request/url_encoded_params_parsing_test.rb
+2
-2
activerecord/lib/active_record/associations.rb
activerecord/lib/active_record/associations.rb
+2
-2
activerecord/lib/active_record/associations/association_proxy.rb
...ecord/lib/active_record/associations/association_proxy.rb
+2
-2
activerecord/lib/active_record/base.rb
activerecord/lib/active_record/base.rb
+2
-2
activerecord/test/cases/associations/has_many_associations_test.rb
...ord/test/cases/associations/has_many_associations_test.rb
+6
-0
activerecord/test/cases/associations/inner_join_association_test.rb
...rd/test/cases/associations/inner_join_association_test.rb
+5
-0
activerecord/test/models/author.rb
activerecord/test/models/author.rb
+2
-0
activerecord/test/models/company.rb
activerecord/test/models/company.rb
+6
-7
未找到文件。
actionpack/lib/action_dispatch/middleware/rewindable_input.rb
浏览文件 @
b10fb7e7
module
ActionDispatch
class
RewindableInput
class
RewindableIO
<
ActiveSupport
::
BasicObject
def
initialize
(
io
)
@io
=
io
@rewindable
=
io
.
is_a?
(
::
StringIO
)
end
def
method_missing
(
method
,
*
args
,
&
block
)
unless
@rewindable
@io
=
::
StringIO
.
new
(
@io
.
read
)
@rewindable
=
true
end
@io
.
__send__
(
method
,
*
args
,
&
block
)
end
end
def
initialize
(
app
)
@app
=
app
end
def
call
(
env
)
env
[
'rack.input'
]
=
RewindableIO
.
new
(
env
[
'rack.input'
])
begin
env
[
'rack.input'
].
rewind
rescue
NoMethodError
,
Errno
::
ESPIPE
# Handles exceptions raised by input streams that cannot be rewound
# such as when using plain CGI under Apache
env
[
'rack.input'
]
=
StringIO
.
new
(
env
[
'rack.input'
].
read
)
end
@app
.
call
(
env
)
end
end
...
...
actionpack/test/controller/dispatcher_test.rb
浏览文件 @
b10fb7e7
...
...
@@ -94,7 +94,7 @@ def test_to_prepare_with_identifier_replaces
def
dispatch
(
cache_classes
=
true
)
ActionController
::
Routing
::
RouteSet
.
any_instance
.
stubs
(
:call
).
returns
([
200
,
{},
'response'
])
Dispatcher
.
define_dispatcher_callbacks
(
cache_classes
)
Dispatcher
.
new
.
call
({})
Dispatcher
.
new
.
call
({
'rack.input'
=>
StringIO
.
new
(
''
)
})
end
def
assert_subclasses
(
howmany
,
klass
,
message
=
klass
.
subclasses
.
inspect
)
...
...
actionpack/test/dispatch/request/multipart_params_parsing_test.rb
浏览文件 @
b10fb7e7
...
...
@@ -206,8 +206,8 @@ def initialize(app)
end
def
call
(
env
)
req
=
Rack
::
Request
.
new
(
env
)
req
.
params
# Parse params
env
[
'rack.input'
].
read
env
[
'rack.input'
].
rewind
@app
.
call
(
env
)
end
end
...
...
actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
浏览文件 @
b10fb7e7
...
...
@@ -150,8 +150,8 @@ def initialize(app)
end
def
call
(
env
)
req
=
Rack
::
Request
.
new
(
env
)
req
.
params
# Parse params
env
[
'rack.input'
].
read
env
[
'rack.input'
].
rewind
@app
.
call
(
env
)
end
end
...
...
activerecord/lib/active_record/associations.rb
浏览文件 @
b10fb7e7
...
...
@@ -1375,7 +1375,7 @@ def configure_dependency_for_has_many(reflection, extra_conditions = nil)
dependent_conditions
=
[]
dependent_conditions
<<
"
#{
reflection
.
primary_key_name
}
=
\#
{record.quoted_id}"
dependent_conditions
<<
"
#{
reflection
.
options
[
:as
]
}
_type = '
#{
base_class
.
name
}
'"
if
reflection
.
options
[
:as
]
dependent_conditions
<<
sanitize_sql
(
reflection
.
options
[
:conditions
])
if
reflection
.
options
[
:conditions
]
dependent_conditions
<<
sanitize_sql
(
reflection
.
options
[
:conditions
]
,
reflection
.
quoted_table_name
)
if
reflection
.
options
[
:conditions
]
dependent_conditions
<<
extra_conditions
if
extra_conditions
dependent_conditions
=
dependent_conditions
.
collect
{
|
where
|
"(
#{
where
}
)"
}.
join
(
" AND "
)
dependent_conditions
=
dependent_conditions
.
gsub
(
'@'
,
'\@'
)
...
...
@@ -2123,7 +2123,7 @@ def association_join
klass
.
send
(
:type_condition
,
aliased_table_name
)]
unless
klass
.
descends_from_active_record?
[
through_reflection
,
reflection
].
each
do
|
ref
|
join
<<
"AND
#{
interpolate_sql
(
sanitize_sql
(
ref
.
options
[
:conditions
]))
}
"
if
ref
&&
ref
.
options
[
:conditions
]
join
<<
"AND
#{
interpolate_sql
(
sanitize_sql
(
ref
.
options
[
:conditions
]
,
aliased_table_name
))
}
"
if
ref
&&
ref
.
options
[
:conditions
]
end
join
...
...
activerecord/lib/active_record/associations/association_proxy.rb
浏览文件 @
b10fb7e7
...
...
@@ -169,8 +169,8 @@ def interpolate_sql(sql, record = nil)
end
# Forwards the call to the reflection class.
def
sanitize_sql
(
sql
)
@reflection
.
klass
.
send
(
:sanitize_sql
,
sql
)
def
sanitize_sql
(
sql
,
table_name
=
@reflection
.
klass
.
quoted_table_name
)
@reflection
.
klass
.
send
(
:sanitize_sql
,
sql
,
table_name
)
end
# Assigns the ID of the owner to the corresponding foreign key in +record+.
...
...
activerecord/lib/active_record/base.rb
浏览文件 @
b10fb7e7
...
...
@@ -2231,12 +2231,12 @@ def class_name_of_active_record_descendant(klass) #:nodoc:
# ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'"
# { :name => "foo'bar", :group_id => 4 } returns "name='foo''bar' and group_id='4'"
# "name='foo''bar' and group_id='4'" returns "name='foo''bar' and group_id='4'"
def
sanitize_sql_for_conditions
(
condition
)
def
sanitize_sql_for_conditions
(
condition
,
table_name
=
quoted_table_name
)
return
nil
if
condition
.
blank?
case
condition
when
Array
;
sanitize_sql_array
(
condition
)
when
Hash
;
sanitize_sql_hash_for_conditions
(
condition
)
when
Hash
;
sanitize_sql_hash_for_conditions
(
condition
,
table_name
)
else
condition
end
end
...
...
activerecord/test/cases/associations/has_many_associations_test.rb
浏览文件 @
b10fb7e7
...
...
@@ -719,6 +719,12 @@ def test_dependence
assert
Client
.
find
(
:all
,
:conditions
=>
"firm_id=
#{
firm
.
id
}
"
).
empty?
end
def
test_dependence_for_associations_with_hash_condition
david
=
authors
(
:david
)
post
=
posts
(
:thinking
).
id
assert_difference
(
'Post.count'
,
-
1
)
{
assert
david
.
destroy
}
end
def
test_destroy_dependent_when_deleted_from_association
firm
=
Firm
.
find
(
:first
)
assert_equal
2
,
firm
.
clients
.
size
...
...
activerecord/test/cases/associations/inner_join_association_test.rb
浏览文件 @
b10fb7e7
...
...
@@ -29,6 +29,11 @@ def test_construct_finder_sql_applies_association_conditions
assert_match
/INNER JOIN .?categories.? ON.*AND.*.?General.?.*TERMINATING_MARKER/
,
sql
end
def
test_construct_finder_sql_applies_aliases_tables_on_association_conditions
result
=
Author
.
find
(
:all
,
:joins
=>
[
:thinking_posts
,
:welcome_posts
])
assert_equal
authors
(
:david
),
result
.
first
end
def
test_construct_finder_sql_unpacks_nested_joins
sql
=
Author
.
send
(
:construct_finder_sql
,
:joins
=>
{
:posts
=>
[[
:comments
]]})
assert_no_match
/inner join.*inner join.*inner join/i
,
sql
,
"only two join clauses should be present"
...
...
activerecord/test/models/author.rb
浏览文件 @
b10fb7e7
...
...
@@ -25,6 +25,8 @@ def testing_proxy_target
has_many
:comments_with_order_and_conditions
,
:through
=>
:posts
,
:source
=>
:comments
,
:order
=>
'comments.body'
,
:conditions
=>
"comments.body like 'Thank%'"
has_many
:comments_with_include
,
:through
=>
:posts
,
:source
=>
:comments
,
:include
=>
:post
has_many
:thinking_posts
,
:class_name
=>
'Post'
,
:conditions
=>
{
:title
=>
'So I was thinking'
},
:dependent
=>
:delete_all
has_many
:welcome_posts
,
:class_name
=>
'Post'
,
:conditions
=>
{
:title
=>
'Welcome to the weblog'
}
has_many
:comments_desc
,
:through
=>
:posts
,
:source
=>
:comments
,
:order
=>
'comments.id DESC'
has_many
:limited_comments
,
:through
=>
:posts
,
:source
=>
:comments
,
:limit
=>
1
...
...
activerecord/test/models/company.rb
浏览文件 @
b10fb7e7
...
...
@@ -78,13 +78,6 @@ class DependentFirm < Company
has_many
:companies
,
:foreign_key
=>
'client_of'
,
:order
=>
"id"
,
:dependent
=>
:nullify
end
class
ExclusivelyDependentFirm
<
Company
has_one
:account
,
:foreign_key
=>
"firm_id"
,
:dependent
=>
:delete
has_many
:dependent_sanitized_conditional_clients_of_firm
,
:foreign_key
=>
"client_of"
,
:class_name
=>
"Client"
,
:order
=>
"id"
,
:dependent
=>
:delete_all
,
:conditions
=>
"name = 'BigShot Inc.'"
has_many
:dependent_conditional_clients_of_firm
,
:foreign_key
=>
"client_of"
,
:class_name
=>
"Client"
,
:order
=>
"id"
,
:dependent
=>
:delete_all
,
:conditions
=>
[
"name = ?"
,
'BigShot Inc.'
]
has_many
:dependent_hash_conditional_clients_of_firm
,
:foreign_key
=>
"client_of"
,
:class_name
=>
"Client"
,
:order
=>
"id"
,
:dependent
=>
:delete_all
,
:conditions
=>
{
:name
=>
'BigShot Inc.'
}
end
class
Client
<
Company
belongs_to
:firm
,
:foreign_key
=>
"client_of"
belongs_to
:firm_with_basic_id
,
:class_name
=>
"Firm"
,
:foreign_key
=>
"firm_id"
...
...
@@ -125,6 +118,12 @@ def private_method
end
end
class
ExclusivelyDependentFirm
<
Company
has_one
:account
,
:foreign_key
=>
"firm_id"
,
:dependent
=>
:delete
has_many
:dependent_sanitized_conditional_clients_of_firm
,
:foreign_key
=>
"client_of"
,
:class_name
=>
"Client"
,
:order
=>
"id"
,
:dependent
=>
:delete_all
,
:conditions
=>
"name = 'BigShot Inc.'"
has_many
:dependent_conditional_clients_of_firm
,
:foreign_key
=>
"client_of"
,
:class_name
=>
"Client"
,
:order
=>
"id"
,
:dependent
=>
:delete_all
,
:conditions
=>
[
"name = ?"
,
'BigShot Inc.'
]
has_many
:dependent_hash_conditional_clients_of_firm
,
:foreign_key
=>
"client_of"
,
:class_name
=>
"Client"
,
:order
=>
"id"
,
:dependent
=>
:delete_all
,
:conditions
=>
{
:name
=>
'BigShot Inc.'
}
end
class
SpecialClient
<
Client
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录