transactd 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CMakeLists.txt +37 -4
  3. data/bin/common/tdclc_32_1_2.dll +0 -0
  4. data/bin/common/tdclc_64_1_2.dll +0 -0
  5. data/build/common/transactd_cl_common.cmake +0 -1
  6. data/build/common/transactd_common.cmake +26 -6
  7. data/build/swig/php/generate.cmake.in +58 -0
  8. data/build/swig/php/generate.cmd.in +41 -0
  9. data/build/swig/php/php.swg +155 -0
  10. data/build/swig/ruby/ruby.swg +38 -0
  11. data/build/swig/tdcl.i +133 -3
  12. data/build/tdclc/CMakeLists.txt +4 -1
  13. data/build/tdclc/tdclc_32.cbproj +1 -1
  14. data/build/tdclc/tdclc_64.cbproj +1 -1
  15. data/build/tdclcpp/CMakeLists.txt +1 -1
  16. data/build/tdclcpp/tdclcpp_bcb_32.cbproj +1 -4
  17. data/build/tdclcpp/tdclcpp_bcb_64.cbproj +0 -3
  18. data/build/tdclrb/CMakeLists.txt +1 -1
  19. data/build/tdclrb/GEM_VERSION +2 -2
  20. data/source/bzs/db/engine/mysql/IReadRecords.h +1 -1
  21. data/source/bzs/db/engine/mysql/bookmark.h +3 -3
  22. data/source/bzs/db/engine/mysql/database.cpp +95 -19
  23. data/source/bzs/db/engine/mysql/database.h +6 -6
  24. data/source/bzs/db/engine/mysql/mysqlInternal.h +43 -1
  25. data/source/bzs/db/engine/mysql/mysqlThd.cpp +10 -8
  26. data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +1 -1
  27. data/source/bzs/db/protocol/tdap/btrDate.h +2 -2
  28. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +15 -8
  29. data/source/bzs/db/protocol/tdap/client/dbDef.h +2 -2
  30. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +4 -0
  31. data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +0 -5
  32. data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +0 -4
  33. data/source/bzs/db/protocol/tdap/client/filter.cpp +0 -484
  34. data/source/bzs/db/protocol/tdap/client/filter.h +696 -84
  35. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +13 -3
  36. data/source/bzs/db/protocol/tdap/client/nsTable.h +12 -6
  37. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +2 -1
  38. data/source/bzs/db/protocol/tdap/client/stringConverter.h +1 -0
  39. data/source/bzs/db/protocol/tdap/client/table.cpp +519 -75
  40. data/source/bzs/db/protocol/tdap/client/table.h +49 -7
  41. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +145 -124
  42. data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +39 -0
  43. data/source/bzs/db/protocol/tdap/client/trdormapi.h +872 -0
  44. data/source/bzs/db/protocol/tdap/myDateTime.cpp +8 -8
  45. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +7 -9
  46. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +406 -195
  47. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +64 -13
  48. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +2 -1
  49. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +35 -3
  50. data/source/bzs/db/protocol/tdap/tdapSchema.h +11 -3
  51. data/source/bzs/db/protocol/tdap/tdapcapi.h +63 -53
  52. data/source/bzs/env/crosscompile.h +8 -3
  53. data/source/bzs/example/connection_pool_c.cpp +1 -7
  54. data/source/bzs/example/useORM.cpp +585 -0
  55. data/source/bzs/rtl/exception.h +6 -0
  56. data/source/bzs/test/tdclatl/bench_tdclatl.js +12 -7
  57. data/source/bzs/test/tdclphp/transactd_Test.php +1845 -0
  58. data/source/bzs/test/tdclphp/transactd_blob_Test.php +325 -0
  59. data/source/bzs/test/tdclphp/transactd_datetime_Test.php +183 -0
  60. data/source/bzs/test/tdclphp/transactd_kanjischema_Test.php +212 -0
  61. data/source/bzs/test/tdclrb/transactd_blob_spec.rb +332 -0
  62. data/source/bzs/test/tdclrb/transactd_spec.rb +256 -1
  63. data/source/bzs/test/trdclengn/test_blob.cpp +327 -0
  64. data/source/bzs/test/trdclengn/test_trdclengn.cpp +485 -5
  65. data/source/global/tdclatl/QueryBase.cpp +231 -0
  66. data/source/global/tdclatl/QueryBase.h +96 -0
  67. data/source/global/tdclatl/Table.cpp +24 -0
  68. data/source/global/tdclatl/Table.h +2 -1
  69. data/source/global/tdclatl/resource.h +0 -0
  70. data/source/global/tdclatl/tdclatl.idl +88 -2
  71. metadata +16 -3
  72. data/bin/common/tdclc_32_1_1.dll +0 -0
  73. data/bin/common/tdclc_64_1_1.dll +0 -0
@@ -27,6 +27,8 @@
27
27
  #include <bzs/db/protocol/tdap/tdapcapi.h>
28
28
  #include <bzs/db/protocol/tdap/client/stringConverter.h>
29
29
  #include <stdio.h>
30
+ #include <bzs/db/protocol/tdap/client/filter.h>
31
+
30
32
 
31
33
  using namespace bzs::db::protocol::tdap::client;
32
34
  using namespace bzs::db::protocol::tdap;
@@ -164,6 +166,20 @@ void testCreateNewDataBase(database* db)
164
166
  def->updateTableDef(1);
165
167
  BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 2 stat = " << def->stat());
166
168
 
169
+ fd = def->insertField(1, 2);
170
+ fd->setName(_T("select"));
171
+ fd->type = ft_integer;
172
+ fd->len = (ushort_td)4;
173
+ def->updateTableDef(1);
174
+ BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 2 stat = " << def->stat());
175
+
176
+ fd = def->insertField(1, 3);
177
+ fd->setName(_T("in"));
178
+ fd->type = ft_integer;
179
+ fd->len = (ushort_td)4;
180
+ def->updateTableDef(1);
181
+ BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 2 stat = " << def->stat());
182
+
167
183
  keydef* kd = def->insertKey(1, 0);
168
184
  kd->segments[0].fieldNum = 0;
169
185
  kd->segments[0].flags.bit8 = 1; // extended key type
@@ -278,6 +294,7 @@ void testFind(database* db)
278
294
  --i;
279
295
  }
280
296
 
297
+ tb->clearBuffer();
281
298
  v = 20000;
282
299
  tb->setFV((short)0, v);
283
300
  tb->find(table::findForword);
@@ -305,6 +322,93 @@ void testFindNext(database* db)
305
322
  tb->release();
306
323
  }
307
324
 
325
+ void testFindIn(database* db)
326
+ {
327
+
328
+ table* tb = openTable(db);
329
+ tb->setKeyNum(0);
330
+ tb->clearBuffer();
331
+ queryBase q;
332
+ q.addSeekKeyValue(_T("10"), true);
333
+ q.addSeekKeyValue(_T("300000"));
334
+ q.addSeekKeyValue(_T("50"));
335
+ q.addSeekKeyValue(_T("-1"));
336
+ q.addSeekKeyValue(_T("80"));
337
+ q.addSeekKeyValue(_T("5000"));
338
+
339
+
340
+
341
+ tb->setQuery(&q);
342
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "find in stat = " << tb->stat());
343
+ tb->find();
344
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "find in stat = " << tb->stat());
345
+ BOOST_CHECK_MESSAGE(tb->getFVint(fdi_id) == 10, "find in 10");
346
+ tb->findNext();
347
+ BOOST_CHECK_MESSAGE(tb->stat() == 4, "find in 300000");
348
+
349
+ _TCHAR msg[1024];
350
+ tb->keyValueDescription(msg, 1024);
351
+ int comp = _tcscmp(_T("table:user\nstat:4\nid = 300000\n"), msg);
352
+ BOOST_CHECK_MESSAGE(comp == 0, "find in keyValueDescription");
353
+
354
+ tb->findNext();
355
+ BOOST_CHECK_MESSAGE(tb->getFVint(fdi_id) == 50, "find in 50");
356
+ tb->findNext();
357
+ BOOST_CHECK_MESSAGE(tb->stat() == 4, "find in -1");
358
+
359
+ tb->keyValueDescription(msg, 1024);
360
+ comp = _tcscmp(_T("table:user\nstat:4\nid = -1\n"), msg);
361
+ BOOST_CHECK_MESSAGE(comp == 0, "find in keyValueDescription");
362
+
363
+ tb->findNext();
364
+ BOOST_CHECK_MESSAGE(tb->getFVint(fdi_id) == 80, "find in 80");
365
+ tb->findNext();
366
+ BOOST_CHECK_MESSAGE(tb->getFVint(fdi_id) == 5000, "find in 5000");
367
+ tb->findNext();
368
+ BOOST_CHECK_MESSAGE(STATUS_EOF == tb->stat(), "find in more");
369
+
370
+ // Many params
371
+ _TCHAR buf[20];
372
+ _ltot_s(1, buf, 20, 10);
373
+ q.addSeekKeyValue(buf, true);
374
+
375
+ for (int i=2;i<=10000;++i)
376
+ {
377
+ _ltot_s(i, buf, 20, 10);
378
+ q.addSeekKeyValue(buf);
379
+ }
380
+ tb->setQuery(&q);
381
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "find in stat = " << tb->stat());
382
+
383
+ tb->find();
384
+ int i = 0;
385
+ while (0 == tb->stat())
386
+ {
387
+
388
+ BOOST_CHECK_MESSAGE(++i == tb->getFVint(fdi_id), "findNext in value");
389
+ tb->findNext(true);
390
+ }
391
+ BOOST_CHECK_MESSAGE(i == 10000, "findNext in count");
392
+ BOOST_CHECK_MESSAGE(9 == tb->stat(), "find in end stat = " << tb->stat());
393
+
394
+ //LogicalCountLimit
395
+ q.addField(_T("id"));
396
+ tb->setQuery(&q);
397
+
398
+ tb->find();
399
+ i = 0;
400
+ while (0 == tb->stat())
401
+ {
402
+
403
+ BOOST_CHECK_MESSAGE(++i == tb->getFVint(fdi_id), "findNext in value");
404
+ tb->findNext(true);
405
+ }
406
+ BOOST_CHECK_MESSAGE(i == 10000, "findNext in count");
407
+ BOOST_CHECK_MESSAGE(9 == tb->stat(), "find in end stat = " << tb->stat());
408
+
409
+ tb->release();
410
+ }
411
+
308
412
  void testGetPercentage(database* db)
309
413
  {
310
414
  table* tb = openTable(db);
@@ -1533,14 +1637,14 @@ void stringFileterCreateTable(database* db, int id, const _TCHAR* name, uchar_td
1533
1637
  // td.charsetIndex = CHARSET_CP932;
1534
1638
 
1535
1639
  def->insertTable(&td);
1536
- BOOST_CHECK_MESSAGE(0 == def->stat(), "insertTable");
1640
+ BOOST_CHECK_MESSAGE(0 == def->stat(), "insertTable stat = " << def->stat());
1537
1641
 
1538
1642
  fielddef* fd = def->insertField(id, 0);
1539
1643
  fd->setName(_T("id"));
1540
1644
  fd->type = ft_integer;
1541
1645
  fd->len = (ushort_td)4;
1542
1646
  def->updateTableDef(id);
1543
- BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 1");
1647
+ BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 1 stat = " << def->stat());
1544
1648
 
1545
1649
  fd = def->insertField(id, 1);
1546
1650
  fd->setName(_T("name"));
@@ -1559,7 +1663,7 @@ void stringFileterCreateTable(database* db, int id, const _TCHAR* name, uchar_td
1559
1663
 
1560
1664
  fd->keylen = fd->len;
1561
1665
  def->updateTableDef(id);
1562
- BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 2");
1666
+ BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 2 stat = " << def->stat());
1563
1667
 
1564
1668
  fd = def->insertField(id, 2);
1565
1669
  fd->setName(_T("namew"));
@@ -1609,6 +1713,7 @@ void stringFileterCreateTable(database* db, int id, const _TCHAR* name, uchar_td
1609
1713
 
1610
1714
  void doInsertStringFileter(table* tb)
1611
1715
  {
1716
+ tb->beginBulkInsert(BULKBUFSIZE);
1612
1717
  tb->clearBuffer();
1613
1718
  int id = 1;
1614
1719
  tb->setFV(_T("id"), id);
@@ -1623,6 +1728,7 @@ void doInsertStringFileter(table* tb)
1623
1728
  tb->setFV(_T("namew"), _T("A123456"));
1624
1729
  tb->insert();
1625
1730
 
1731
+
1626
1732
  tb->clearBuffer();
1627
1733
  id = 3;
1628
1734
  tb->setFV(_T("id"), id);
@@ -1643,7 +1749,7 @@ void doInsertStringFileter(table* tb)
1643
1749
  tb->setFV(_T("name"), _T("おめでとうございます。"));
1644
1750
  tb->setFV(_T("namew"), _T("おめでとうございます。"));
1645
1751
  tb->insert();
1646
-
1752
+ tb->commitBulkInsert();
1647
1753
  }
1648
1754
 
1649
1755
  void doTestReadSF(table* tb)
@@ -1683,15 +1789,52 @@ void doTestSF(table* tb)
1683
1789
  tb->setKeyNum(0);
1684
1790
  tb->clearBuffer();
1685
1791
 
1792
+
1793
+
1686
1794
  tb->setFilter(_T("name = 'あい*'"), 0, 10);
1795
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
1687
1796
  tb->seekFirst();
1797
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
1688
1798
  tb->findNext(false);
1689
1799
  BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
1690
1800
  BOOST_CHECK_MESSAGE(_tstring(_T("あいうえおかきくこ")) == _tstring(tb->getFVstr(1)), "doTestReadSF2");
1691
1801
  BOOST_CHECK_MESSAGE(2 == (int)tb->recordCount(), "doTestReadSF2");
1692
1802
 
1803
+
1693
1804
  tb->setFilter(_T("name <> 'あい*'"), 0, 10);
1694
1805
  BOOST_CHECK_MESSAGE(3 == (int)tb->recordCount(), "doTestReadSF2");
1806
+ tb->clearBuffer();
1807
+ tb->seekFirst();
1808
+ tb->findNext(false);
1809
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
1810
+ BOOST_CHECK_MESSAGE(_tstring(_T("A123456")) == _tstring(tb->getFVstr(2)), "doTestReadSF1");
1811
+
1812
+ tb->findNext();
1813
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
1814
+ BOOST_CHECK_MESSAGE(_tstring(_T("おはようございます")) == _tstring(tb->getFVstr(2)), "doTestReadSF1");
1815
+
1816
+ tb->findNext();
1817
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
1818
+ BOOST_CHECK_MESSAGE(_tstring(_T("おめでとうございます。")) == _tstring(tb->getFVstr(2)), "doTestReadSF1");
1819
+ tb->findNext();
1820
+ BOOST_CHECK_MESSAGE(9 == tb->stat(), "doTestReadSF1");
1821
+
1822
+ tb->clearBuffer();
1823
+ tb->seekLast();
1824
+ tb->findPrev(false);
1825
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
1826
+ BOOST_CHECK_MESSAGE(_tstring(_T("おめでとうございます。")) == _tstring(tb->getFVstr(2)), "doTestReadSF1");
1827
+
1828
+ tb->findPrev();
1829
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
1830
+ BOOST_CHECK_MESSAGE(_tstring(_T("おはようございます")) == _tstring(tb->getFVstr(2)), "doTestReadSF1");
1831
+
1832
+ tb->findPrev(false);
1833
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
1834
+ BOOST_CHECK_MESSAGE(_tstring(_T("A123456")) == _tstring(tb->getFVstr(2)), "doTestReadSF1");
1835
+
1836
+ tb->findPrev();
1837
+ BOOST_CHECK_MESSAGE(9 == tb->stat(), "doTestReadSF1");
1695
1838
 
1696
1839
  tb->setFilter(_T("name = 'あい'"), 0, 10);
1697
1840
  BOOST_CHECK_MESSAGE(0 == (int)tb->recordCount(), "doTestReadSF2");
@@ -1699,6 +1842,42 @@ void doTestSF(table* tb)
1699
1842
  tb->setFilter(_T("name <> ''"), 0, 10);
1700
1843
  BOOST_CHECK_MESSAGE(5 == (int)tb->recordCount(), "doTestReadSF2");
1701
1844
 
1845
+ //test setFilter don't change field value
1846
+ tb->clearBuffer();
1847
+ tb->setFV(_T("name"), _T("ABCDE"));
1848
+ tb->setFilter(_T("name = 'あい'"), 0, 10);
1849
+ BOOST_CHECK_MESSAGE(_tstring(_T("ABCDE")) == _tstring(tb->getFVstr(1)), "doTestReadSF2 field value");
1850
+
1851
+ }
1852
+
1853
+ void doTestUpdateSF(table* tb)
1854
+ {
1855
+
1856
+ tb->setKeyNum(0);
1857
+ tb->clearBuffer();
1858
+ tb->seekFirst();
1859
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestUpdateSF stat = " << tb->stat());
1860
+ tb->setFV(_T("name"), _T("ABCDE"));
1861
+ tb->setFV(_T("namew"), _T("ABCDEW"));
1862
+ tb->update();
1863
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestUpdateSF stat = " << tb->stat());
1864
+ tb->seekNext();
1865
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestUpdateSF stat = " << tb->stat());
1866
+
1867
+ tb->setFV(_T("name"), _T("ABCDE2"));
1868
+ tb->setFV(_T("namew"), _T("ABCDEW2"));
1869
+ tb->update();
1870
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestUpdateSF stat = " << tb->stat());
1871
+
1872
+ tb->seekFirst();
1873
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestUpdateSF stat = " << tb->stat());
1874
+ BOOST_CHECK_MESSAGE(_tstring(_T("ABCDE")) == _tstring(tb->getFVstr(1)), "doTestUpdateSF");
1875
+ BOOST_CHECK_MESSAGE(_tstring(_T("ABCDEW")) == _tstring(tb->getFVstr(2)), "doTestUpdateSF" );
1876
+ tb->seekNext();
1877
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestUpdateSF stat = " << tb->stat());
1878
+ BOOST_CHECK_MESSAGE(_tstring(_T("ABCDE2")) == _tstring(tb->getFVstr(1)), "doTestUpdateSF");
1879
+ BOOST_CHECK_MESSAGE(_tstring(_T("ABCDEW2")) == _tstring(tb->getFVstr(2)), "doTestUpdateSF" );
1880
+
1702
1881
  }
1703
1882
 
1704
1883
  void doTestStringFileter(database* db, int id, const _TCHAR* name, uchar_td type, uchar_td type2)
@@ -1711,6 +1890,7 @@ void doTestStringFileter(database* db, int id, const _TCHAR* name, uchar_td type
1711
1890
  doInsertStringFileter(tb);
1712
1891
  doTestReadSF(tb);
1713
1892
  doTestSF(tb);
1893
+ doTestUpdateSF(tb);
1714
1894
  tb->release();
1715
1895
  }
1716
1896
 
@@ -1894,6 +2074,278 @@ void testGetEqualKanji(database* db)
1894
2074
 
1895
2075
  }
1896
2076
 
2077
+ // ------------------------------------------------------------------------
2078
+ void testResultField(database* db)
2079
+ {
2080
+ table* tb = openTable(db);
2081
+ resultField rf;
2082
+ rf.setParam(tb, _T("name"));
2083
+
2084
+ BOOST_CHECK_MESSAGE(rf.len == 33, " resultField.setParam");
2085
+ BOOST_CHECK_MESSAGE(rf.pos == 4, " resultField.setParam");
2086
+
2087
+ size_t len = rf.writeBuffer(0, true) - (unsigned char*)0;
2088
+ BOOST_CHECK_MESSAGE(len == 4, " resultField.writeBuffer");
2089
+
2090
+ }
2091
+
2092
+ void testResultDef()
2093
+ {
2094
+ resultDef rd;
2095
+
2096
+ rd.reset();
2097
+ BOOST_CHECK_MESSAGE(rd.maxRows == 0, " resultDef.maxRows");
2098
+ BOOST_CHECK_MESSAGE(rd.fieldCount == 0, " resultDef.fieldCount");
2099
+
2100
+ size_t len = rd.writeBuffer(0, true) - (unsigned char*)0;
2101
+ BOOST_CHECK_MESSAGE(len == 4, " resultDef.writeBuffer");
2102
+
2103
+
2104
+ }
2105
+
2106
+
2107
+ void testLogic(database* db)
2108
+ {
2109
+ table* tb = openTable(db);
2110
+ logic lc;
2111
+
2112
+ lc.setParam(tb, _T("name"), _T("="), _T("abc"), eCend);
2113
+
2114
+
2115
+ BOOST_CHECK_MESSAGE(lc.type == ft_zstring, " logic.type");
2116
+ BOOST_CHECK_MESSAGE(lc.len == 33, " logic.len");
2117
+ BOOST_CHECK_MESSAGE(lc.pos == 4, " logic.pos");
2118
+ BOOST_CHECK_MESSAGE(lc.logType == 1, " logic.logType");
2119
+ BOOST_CHECK_MESSAGE(lc.opr == eCend, " logic.opr");
2120
+ BOOST_CHECK_MESSAGE(strcmp((char*)lc.data, "abc")==0, " logic.data");
2121
+
2122
+ size_t len = lc.writeBuffer(0, true, false) - (unsigned char*)0;
2123
+ BOOST_CHECK_MESSAGE(len == 7+33, " logic.writeBuffer");
2124
+
2125
+ //compField invalid filed name
2126
+ bool ret = lc.setParam(tb, _T("name"), _T("="), _T("1"), eCend, true);
2127
+ BOOST_CHECK_MESSAGE(ret == false, " logic invalid filed name");
2128
+
2129
+ //compField
2130
+ ret = lc.setParam(tb, _T("name"), _T("="), _T("id"), eCend, true);
2131
+ BOOST_CHECK_MESSAGE(ret == true, " logic filed name");
2132
+ BOOST_CHECK_MESSAGE(lc.type == ft_zstring, " logic.type");
2133
+ BOOST_CHECK_MESSAGE(lc.len == 33, " logic.len");
2134
+ BOOST_CHECK_MESSAGE(lc.pos == 4, " logic.pos");
2135
+ BOOST_CHECK_MESSAGE(lc.logType == 1+CMPLOGICAL_FIELD, " logic.logType compField");
2136
+ BOOST_CHECK_MESSAGE(lc.opr == eCend, " logic.opr");
2137
+ BOOST_CHECK_MESSAGE(*((short*)lc.data) == 0, " logic.data");
2138
+ len = lc.writeBuffer(0, true, false) - (unsigned char*)0;
2139
+ BOOST_CHECK_MESSAGE(len == 7+2, " logic.writeBuffer");
2140
+
2141
+ //invalid filed name
2142
+ ret = lc.setParam(tb, _T("name1"), _T("="), _T("id"), eCend, true);
2143
+ BOOST_CHECK_MESSAGE(ret == false, " logic invalid filed name2");
2144
+
2145
+ //wildcard
2146
+ ret = lc.setParam(tb, _T("name"), _T("="), _T("abc*"), eCend, false);
2147
+ BOOST_CHECK_MESSAGE(lc.type == ft_zstring, " logic.type");
2148
+ BOOST_CHECK_MESSAGE(lc.len == 3, " logic.len");
2149
+ BOOST_CHECK_MESSAGE(lc.pos == 4, " logic.pos");
2150
+ BOOST_CHECK_MESSAGE(lc.logType == 1, " logic.logType");
2151
+ BOOST_CHECK_MESSAGE(lc.opr == eCend, " logic.opr");
2152
+ BOOST_CHECK_MESSAGE(strcmp((char*)lc.data, "abc")==0, " logic.data");
2153
+
2154
+ len = lc.writeBuffer(0, true, false) - (unsigned char*)0;
2155
+ BOOST_CHECK_MESSAGE(len == 7+3, " logic.writeBuffer");
2156
+
2157
+ ret = lc.setParam(tb, _T("name"), _T("="), _T("漢字*"), eCend, false);
2158
+ BOOST_CHECK_MESSAGE(strcmp((char*)lc.data, "漢字")==0, " logic.data");
2159
+
2160
+ len = lc.writeBuffer(0, true, false) - (unsigned char*)0;
2161
+ BOOST_CHECK_MESSAGE(len == 7 + (_tcslen(_T("漢字"))*sizeof(_TCHAR))
2162
+ , " logic.writeBuffer len =" << len);
2163
+
2164
+
2165
+ //combine
2166
+ ret = lc.setParam(tb, _T("name"), _T("="), _T("abc*"), eCor, false);
2167
+ BOOST_CHECK_MESSAGE(lc.opr == 2, " logic.opr or");
2168
+ ret = lc.setParam(tb, _T("name"), _T("="), _T("abc*"), eCand, false);
2169
+ BOOST_CHECK_MESSAGE(lc.opr == 1, " logic.opr and");
2170
+
2171
+ //logType
2172
+ ret = lc.setParam(tb, _T("name"), _T("!="), _T("abc*"), eCend, false);
2173
+ BOOST_CHECK_MESSAGE(lc.logType == 255, " logic.logType !=");
2174
+ BOOST_CHECK_MESSAGE(ret == false, " logic invalid logType");
2175
+
2176
+ //canJoin
2177
+
2178
+ //zstring is cannot join
2179
+ lc.setParam(tb, _T("name"), _T("="), _T("1"), eCand, false);
2180
+ BOOST_CHECK_MESSAGE(lc.canJoin(false) == false, " logic canJoin");
2181
+ BOOST_CHECK_MESSAGE(lc.canJoin(true) == false, " logic canJoin");
2182
+
2183
+ lc.setParam(tb, _T("id"), _T("="), _T("1"), eCand, false);
2184
+ BOOST_CHECK_MESSAGE(lc.canJoin(false) == true, " logic canJoin");
2185
+ BOOST_CHECK_MESSAGE(lc.canJoin(true) == true, " logic canJoin");
2186
+ lc.opr = eCend;
2187
+ BOOST_CHECK_MESSAGE(lc.canJoin(true) == false, " logic canJoin");
2188
+ BOOST_CHECK_MESSAGE(lc.canJoin(false) == true, " logic canJoin");
2189
+
2190
+ lc.opr = eCor;
2191
+ BOOST_CHECK_MESSAGE(lc.canJoin(true) == false, " logic canJoin");
2192
+ BOOST_CHECK_MESSAGE(lc.canJoin(false) == true, " logic canJoin");
2193
+
2194
+
2195
+ lc.opr = eCand;
2196
+
2197
+ logic lc2;
2198
+ lc2.setParam(tb, _T("id"), _T("="), _T("1"), eCend, false);
2199
+ lc2.pos = 3;
2200
+
2201
+ lc.isNextFiled(&lc2);
2202
+ BOOST_CHECK_MESSAGE(lc.isNextFiled(&lc2) == false, " logic isNextFiled");
2203
+ lc2.pos = 4;
2204
+ BOOST_CHECK_MESSAGE(lc.isNextFiled(&lc2) == true, " logic isNextFiled");
2205
+
2206
+ //join
2207
+ lc.joinAfter(&lc2);
2208
+ BOOST_CHECK_MESSAGE(lc.len == 8, " logic joinAfter");
2209
+
2210
+ BOOST_CHECK_MESSAGE(lc.opr == eCend, " logic joinAfter");
2211
+
2212
+ header hd;
2213
+ len = hd.writeBuffer(0, true) - (unsigned char*)0;
2214
+ BOOST_CHECK_MESSAGE(len == 8, " header.writeBuffer");
2215
+
2216
+
2217
+ }
2218
+
2219
+
2220
+
2221
+ void testQuery()
2222
+ {
2223
+ queryBase q;
2224
+ q.queryString(_T("id = 0 and name = 'Abc efg'"));
2225
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("id = '0' and name = 'Abc efg'")
2226
+ , "queryString");
2227
+
2228
+ q.queryString(_T(""));
2229
+ q.addLogic(_T("id"), _T("="), _T("0"));
2230
+ q.addLogic(_T("and"), _T("name"), _T("="), _T("Abc efg"));
2231
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("id = '0' and name = 'Abc efg'"), "queryString");
2232
+
2233
+ q.queryString(_T("select id,name id = 0 AND name = 'Abc&' efg'"));
2234
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name id = '0' AND name = 'Abc&' efg'")
2235
+ , "queryString");
2236
+
2237
+ q.queryString(_T(""));
2238
+ q.addField(_T("id"));
2239
+ q.addField(_T("name"));
2240
+ q.addLogic(_T("id"), _T("="), _T("0"));
2241
+ q.addLogic(_T("AND"), _T("name"), _T("="), _T("Abc' efg"));
2242
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name id = '0' AND name = 'Abc&' efg'")
2243
+ , "queryString");
2244
+
2245
+ q.queryString(_T("select id,name id = 0 AND name = 'Abc&& efg'"));
2246
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name id = '0' AND name = 'Abc&& efg'")
2247
+ , "queryString");
2248
+
2249
+ q.queryString(_T(""));
2250
+ q.addField(_T("id"));
2251
+ q.addField(_T("name"));
2252
+ q.addLogic(_T("id"), _T("="), _T("0"));
2253
+ q.addLogic(_T("AND"), _T("name"), _T("="), _T("Abc& efg"));
2254
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name id = '0' AND name = 'Abc&& efg'")
2255
+ , "queryString");
2256
+
2257
+ q.queryString(_T("*"));
2258
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("*"), "queryString");
2259
+
2260
+ q.queryString(_T(""));
2261
+ q.all();
2262
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("*"), "queryString");
2263
+
2264
+ q.queryString(_T("Select id,name id = 2"));
2265
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name id = '2'")
2266
+ , "queryString");
2267
+
2268
+ q.queryString(_T(""));
2269
+ q.addField(_T("id"));
2270
+ q.addField(_T("name"));
2271
+ q.addLogic(_T("id"), _T("="), _T("2"));
2272
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name id = '2'")
2273
+ , "queryString");
2274
+
2275
+ q.queryString(_T("SELECT id,name,fc id = 2"));
2276
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name,fc id = '2'")
2277
+ , "queryString");
2278
+
2279
+ q.queryString(_T(""));
2280
+ q.addField(_T("id"));
2281
+ q.addField(_T("name"));
2282
+ q.addField(_T("fc"));
2283
+ q.addLogic(_T("id"), _T("="), _T("2"));
2284
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name,fc id = '2'")
2285
+ , "queryString");
2286
+
2287
+ q.queryString(_T("select id,name,fc id = 2 and name = '3'"));
2288
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name,fc id = '2' and name = '3'")
2289
+ , "queryString");
2290
+
2291
+ q.queryString(_T(""));
2292
+ q.addField(_T("id"));
2293
+ q.addField(_T("name"));
2294
+ q.addField(_T("fc"));
2295
+ q.addLogic(_T("id"), _T("="), _T("2"));
2296
+ q.addLogic(_T("and"), _T("name"), _T("="), _T("3"));
2297
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name,fc id = '2' and name = '3'")
2298
+ , "queryString");
2299
+
2300
+ //IN include
2301
+ q.queryString(_T("select id,name,fc IN '1','2','3'"));
2302
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name,fc in '1','2','3'")
2303
+ , "queryString");
2304
+
2305
+ q.queryString(_T(""));
2306
+ q.addField(_T("id"));
2307
+ q.addField(_T("name"));
2308
+ q.addField(_T("fc"));
2309
+ q.addSeekKeyValue(_T("1"));
2310
+ q.addSeekKeyValue(_T("2"));
2311
+ q.addSeekKeyValue(_T("3"));
2312
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select id,name,fc in '1','2','3'")
2313
+ , "queryString");
2314
+
2315
+ q.queryString(_T("IN '1','2','3'"));
2316
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("in '1','2','3'")
2317
+ , "queryString");
2318
+
2319
+ q.queryString(_T("IN 1,2,3"));
2320
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("in '1','2','3'")
2321
+ , "queryString");
2322
+
2323
+ q.queryString(_T(""));
2324
+ q.addSeekKeyValue(_T("1"));
2325
+ q.addSeekKeyValue(_T("2"));
2326
+ q.addSeekKeyValue(_T("3"));
2327
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("in '1','2','3'")
2328
+ , "queryString");
2329
+
2330
+ //special field name
2331
+ q.queryString(_T("select = 1"));
2332
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select = '1'")
2333
+ , "queryString");
2334
+
2335
+ q.queryString(_T(""));
2336
+ q.addLogic(_T("select"), _T("="), _T("1"));
2337
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("select = '1'")
2338
+ , "queryString");
2339
+
2340
+ q.queryString(_T("in <> 1"));
2341
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("in <> '1'")
2342
+ , "queryString");
2343
+
2344
+ q.queryString(_T(""));
2345
+ q.addLogic(_T("in"), _T("<>"), _T("1"));
2346
+ BOOST_CHECK_MESSAGE(_tstring(q.toString()) == _T("in <> '1'")
2347
+ , "queryString");
2348
+ }
1897
2349
  // ------------------------------------------------------------------------
1898
2350
  BOOST_AUTO_TEST_SUITE(btrv_nativ)
1899
2351
 
@@ -1913,7 +2365,11 @@ BOOST_AUTO_TEST_SUITE(btrv_nativ)
1913
2365
 
1914
2366
  BOOST_FIXTURE_TEST_CASE(find, fixture) {testFind(db());}
1915
2367
 
1916
- BOOST_FIXTURE_TEST_CASE(findNext, fixture) {testFindNext(db());}
2368
+ BOOST_FIXTURE_TEST_CASE(findNext, fixture)
2369
+ {
2370
+ testFindNext(db());
2371
+ testFindIn(db());
2372
+ }
1917
2373
 
1918
2374
  BOOST_FIXTURE_TEST_CASE(getPercentage, fixture) {testGetPercentage(db());}
1919
2375
 
@@ -2025,6 +2481,30 @@ BOOST_AUTO_TEST_SUITE(kanjiSchema)
2025
2481
 
2026
2482
  BOOST_FIXTURE_TEST_CASE(dropDatabaseKanji, fixture) {testDropDatabaseKanji(db());}
2027
2483
 
2484
+ BOOST_AUTO_TEST_SUITE_END()
2485
+
2486
+ // ------------------------------------------------------------------------
2487
+ BOOST_AUTO_TEST_SUITE(filter)
2488
+
2489
+ BOOST_FIXTURE_TEST_CASE(resultField, fixture)
2490
+ {
2491
+
2492
+ if (db()->open(makeUri(PROTOCOL, HOSTNAME, DBNAME, BDFNAME)))
2493
+ db()->drop();
2494
+ testCreateNewDataBase(db());
2495
+ testResultField(db());
2496
+ testResultDef();
2497
+ testLogic(db());
2498
+ testQuery();
2499
+ }
2500
+ BOOST_FIXTURE_TEST_CASE(drop, fixture)
2501
+ {
2502
+ testDropDatabase(db());
2503
+ }
2028
2504
  BOOST_FIXTURE_TEST_CASE(fuga, fixture) {BOOST_CHECK_EQUAL(2 * 3, 6);}
2505
+
2029
2506
  BOOST_AUTO_TEST_SUITE_END()
2507
+
2030
2508
  // ------------------------------------------------------------------------
2509
+
2510
+