Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
6b436c23
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,发现更多精彩内容 >>
提交
6b436c23
编写于
5月 25, 2011
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1285 from joshk/remove_active_record_deprecations
removed deprecated methods, and related tests, from ActiveRecord
上级
d25b7c2e
542114e1
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
4 addition
and
162 deletion
+4
-162
activerecord/lib/active_record/associations/builder/singular_association.rb
...ctive_record/associations/builder/singular_association.rb
+0
-13
activerecord/lib/active_record/associations/collection_proxy.rb
...record/lib/active_record/associations/collection_proxy.rb
+0
-24
activerecord/lib/active_record/base.rb
activerecord/lib/active_record/base.rb
+2
-15
activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
...ecord/connection_adapters/abstract/database_statements.rb
+2
-29
activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
...d/lib/active_record/connection_adapters/mysql2_adapter.rb
+0
-18
activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
...rd/lib/active_record/connection_adapters/mysql_adapter.rb
+0
-18
activerecord/lib/active_record/fixtures.rb
activerecord/lib/active_record/fixtures.rb
+0
-4
activerecord/lib/active_record/reflection.rb
activerecord/lib/active_record/reflection.rb
+0
-6
activerecord/test/cases/associations/has_one_associations_test.rb
...cord/test/cases/associations/has_one_associations_test.rb
+0
-9
activerecord/test/cases/associations_test.rb
activerecord/test/cases/associations_test.rb
+0
-12
activerecord/test/cases/base_test.rb
activerecord/test/cases/base_test.rb
+0
-7
activerecord/test/cases/reflection_test.rb
activerecord/test/cases/reflection_test.rb
+0
-7
未找到文件。
activerecord/lib/active_record/associations/builder/singular_association.rb
浏览文件 @
6b436c23
...
...
@@ -13,19 +13,6 @@ def define_accessors
private
def
define_readers
super
name
=
self
.
name
model
.
redefine_method
(
"
#{
name
}
_loaded?"
)
do
ActiveSupport
::
Deprecation
.
warn
(
"Calling obj.
#{
name
}
_loaded? is deprecated. Please use "
\
"obj.association(:
#{
name
}
).loaded? instead."
)
association
(
name
).
loaded?
end
end
def
define_constructors
name
=
self
.
name
...
...
activerecord/lib/active_record/associations/collection_proxy.rb
浏览文件 @
6b436c23
...
...
@@ -123,30 +123,6 @@ def new(*args, &block)
method_missing
(
:new
,
*
args
,
&
block
)
end
end
def
proxy_owner
ActiveSupport
::
Deprecation
.
warn
(
"Calling record.
#{
@association
.
reflection
.
name
}
.proxy_owner is deprecated. Please use "
\
"record.association(:
#{
@association
.
reflection
.
name
}
).owner instead."
)
@association
.
owner
end
def
proxy_target
ActiveSupport
::
Deprecation
.
warn
(
"Calling record.
#{
@association
.
reflection
.
name
}
.proxy_target is deprecated. Please use "
\
"record.association(:
#{
@association
.
reflection
.
name
}
).target instead."
)
@association
.
target
end
def
proxy_reflection
ActiveSupport
::
Deprecation
.
warn
(
"Calling record.
#{
@association
.
reflection
.
name
}
.proxy_reflection is deprecated. Please use "
\
"record.association(:
#{
@association
.
reflection
.
name
}
).reflection instead."
)
@association
.
reflection
end
end
end
end
activerecord/lib/active_record/base.rb
浏览文件 @
6b436c23
...
...
@@ -1662,9 +1662,6 @@ def attribute_names
# If any attributes are protected by either +attr_protected+ or
# +attr_accessible+ then only settable attributes will be assigned.
#
# The +guard_protected_attributes+ argument is now deprecated, use
# the +assign_attributes+ method if you want to bypass mass-assignment security.
#
# class User < ActiveRecord::Base
# attr_protected :is_admin
# end
...
...
@@ -1673,20 +1670,10 @@ def attribute_names
# user.attributes = { :username => 'Phusion', :is_admin => true }
# user.username # => "Phusion"
# user.is_admin? # => false
def
attributes
=
(
new_attributes
,
guard_protected_attributes
=
nil
)
unless
guard_protected_attributes
.
nil?
message
=
"the use of 'guard_protected_attributes' will be removed from the next major release of rails, "
+
"if you want to bypass mass-assignment security then look into using assign_attributes"
ActiveSupport
::
Deprecation
.
warn
(
message
)
end
def
attributes
=
(
new_attributes
)
return
unless
new_attributes
.
is_a?
(
Hash
)
if
guard_protected_attributes
==
false
assign_attributes
(
new_attributes
,
:without_protection
=>
true
)
else
assign_attributes
(
new_attributes
)
end
assign_attributes
(
new_attributes
)
end
# Allows you to set all the attributes for a particular mass-assignment
...
...
activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
浏览文件 @
6b436c23
require
'active_support/core_ext/module/deprecation'
module
ActiveRecord
module
ConnectionAdapters
# :nodoc:
module
DatabaseStatements
...
...
@@ -245,31 +243,6 @@ def commit_db_transaction() end
# done if the transaction block raises an exception or returns false.
def
rollback_db_transaction
()
end
# Appends +LIMIT+ and +OFFSET+ options to an SQL statement, or some SQL
# fragment that has the same semantics as LIMIT and OFFSET.
#
# +options+ must be a Hash which contains a +:limit+ option
# and an +:offset+ option.
#
# This method *modifies* the +sql+ parameter.
#
# This method is deprecated!! Stop using it!
#
# ===== Examples
# add_limit_offset!('SELECT * FROM suppliers', {:limit => 10, :offset => 50})
# generates
# SELECT * FROM suppliers LIMIT 10 OFFSET 50
def
add_limit_offset!
(
sql
,
options
)
if
limit
=
options
[
:limit
]
sql
<<
" LIMIT
#{
sanitize_limit
(
limit
)
}
"
end
if
offset
=
options
[
:offset
]
sql
<<
" OFFSET
#{
offset
.
to_i
}
"
end
sql
end
deprecate
:add_limit_offset!
def
default_sequence_name
(
table
,
column
)
nil
end
...
...
@@ -308,10 +281,10 @@ def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key)
# Sanitizes the given LIMIT parameter in order to prevent SQL injection.
#
# The +limit+ may be anything that can evaluate to a string via #to_s. It
# should look like an integer, or a comma-delimited list of integers, or
# should look like an integer, or a comma-delimited list of integers, or
# an Arel SQL literal.
#
# Returns Integer and Arel::Nodes::SqlLiteral limits as is.
# Returns Integer and Arel::Nodes::SqlLiteral limits as is.
# Returns the sanitized limit parameter, either as an integer, or as a
# string which contains a comma-delimited list of integers.
def
sanitize_limit
(
limit
)
...
...
activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
浏览文件 @
6b436c23
...
...
@@ -347,19 +347,6 @@ def release_savepoint
execute
(
"RELEASE SAVEPOINT
#{
current_savepoint_name
}
"
)
end
def
add_limit_offset!
(
sql
,
options
)
limit
,
offset
=
options
[
:limit
],
options
[
:offset
]
if
limit
&&
offset
sql
<<
" LIMIT
#{
offset
.
to_i
}
,
#{
sanitize_limit
(
limit
)
}
"
elsif
limit
sql
<<
" LIMIT
#{
sanitize_limit
(
limit
)
}
"
elsif
offset
sql
<<
" OFFSET
#{
offset
.
to_i
}
"
end
sql
end
deprecate
:add_limit_offset!
# SCHEMA STATEMENTS ========================================
def
structure_dump
...
...
@@ -582,11 +569,6 @@ def primary_key(table)
pk_and_sequence
&&
pk_and_sequence
.
first
end
def
case_sensitive_equality_operator
"= BINARY"
end
deprecate
:case_sensitive_equality_operator
def
case_sensitive_modifier
(
node
)
Arel
::
Nodes
::
Bin
.
new
(
node
)
end
...
...
activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
浏览文件 @
6b436c23
...
...
@@ -487,19 +487,6 @@ def release_savepoint
execute
(
"RELEASE SAVEPOINT
#{
current_savepoint_name
}
"
)
end
def
add_limit_offset!
(
sql
,
options
)
#:nodoc:
limit
,
offset
=
options
[
:limit
],
options
[
:offset
]
if
limit
&&
offset
sql
<<
" LIMIT
#{
offset
.
to_i
}
,
#{
sanitize_limit
(
limit
)
}
"
elsif
limit
sql
<<
" LIMIT
#{
sanitize_limit
(
limit
)
}
"
elsif
offset
sql
<<
" OFFSET
#{
offset
.
to_i
}
"
end
sql
end
deprecate
:add_limit_offset!
# SCHEMA STATEMENTS ========================================
def
structure_dump
#:nodoc:
...
...
@@ -712,11 +699,6 @@ def primary_key(table)
pk_and_sequence
&&
pk_and_sequence
.
first
end
def
case_sensitive_equality_operator
"= BINARY"
end
deprecate
:case_sensitive_equality_operator
def
case_sensitive_modifier
(
node
)
Arel
::
Nodes
::
Bin
.
new
(
node
)
end
...
...
activerecord/lib/active_record/fixtures.rb
浏览文件 @
6b436c23
...
...
@@ -12,7 +12,6 @@
require
'active_support/core_ext/object/blank'
require
'active_support/core_ext/logger'
require
'active_support/ordered_hash'
require
'active_support/core_ext/module/deprecation'
require
'active_record/fixtures/file'
if
defined?
ActiveRecord
...
...
@@ -393,9 +392,6 @@ class FixturesFileNotFound < StandardError; end
#
# Any fixture labeled "DEFAULTS" is safely ignored.
Fixture
=
ActiveSupport
::
Deprecation
::
DeprecatedConstantProxy
.
new
(
'Fixture'
,
'ActiveRecord::Fixture'
)
Fixtures
=
ActiveSupport
::
Deprecation
::
DeprecatedConstantProxy
.
new
(
'Fixtures'
,
'ActiveRecord::Fixtures'
)
module
ActiveRecord
class
Fixtures
MAX_ID
=
2
**
30
-
1
...
...
activerecord/lib/active_record/reflection.rb
浏览文件 @
6b436c23
require
'active_support/core_ext/class/attribute'
require
'active_support/core_ext/module/deprecation'
require
'active_support/core_ext/object/inclusion'
module
ActiveRecord
...
...
@@ -202,11 +201,6 @@ def foreign_key
@foreign_key
||=
options
[
:foreign_key
]
||
derive_foreign_key
end
def
primary_key_name
foreign_key
end
deprecate
:primary_key_name
=>
:foreign_key
def
foreign_type
@foreign_type
||=
options
[
:foreign_type
]
||
"
#{
name
}
_type"
end
...
...
activerecord/test/cases/associations/has_one_associations_test.rb
浏览文件 @
6b436c23
...
...
@@ -370,15 +370,6 @@ def test_replacement_failure_due_to_new_record_should_raise_error
assert_nil
new_ship
.
pirate_id
end
def
test_deprecated_association_loaded
firm
=
companies
(
:first_firm
)
firm
.
association
(
:account
).
stubs
(
:loaded?
).
returns
(
stub
)
assert_deprecated
do
assert_equal
firm
.
association
(
:account
).
loaded?
,
firm
.
account_loaded?
end
end
def
test_association_keys_bypass_attribute_protection
car
=
Car
.
create
(
:name
=>
'honda'
)
...
...
activerecord/test/cases/associations_test.rb
浏览文件 @
6b436c23
...
...
@@ -203,18 +203,6 @@ def test_reload_returns_assocition
assert_equal
david
.
projects
,
david
.
projects
.
reload
.
reload
end
end
# Tests that proxy_owner, proxy_target and proxy_reflection are implement as deprecated methods
def
test_proxy_deprecations
david
=
developers
(
:david
)
david
.
projects
.
load_target
[
:owner
,
:target
,
:reflection
].
each
do
|
name
|
assert_deprecated
do
assert_equal
david
.
association
(
:projects
).
send
(
name
),
david
.
projects
.
send
(
"proxy_
#{
name
}
"
)
end
end
end
end
class
OverridingAssociationsTest
<
ActiveRecord
::
TestCase
...
...
activerecord/test/cases/base_test.rb
浏览文件 @
6b436c23
...
...
@@ -502,13 +502,6 @@ def test_non_valid_identifier_column_name
assert_equal
'value2'
,
weird
.
send
(
'a$b'
)
end
def
test_attributes_guard_protected_attributes_is_deprecated
attributes
=
{
"title"
=>
"An amazing title"
}
post
=
ProtectedTitlePost
.
new
assert_deprecated
{
post
.
send
(
:attributes
=
,
attributes
,
false
)
}
assert_equal
"An amazing title"
,
post
.
title
end
def
test_multiparameter_attributes_on_date
attributes
=
{
"last_read(1i)"
=>
"2004"
,
"last_read(2i)"
=>
"6"
,
"last_read(3i)"
=>
"24"
}
topic
=
Topic
.
find
(
1
)
...
...
activerecord/test/cases/reflection_test.rb
浏览文件 @
6b436c23
...
...
@@ -304,13 +304,6 @@ def test_foreign_key
assert_equal
"category_id"
,
Post
.
reflect_on_association
(
:categorizations
).
foreign_key
.
to_s
end
def
test_primary_key_name
assert_deprecated
do
assert_equal
"author_id"
,
Author
.
reflect_on_association
(
:posts
).
primary_key_name
.
to_s
assert_equal
"category_id"
,
Post
.
reflect_on_association
(
:categorizations
).
primary_key_name
.
to_s
end
end
private
def
assert_reflection
(
klass
,
association
,
options
)
assert
reflection
=
klass
.
reflect_on_association
(
association
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录