Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
4a064895
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,发现更多精彩内容 >>
提交
4a064895
编写于
7月 14, 2010
作者:
P
Pratik Naik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Style fixes
上级
b7944e1b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
24 deletion
+22
-24
activerecord/lib/active_record/base.rb
activerecord/lib/active_record/base.rb
+1
-1
activerecord/lib/active_record/relation/query_methods.rb
activerecord/lib/active_record/relation/query_methods.rb
+20
-20
activerecord/test/cases/base_test.rb
activerecord/test/cases/base_test.rb
+1
-3
未找到文件。
activerecord/lib/active_record/base.rb
浏览文件 @
4a064895
...
...
@@ -1471,7 +1471,7 @@ def []=(attr_name, value)
# user.send(:attributes=, { :username => 'Phusion', :is_admin => true }, false)
# user.is_admin? # => true
def
attributes
=
(
new_attributes
,
guard_protected_attributes
=
true
)
return
unless
new_attributes
.
is_a?
Hash
return
unless
new_attributes
.
is_a?
(
Hash
)
attributes
=
new_attributes
.
stringify_keys
multi_parameter_attributes
=
[]
...
...
activerecord/lib/active_record/relation/query_methods.rb
浏览文件 @
4a064895
...
...
@@ -11,84 +11,84 @@ module QueryMethods
def
includes
(
*
args
)
args
.
reject!
{
|
a
|
a
.
blank?
}
clone
.
tap
{
|
r
|
r
.
includes_values
+=
args
if
args
.
present?
}
clone
.
tap
{
|
r
|
r
.
includes_values
+=
args
if
args
.
present?
}
end
def
eager_load
(
*
args
)
clone
.
tap
{
|
r
|
r
.
eager_load_values
+=
args
if
args
.
present?
}
clone
.
tap
{
|
r
|
r
.
eager_load_values
+=
args
if
args
.
present?
}
end
def
preload
(
*
args
)
clone
.
tap
{
|
r
|
r
.
preload_values
+=
args
if
args
.
present?
}
clone
.
tap
{
|
r
|
r
.
preload_values
+=
args
if
args
.
present?
}
end
def
select
(
*
args
)
if
block_given?
to_a
.
select
{
|*
block_args
|
yield
(
*
block_args
)
}
to_a
.
select
{
|*
block_args
|
yield
(
*
block_args
)
}
else
clone
.
tap
{
|
r
|
r
.
select_values
+=
args
if
args
.
present?
}
clone
.
tap
{
|
r
|
r
.
select_values
+=
args
if
args
.
present?
}
end
end
def
group
(
*
args
)
clone
.
tap
{
|
r
|
r
.
group_values
+=
args
if
args
.
present?
}
clone
.
tap
{
|
r
|
r
.
group_values
+=
args
if
args
.
present?
}
end
def
order
(
*
args
)
clone
.
tap
{
|
r
|
r
.
order_values
+=
args
if
args
.
present?
}
clone
.
tap
{
|
r
|
r
.
order_values
+=
args
if
args
.
present?
}
end
def
reorder
(
*
args
)
clone
.
tap
{
|
r
|
r
.
order_values
=
args
if
args
.
present?
}
clone
.
tap
{
|
r
|
r
.
order_values
=
args
if
args
.
present?
}
end
def
joins
(
*
args
)
args
.
flatten!
clone
.
tap
{
|
r
|
r
.
joins_values
+=
args
if
args
.
present?
}
clone
.
tap
{
|
r
|
r
.
joins_values
+=
args
if
args
.
present?
}
end
def
where
(
*
args
)
value
=
build_where
(
*
args
)
clone
.
tap
{
|
r
|
r
.
where_values
+=
Array
.
wrap
(
value
)
if
value
.
present?
}
clone
.
tap
{
|
r
|
r
.
where_values
+=
Array
.
wrap
(
value
)
if
value
.
present?
}
end
def
having
(
*
args
)
value
=
build_where
(
*
args
)
clone
.
tap
{
|
r
|
r
.
having_values
+=
Array
.
wrap
(
value
)
if
value
.
present?
}
clone
.
tap
{
|
r
|
r
.
having_values
+=
Array
.
wrap
(
value
)
if
value
.
present?
}
end
def
limit
(
value
=
true
)
clone
.
tap
{
|
r
|
r
.
limit_value
=
value
}
clone
.
tap
{
|
r
|
r
.
limit_value
=
value
}
end
def
offset
(
value
=
true
)
clone
.
tap
{
|
r
|
r
.
offset_value
=
value
}
clone
.
tap
{
|
r
|
r
.
offset_value
=
value
}
end
def
lock
(
locks
=
true
)
case
locks
when
String
,
TrueClass
,
NilClass
clone
.
tap
{
|
r
|
r
.
lock_value
=
locks
||
true
}
clone
.
tap
{
|
r
|
r
.
lock_value
=
locks
||
true
}
else
clone
.
tap
{
|
r
|
r
.
lock_value
=
false
}
clone
.
tap
{
|
r
|
r
.
lock_value
=
false
}
end
end
def
readonly
(
value
=
true
)
clone
.
tap
{
|
r
|
r
.
readonly_value
=
value
}
clone
.
tap
{
|
r
|
r
.
readonly_value
=
value
}
end
def
create_with
(
value
=
true
)
clone
.
tap
{
|
r
|
r
.
create_with_value
=
value
}
clone
.
tap
{
|
r
|
r
.
create_with_value
=
value
}
end
def
from
(
value
=
true
)
clone
.
tap
{
|
r
|
r
.
from_value
=
value
}
clone
.
tap
{
|
r
|
r
.
from_value
=
value
}
end
def
extending
(
*
modules
,
&
block
)
modules
<<
Module
.
new
(
&
block
)
if
block_given?
clone
.
tap
{
|
r
|
r
.
send
(
:apply_modules
,
*
modules
)
}
clone
.
tap
{
|
r
|
r
.
send
(
:apply_modules
,
*
modules
)
}
end
def
reverse_order
...
...
@@ -230,7 +230,7 @@ def build_select(arel, selects)
@implicit_readonly
=
false
# TODO: fix this ugly hack, we should refactor the callers to get an ARel compatible array.
# Before this change we were passing to ARel the last element only, and ARel is capable of handling an array
if
selects
.
all?
{
|
s
|
s
.
is_a?
(
String
)
||
!
s
.
is_a?
(
Arel
::
Expression
)
}
&&
!
(
selects
.
last
=~
/^COUNT\(/
)
if
selects
.
all?
{
|
s
|
s
.
is_a?
(
String
)
||
!
s
.
is_a?
(
Arel
::
Expression
)
}
&&
!
(
selects
.
last
=~
/^COUNT\(/
)
arel
.
project
(
*
selects
)
else
arel
.
project
(
selects
.
last
)
...
...
activerecord/test/cases/base_test.rb
浏览文件 @
4a064895
...
...
@@ -63,9 +63,7 @@ def test_set_attributes
def
test_set_attributes_without_hash
topic
=
Topic
.
new
assert_nothing_raised
do
topic
.
attributes
=
''
end
assert_nothing_raised
{
topic
.
attributes
=
''
}
end
def
test_integers_as_nil
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录