Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
0472839d
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,发现更多精彩内容 >>
提交
0472839d
编写于
8月 10, 2009
作者:
T
Tristan Dunn
提交者:
Pratik Naik
8月 10, 2009
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prevent overwriting of table name in merging SQL conditions [#2949 state:resolved]
上级
00d6c766
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
14 addition
and
2 deletion
+14
-2
activerecord/lib/active_record/base.rb
activerecord/lib/active_record/base.rb
+3
-1
activerecord/test/cases/named_scope_test.rb
activerecord/test/cases/named_scope_test.rb
+6
-0
activerecord/test/models/comment.rb
activerecord/test/models/comment.rb
+5
-1
未找到文件。
activerecord/lib/active_record/base.rb
浏览文件 @
0472839d
...
...
@@ -2294,10 +2294,12 @@ def expand_hash_conditions_for_aggregates(attrs)
# And for value objects on a composed_of relationship:
# { :address => Address.new("123 abc st.", "chicago") }
# # => "address_street='123 abc st.' and address_city='chicago'"
def
sanitize_sql_hash_for_conditions
(
attrs
,
table_name
=
quoted_table_name
)
def
sanitize_sql_hash_for_conditions
(
attrs
,
default_
table_name
=
quoted_table_name
)
attrs
=
expand_hash_conditions_for_aggregates
(
attrs
)
conditions
=
attrs
.
map
do
|
attr
,
value
|
table_name
=
default_table_name
unless
value
.
is_a?
(
Hash
)
attr
=
attr
.
to_s
...
...
activerecord/test/cases/named_scope_test.rb
浏览文件 @
0472839d
...
...
@@ -368,6 +368,12 @@ def test_named_scopes_batch_finders
end
end
end
def
test_table_names_for_chaining_scopes_with_and_without_table_name_included
assert_nothing_raised
do
Comment
.
for_first_post
.
for_first_author
.
all
end
end
end
class
DynamicScopeMatchTest
<
ActiveRecord
::
TestCase
...
...
activerecord/test/models/comment.rb
浏览文件 @
0472839d
class
Comment
<
ActiveRecord
::
Base
named_scope
:containing_the_letter_e
,
:conditions
=>
"comments.body LIKE '%e%'"
named_scope
:for_first_post
,
:conditions
=>
{
:post_id
=>
1
}
named_scope
:for_first_author
,
:joins
=>
:post
,
:conditions
=>
{
"posts.author_id"
=>
1
}
belongs_to
:post
,
:counter_cache
=>
true
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录