This project is archived and is in readonly mode.
Add short-hand definition for PostgreSQL XML data type
-
Pratik
- Assigned user set to Tarmo Tänav
-
Leonardo Borges
- Tag set to patch
Added proper patch diff to show the changes. Also the patch includes fix for the schema dumping.
It was dumping as:
t.string
instead of:
t.xml
-
Tarmo Tänav
Shouldn't there be a fallback for other databases that don't have an XML type, so that a migration that in PostgreSQL uses xml falls back to string for example on mysql?
-
Leonardo Borges
I guess that depends.
Attached is a possible solution within the same diff.
This falls back to the sqltype :text for mysql and sqlite if trying to use the XML datatype. I chose :text as the default because if you're coming from a DB that supports XML, it's likely your data exceeds the limit of a varchar column, which is the one string defaults to.
Also, other databases, such as oracle, have different types to handle such content. In fact, Oracle has a XML dataype which is named differently.
My feeling is that moving away from a XML column shouldn't be that transparent because in such cases you're doing it for a very specific reason, such as spreading the XML content overr relational tables, in which case the former XML column would be dropped, or storing it as text for further processing, in which case, each database data type should be analyzed carefully to find a suitable match for the content.
-
Leonardo Borges
Small update to the patch.
I forgot to add xml to the NATIVE_DATABASE_TYPES hash.
With this change, this is the fully working patch I'm using here.
-
Pedro Pimentel (zukunftsalick)
I agree with Leonardo when he says you don´t need to be transparent in such cases, because for most of cases are situations where you are just moving away from XML and just want to keep the xml data column for legacy reasons.
We need to remember that RAILS is a opinionated framework and I believe it´s fair to have that assumptions for this patch.
-
Philip MacIver
I think that this change needs to be applied. Also I have used it and it works fine. Also I created a 1 character fix so that escape characters within xml that is saved to the database in postgres get converted properly without throwing any deprecation warnings.
-
Xavier Noria
I've worked with this patch for a couple of weeks. It works smoothly once Philip's is applied.
I think this is a nice addition. Note that is consistent with TableDefinition#column, which is open by design to custom datatypes.
A formal detail: I'd like the new arrow in the native datatype listing to be aligned with the rest.
-
Pratik
You should rebase all the patches into a single patch. And also, needs some tests.
-
Leonardo Borges
Combined changes in a single patch and added tests.
-
Leonardo Borges
So is it missing anything in the patch?
Just wondering is you had time to take a look at it.
Tks
-
CancelProfileIsBroken
- Tag changed from patch to bugmash, patch
-
Nikolay Petrachkov
I applied this above patch to master. No new fail test.
I've attached patch for master branch. -
Jeremy Kemper
- Assigned user changed from Tarmo Tänav to Jeremy Kemper
- State changed from new to open
- Milestone changed from 2.x to 2.3.4
Please avoid making whitespace changes in the same commit as a major feature. It makes merging difficult.
-
Jeremy Kemper
- State changed from open to committed
- Tag changed from bugmash, patch to patch
-
Repository
(from [0c391b46fb39b697bbae1493caade23e2ddbd8a6]) PostgreSQL: XML datatype support
[#1874 Add short-hand definition for PostgreSQL XML data type state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/0c391b46fb39b697bbae1493caade2... -
Repository
(from [5c74cffae66be19418e7d99e08eae0c5beeb3134]) PostgreSQL: XML datatype support
[#1874 Add short-hand definition for PostgreSQL XML data type state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/5c74cffae66be19418e7d99e08eae0...
