Changeset 181

Show
Ignore:
Timestamp:
09/02/08 11:54:14 (4 months ago)
Author:
zork
Message:

last added node was not reset after collection store

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dba/dba/xmlostream.cpp

    r180 r181  
    197197  if (mParentNode != xmlDocGetRootElement(mDocument)) { 
    198198    debug("up from mParent '%s'", (const char*)mParentNode->name); 
     199    mLastAddedNode = mParentNode; 
    199200    mParentNode = mParentNode->parent; 
    200201  }; 
  • trunk/dba/test/main.cpp

    r180 r181  
    151151  //runner.addTest(new CppUnit::TestCaller<SQLite3SQLArchiveTestCase>("debug_test",&SQLite3SQLArchiveTestCase::transactions_rollback)); 
    152152  //runner.addTest(dba_tests::XMLTestCase::suite()); 
    153   //runner.addTest(new CppUnit::TestCaller<dba_tests::XMLTestCase>("debug_test",&dba_tests::XMLTestCase::storeBug3)); 
     153  //runner.addTest(new CppUnit::TestCaller<dba_tests::XMLTestCase>("debug_test",&dba_tests::XMLTestCase::storeBug4)); 
    154154  //runner.addTest(new CppUnit::TestCaller<dba_tests::XMLTestCase>("debug_test",&dba_tests::XMLTestCase::store_two)); 
    155155  //runner.addTest(new CppUnit::TestCaller<OdbcPluginTestCase>("debug_test",&OdbcPluginTestCase::dbConnection)); 
  • trunk/dba/test/xmltestcase.cpp

    r180 r181  
    10281028 
    10291029 
     1030struct bug4_A : public dba::Storeable { 
     1031  DECLARE_STORE_TABLE(); 
     1032};  
     1033BEGIN_STORE_TABLE(bug4_A, dba::Storeable, "A") 
     1034END_STORE_TABLE() 
     1035 
     1036struct bug4_B : public dba::Storeable { 
     1037  DECLARE_STORE_TABLE(); 
     1038}; 
     1039BEGIN_STORE_TABLE(bug4_B, dba::Storeable, "B") 
     1040END_STORE_TABLE() 
     1041 
     1042struct bug4_B_Full : public bug4_B { 
     1043  std::list<bug4_A> mAItems; 
     1044  DECLARE_STORE_TABLE(); 
     1045}; 
     1046BEGIN_STORE_TABLE(bug4_B_Full, bug4_B, "B") 
     1047BIND_COL(bug4_B_Full::mAItems, dba::stdList<bug4_A>, NULL) 
     1048END_STORE_TABLE() 
     1049 
     1050struct bug4_C : public dba::Storeable { 
     1051  bug4_B_Full mB; 
     1052  DECLARE_STORE_TABLE(); 
     1053}; 
     1054BEGIN_STORE_TABLE(bug4_C, dba::Storeable, "C") 
     1055BIND_COL(mB, dba::Single, NULL) 
     1056END_STORE_TABLE() 
     1057 
     1058struct bug4_D : public dba::Storeable { 
     1059  bug4_D() { 
     1060    bug4_C c1; 
     1061    bug4_A c1a1; 
     1062    bug4_A c1a2; 
     1063    c1.mB.mAItems.push_back(c1a1); 
     1064    c1.mB.mAItems.push_back(c1a2); 
     1065    mCItems.push_back(c1); 
     1066    bug4_C c2; 
     1067    mCItems.push_back(c2); 
     1068    bug4_C c3; 
     1069    mCItems.push_back(c3); 
     1070  } 
     1071  std::list<bug4_C> mCItems; 
     1072  DECLARE_STORE_TABLE(); 
     1073};  
     1074BEGIN_STORE_TABLE(bug4_D, dba::Storeable, "D") 
     1075BIND_COL(mCItems, dba::stdList<bug4_C>, NULL) 
     1076END_STORE_TABLE() 
     1077 
     1078void 
     1079XMLTestCase::storeBug4() { 
     1080  /* bug: the result is: 
     1081  <D> 
     1082    <C> 
     1083      <C> 
     1084        <B/> 
     1085      </C> 
     1086      <C> 
     1087        <B/> 
     1088      </C> 
     1089      <B> 
     1090        <A/> 
     1091        <A/> 
     1092      </B> 
     1093    </C> 
     1094  </D> 
     1095  */ 
     1096 
     1097  /** 
     1098    Note: the problem is caused by the fact that B is splitted (bug3_B & bug3_B_Full) 
     1099  */ 
     1100 
     1101  const char* result =  
     1102    "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 
     1103    "<D>\n" 
     1104    "  <C>\n" 
     1105    "    <B/>\n" 
     1106    "  </C>\n" 
     1107    "  <C>\n" 
     1108    "    <B/>\n" 
     1109    "  </C>\n" 
     1110    "  <C>\n" 
     1111    "    <B>\n" 
     1112    "      <A/>\n" 
     1113    "      <A/>\n" 
     1114    "    </B>\n" 
     1115    "  </C>\n" 
     1116    "</D>\n" 
     1117    ; 
     1118  { 
     1119    dba::XMLArchive ar; 
     1120    ar.setRootNodeName(NULL); 
     1121    ar.useElements(); 
     1122    bug4_D obj; 
     1123    unlink("storebug4.xml"); 
     1124    ar.open("storebug4.xml"); 
     1125    dba::XMLOStream stream(ar.getOStream()); 
     1126    stream.enableDebug(); 
     1127    stream.open(); 
     1128    stream.put(&obj); 
     1129  } 
     1130  CPPUNIT_ASSERT(compareXML("storebug4.xml",result)); 
     1131}; 
     1132 
     1133 
    10301134} //namespace 
    10311135 
    10321136#endif //TEST_XML 
    10331137 
     1138 
  • trunk/dba/test/xmltestcase.h

    r180 r181  
    5555      CPPUNIT_TEST(storeBug2); 
    5656      CPPUNIT_TEST(storeBug3); 
     57      CPPUNIT_TEST(storeBug4); 
    5758    CPPUNIT_TEST_SUITE_END(); 
    5859  public: 
     
    9495    void storeBug2(); 
    9596    void storeBug3(); 
     97    void storeBug4(); 
    9698  private: 
    9799    bool compareXML(const char* pFilename, const char* pData);