Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make to private the visibility of
_quote
and _type_cast
- Loading branch information
Showing
4 changed files
with
54 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
activerecord/lib/active_record/connection_adapters/mysql/quoting.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module ActiveRecord | ||
module ConnectionAdapters | ||
module MySQL | ||
module Quoting # :nodoc: | ||
private | ||
|
||
def _quote(value) | ||
if value.is_a?(Type::Binary::Data) | ||
"x'#{value.hex}'" | ||
else | ||
super | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
32 changes: 32 additions & 0 deletions
32
activerecord/lib/active_record/connection_adapters/sqlite3/quoting.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module ActiveRecord | ||
module ConnectionAdapters | ||
module SQLite3 | ||
module Quoting # :nodoc: | ||
private | ||
|
||
def _quote(value) | ||
if value.is_a?(Type::Binary::Data) | ||
"x'#{value.hex}'" | ||
else | ||
super | ||
end | ||
end | ||
|
||
def _type_cast(value) | ||
case value | ||
when BigDecimal | ||
value.to_f | ||
when String | ||
if value.encoding == Encoding::ASCII_8BIT | ||
super(value.encode(Encoding::UTF_8)) | ||
else | ||
super | ||
end | ||
else | ||
super | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters