1

我在:
Windows XP
MSSQL 2005
Rails 3.0.9
activerecord-sqlserver-adapter
tinytds

当我尝试检索具有 xml 类型的字段内容时,我遇到了 xml 字符串被剪切的问题。

提前感谢您的帮助

这是存储在 DB 中的 xml(对不起,俄语字母):

<application>
  <patent-type>Заявка на винахід</patent-type>
  <title>WAY</title>
  <native-number>inner123</native-number>
  <inid51 type="array" />
  <inid54>
    <x54-title-ukr>WAY</x54-title-ukr>
    <x54-title-rus />
    <x54-title-eng />
  </inid54>
  <applicants type="array">
    <applicant order="1">
      <app-person>physical</app-person>
      <app-name-ukr>Drobyazko Ob Ob</app-name-ukr>
      <app-addr-ukr>Ukrainka</app-addr-ukr>
      <app-country>UA</app-country>
      <app-kzo />
      <app-name-rus />
      <app-addr-rus />
      <app-name-eng />
      <app-addr-eng />
    </applicant>
    <applicant order="2">
      <app-person>physical</app-person>
      <app-name-ukr>Stetsenko Ser Vol</app-name-ukr>
      <app-addr-ukr>Kyiv</app-addr-ukr>
      <app-country>UA</app-country>
      <app-kzo />
      <app-name-rus />
      <app-addr-rus />
      <app-name-eng />
      <app-addr-eng />
    </applicant>
  </applicants>
  <inventors type="array">
    <inventor order="1">
      <inv-name-ukr>Drobyazko Ob Ob</inv-name-ukr>
      <inv-addr-ukr>Ukrainka</inv-addr-ukr>
      <inv-country>UA</inv-country>
      <inv-publ>Ні</inv-publ>
      <inv-name-rus />
      <inv-addr-rus />
      <inv-name-eng />
      <inv-addr-eng />
    </inventor>
    <inventor order="2">
      <inv-name-ukr>Stetsenko Ser Vol</inv-name-ukr>
      <inv-addr-ukr>Kyiv</inv-addr-ukr>
      <inv-country>UA</inv-country>
      <inv-publ>Ні</inv-publ>
      <inv-name-rus />
      <inv-addr-rus />
      <inv-name-eng />
      <inv-addr-eng />
    </inventor>
  </inventors>
  <priorities>
    <priority-cfg>
      <type>prr-none</type>
      <prr-date />
      <prr-numb />
      <is-priority-3x />
      <is-priority-62 />
      <is-priority-66 />
    </priority-cfg>
    <priority-3x type="array" />
    <priority-62 type="array" />
    <priority-66 type="array" />
  </priorities>
  <inid86>
    <x86-numb />
    <x86-date />
  </inid86>
  <inid87>
    <x87-numb />
    <x87-date />
  </inid87>
  <representative>
    <repr-name>Drobyazko Ooo KKK</repr-name>
    <repr-regnum>200</repr-regnum>
    <repr-person>legal</repr-person>
  </representative>
  <address>
    <addr-country>UA</addr-country>
    <addr-zipcode />
    <addr-region />
    <addr-town-type>м.</addr-town-type>
    <addr-town-val>Kyiv</addr-town-val>
    <addr-rayon />
    <addr-street-type>вул.</addr-street-type>
    <addr-street-val />
    <addr-building-type>буд.</addr-building-type>
    <addr-building-val />
    <addr-room-type>кв.</addr-room-type>
    <addr-room-val />
    <addr-addressee-person>physical</addr-addressee-person>
    <addr-addressee>Drobyazko Dkkd Lll</addr-addressee>
    <addr-tel>2323232</addr-tel>
    <addr-fax />
    <addr-email />
    <full-address>м. Kyiv, UA; Drobyazko Dkkd Lll</full-address>
  </address>
  <flags>
    <force-publication />
    <patent-foreign />
  </flags>
</application>

使用Eclaim.find(1).app_xml我得到了上述字段的内容。
我也在将 xml 字段写入文件File.open("c:/w.txt", 'wb') { |f| f.write Eclaim.find(100003).app_xml }

文件内容(大小2070字节)为:

<application><patent-type>Заявка на винахід&lt;/patent-type><title>WAY</title><native-number>inner123</native-number><inid51 type="array"/><inid54><x54-title-ukr>WAY2</x54-title-ukr><x54-title-rus/><x54-title-eng/></inid54><applicants type="array"><applicant order="1"><app-person>physical</app-person><app-name-ukr>Drobyazko Ob Ob</app-name-ukr><app-addr-ukr>Ukrainka</app-addr-ukr><app-country>UA</app-country><app-kzo/><app-name-rus/><app-addr-rus/><app-name-eng/><app-addr-eng/></applicant><applicant order="2"><app-person>physical</app-person><app-name-ukr>Stetsenko Ser Vol</app-name-ukr><app-addr-ukr>Kyiv</app-addr-ukr><app-country>UA</app-country><app-kzo/><app-name-rus/><app-addr-rus/><app-name-eng/><app-addr-eng/></applicant></applicants><inventors type="array"><inventor order="1"><inv-name-ukr>Drobyazko Ob Ob</inv-name-ukr><inv-addr-ukr>Ukrainka</inv-addr-ukr><inv-country>UA</inv-country><inv-publ>Ні&lt;/inv-publ><inv-name-rus/><inv-addr-rus/><inv-name-eng/><inv-addr-eng/></inventor><inventor order="2"><inv-name-ukr>Stetsenko Ser Vol</inv-name-ukr><inv-addr-ukr>Kyiv</inv-addr-ukr><inv-country>UA</inv-country><inv-publ>Ні&lt;/inv-publ><inv-name-rus/><inv-addr-rus/><inv-name-eng/><inv-addr-eng/></inventor></inventors><priorities><priority-cfg><type>prr-none</type><prr-date/><prr-numb/><is-priority-3x/><is-priority-62/><is-priority-66/></priority-cfg><priority-3x type="array"/><priority-62 type="array"/><priority-66 type="array"/></priorities><inid86><x86-numb/><x86-date/></inid86><inid87><x87-numb/><x87-date/></inid87><representative><repr-name>Drobyazko Ooo KKK</repr-name><repr-regnum>200</repr-regnum><repr-person>legal</repr-person></representative><address><addr-country>UA</addr-country><addr-zipcode/><addr-region/><addr-town-type>м.</addr-town-type><addr-town-val>Kyiv</addr-town-val><addr-rayon/><addr-street-type>вул.</addr-street-type><addr-street-val/><addr-building-type>буд.</addr-building-type><addr-building-val/><addr-room-type>кв.</addr-room-type><addr-room-val/><addr-addressee-person>physical</addr-addressee-

看起来 Rails 将 xml 字段的内容截断为2070字节。

有人可以帮助我吗?

4

1 回答 1

2

我经常看到这个问题,并且有一个非常简单的答案。SQL Server 有一个名为 TEXTSIZE (1) 的设置,该设置为 DBLIB/TinyTDS 连接设置为相对较小的大小。最近我在这里让适配器将其设置为模拟默认 ODBC 连接 (2) 的大小。我们的 README (3) 中还有一个部分用于旧版本的适配器,允许您配置连接,以便您也可以设置 TEXTSIZE。

于 2012-05-11T11:11:12.567 回答