Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
4f5f59a4
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,发现更多精彩内容 >>
提交
4f5f59a4
编写于
8月 09, 2013
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11820 from vipulnsward/remove_s2b
Remove redundant `string_to_binary` from type-casting
上级
0053b2a1
5ef02de1
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
4 addition
and
37 deletion
+4
-37
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
...lib/active_record/connection_adapters/abstract/quoting.rb
+0
-1
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
...record/connection_adapters/abstract/schema_definitions.rb
+0
-3
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
...tive_record/connection_adapters/abstract_mysql_adapter.rb
+2
-2
activerecord/lib/active_record/connection_adapters/column.rb
activerecord/lib/active_record/connection_adapters/column.rb
+0
-10
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
.../lib/active_record/connection_adapters/sqlite3_adapter.rb
+2
-2
activerecord/test/cases/quoting_test.rb
activerecord/test/cases/quoting_test.rb
+0
-19
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
浏览文件 @
4f5f59a4
...
...
@@ -15,7 +15,6 @@ def quote(value, column = nil)
return
"'
#{
quote_string
(
value
)
}
'"
unless
column
case
column
.
type
when
:binary
then
"'
#{
quote_string
(
column
.
string_to_binary
(
value
))
}
'"
when
:integer
then
value
.
to_i
.
to_s
when
:float
then
value
.
to_f
.
to_s
else
...
...
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
浏览文件 @
4f5f59a4
...
...
@@ -16,9 +16,6 @@ class IndexDefinition < Struct.new(:table, :name, :unique, :columns, :lengths, :
# +columns+ attribute of said TableDefinition object, in order to be used
# for generating a number of table creation or table changing SQL statements.
class
ColumnDefinition
<
Struct
.
new
(
:name
,
:type
,
:limit
,
:precision
,
:scale
,
:default
,
:null
,
:first
,
:after
,
:primary_key
)
#:nodoc:
def
string_to_binary
(
value
)
value
end
def
primary_key?
primary_key
||
type
.
to_sym
==
:primary_key
...
...
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
浏览文件 @
4f5f59a4
...
...
@@ -246,8 +246,8 @@ def error_number(exception) # :nodoc:
# QUOTING ==================================================
def
quote
(
value
,
column
=
nil
)
if
value
.
kind_of?
(
String
)
&&
column
&&
column
.
type
==
:binary
&&
column
.
class
.
respond_to?
(
:string_to_binary
)
s
=
column
.
class
.
string_to_binary
(
value
)
.
unpack
(
"H*"
)[
0
]
if
value
.
kind_of?
(
String
)
&&
column
&&
column
.
type
==
:binary
s
=
value
.
unpack
(
"H*"
)[
0
]
"x'
#{
s
}
'"
elsif
value
.
kind_of?
(
BigDecimal
)
value
.
to_s
(
"F"
)
...
...
activerecord/lib/active_record/connection_adapters/column.rb
浏览文件 @
4f5f59a4
...
...
@@ -119,17 +119,7 @@ def extract_default(default)
type_cast
(
default
)
end
# Used to convert from Strings to BLOBs
def
string_to_binary
(
value
)
self
.
class
.
string_to_binary
(
value
)
end
class
<<
self
# Used to convert from Strings to BLOBs
def
string_to_binary
(
value
)
value
end
# Used to convert from BLOBs to Strings
def
binary_to_string
(
value
)
value
...
...
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
浏览文件 @
4f5f59a4
...
...
@@ -226,8 +226,8 @@ def supports_explain?
# QUOTING ==================================================
def
quote
(
value
,
column
=
nil
)
if
value
.
kind_of?
(
String
)
&&
column
&&
column
.
type
==
:binary
&&
column
.
class
.
respond_to?
(
:string_to_binary
)
s
=
column
.
class
.
string_to_binary
(
value
)
.
unpack
(
"H*"
)[
0
]
if
value
.
kind_of?
(
String
)
&&
column
&&
column
.
type
==
:binary
s
=
value
.
unpack
(
"H*"
)[
0
]
"x'
#{
s
}
'"
else
super
...
...
activerecord/test/cases/quoting_test.rb
浏览文件 @
4f5f59a4
...
...
@@ -184,25 +184,6 @@ def test_quote_binary_without_string_to_binary
assert_equal
"'lo
\\\\
l'"
,
@quoter
.
quote
(
'lo\l'
,
FakeColumn
.
new
(
:binary
))
end
def
test_quote_binary_with_string_to_binary
col
=
Class
.
new
(
FakeColumn
)
{
def
string_to_binary
(
value
)
'foo'
end
}.
new
(
:binary
)
assert_equal
"'foo'"
,
@quoter
.
quote
(
'lo\l'
,
col
)
end
def
test_quote_as_mb_chars_binary_column_with_string_to_binary
col
=
Class
.
new
(
FakeColumn
)
{
def
string_to_binary
(
value
)
'foo'
end
}.
new
(
:binary
)
string
=
ActiveSupport
::
Multibyte
::
Chars
.
new
(
'lo\l'
)
assert_equal
"'foo'"
,
@quoter
.
quote
(
string
,
col
)
end
def
test_string_with_crazy_column
assert_equal
"'lo
\\\\
l'"
,
@quoter
.
quote
(
'lo\l'
,
FakeColumn
.
new
(
:foo
))
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录