-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't rely on the sql type to quote XML columns in PG
- Loading branch information
Showing
5 changed files
with
56 additions
and
5 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
32 changes: 32 additions & 0 deletions
32
activerecord/lib/active_record/connection_adapters/postgresql/oid/xml.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 PostgreSQL | ||
module OID # :nodoc: | ||
class Xml < Type::String # :nodoc: | ||
def type | ||
:xml | ||
end | ||
|
||
def text? | ||
false | ||
end | ||
|
||
def type_cast_for_database(value) | ||
return unless value | ||
Data.new(super) | ||
end | ||
|
||
class Data # :nodoc: | ||
def initialize(value) | ||
@value = value | ||
end | ||
|
||
def to_s | ||
@value | ||
end | ||
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
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
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