Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

model.to_xml does not generate all type attributes

#1587

I noticed the to_xml method does not generate type attributes for all the elements for a given model. For example,

Model:

<person> <created-at type="datetime">2008-08-16T17:28:19Z</created-at> <description>This is a test</description> <id type="integer">1</id> <name>Conrad</name> <updated-at type="datetime">2008-08-16T17:28:19Z</updated-at> </person>

Collection:

<people type="array"> <person>

<created-at type="datetime">2008-08-16T17:28:19Z</created-at>
<description>This is a test</description>
<id type="integer">1</id>
<name>Conrad</name>
<updated-at type="datetime">2008-08-16T17:28:19Z</updated-at>

<created-at type="datetime">2008-09-27T23:25:40Z</created-at>
<description>This is yet another test 2.</description>
<id type="integer">2</id>
<name>Conrad Taylor</name>
<updated-at type="datetime">2008-09-27T23:26:02Z</updated-at>

BTW, name is a "string" field and description is a "text" field. It appears that the :skip_type => false is the default behavior from the documentation.

Reported by Conrad Taylor · December 17th, 2008 @ 02:14 PM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Frederick Cheung
    Frederick Cheung

    What where you expecting ? and ?

    December 18th, 2008 @ 12:38 AM

  2. Conrad Taylor
    Conrad Taylor

    I was expecting to see the following for the name and description elements:

    <people>

    <person>
    
      <description type="text" >This is a test</description>
    
      ...
    
      <name type="string">Conrad</name>
    
    </person>
    
    
    <description type="text">This is yet another test 2.</description>
    
    ...
    
    <name type="string">Conrad</name>
    
    

    December 20th, 2008 @ 04:10 AM

  3. Frederick Cheung
    Frederick Cheung

    They're both just plain text data. the type atribute isn't supposed to replicate the database schema, ie you see integer not bigint(12) so that whatever is reading the xml knows how to interpret the plain text content. In the case where the content is just plain text we don't need to say anything.

    December 20th, 2008 @ 11:09 AM

  4. Conrad Taylor
    Conrad Taylor

    OK, why do we have some type attributes for some elements and no type attributes for others? Next, the generated XML appears to simply display what's contained in the schema.rb file. The :skip_type option is set to false by default from reading the documentation. In any case, I was thinking about using this generated XML file with it's type attribute to populate a Gemstone/S database.

    December 20th, 2008 @ 12:51 PM

  5. Frederick Cheung
    Frederick Cheung

    I believe the only type without attributes are the ones which are purely textual in nature (and if you look at the source this is quite deliberate). I know nothing about gemstone/S but when loading a record does it really care about whether the value came from a text column or a varchar column ?

    December 20th, 2008 @ 01:57 PM

  6. Conrad Taylor
    Conrad Taylor

    Why even define the type attribute when generating XML? The type of an XML field can be determined or selected from an XML Schema.

    December 20th, 2008 @ 02:59 PM

  7. Frederick Cheung
    Frederick Cheung

    That's why skip_types is there I suppose. On the other why not be helpful when there is no xsd / client doesn't support xsd/ you can't be bother with an xsd.

    December 21st, 2008 @ 10:58 AM

  8. Conrad Taylor
  9. Pratik
    Pratik
    • State changed from new to invalid

    Please reopen if this is an open issue.

    January 18th, 2009 @ 05:50 AM