Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
4b2e16ed
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,体验更适合开发者的 AI 搜索 >>
提交
4b2e16ed
编写于
10月 12, 2010
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
all columns respond to string_to_binary, so no need to check respond_to?
上级
5b5ae01f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
5 deletion
+19
-5
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
...lib/active_record/connection_adapters/abstract/quoting.rb
+2
-2
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
...record/connection_adapters/abstract/schema_definitions.rb
+9
-0
activerecord/test/cases/quoting_test.rb
activerecord/test/cases/quoting_test.rb
+8
-3
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
浏览文件 @
4b2e16ed
...
...
@@ -14,8 +14,8 @@ def quote(value, column = nil)
value
=
value
.
to_s
return
"'
#{
quote_string
(
value
)
}
'"
unless
column
if
column
.
type
==
:binary
&&
column
.
class
.
respond_to?
(
:string_to_binary
)
"'
#{
quote_string
(
column
.
class
.
string_to_binary
(
value
))
}
'"
# ' (for ruby-mode)
if
column
.
type
==
:binary
"'
#{
quote_string
(
column
.
string_to_binary
(
value
))
}
'"
# ' (for ruby-mode)
elsif
[
:integer
,
:float
].
include?
(
column
.
type
)
(
column
.
type
==
:integer
?
value
.
to_i
:
value
.
to_f
).
to_s
else
...
...
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
浏览文件 @
4b2e16ed
...
...
@@ -114,6 +114,11 @@ 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
)
...
...
@@ -268,6 +273,10 @@ class IndexDefinition < Struct.new(:table, :name, :unique, :columns, :lengths) #
# for generating a number of table creation or table changing SQL statements.
class
ColumnDefinition
<
Struct
.
new
(
:base
,
:name
,
:type
,
:limit
,
:precision
,
:scale
,
:default
,
:null
)
#:nodoc:
def
string_to_binary
(
value
)
value
end
def
sql_type
base
.
type_to_sql
(
type
.
to_sym
,
limit
,
precision
,
scale
)
rescue
type
end
...
...
activerecord/test/cases/quoting_test.rb
浏览文件 @
4b2e16ed
...
...
@@ -3,7 +3,12 @@
module
ActiveRecord
module
ConnectionAdapters
class
QuotingTest
<
ActiveRecord
::
TestCase
class
FakeColumn
<
Struct
.
new
(
:type
)
class
FakeColumn
<
ActiveRecord
::
ConnectionAdapters
::
Column
attr_accessor
:type
def
initialize
type
@type
=
type
end
end
def
setup
...
...
@@ -190,7 +195,7 @@ def test_quote_binary_without_string_to_binary
def
test_quote_binary_with_string_to_binary
col
=
Class
.
new
(
FakeColumn
)
{
def
s
elf
.
s
tring_to_binary
(
value
)
def
string_to_binary
(
value
)
'foo'
end
}.
new
(
:binary
)
...
...
@@ -199,7 +204,7 @@ def self.string_to_binary(value)
def
test_quote_as_mb_chars_binary_column_with_string_to_binary
col
=
Class
.
new
(
FakeColumn
)
{
def
s
elf
.
s
tring_to_binary
(
value
)
def
string_to_binary
(
value
)
'foo'
end
}.
new
(
:binary
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录