From 0d49ea1fe08cf1eab41a00149393a291c65a59d7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 25 Jan 2024 20:32:06 +0300 Subject: Turn odb-tests repository into package for muti-package repository --- .gitignore | 41 - GPLv2 | 340 --- LICENSE | 20 - README.md | 4 - boost/common/multi-index/driver.cxx | 189 -- boost/common/multi-index/test.hxx | 113 - boost/common/optional/driver.cxx | 74 - boost/common/optional/test.hxx | 31 - boost/common/smart-ptr/driver.cxx | 202 -- boost/common/smart-ptr/test.hxx | 82 - boost/common/template/driver.cxx | 39 - boost/common/template/template-vc10.vcxproj | 177 -- .../common/template/template-vc10.vcxproj.filters | 24 - boost/common/template/template-vc11.vcxproj | 181 -- .../common/template/template-vc11.vcxproj.filters | 24 - boost/common/template/template-vc12.vcxproj | 185 -- .../common/template/template-vc12.vcxproj.filters | 24 - boost/common/template/template-vc8.vcproj | 353 ---- boost/common/template/template-vc9.vcproj | 360 ---- boost/common/template/test.hxx | 25 - boost/common/unordered/driver.cxx | 212 -- boost/common/unordered/test.hxx | 113 - boost/common/uuid/driver.cxx | 69 - boost/common/uuid/test.hxx | 37 - boost/mssql/date-time/driver.cxx | 158 -- boost/mssql/date-time/test.hxx | 58 - boost/mssql/template/driver.cxx | 39 - boost/mssql/template/template-vc10.vcxproj | 180 -- boost/mssql/template/template-vc10.vcxproj.filters | 25 - boost/mssql/template/template-vc11.vcxproj | 184 -- boost/mssql/template/template-vc11.vcxproj.filters | 25 - boost/mssql/template/template-vc12.vcxproj | 188 -- boost/mssql/template/template-vc12.vcxproj.filters | 25 - boost/mssql/template/template-vc8.vcproj | 354 ---- boost/mssql/template/template-vc9.vcproj | 361 ---- boost/mssql/template/test.hxx | 25 - boost/mysql/date-time/driver.cxx | 218 -- boost/mysql/date-time/test.hxx | 65 - boost/mysql/template/driver.cxx | 39 - boost/mysql/template/template-vc10.vcxproj | 180 -- boost/mysql/template/template-vc10.vcxproj.filters | 25 - boost/mysql/template/template-vc11.vcxproj | 184 -- boost/mysql/template/template-vc11.vcxproj.filters | 25 - boost/mysql/template/template-vc12.vcxproj | 188 -- boost/mysql/template/template-vc12.vcxproj.filters | 25 - boost/mysql/template/template-vc8.vcproj | 354 ---- boost/mysql/template/template-vc9.vcproj | 361 ---- boost/mysql/template/test.hxx | 25 - boost/oracle/date-time/driver.cxx | 136 -- boost/oracle/date-time/test.hxx | 42 - boost/oracle/template/driver.cxx | 39 - boost/oracle/template/template-vc10.vcxproj | 180 -- .../oracle/template/template-vc10.vcxproj.filters | 25 - boost/oracle/template/template-vc11.vcxproj | 184 -- .../oracle/template/template-vc11.vcxproj.filters | 25 - boost/oracle/template/template-vc12.vcxproj | 188 -- .../oracle/template/template-vc12.vcxproj.filters | 25 - boost/oracle/template/template-vc8.vcproj | 354 ---- boost/oracle/template/template-vc9.vcproj | 361 ---- boost/oracle/template/test.hxx | 25 - boost/pgsql/date-time/driver.cxx | 157 -- boost/pgsql/date-time/test.hxx | 39 - boost/pgsql/template/driver.cxx | 39 - boost/pgsql/template/template-vc10.vcxproj | 180 -- boost/pgsql/template/template-vc10.vcxproj.filters | 25 - boost/pgsql/template/template-vc11.vcxproj | 184 -- boost/pgsql/template/template-vc11.vcxproj.filters | 25 - boost/pgsql/template/template-vc12.vcxproj | 188 -- boost/pgsql/template/template-vc12.vcxproj.filters | 25 - boost/pgsql/template/template-vc8.vcproj | 354 ---- boost/pgsql/template/template-vc9.vcproj | 361 ---- boost/pgsql/template/test.hxx | 25 - boost/sqlite/date-time/driver.cxx | 208 -- boost/sqlite/date-time/test.hxx | 57 - boost/sqlite/template/driver.cxx | 39 - boost/sqlite/template/template-vc10.vcxproj | 180 -- .../sqlite/template/template-vc10.vcxproj.filters | 25 - boost/sqlite/template/template-vc11.vcxproj | 184 -- .../sqlite/template/template-vc11.vcxproj.filters | 25 - boost/sqlite/template/template-vc12.vcxproj | 188 -- .../sqlite/template/template-vc12.vcxproj.filters | 25 - boost/sqlite/template/template-vc8.vcproj | 354 ---- boost/sqlite/template/template-vc9.vcproj | 361 ---- boost/sqlite/template/test.hxx | 25 - build/.gitignore | 3 - build/bootstrap.build | 9 - build/export.build | 9 - build/root.build | 270 --- buildfile | 10 - common/access/buildfile | 45 - common/access/driver.cxx | 262 --- common/access/test.hxx | 592 ------ common/access/testscript | 33 - common/as/buildfile | 49 - common/as/driver.cxx | 348 --- common/as/test.hxx | 270 --- common/as/testscript | 33 - common/blob/buildfile | 40 - common/blob/driver.cxx | 76 - common/blob/test.hxx | 71 - common/blob/testscript | 33 - common/buildfile | 6 - common/bulk/buildfile | 49 - common/bulk/driver.cxx | 1203 ----------- common/bulk/test.hxx | 211 -- common/bulk/testscript | 503 ----- common/callback/buildfile | 41 - common/callback/driver.cxx | 184 -- common/callback/test.hxx | 43 - common/callback/testscript | 100 - common/changelog/.gitignore | 3 - common/changelog/add-column-mssql-diff.xml | 16 - common/changelog/add-column-mssql-patch.xml | 13 - common/changelog/add-column-mysql-diff.xml | 16 - common/changelog/add-column-mysql-patch.xml | 13 - common/changelog/add-column-oracle-diff.xml | 16 - common/changelog/add-column-oracle-patch.xml | 13 - common/changelog/add-column-pgsql-diff.xml | 16 - common/changelog/add-column-pgsql-patch.xml | 13 - common/changelog/add-column-sqlite-diff.xml | 16 - common/changelog/add-column-sqlite-patch.xml | 13 - common/changelog/add-column.hxx | 20 - common/changelog/add-foreign-key-diff.xml | 28 - common/changelog/add-foreign-key-mssql-diff.xml | 28 - common/changelog/add-foreign-key-mssql-patch.xml | 25 - common/changelog/add-foreign-key-mysql-diff.xml | 28 - common/changelog/add-foreign-key-mysql-patch.xml | 25 - common/changelog/add-foreign-key-oracle-diff.xml | 28 - common/changelog/add-foreign-key-oracle-patch.xml | 25 - common/changelog/add-foreign-key-pgsql-diff.xml | 28 - common/changelog/add-foreign-key-pgsql-patch.xml | 25 - common/changelog/add-foreign-key-sqlite-diff.xml | 28 - common/changelog/add-foreign-key-sqlite-patch.xml | 25 - common/changelog/add-foreign-key.hxx | 29 - common/changelog/add-index-mssql-diff.xml | 21 - common/changelog/add-index-mssql-patch.xml | 18 - common/changelog/add-index-mysql-diff.xml | 21 - common/changelog/add-index-mysql-patch.xml | 18 - common/changelog/add-index-oracle-diff.xml | 21 - common/changelog/add-index-oracle-patch.xml | 18 - common/changelog/add-index-pgsql-diff.xml | 21 - common/changelog/add-index-pgsql-patch.xml | 18 - common/changelog/add-index-sqlite-diff.xml | 21 - common/changelog/add-index-sqlite-patch.xml | 18 - common/changelog/add-index.hxx | 24 - common/changelog/add-table-mssql-diff.xml | 45 - common/changelog/add-table-mssql-patch.xml | 44 - common/changelog/add-table-mysql-diff.xml | 45 - common/changelog/add-table-mysql-patch.xml | 44 - common/changelog/add-table-oracle-diff.xml | 45 - common/changelog/add-table-oracle-patch.xml | 44 - common/changelog/add-table-pgsql-diff.xml | 45 - common/changelog/add-table-pgsql-patch.xml | 44 - common/changelog/add-table-sqlite-diff.xml | 45 - common/changelog/add-table-sqlite-patch.xml | 44 - common/changelog/add-table.hxx | 34 - common/changelog/alter-column-mssql-diff.xml | 17 - common/changelog/alter-column-mssql-patch.xml | 13 - common/changelog/alter-column-mysql-diff.xml | 17 - common/changelog/alter-column-mysql-patch.xml | 13 - common/changelog/alter-column-oracle-diff.xml | 17 - common/changelog/alter-column-oracle-patch.xml | 13 - common/changelog/alter-column-pgsql-diff.xml | 17 - common/changelog/alter-column-pgsql-patch.xml | 13 - common/changelog/alter-column-sqlite-diff.xml | 17 - common/changelog/alter-column-sqlite-patch.xml | 13 - common/changelog/alter-column.hxx | 21 - common/changelog/buildfile | 30 - common/changelog/drop-column-mssql-diff.xml | 17 - common/changelog/drop-column-mssql-patch.xml | 12 - common/changelog/drop-column-mysql-diff.xml | 17 - common/changelog/drop-column-mysql-patch.xml | 12 - common/changelog/drop-column-oracle-diff.xml | 17 - common/changelog/drop-column-oracle-patch.xml | 12 - common/changelog/drop-column-pgsql-diff.xml | 17 - common/changelog/drop-column-pgsql-patch.xml | 12 - common/changelog/drop-column-sqlite-diff.xml | 17 - common/changelog/drop-column-sqlite-patch.xml | 12 - common/changelog/drop-column.hxx | 20 - common/changelog/drop-foreign-key-mssql-diff.xml | 30 - common/changelog/drop-foreign-key-mssql-patch.xml | 18 - common/changelog/drop-foreign-key-mysql-diff.xml | 30 - common/changelog/drop-foreign-key-mysql-patch.xml | 18 - common/changelog/drop-foreign-key-oracle-diff.xml | 30 - common/changelog/drop-foreign-key-oracle-patch.xml | 18 - common/changelog/drop-foreign-key-pgsql-diff.xml | 30 - common/changelog/drop-foreign-key-pgsql-patch.xml | 18 - common/changelog/drop-foreign-key-sqlite-diff.xml | 30 - common/changelog/drop-foreign-key-sqlite-patch.xml | 18 - common/changelog/drop-foreign-key.hxx | 29 - common/changelog/drop-index-mssql-diff.xml | 20 - common/changelog/drop-index-mssql-patch.xml | 13 - common/changelog/drop-index-mysql-diff.xml | 20 - common/changelog/drop-index-mysql-patch.xml | 13 - common/changelog/drop-index-oracle-diff.xml | 20 - common/changelog/drop-index-oracle-patch.xml | 13 - common/changelog/drop-index-pgsql-diff.xml | 20 - common/changelog/drop-index-pgsql-patch.xml | 13 - common/changelog/drop-index-sqlite-diff.xml | 20 - common/changelog/drop-index-sqlite-patch.xml | 13 - common/changelog/drop-index.hxx | 21 - common/changelog/drop-table-mssql-diff.xml | 47 - common/changelog/drop-table-mssql-patch.xml | 13 - common/changelog/drop-table-mysql-diff.xml | 47 - common/changelog/drop-table-mysql-patch.xml | 13 - common/changelog/drop-table-oracle-diff.xml | 47 - common/changelog/drop-table-oracle-patch.xml | 13 - common/changelog/drop-table-pgsql-diff.xml | 47 - common/changelog/drop-table-pgsql-patch.xml | 13 - common/changelog/drop-table-sqlite-diff.xml | 47 - common/changelog/drop-table-sqlite-patch.xml | 13 - common/changelog/drop-table.hxx | 34 - common/changelog/model-mssql-diff.xml | 1 - common/changelog/model-mssql-patch.xml | 1 - common/changelog/model-mssql.xml | 56 - common/changelog/model-mysql-diff.xml | 1 - common/changelog/model-mysql-patch.xml | 1 - common/changelog/model-mysql.xml | 56 - common/changelog/model-oracle-diff.xml | 1 - common/changelog/model-oracle-patch.xml | 1 - common/changelog/model-oracle.xml | 56 - common/changelog/model-pgsql-diff.xml | 1 - common/changelog/model-pgsql-patch.xml | 1 - common/changelog/model-pgsql.xml | 56 - common/changelog/model-sqlite-diff.xml | 1 - common/changelog/model-sqlite-patch.xml | 1 - common/changelog/model-sqlite.xml | 56 - common/changelog/model.hxx | 46 - common/changelog/testscript | 66 - common/circular/multiple/.gitignore | 6 - common/circular/multiple/buildfile | 49 - common/circular/multiple/driver.cxx | 69 - common/circular/multiple/test1.hxx | 27 - common/circular/multiple/test2.hxx | 17 - common/circular/multiple/testscript | 31 - common/circular/single/buildfile | 41 - common/circular/single/driver.cxx | 40 - common/circular/single/test.hxx | 28 - common/circular/single/testscript | 33 - common/composite/buildfile | 41 - common/composite/driver.cxx | 229 -- common/composite/test.hxx | 250 --- common/composite/testscript | 33 - common/const-member/buildfile | 40 - common/const-member/driver.cxx | 119 -- common/const-member/test.hxx | 109 - common/const-member/testscript | 33 - common/const-object/buildfile | 41 - common/const-object/driver.cxx | 216 -- common/const-object/test.hxx | 51 - common/const-object/testscript | 33 - common/container/basics/buildfile | 40 - common/container/basics/driver.cxx | 523 ----- common/container/basics/test.hxx | 245 --- common/container/basics/testscript | 33 - common/container/change-tracking/buildfile | 40 - common/container/change-tracking/driver.cxx | 729 ------- common/container/change-tracking/test.hxx | 106 - common/container/change-tracking/testscript | 33 - common/ctor/buildfile | 41 - common/ctor/driver.cxx | 79 - common/ctor/test.hxx | 29 - common/ctor/testscript | 33 - common/default/buildfile | 41 - common/default/driver.cxx | 81 - common/default/test.hxx | 67 - common/default/testscript | 33 - common/definition/.gitignore | 6 - common/definition/buildfile | 52 - common/definition/driver.cxx | 56 - common/definition/test.hxx | 26 - common/definition/testscript | 33 - common/definition/time-mapping.hxx | 17 - common/enum/buildfile | 41 - common/enum/driver.cxx | 84 - common/enum/test.hxx | 47 - common/enum/testscript | 33 - common/erase-query/buildfile | 41 - common/erase-query/driver.cxx | 181 -- common/erase-query/test.hxx | 46 - common/erase-query/testscript | 33 - common/id/auto/buildfile | 40 - common/id/auto/driver.cxx | 96 - common/id/auto/test.hxx | 40 - common/id/auto/testscript | 33 - common/id/composite/buildfile | 42 - common/id/composite/driver.cxx | 731 ------- common/id/composite/test.hxx | 519 ----- common/id/composite/testscript | 33 - common/id/nested/buildfile | 41 - common/id/nested/driver.cxx | 266 --- common/id/nested/test.hxx | 217 -- common/id/nested/testscript | 33 - common/include/.gitignore | 17 - common/include/buildfile | 51 - common/include/driver.cxx | 42 - common/include/obj1.hxx | 25 - common/include/obj2.hxx | 25 - common/include/obj3.hxx | 25 - common/include/objs1.hxx | 13 - common/include/objs2.hxx | 13 - common/include/objs3.hxx | 11 - common/include/objs4.hxx | 11 - common/include/test1.hxx | 16 - common/include/test2.hxx | 15 - common/include/test3.hxx | 12 - common/include/test4.hxx | 12 - common/include/testscript | 31 - common/index/buildfile | 40 - common/index/driver.cxx | 44 - common/index/test.hxx | 142 -- common/index/testscript | 33 - common/inheritance/polymorphism/.gitignore | 76 - common/inheritance/polymorphism/buildfile | 52 - common/inheritance/polymorphism/driver.cxx | 2093 ------------------ common/inheritance/polymorphism/test1.hxx | 115 - common/inheritance/polymorphism/test10.hxx | 78 - common/inheritance/polymorphism/test11.hxx | 78 - common/inheritance/polymorphism/test12.hxx | 79 - common/inheritance/polymorphism/test13.hxx | 46 - common/inheritance/polymorphism/test14.hxx | 99 - common/inheritance/polymorphism/test15.hxx | 44 - common/inheritance/polymorphism/test2.hxx | 105 - common/inheritance/polymorphism/test3.hxx | 146 -- common/inheritance/polymorphism/test4.hxx | 84 - common/inheritance/polymorphism/test5.hxx | 92 - common/inheritance/polymorphism/test6.hxx | 64 - common/inheritance/polymorphism/test7.hxx | 54 - common/inheritance/polymorphism/test8.hxx | 129 -- common/inheritance/polymorphism/test9.hxx | 161 -- common/inheritance/polymorphism/testscript | 80 - common/inheritance/reuse/buildfile | 41 - common/inheritance/reuse/driver.cxx | 237 --- common/inheritance/reuse/test.hxx | 163 -- common/inheritance/reuse/testscript | 33 - common/inheritance/transient/buildfile | 41 - common/inheritance/transient/driver.cxx | 80 - common/inheritance/transient/test.hxx | 60 - common/inheritance/transient/testscript | 33 - common/inverse/buildfile | 42 - common/inverse/driver.cxx | 502 ----- common/inverse/test.hxx | 391 ---- common/inverse/testscript | 33 - common/lazy-ptr/buildfile | 41 - common/lazy-ptr/driver.cxx | 360 ---- common/lazy-ptr/test.hxx | 147 -- common/lazy-ptr/testscript | 33 - common/lifecycle/buildfile | 40 - common/lifecycle/driver.cxx | 248 --- common/lifecycle/test.hxx | 27 - common/lifecycle/testscript | 33 - common/no-id/buildfile | 41 - common/no-id/driver.cxx | 102 - common/no-id/test.hxx | 21 - common/no-id/testscript | 33 - common/object/buildfile | 41 - common/object/driver.cxx | 84 - common/object/test.hxx | 49 - common/object/testscript | 33 - common/optimistic/buildfile | 41 - common/optimistic/driver.cxx | 300 --- common/optimistic/test.hxx | 76 - common/optimistic/testscript | 33 - common/pragma/buildfile | 39 - common/pragma/driver.cxx | 27 - common/pragma/test.hxx | 40 - common/pragma/testscript | 31 - common/prepared/buildfile | 43 - common/prepared/driver.cxx | 444 ---- common/prepared/test.hxx | 32 - common/prepared/testscript | 33 - common/query/array/buildfile | 43 - common/query/array/driver.cxx | 220 -- common/query/array/test.hxx | 70 - common/query/array/testscript | 33 - common/query/basics/buildfile | 42 - common/query/basics/driver.cxx | 668 ------ common/query/basics/test.hxx | 117 -- common/query/basics/testscript | 150 -- common/query/one/buildfile | 42 - common/query/one/driver.cxx | 205 -- common/query/one/test.hxx | 26 - common/query/one/testscript | 33 - common/readonly/buildfile | 40 - common/readonly/driver.cxx | 324 --- common/readonly/test.hxx | 225 -- common/readonly/testscript | 33 - common/relationship/basics/buildfile | 41 - common/relationship/basics/driver.cxx | 150 -- common/relationship/basics/test.hxx | 260 --- common/relationship/basics/testscript | 33 - common/relationship/on-delete/buildfile | 43 - common/relationship/on-delete/driver.cxx | 82 - common/relationship/on-delete/test.hxx | 58 - common/relationship/on-delete/testscript | 33 - common/relationship/query/buildfile | 42 - common/relationship/query/driver.cxx | 168 -- common/relationship/query/test.hxx | 140 -- common/relationship/query/testscript | 33 - common/schema/embedded/basics/buildfile | 42 - common/schema/embedded/basics/driver.cxx | 59 - common/schema/embedded/basics/test.hxx | 23 - common/schema/embedded/basics/testscript | 31 - common/schema/embedded/order/.gitignore | 6 - common/schema/embedded/order/buildfile | 48 - common/schema/embedded/order/driver.cxx | 65 - common/schema/embedded/order/test1.hxx | 23 - common/schema/embedded/order/test2.hxx | 17 - common/schema/embedded/order/testscript | 31 - common/schema/namespace/buildfile | 41 - common/schema/namespace/driver.cxx | 113 - common/schema/namespace/test.hxx | 158 -- common/schema/namespace/testscript | 33 - common/section/basics/buildfile | 41 - common/section/basics/driver.cxx | 1735 --------------- common/section/basics/test.hxx | 628 ------ common/section/basics/testscript | 33 - common/section/polymorphism/buildfile | 41 - common/section/polymorphism/driver.cxx | 1807 ---------------- common/section/polymorphism/test.hxx | 542 ----- common/section/polymorphism/testscript | 33 - common/session/cache/buildfile | 41 - common/session/cache/driver.cxx | 83 - common/session/cache/test.hxx | 50 - common/session/cache/testscript | 33 - common/session/custom/buildfile | 43 - common/session/custom/driver.cxx | 231 -- common/session/custom/session.cxx | 57 - common/session/custom/session.hxx | 191 -- common/session/custom/session.txx | 159 -- common/session/custom/test.hxx | 118 -- common/session/custom/testscript | 33 - common/statement/processing/buildfile | 8 - common/statement/processing/driver.cxx | 619 ------ common/statement/processing/testscript | 6 - common/threads/buildfile | 49 - common/threads/driver.cxx | 236 --- common/threads/test.hxx | 29 - common/threads/testscript | 50 - common/transaction/basics/buildfile | 13 - common/transaction/basics/driver.cxx | 151 -- common/transaction/basics/testscript | 62 - common/transaction/callback/buildfile | 13 - common/transaction/callback/driver.cxx | 231 -- common/transaction/callback/testscript | 72 - common/types/buildfile | 39 - common/types/driver.cxx | 37 - common/types/test.hxx | 55 - common/types/testscript | 6 - common/view/basics/buildfile | 42 - common/view/basics/driver.cxx | 846 -------- common/view/basics/test.hxx | 640 ------ common/view/basics/testscript | 33 - common/view/olv/.gitignore | 46 - common/view/olv/buildfile | 50 - common/view/olv/driver.cxx | 654 ------ common/view/olv/test1.hxx | 116 - common/view/olv/test2.hxx | 122 -- common/view/olv/test3.hxx | 106 - common/view/olv/test4.hxx | 151 -- common/view/olv/test5.hxx | 86 - common/view/olv/test6.hxx | 57 - common/view/olv/test7.hxx | 57 - common/view/olv/test8.hxx | 54 - common/view/olv/test9.hxx | 78 - common/view/olv/testscript | 39 - common/virtual/buildfile | 42 - common/virtual/driver.cxx | 154 -- common/virtual/test.hxx | 171 -- common/virtual/testscript | 33 - common/wrapper/buildfile | 40 - common/wrapper/driver.cxx | 216 -- common/wrapper/test.hxx | 214 -- common/wrapper/testscript | 33 - database-options.testscript | 75 - evolution/add-column/driver.cxx | 125 -- evolution/add-column/model.hxx | 38 - evolution/add-column/test1.hxx | 9 - evolution/add-column/test2.hxx | 11 - evolution/add-column/test3.hxx | 11 - evolution/add-foreign-key/driver.cxx | 173 -- evolution/add-foreign-key/model.hxx | 66 - evolution/add-foreign-key/test1.hxx | 9 - evolution/add-foreign-key/test2.hxx | 11 - evolution/add-foreign-key/test3.hxx | 11 - evolution/add-index/driver.cxx | 165 -- evolution/add-index/model.hxx | 33 - evolution/add-index/test1.hxx | 9 - evolution/add-index/test2.hxx | 11 - evolution/add-index/test3.hxx | 11 - evolution/add-table/driver.cxx | 140 -- evolution/add-table/model.hxx | 48 - evolution/add-table/test1.hxx | 9 - evolution/add-table/test2.hxx | 11 - evolution/add-table/test3.hxx | 11 - evolution/alter-column/driver.cxx | 160 -- evolution/alter-column/model.hxx | 56 - evolution/alter-column/test1.hxx | 9 - evolution/alter-column/test2.hxx | 11 - evolution/alter-column/test3.hxx | 11 - evolution/combined/driver.cxx | 157 -- evolution/combined/model.hxx | 174 -- evolution/combined/test1.hxx | 9 - evolution/combined/test2.hxx | 11 - evolution/combined/test3.hxx | 11 - evolution/data/driver.cxx | 178 -- evolution/data/model.hxx | 45 - evolution/data/test1.hxx | 9 - evolution/data/test2.hxx | 11 - evolution/data/test3.hxx | 11 - evolution/drop-column/driver.cxx | 126 -- evolution/drop-column/model.hxx | 59 - evolution/drop-column/test1.hxx | 9 - evolution/drop-column/test2.hxx | 11 - evolution/drop-column/test3.hxx | 11 - evolution/drop-foreign-key/driver.cxx | 145 -- evolution/drop-foreign-key/model.hxx | 50 - evolution/drop-foreign-key/test1.hxx | 9 - evolution/drop-foreign-key/test2.hxx | 11 - evolution/drop-foreign-key/test3.hxx | 11 - evolution/drop-index/driver.cxx | 154 -- evolution/drop-index/model.hxx | 33 - evolution/drop-index/test1.hxx | 9 - evolution/drop-index/test2.hxx | 11 - evolution/drop-index/test3.hxx | 11 - evolution/drop-table/driver.cxx | 168 -- evolution/drop-table/model.hxx | 94 - evolution/drop-table/test1.hxx | 9 - evolution/drop-table/test2.hxx | 11 - evolution/drop-table/test3.hxx | 11 - evolution/embedded/driver.cxx | 181 -- evolution/embedded/model.hxx | 45 - evolution/embedded/test1.hxx | 9 - evolution/embedded/test2.hxx | 11 - evolution/embedded/test3.hxx | 11 - evolution/soft-add/driver.cxx | 2219 -------------------- evolution/soft-add/model.hxx | 504 ----- evolution/soft-add/test1.hxx | 9 - evolution/soft-add/test2.hxx | 11 - evolution/soft-add/test3.hxx | 11 - evolution/soft-delete/driver.cxx | 2202 ------------------- evolution/soft-delete/model.hxx | 518 ----- evolution/soft-delete/test1.hxx | 9 - evolution/soft-delete/test2.hxx | 11 - evolution/soft-delete/test3.hxx | 11 - evolution/template/driver.cxx | 124 -- evolution/template/model.hxx | 40 - evolution/template/template-vc10.vcxproj | 196 -- evolution/template/template-vc10.vcxproj.filters | 32 - evolution/template/template-vc11.vcxproj | 200 -- evolution/template/template-vc11.vcxproj.filters | 32 - evolution/template/template-vc12.vcxproj | 204 -- evolution/template/template-vc12.vcxproj.filters | 32 - evolution/template/template-vc8.vcproj | 372 ---- evolution/template/template-vc9.vcproj | 379 ---- evolution/template/test1.hxx | 9 - evolution/template/test2.hxx | 11 - evolution/template/test3.hxx | 11 - evolution/version/driver.cxx | 156 -- evolution/version/model.hxx | 45 - evolution/version/test1.hxx | 9 - evolution/version/test2.hxx | 11 - evolution/version/test3.hxx | 11 - libcommon/.gitignore | 3 - libcommon/buffer.hxx | 104 - libcommon/buildfile | 50 - libcommon/common.cxx | 355 ---- libcommon/common.hxx | 47 - libcommon/common.txx | 24 - libcommon/concrete.hxx | 57 - libcommon/config.hxx.in | 14 - libcommon/export.hxx | 39 - manifest | 48 - mssql/custom/custom.sql | 42 - mssql/custom/driver.cxx | 135 -- mssql/custom/query.hxx | 183 -- mssql/custom/test.hxx | 121 -- mssql/custom/traits.cxx | 128 -- mssql/custom/traits.hxx | 148 -- mssql/database/driver.cxx | 105 - mssql/native/driver.cxx | 73 - mssql/query/driver.cxx | 188 -- mssql/query/test.hxx | 38 - mssql/stored-proc/driver.cxx | 231 -- mssql/stored-proc/test.hxx | 63 - mssql/template/driver.cxx | 40 - mssql/template/template-vc10.vcxproj | 180 -- mssql/template/template-vc10.vcxproj.filters | 25 - mssql/template/template-vc11.vcxproj | 184 -- mssql/template/template-vc11.vcxproj.filters | 25 - mssql/template/template-vc12.vcxproj | 188 -- mssql/template/template-vc12.vcxproj.filters | 25 - mssql/template/template-vc8.vcproj | 354 ---- mssql/template/template-vc9.vcproj | 361 ---- mssql/template/test.hxx | 25 - mssql/types/driver.cxx | 381 ---- mssql/types/test.hxx | 517 ----- mssql/types/traits.hxx | 223 -- mysql-schema.testscript | 9 - mysql.testscript | 12 - mysql/custom/buildfile | 37 - mysql/custom/driver.cxx | 117 -- mysql/custom/query.hxx | 160 -- mysql/custom/test.hxx | 54 - mysql/custom/testscript | 11 - mysql/custom/traits.hxx | 88 - mysql/database/buildfile | 11 - mysql/database/driver.cxx | 72 - mysql/database/testscript | 6 - mysql/index/buildfile | 34 - mysql/index/driver.cxx | 44 - mysql/index/test.hxx | 20 - mysql/index/testscript | 11 - mysql/native/buildfile | 16 - mysql/native/driver.cxx | 75 - mysql/native/testscript | 9 - mysql/truncation/buildfile | 35 - mysql/truncation/driver.cxx | 192 -- mysql/truncation/test.hxx | 48 - mysql/truncation/testscript | 11 - mysql/types/buildfile | 36 - mysql/types/driver.cxx | 168 -- mysql/types/test.hxx | 328 --- mysql/types/testscript | 11 - mysql/types/traits.hxx | 198 -- odb-tests/.gitignore | 41 + odb-tests/GPLv2 | 340 +++ odb-tests/LICENSE | 20 + odb-tests/README.md | 4 + odb-tests/boost/common/multi-index/driver.cxx | 189 ++ odb-tests/boost/common/multi-index/test.hxx | 113 + odb-tests/boost/common/optional/driver.cxx | 74 + odb-tests/boost/common/optional/test.hxx | 31 + odb-tests/boost/common/smart-ptr/driver.cxx | 202 ++ odb-tests/boost/common/smart-ptr/test.hxx | 82 + odb-tests/boost/common/template/driver.cxx | 39 + .../boost/common/template/template-vc10.vcxproj | 177 ++ .../common/template/template-vc10.vcxproj.filters | 24 + .../boost/common/template/template-vc11.vcxproj | 181 ++ .../common/template/template-vc11.vcxproj.filters | 24 + .../boost/common/template/template-vc12.vcxproj | 185 ++ .../common/template/template-vc12.vcxproj.filters | 24 + .../boost/common/template/template-vc8.vcproj | 353 ++++ .../boost/common/template/template-vc9.vcproj | 360 ++++ odb-tests/boost/common/template/test.hxx | 25 + odb-tests/boost/common/unordered/driver.cxx | 212 ++ odb-tests/boost/common/unordered/test.hxx | 113 + odb-tests/boost/common/uuid/driver.cxx | 69 + odb-tests/boost/common/uuid/test.hxx | 37 + odb-tests/boost/mssql/date-time/driver.cxx | 158 ++ odb-tests/boost/mssql/date-time/test.hxx | 58 + odb-tests/boost/mssql/template/driver.cxx | 39 + .../boost/mssql/template/template-vc10.vcxproj | 180 ++ .../mssql/template/template-vc10.vcxproj.filters | 25 + .../boost/mssql/template/template-vc11.vcxproj | 184 ++ .../mssql/template/template-vc11.vcxproj.filters | 25 + .../boost/mssql/template/template-vc12.vcxproj | 188 ++ .../mssql/template/template-vc12.vcxproj.filters | 25 + odb-tests/boost/mssql/template/template-vc8.vcproj | 354 ++++ odb-tests/boost/mssql/template/template-vc9.vcproj | 361 ++++ odb-tests/boost/mssql/template/test.hxx | 25 + odb-tests/boost/mysql/date-time/driver.cxx | 218 ++ odb-tests/boost/mysql/date-time/test.hxx | 65 + odb-tests/boost/mysql/template/driver.cxx | 39 + .../boost/mysql/template/template-vc10.vcxproj | 180 ++ .../mysql/template/template-vc10.vcxproj.filters | 25 + .../boost/mysql/template/template-vc11.vcxproj | 184 ++ .../mysql/template/template-vc11.vcxproj.filters | 25 + .../boost/mysql/template/template-vc12.vcxproj | 188 ++ .../mysql/template/template-vc12.vcxproj.filters | 25 + odb-tests/boost/mysql/template/template-vc8.vcproj | 354 ++++ odb-tests/boost/mysql/template/template-vc9.vcproj | 361 ++++ odb-tests/boost/mysql/template/test.hxx | 25 + odb-tests/boost/oracle/date-time/driver.cxx | 136 ++ odb-tests/boost/oracle/date-time/test.hxx | 42 + odb-tests/boost/oracle/template/driver.cxx | 39 + .../boost/oracle/template/template-vc10.vcxproj | 180 ++ .../oracle/template/template-vc10.vcxproj.filters | 25 + .../boost/oracle/template/template-vc11.vcxproj | 184 ++ .../oracle/template/template-vc11.vcxproj.filters | 25 + .../boost/oracle/template/template-vc12.vcxproj | 188 ++ .../oracle/template/template-vc12.vcxproj.filters | 25 + .../boost/oracle/template/template-vc8.vcproj | 354 ++++ .../boost/oracle/template/template-vc9.vcproj | 361 ++++ odb-tests/boost/oracle/template/test.hxx | 25 + odb-tests/boost/pgsql/date-time/driver.cxx | 157 ++ odb-tests/boost/pgsql/date-time/test.hxx | 39 + odb-tests/boost/pgsql/template/driver.cxx | 39 + .../boost/pgsql/template/template-vc10.vcxproj | 180 ++ .../pgsql/template/template-vc10.vcxproj.filters | 25 + .../boost/pgsql/template/template-vc11.vcxproj | 184 ++ .../pgsql/template/template-vc11.vcxproj.filters | 25 + .../boost/pgsql/template/template-vc12.vcxproj | 188 ++ .../pgsql/template/template-vc12.vcxproj.filters | 25 + odb-tests/boost/pgsql/template/template-vc8.vcproj | 354 ++++ odb-tests/boost/pgsql/template/template-vc9.vcproj | 361 ++++ odb-tests/boost/pgsql/template/test.hxx | 25 + odb-tests/boost/sqlite/date-time/driver.cxx | 208 ++ odb-tests/boost/sqlite/date-time/test.hxx | 57 + odb-tests/boost/sqlite/template/driver.cxx | 39 + .../boost/sqlite/template/template-vc10.vcxproj | 180 ++ .../sqlite/template/template-vc10.vcxproj.filters | 25 + .../boost/sqlite/template/template-vc11.vcxproj | 184 ++ .../sqlite/template/template-vc11.vcxproj.filters | 25 + .../boost/sqlite/template/template-vc12.vcxproj | 188 ++ .../sqlite/template/template-vc12.vcxproj.filters | 25 + .../boost/sqlite/template/template-vc8.vcproj | 354 ++++ .../boost/sqlite/template/template-vc9.vcproj | 361 ++++ odb-tests/boost/sqlite/template/test.hxx | 25 + odb-tests/build/.gitignore | 3 + odb-tests/build/bootstrap.build | 9 + odb-tests/build/export.build | 9 + odb-tests/build/root.build | 270 +++ odb-tests/buildfile | 10 + odb-tests/common/access/buildfile | 45 + odb-tests/common/access/driver.cxx | 262 +++ odb-tests/common/access/test.hxx | 592 ++++++ odb-tests/common/access/testscript | 33 + odb-tests/common/as/buildfile | 49 + odb-tests/common/as/driver.cxx | 348 +++ odb-tests/common/as/test.hxx | 270 +++ odb-tests/common/as/testscript | 33 + odb-tests/common/blob/buildfile | 40 + odb-tests/common/blob/driver.cxx | 76 + odb-tests/common/blob/test.hxx | 71 + odb-tests/common/blob/testscript | 33 + odb-tests/common/buildfile | 6 + odb-tests/common/bulk/buildfile | 49 + odb-tests/common/bulk/driver.cxx | 1203 +++++++++++ odb-tests/common/bulk/test.hxx | 211 ++ odb-tests/common/bulk/testscript | 503 +++++ odb-tests/common/callback/buildfile | 41 + odb-tests/common/callback/driver.cxx | 184 ++ odb-tests/common/callback/test.hxx | 43 + odb-tests/common/callback/testscript | 100 + odb-tests/common/changelog/.gitignore | 3 + .../common/changelog/add-column-mssql-diff.xml | 16 + .../common/changelog/add-column-mssql-patch.xml | 13 + .../common/changelog/add-column-mysql-diff.xml | 16 + .../common/changelog/add-column-mysql-patch.xml | 13 + .../common/changelog/add-column-oracle-diff.xml | 16 + .../common/changelog/add-column-oracle-patch.xml | 13 + .../common/changelog/add-column-pgsql-diff.xml | 16 + .../common/changelog/add-column-pgsql-patch.xml | 13 + .../common/changelog/add-column-sqlite-diff.xml | 16 + .../common/changelog/add-column-sqlite-patch.xml | 13 + odb-tests/common/changelog/add-column.hxx | 20 + .../common/changelog/add-foreign-key-diff.xml | 28 + .../changelog/add-foreign-key-mssql-diff.xml | 28 + .../changelog/add-foreign-key-mssql-patch.xml | 25 + .../changelog/add-foreign-key-mysql-diff.xml | 28 + .../changelog/add-foreign-key-mysql-patch.xml | 25 + .../changelog/add-foreign-key-oracle-diff.xml | 28 + .../changelog/add-foreign-key-oracle-patch.xml | 25 + .../changelog/add-foreign-key-pgsql-diff.xml | 28 + .../changelog/add-foreign-key-pgsql-patch.xml | 25 + .../changelog/add-foreign-key-sqlite-diff.xml | 28 + .../changelog/add-foreign-key-sqlite-patch.xml | 25 + odb-tests/common/changelog/add-foreign-key.hxx | 29 + .../common/changelog/add-index-mssql-diff.xml | 21 + .../common/changelog/add-index-mssql-patch.xml | 18 + .../common/changelog/add-index-mysql-diff.xml | 21 + .../common/changelog/add-index-mysql-patch.xml | 18 + .../common/changelog/add-index-oracle-diff.xml | 21 + .../common/changelog/add-index-oracle-patch.xml | 18 + .../common/changelog/add-index-pgsql-diff.xml | 21 + .../common/changelog/add-index-pgsql-patch.xml | 18 + .../common/changelog/add-index-sqlite-diff.xml | 21 + .../common/changelog/add-index-sqlite-patch.xml | 18 + odb-tests/common/changelog/add-index.hxx | 24 + .../common/changelog/add-table-mssql-diff.xml | 45 + .../common/changelog/add-table-mssql-patch.xml | 44 + .../common/changelog/add-table-mysql-diff.xml | 45 + .../common/changelog/add-table-mysql-patch.xml | 44 + .../common/changelog/add-table-oracle-diff.xml | 45 + .../common/changelog/add-table-oracle-patch.xml | 44 + .../common/changelog/add-table-pgsql-diff.xml | 45 + .../common/changelog/add-table-pgsql-patch.xml | 44 + .../common/changelog/add-table-sqlite-diff.xml | 45 + .../common/changelog/add-table-sqlite-patch.xml | 44 + odb-tests/common/changelog/add-table.hxx | 34 + .../common/changelog/alter-column-mssql-diff.xml | 17 + .../common/changelog/alter-column-mssql-patch.xml | 13 + .../common/changelog/alter-column-mysql-diff.xml | 17 + .../common/changelog/alter-column-mysql-patch.xml | 13 + .../common/changelog/alter-column-oracle-diff.xml | 17 + .../common/changelog/alter-column-oracle-patch.xml | 13 + .../common/changelog/alter-column-pgsql-diff.xml | 17 + .../common/changelog/alter-column-pgsql-patch.xml | 13 + .../common/changelog/alter-column-sqlite-diff.xml | 17 + .../common/changelog/alter-column-sqlite-patch.xml | 13 + odb-tests/common/changelog/alter-column.hxx | 21 + odb-tests/common/changelog/buildfile | 30 + .../common/changelog/drop-column-mssql-diff.xml | 17 + .../common/changelog/drop-column-mssql-patch.xml | 12 + .../common/changelog/drop-column-mysql-diff.xml | 17 + .../common/changelog/drop-column-mysql-patch.xml | 12 + .../common/changelog/drop-column-oracle-diff.xml | 17 + .../common/changelog/drop-column-oracle-patch.xml | 12 + .../common/changelog/drop-column-pgsql-diff.xml | 17 + .../common/changelog/drop-column-pgsql-patch.xml | 12 + .../common/changelog/drop-column-sqlite-diff.xml | 17 + .../common/changelog/drop-column-sqlite-patch.xml | 12 + odb-tests/common/changelog/drop-column.hxx | 20 + .../changelog/drop-foreign-key-mssql-diff.xml | 30 + .../changelog/drop-foreign-key-mssql-patch.xml | 18 + .../changelog/drop-foreign-key-mysql-diff.xml | 30 + .../changelog/drop-foreign-key-mysql-patch.xml | 18 + .../changelog/drop-foreign-key-oracle-diff.xml | 30 + .../changelog/drop-foreign-key-oracle-patch.xml | 18 + .../changelog/drop-foreign-key-pgsql-diff.xml | 30 + .../changelog/drop-foreign-key-pgsql-patch.xml | 18 + .../changelog/drop-foreign-key-sqlite-diff.xml | 30 + .../changelog/drop-foreign-key-sqlite-patch.xml | 18 + odb-tests/common/changelog/drop-foreign-key.hxx | 29 + .../common/changelog/drop-index-mssql-diff.xml | 20 + .../common/changelog/drop-index-mssql-patch.xml | 13 + .../common/changelog/drop-index-mysql-diff.xml | 20 + .../common/changelog/drop-index-mysql-patch.xml | 13 + .../common/changelog/drop-index-oracle-diff.xml | 20 + .../common/changelog/drop-index-oracle-patch.xml | 13 + .../common/changelog/drop-index-pgsql-diff.xml | 20 + .../common/changelog/drop-index-pgsql-patch.xml | 13 + .../common/changelog/drop-index-sqlite-diff.xml | 20 + .../common/changelog/drop-index-sqlite-patch.xml | 13 + odb-tests/common/changelog/drop-index.hxx | 21 + .../common/changelog/drop-table-mssql-diff.xml | 47 + .../common/changelog/drop-table-mssql-patch.xml | 13 + .../common/changelog/drop-table-mysql-diff.xml | 47 + .../common/changelog/drop-table-mysql-patch.xml | 13 + .../common/changelog/drop-table-oracle-diff.xml | 47 + .../common/changelog/drop-table-oracle-patch.xml | 13 + .../common/changelog/drop-table-pgsql-diff.xml | 47 + .../common/changelog/drop-table-pgsql-patch.xml | 13 + .../common/changelog/drop-table-sqlite-diff.xml | 47 + .../common/changelog/drop-table-sqlite-patch.xml | 13 + odb-tests/common/changelog/drop-table.hxx | 34 + odb-tests/common/changelog/model-mssql-diff.xml | 1 + odb-tests/common/changelog/model-mssql-patch.xml | 1 + odb-tests/common/changelog/model-mssql.xml | 56 + odb-tests/common/changelog/model-mysql-diff.xml | 1 + odb-tests/common/changelog/model-mysql-patch.xml | 1 + odb-tests/common/changelog/model-mysql.xml | 56 + odb-tests/common/changelog/model-oracle-diff.xml | 1 + odb-tests/common/changelog/model-oracle-patch.xml | 1 + odb-tests/common/changelog/model-oracle.xml | 56 + odb-tests/common/changelog/model-pgsql-diff.xml | 1 + odb-tests/common/changelog/model-pgsql-patch.xml | 1 + odb-tests/common/changelog/model-pgsql.xml | 56 + odb-tests/common/changelog/model-sqlite-diff.xml | 1 + odb-tests/common/changelog/model-sqlite-patch.xml | 1 + odb-tests/common/changelog/model-sqlite.xml | 56 + odb-tests/common/changelog/model.hxx | 46 + odb-tests/common/changelog/testscript | 66 + odb-tests/common/circular/multiple/.gitignore | 6 + odb-tests/common/circular/multiple/buildfile | 49 + odb-tests/common/circular/multiple/driver.cxx | 69 + odb-tests/common/circular/multiple/test1.hxx | 27 + odb-tests/common/circular/multiple/test2.hxx | 17 + odb-tests/common/circular/multiple/testscript | 31 + odb-tests/common/circular/single/buildfile | 41 + odb-tests/common/circular/single/driver.cxx | 40 + odb-tests/common/circular/single/test.hxx | 28 + odb-tests/common/circular/single/testscript | 33 + odb-tests/common/composite/buildfile | 41 + odb-tests/common/composite/driver.cxx | 229 ++ odb-tests/common/composite/test.hxx | 250 +++ odb-tests/common/composite/testscript | 33 + odb-tests/common/const-member/buildfile | 40 + odb-tests/common/const-member/driver.cxx | 119 ++ odb-tests/common/const-member/test.hxx | 109 + odb-tests/common/const-member/testscript | 33 + odb-tests/common/const-object/buildfile | 41 + odb-tests/common/const-object/driver.cxx | 216 ++ odb-tests/common/const-object/test.hxx | 51 + odb-tests/common/const-object/testscript | 33 + odb-tests/common/container/basics/buildfile | 40 + odb-tests/common/container/basics/driver.cxx | 523 +++++ odb-tests/common/container/basics/test.hxx | 245 +++ odb-tests/common/container/basics/testscript | 33 + .../common/container/change-tracking/buildfile | 40 + .../common/container/change-tracking/driver.cxx | 729 +++++++ .../common/container/change-tracking/test.hxx | 106 + .../common/container/change-tracking/testscript | 33 + odb-tests/common/ctor/buildfile | 41 + odb-tests/common/ctor/driver.cxx | 79 + odb-tests/common/ctor/test.hxx | 29 + odb-tests/common/ctor/testscript | 33 + odb-tests/common/default/buildfile | 41 + odb-tests/common/default/driver.cxx | 81 + odb-tests/common/default/test.hxx | 67 + odb-tests/common/default/testscript | 33 + odb-tests/common/definition/.gitignore | 6 + odb-tests/common/definition/buildfile | 52 + odb-tests/common/definition/driver.cxx | 56 + odb-tests/common/definition/test.hxx | 26 + odb-tests/common/definition/testscript | 33 + odb-tests/common/definition/time-mapping.hxx | 17 + odb-tests/common/enum/buildfile | 41 + odb-tests/common/enum/driver.cxx | 84 + odb-tests/common/enum/test.hxx | 47 + odb-tests/common/enum/testscript | 33 + odb-tests/common/erase-query/buildfile | 41 + odb-tests/common/erase-query/driver.cxx | 181 ++ odb-tests/common/erase-query/test.hxx | 46 + odb-tests/common/erase-query/testscript | 33 + odb-tests/common/id/auto/buildfile | 40 + odb-tests/common/id/auto/driver.cxx | 96 + odb-tests/common/id/auto/test.hxx | 40 + odb-tests/common/id/auto/testscript | 33 + odb-tests/common/id/composite/buildfile | 42 + odb-tests/common/id/composite/driver.cxx | 731 +++++++ odb-tests/common/id/composite/test.hxx | 519 +++++ odb-tests/common/id/composite/testscript | 33 + odb-tests/common/id/nested/buildfile | 41 + odb-tests/common/id/nested/driver.cxx | 266 +++ odb-tests/common/id/nested/test.hxx | 217 ++ odb-tests/common/id/nested/testscript | 33 + odb-tests/common/include/.gitignore | 17 + odb-tests/common/include/buildfile | 51 + odb-tests/common/include/driver.cxx | 42 + odb-tests/common/include/obj1.hxx | 25 + odb-tests/common/include/obj2.hxx | 25 + odb-tests/common/include/obj3.hxx | 25 + odb-tests/common/include/objs1.hxx | 13 + odb-tests/common/include/objs2.hxx | 13 + odb-tests/common/include/objs3.hxx | 11 + odb-tests/common/include/objs4.hxx | 11 + odb-tests/common/include/test1.hxx | 16 + odb-tests/common/include/test2.hxx | 15 + odb-tests/common/include/test3.hxx | 12 + odb-tests/common/include/test4.hxx | 12 + odb-tests/common/include/testscript | 31 + odb-tests/common/index/buildfile | 40 + odb-tests/common/index/driver.cxx | 44 + odb-tests/common/index/test.hxx | 142 ++ odb-tests/common/index/testscript | 33 + .../common/inheritance/polymorphism/.gitignore | 76 + .../common/inheritance/polymorphism/buildfile | 52 + .../common/inheritance/polymorphism/driver.cxx | 2093 ++++++++++++++++++ .../common/inheritance/polymorphism/test1.hxx | 115 + .../common/inheritance/polymorphism/test10.hxx | 78 + .../common/inheritance/polymorphism/test11.hxx | 78 + .../common/inheritance/polymorphism/test12.hxx | 79 + .../common/inheritance/polymorphism/test13.hxx | 46 + .../common/inheritance/polymorphism/test14.hxx | 99 + .../common/inheritance/polymorphism/test15.hxx | 44 + .../common/inheritance/polymorphism/test2.hxx | 105 + .../common/inheritance/polymorphism/test3.hxx | 146 ++ .../common/inheritance/polymorphism/test4.hxx | 84 + .../common/inheritance/polymorphism/test5.hxx | 92 + .../common/inheritance/polymorphism/test6.hxx | 64 + .../common/inheritance/polymorphism/test7.hxx | 54 + .../common/inheritance/polymorphism/test8.hxx | 129 ++ .../common/inheritance/polymorphism/test9.hxx | 161 ++ .../common/inheritance/polymorphism/testscript | 80 + odb-tests/common/inheritance/reuse/buildfile | 41 + odb-tests/common/inheritance/reuse/driver.cxx | 237 +++ odb-tests/common/inheritance/reuse/test.hxx | 163 ++ odb-tests/common/inheritance/reuse/testscript | 33 + odb-tests/common/inheritance/transient/buildfile | 41 + odb-tests/common/inheritance/transient/driver.cxx | 80 + odb-tests/common/inheritance/transient/test.hxx | 60 + odb-tests/common/inheritance/transient/testscript | 33 + odb-tests/common/inverse/buildfile | 42 + odb-tests/common/inverse/driver.cxx | 502 +++++ odb-tests/common/inverse/test.hxx | 391 ++++ odb-tests/common/inverse/testscript | 33 + odb-tests/common/lazy-ptr/buildfile | 41 + odb-tests/common/lazy-ptr/driver.cxx | 360 ++++ odb-tests/common/lazy-ptr/test.hxx | 147 ++ odb-tests/common/lazy-ptr/testscript | 33 + odb-tests/common/lifecycle/buildfile | 40 + odb-tests/common/lifecycle/driver.cxx | 248 +++ odb-tests/common/lifecycle/test.hxx | 27 + odb-tests/common/lifecycle/testscript | 33 + odb-tests/common/no-id/buildfile | 41 + odb-tests/common/no-id/driver.cxx | 102 + odb-tests/common/no-id/test.hxx | 21 + odb-tests/common/no-id/testscript | 33 + odb-tests/common/object/buildfile | 41 + odb-tests/common/object/driver.cxx | 84 + odb-tests/common/object/test.hxx | 49 + odb-tests/common/object/testscript | 33 + odb-tests/common/optimistic/buildfile | 41 + odb-tests/common/optimistic/driver.cxx | 300 +++ odb-tests/common/optimistic/test.hxx | 76 + odb-tests/common/optimistic/testscript | 33 + odb-tests/common/pragma/buildfile | 39 + odb-tests/common/pragma/driver.cxx | 27 + odb-tests/common/pragma/test.hxx | 40 + odb-tests/common/pragma/testscript | 31 + odb-tests/common/prepared/buildfile | 43 + odb-tests/common/prepared/driver.cxx | 444 ++++ odb-tests/common/prepared/test.hxx | 32 + odb-tests/common/prepared/testscript | 33 + odb-tests/common/query/array/buildfile | 43 + odb-tests/common/query/array/driver.cxx | 220 ++ odb-tests/common/query/array/test.hxx | 70 + odb-tests/common/query/array/testscript | 33 + odb-tests/common/query/basics/buildfile | 42 + odb-tests/common/query/basics/driver.cxx | 668 ++++++ odb-tests/common/query/basics/test.hxx | 117 ++ odb-tests/common/query/basics/testscript | 150 ++ odb-tests/common/query/one/buildfile | 42 + odb-tests/common/query/one/driver.cxx | 205 ++ odb-tests/common/query/one/test.hxx | 26 + odb-tests/common/query/one/testscript | 33 + odb-tests/common/readonly/buildfile | 40 + odb-tests/common/readonly/driver.cxx | 324 +++ odb-tests/common/readonly/test.hxx | 225 ++ odb-tests/common/readonly/testscript | 33 + odb-tests/common/relationship/basics/buildfile | 41 + odb-tests/common/relationship/basics/driver.cxx | 150 ++ odb-tests/common/relationship/basics/test.hxx | 260 +++ odb-tests/common/relationship/basics/testscript | 33 + odb-tests/common/relationship/on-delete/buildfile | 43 + odb-tests/common/relationship/on-delete/driver.cxx | 82 + odb-tests/common/relationship/on-delete/test.hxx | 58 + odb-tests/common/relationship/on-delete/testscript | 33 + odb-tests/common/relationship/query/buildfile | 42 + odb-tests/common/relationship/query/driver.cxx | 168 ++ odb-tests/common/relationship/query/test.hxx | 140 ++ odb-tests/common/relationship/query/testscript | 33 + odb-tests/common/schema/embedded/basics/buildfile | 42 + odb-tests/common/schema/embedded/basics/driver.cxx | 59 + odb-tests/common/schema/embedded/basics/test.hxx | 23 + odb-tests/common/schema/embedded/basics/testscript | 31 + odb-tests/common/schema/embedded/order/.gitignore | 6 + odb-tests/common/schema/embedded/order/buildfile | 48 + odb-tests/common/schema/embedded/order/driver.cxx | 65 + odb-tests/common/schema/embedded/order/test1.hxx | 23 + odb-tests/common/schema/embedded/order/test2.hxx | 17 + odb-tests/common/schema/embedded/order/testscript | 31 + odb-tests/common/schema/namespace/buildfile | 41 + odb-tests/common/schema/namespace/driver.cxx | 113 + odb-tests/common/schema/namespace/test.hxx | 158 ++ odb-tests/common/schema/namespace/testscript | 33 + odb-tests/common/section/basics/buildfile | 41 + odb-tests/common/section/basics/driver.cxx | 1735 +++++++++++++++ odb-tests/common/section/basics/test.hxx | 628 ++++++ odb-tests/common/section/basics/testscript | 33 + odb-tests/common/section/polymorphism/buildfile | 41 + odb-tests/common/section/polymorphism/driver.cxx | 1807 ++++++++++++++++ odb-tests/common/section/polymorphism/test.hxx | 542 +++++ odb-tests/common/section/polymorphism/testscript | 33 + odb-tests/common/session/cache/buildfile | 41 + odb-tests/common/session/cache/driver.cxx | 83 + odb-tests/common/session/cache/test.hxx | 50 + odb-tests/common/session/cache/testscript | 33 + odb-tests/common/session/custom/buildfile | 43 + odb-tests/common/session/custom/driver.cxx | 231 ++ odb-tests/common/session/custom/session.cxx | 57 + odb-tests/common/session/custom/session.hxx | 191 ++ odb-tests/common/session/custom/session.txx | 159 ++ odb-tests/common/session/custom/test.hxx | 118 ++ odb-tests/common/session/custom/testscript | 33 + odb-tests/common/statement/processing/buildfile | 8 + odb-tests/common/statement/processing/driver.cxx | 619 ++++++ odb-tests/common/statement/processing/testscript | 6 + odb-tests/common/threads/buildfile | 49 + odb-tests/common/threads/driver.cxx | 236 +++ odb-tests/common/threads/test.hxx | 29 + odb-tests/common/threads/testscript | 50 + odb-tests/common/transaction/basics/buildfile | 13 + odb-tests/common/transaction/basics/driver.cxx | 151 ++ odb-tests/common/transaction/basics/testscript | 62 + odb-tests/common/transaction/callback/buildfile | 13 + odb-tests/common/transaction/callback/driver.cxx | 231 ++ odb-tests/common/transaction/callback/testscript | 72 + odb-tests/common/types/buildfile | 39 + odb-tests/common/types/driver.cxx | 37 + odb-tests/common/types/test.hxx | 55 + odb-tests/common/types/testscript | 6 + odb-tests/common/view/basics/buildfile | 42 + odb-tests/common/view/basics/driver.cxx | 846 ++++++++ odb-tests/common/view/basics/test.hxx | 640 ++++++ odb-tests/common/view/basics/testscript | 33 + odb-tests/common/view/olv/.gitignore | 46 + odb-tests/common/view/olv/buildfile | 50 + odb-tests/common/view/olv/driver.cxx | 654 ++++++ odb-tests/common/view/olv/test1.hxx | 116 + odb-tests/common/view/olv/test2.hxx | 122 ++ odb-tests/common/view/olv/test3.hxx | 106 + odb-tests/common/view/olv/test4.hxx | 151 ++ odb-tests/common/view/olv/test5.hxx | 86 + odb-tests/common/view/olv/test6.hxx | 57 + odb-tests/common/view/olv/test7.hxx | 57 + odb-tests/common/view/olv/test8.hxx | 54 + odb-tests/common/view/olv/test9.hxx | 78 + odb-tests/common/view/olv/testscript | 39 + odb-tests/common/virtual/buildfile | 42 + odb-tests/common/virtual/driver.cxx | 154 ++ odb-tests/common/virtual/test.hxx | 171 ++ odb-tests/common/virtual/testscript | 33 + odb-tests/common/wrapper/buildfile | 40 + odb-tests/common/wrapper/driver.cxx | 216 ++ odb-tests/common/wrapper/test.hxx | 214 ++ odb-tests/common/wrapper/testscript | 33 + odb-tests/database-options.testscript | 75 + odb-tests/evolution/add-column/driver.cxx | 125 ++ odb-tests/evolution/add-column/model.hxx | 38 + odb-tests/evolution/add-column/test1.hxx | 9 + odb-tests/evolution/add-column/test2.hxx | 11 + odb-tests/evolution/add-column/test3.hxx | 11 + odb-tests/evolution/add-foreign-key/driver.cxx | 173 ++ odb-tests/evolution/add-foreign-key/model.hxx | 66 + odb-tests/evolution/add-foreign-key/test1.hxx | 9 + odb-tests/evolution/add-foreign-key/test2.hxx | 11 + odb-tests/evolution/add-foreign-key/test3.hxx | 11 + odb-tests/evolution/add-index/driver.cxx | 165 ++ odb-tests/evolution/add-index/model.hxx | 33 + odb-tests/evolution/add-index/test1.hxx | 9 + odb-tests/evolution/add-index/test2.hxx | 11 + odb-tests/evolution/add-index/test3.hxx | 11 + odb-tests/evolution/add-table/driver.cxx | 140 ++ odb-tests/evolution/add-table/model.hxx | 48 + odb-tests/evolution/add-table/test1.hxx | 9 + odb-tests/evolution/add-table/test2.hxx | 11 + odb-tests/evolution/add-table/test3.hxx | 11 + odb-tests/evolution/alter-column/driver.cxx | 160 ++ odb-tests/evolution/alter-column/model.hxx | 56 + odb-tests/evolution/alter-column/test1.hxx | 9 + odb-tests/evolution/alter-column/test2.hxx | 11 + odb-tests/evolution/alter-column/test3.hxx | 11 + odb-tests/evolution/combined/driver.cxx | 157 ++ odb-tests/evolution/combined/model.hxx | 174 ++ odb-tests/evolution/combined/test1.hxx | 9 + odb-tests/evolution/combined/test2.hxx | 11 + odb-tests/evolution/combined/test3.hxx | 11 + odb-tests/evolution/data/driver.cxx | 178 ++ odb-tests/evolution/data/model.hxx | 45 + odb-tests/evolution/data/test1.hxx | 9 + odb-tests/evolution/data/test2.hxx | 11 + odb-tests/evolution/data/test3.hxx | 11 + odb-tests/evolution/drop-column/driver.cxx | 126 ++ odb-tests/evolution/drop-column/model.hxx | 59 + odb-tests/evolution/drop-column/test1.hxx | 9 + odb-tests/evolution/drop-column/test2.hxx | 11 + odb-tests/evolution/drop-column/test3.hxx | 11 + odb-tests/evolution/drop-foreign-key/driver.cxx | 145 ++ odb-tests/evolution/drop-foreign-key/model.hxx | 50 + odb-tests/evolution/drop-foreign-key/test1.hxx | 9 + odb-tests/evolution/drop-foreign-key/test2.hxx | 11 + odb-tests/evolution/drop-foreign-key/test3.hxx | 11 + odb-tests/evolution/drop-index/driver.cxx | 154 ++ odb-tests/evolution/drop-index/model.hxx | 33 + odb-tests/evolution/drop-index/test1.hxx | 9 + odb-tests/evolution/drop-index/test2.hxx | 11 + odb-tests/evolution/drop-index/test3.hxx | 11 + odb-tests/evolution/drop-table/driver.cxx | 168 ++ odb-tests/evolution/drop-table/model.hxx | 94 + odb-tests/evolution/drop-table/test1.hxx | 9 + odb-tests/evolution/drop-table/test2.hxx | 11 + odb-tests/evolution/drop-table/test3.hxx | 11 + odb-tests/evolution/embedded/driver.cxx | 181 ++ odb-tests/evolution/embedded/model.hxx | 45 + odb-tests/evolution/embedded/test1.hxx | 9 + odb-tests/evolution/embedded/test2.hxx | 11 + odb-tests/evolution/embedded/test3.hxx | 11 + odb-tests/evolution/soft-add/driver.cxx | 2219 ++++++++++++++++++++ odb-tests/evolution/soft-add/model.hxx | 504 +++++ odb-tests/evolution/soft-add/test1.hxx | 9 + odb-tests/evolution/soft-add/test2.hxx | 11 + odb-tests/evolution/soft-add/test3.hxx | 11 + odb-tests/evolution/soft-delete/driver.cxx | 2202 +++++++++++++++++++ odb-tests/evolution/soft-delete/model.hxx | 518 +++++ odb-tests/evolution/soft-delete/test1.hxx | 9 + odb-tests/evolution/soft-delete/test2.hxx | 11 + odb-tests/evolution/soft-delete/test3.hxx | 11 + odb-tests/evolution/template/driver.cxx | 124 ++ odb-tests/evolution/template/model.hxx | 40 + odb-tests/evolution/template/template-vc10.vcxproj | 196 ++ .../template/template-vc10.vcxproj.filters | 32 + odb-tests/evolution/template/template-vc11.vcxproj | 200 ++ .../template/template-vc11.vcxproj.filters | 32 + odb-tests/evolution/template/template-vc12.vcxproj | 204 ++ .../template/template-vc12.vcxproj.filters | 32 + odb-tests/evolution/template/template-vc8.vcproj | 372 ++++ odb-tests/evolution/template/template-vc9.vcproj | 379 ++++ odb-tests/evolution/template/test1.hxx | 9 + odb-tests/evolution/template/test2.hxx | 11 + odb-tests/evolution/template/test3.hxx | 11 + odb-tests/evolution/version/driver.cxx | 156 ++ odb-tests/evolution/version/model.hxx | 45 + odb-tests/evolution/version/test1.hxx | 9 + odb-tests/evolution/version/test2.hxx | 11 + odb-tests/evolution/version/test3.hxx | 11 + odb-tests/libcommon/.gitignore | 3 + odb-tests/libcommon/buffer.hxx | 104 + odb-tests/libcommon/buildfile | 50 + odb-tests/libcommon/common.cxx | 355 ++++ odb-tests/libcommon/common.hxx | 47 + odb-tests/libcommon/common.txx | 24 + odb-tests/libcommon/concrete.hxx | 57 + odb-tests/libcommon/config.hxx.in | 14 + odb-tests/libcommon/export.hxx | 39 + odb-tests/manifest | 48 + odb-tests/mssql/custom/custom.sql | 42 + odb-tests/mssql/custom/driver.cxx | 135 ++ odb-tests/mssql/custom/query.hxx | 183 ++ odb-tests/mssql/custom/test.hxx | 121 ++ odb-tests/mssql/custom/traits.cxx | 128 ++ odb-tests/mssql/custom/traits.hxx | 148 ++ odb-tests/mssql/database/driver.cxx | 105 + odb-tests/mssql/native/driver.cxx | 73 + odb-tests/mssql/query/driver.cxx | 188 ++ odb-tests/mssql/query/test.hxx | 38 + odb-tests/mssql/stored-proc/driver.cxx | 231 ++ odb-tests/mssql/stored-proc/test.hxx | 63 + odb-tests/mssql/template/driver.cxx | 40 + odb-tests/mssql/template/template-vc10.vcxproj | 180 ++ .../mssql/template/template-vc10.vcxproj.filters | 25 + odb-tests/mssql/template/template-vc11.vcxproj | 184 ++ .../mssql/template/template-vc11.vcxproj.filters | 25 + odb-tests/mssql/template/template-vc12.vcxproj | 188 ++ .../mssql/template/template-vc12.vcxproj.filters | 25 + odb-tests/mssql/template/template-vc8.vcproj | 354 ++++ odb-tests/mssql/template/template-vc9.vcproj | 361 ++++ odb-tests/mssql/template/test.hxx | 25 + odb-tests/mssql/types/driver.cxx | 381 ++++ odb-tests/mssql/types/test.hxx | 517 +++++ odb-tests/mssql/types/traits.hxx | 223 ++ odb-tests/mysql-schema.testscript | 9 + odb-tests/mysql.testscript | 12 + odb-tests/mysql/custom/buildfile | 37 + odb-tests/mysql/custom/driver.cxx | 117 ++ odb-tests/mysql/custom/query.hxx | 160 ++ odb-tests/mysql/custom/test.hxx | 54 + odb-tests/mysql/custom/testscript | 11 + odb-tests/mysql/custom/traits.hxx | 88 + odb-tests/mysql/database/buildfile | 11 + odb-tests/mysql/database/driver.cxx | 72 + odb-tests/mysql/database/testscript | 6 + odb-tests/mysql/index/buildfile | 34 + odb-tests/mysql/index/driver.cxx | 44 + odb-tests/mysql/index/test.hxx | 20 + odb-tests/mysql/index/testscript | 11 + odb-tests/mysql/native/buildfile | 16 + odb-tests/mysql/native/driver.cxx | 75 + odb-tests/mysql/native/testscript | 9 + odb-tests/mysql/truncation/buildfile | 35 + odb-tests/mysql/truncation/driver.cxx | 192 ++ odb-tests/mysql/truncation/test.hxx | 48 + odb-tests/mysql/truncation/testscript | 11 + odb-tests/mysql/types/buildfile | 36 + odb-tests/mysql/types/driver.cxx | 168 ++ odb-tests/mysql/types/test.hxx | 328 +++ odb-tests/mysql/types/testscript | 11 + odb-tests/mysql/types/traits.hxx | 198 ++ odb-tests/oracle/custom/custom.sql | 53 + odb-tests/oracle/custom/driver.cxx | 77 + odb-tests/oracle/custom/test.hxx | 40 + odb-tests/oracle/custom/traits.hxx | 76 + odb-tests/oracle/database/driver.cxx | 33 + odb-tests/oracle/native/driver.cxx | 77 + odb-tests/oracle/template/driver.cxx | 40 + odb-tests/oracle/template/template-vc10.vcxproj | 180 ++ .../oracle/template/template-vc10.vcxproj.filters | 25 + odb-tests/oracle/template/template-vc11.vcxproj | 184 ++ .../oracle/template/template-vc11.vcxproj.filters | 25 + odb-tests/oracle/template/template-vc12.vcxproj | 188 ++ .../oracle/template/template-vc12.vcxproj.filters | 25 + odb-tests/oracle/template/template-vc8.vcproj | 354 ++++ odb-tests/oracle/template/template-vc9.vcproj | 361 ++++ odb-tests/oracle/template/test.hxx | 25 + odb-tests/oracle/types/driver.cxx | 366 ++++ odb-tests/oracle/types/test.hxx | 353 ++++ odb-tests/oracle/types/traits.hxx | 192 ++ odb-tests/pgsql-schema.testscript | 6 + odb-tests/pgsql.testscript | 12 + odb-tests/pgsql/buildfile | 6 + odb-tests/pgsql/bulk/buildfile | 40 + odb-tests/pgsql/bulk/driver.cxx | 361 ++++ odb-tests/pgsql/bulk/test.hxx | 34 + odb-tests/pgsql/bulk/testscript | 18 + odb-tests/pgsql/custom/buildfile | 37 + odb-tests/pgsql/custom/driver.cxx | 125 ++ odb-tests/pgsql/custom/query.hxx | 158 ++ odb-tests/pgsql/custom/test.hxx | 86 + odb-tests/pgsql/custom/testscript | 11 + odb-tests/pgsql/custom/traits.hxx | 166 ++ odb-tests/pgsql/database/buildfile | 11 + odb-tests/pgsql/database/driver.cxx | 44 + odb-tests/pgsql/database/testscript | 6 + odb-tests/pgsql/index/buildfile | 34 + odb-tests/pgsql/index/driver.cxx | 44 + odb-tests/pgsql/index/test.hxx | 19 + odb-tests/pgsql/index/testscript | 11 + odb-tests/pgsql/native/buildfile | 16 + odb-tests/pgsql/native/driver.cxx | 75 + odb-tests/pgsql/native/testscript | 9 + odb-tests/pgsql/truncation/buildfile | 35 + odb-tests/pgsql/truncation/driver.cxx | 163 ++ odb-tests/pgsql/truncation/test.hxx | 46 + odb-tests/pgsql/truncation/testscript | 11 + odb-tests/pgsql/types/buildfile | 36 + odb-tests/pgsql/types/driver.cxx | 165 ++ odb-tests/pgsql/types/test.hxx | 220 ++ odb-tests/pgsql/types/testscript | 11 + odb-tests/pgsql/types/traits.hxx | 171 ++ odb-tests/qt/common/basic/driver.cxx | 66 + odb-tests/qt/common/basic/test.hxx | 35 + odb-tests/qt/common/containers/basics/driver.cxx | 569 +++++ odb-tests/qt/common/containers/basics/test.hxx | 224 ++ .../common/containers/change-tracking/driver.cxx | 643 ++++++ .../qt/common/containers/change-tracking/test.hxx | 46 + odb-tests/qt/common/smart-ptr/driver.cxx | 248 +++ odb-tests/qt/common/smart-ptr/test.hxx | 77 + odb-tests/qt/common/template/driver.cxx | 43 + .../qt/common/template/template-qt4-vc10.vcxproj | 177 ++ .../template/template-qt4-vc10.vcxproj.filters | 24 + .../qt/common/template/template-qt4-vc11.vcxproj | 181 ++ .../template/template-qt4-vc11.vcxproj.filters | 24 + .../qt/common/template/template-qt4-vc12.vcxproj | 185 ++ .../template/template-qt4-vc12.vcxproj.filters | 24 + .../qt/common/template/template-qt4-vc8.vcproj | 353 ++++ .../qt/common/template/template-qt4-vc9.vcproj | 360 ++++ .../qt/common/template/template-qt5-vc10.vcxproj | 177 ++ .../template/template-qt5-vc10.vcxproj.filters | 24 + .../qt/common/template/template-qt5-vc11.vcxproj | 181 ++ .../template/template-qt5-vc11.vcxproj.filters | 24 + .../qt/common/template/template-qt5-vc12.vcxproj | 185 ++ .../template/template-qt5-vc12.vcxproj.filters | 24 + .../qt/common/template/template-qt5-vc9.vcproj | 360 ++++ odb-tests/qt/common/template/test.hxx | 25 + odb-tests/qt/mssql/basic/driver.cxx | 65 + odb-tests/qt/mssql/basic/test.hxx | 46 + odb-tests/qt/mssql/date-time/driver.cxx | 94 + odb-tests/qt/mssql/date-time/test.hxx | 68 + odb-tests/qt/mssql/template/driver.cxx | 43 + .../qt/mssql/template/template-qt4-vc10.vcxproj | 180 ++ .../template/template-qt4-vc10.vcxproj.filters | 25 + .../qt/mssql/template/template-qt4-vc11.vcxproj | 184 ++ .../template/template-qt4-vc11.vcxproj.filters | 25 + .../qt/mssql/template/template-qt4-vc12.vcxproj | 188 ++ .../template/template-qt4-vc12.vcxproj.filters | 25 + .../qt/mssql/template/template-qt4-vc8.vcproj | 354 ++++ .../qt/mssql/template/template-qt4-vc9.vcproj | 361 ++++ .../qt/mssql/template/template-qt5-vc10.vcxproj | 180 ++ .../template/template-qt5-vc10.vcxproj.filters | 25 + .../qt/mssql/template/template-qt5-vc11.vcxproj | 184 ++ .../template/template-qt5-vc11.vcxproj.filters | 25 + .../qt/mssql/template/template-qt5-vc12.vcxproj | 188 ++ .../template/template-qt5-vc12.vcxproj.filters | 25 + .../qt/mssql/template/template-qt5-vc9.vcproj | 361 ++++ odb-tests/qt/mssql/template/test.hxx | 25 + odb-tests/qt/mysql/basic/driver.cxx | 60 + odb-tests/qt/mysql/basic/test.hxx | 27 + odb-tests/qt/mysql/date-time/driver.cxx | 178 ++ odb-tests/qt/mysql/date-time/test.hxx | 70 + odb-tests/qt/mysql/template/driver.cxx | 43 + .../qt/mysql/template/template-qt4-vc10.vcxproj | 180 ++ .../template/template-qt4-vc10.vcxproj.filters | 25 + .../qt/mysql/template/template-qt4-vc11.vcxproj | 184 ++ .../template/template-qt4-vc11.vcxproj.filters | 25 + .../qt/mysql/template/template-qt4-vc12.vcxproj | 188 ++ .../template/template-qt4-vc12.vcxproj.filters | 25 + .../qt/mysql/template/template-qt4-vc8.vcproj | 354 ++++ .../qt/mysql/template/template-qt4-vc9.vcproj | 361 ++++ .../qt/mysql/template/template-qt5-vc10.vcxproj | 180 ++ .../template/template-qt5-vc10.vcxproj.filters | 25 + .../qt/mysql/template/template-qt5-vc11.vcxproj | 184 ++ .../template/template-qt5-vc11.vcxproj.filters | 25 + .../qt/mysql/template/template-qt5-vc12.vcxproj | 188 ++ .../template/template-qt5-vc12.vcxproj.filters | 25 + .../qt/mysql/template/template-qt5-vc9.vcproj | 361 ++++ odb-tests/qt/mysql/template/test.hxx | 25 + odb-tests/qt/oracle/basic/driver.cxx | 81 + odb-tests/qt/oracle/basic/test.hxx | 51 + odb-tests/qt/oracle/date-time/driver.cxx | 80 + odb-tests/qt/oracle/date-time/test.hxx | 45 + odb-tests/qt/oracle/template/driver.cxx | 43 + .../qt/oracle/template/template-qt4-vc10.vcxproj | 180 ++ .../template/template-qt4-vc10.vcxproj.filters | 25 + .../qt/oracle/template/template-qt4-vc11.vcxproj | 184 ++ .../template/template-qt4-vc11.vcxproj.filters | 25 + .../qt/oracle/template/template-qt4-vc12.vcxproj | 188 ++ .../template/template-qt4-vc12.vcxproj.filters | 25 + .../qt/oracle/template/template-qt4-vc8.vcproj | 354 ++++ .../qt/oracle/template/template-qt4-vc9.vcproj | 361 ++++ .../qt/oracle/template/template-qt5-vc10.vcxproj | 180 ++ .../template/template-qt5-vc10.vcxproj.filters | 25 + .../qt/oracle/template/template-qt5-vc11.vcxproj | 184 ++ .../template/template-qt5-vc11.vcxproj.filters | 25 + .../qt/oracle/template/template-qt5-vc12.vcxproj | 188 ++ .../template/template-qt5-vc12.vcxproj.filters | 25 + .../qt/oracle/template/template-qt5-vc9.vcproj | 361 ++++ odb-tests/qt/oracle/template/test.hxx | 25 + odb-tests/qt/pgsql/basic/driver.cxx | 60 + odb-tests/qt/pgsql/basic/test.hxx | 27 + odb-tests/qt/pgsql/date-time/driver.cxx | 108 + odb-tests/qt/pgsql/date-time/test.hxx | 43 + odb-tests/qt/pgsql/template/driver.cxx | 43 + .../qt/pgsql/template/template-qt4-vc10.vcxproj | 180 ++ .../template/template-qt4-vc10.vcxproj.filters | 25 + .../qt/pgsql/template/template-qt4-vc11.vcxproj | 184 ++ .../template/template-qt4-vc11.vcxproj.filters | 25 + .../qt/pgsql/template/template-qt4-vc12.vcxproj | 188 ++ .../template/template-qt4-vc12.vcxproj.filters | 25 + .../qt/pgsql/template/template-qt4-vc8.vcproj | 354 ++++ .../qt/pgsql/template/template-qt4-vc9.vcproj | 361 ++++ .../qt/pgsql/template/template-qt5-vc10.vcxproj | 180 ++ .../template/template-qt5-vc10.vcxproj.filters | 25 + .../qt/pgsql/template/template-qt5-vc11.vcxproj | 184 ++ .../template/template-qt5-vc11.vcxproj.filters | 25 + .../qt/pgsql/template/template-qt5-vc12.vcxproj | 188 ++ .../template/template-qt5-vc12.vcxproj.filters | 25 + .../qt/pgsql/template/template-qt5-vc9.vcproj | 361 ++++ odb-tests/qt/pgsql/template/test.hxx | 25 + odb-tests/qt/sqlite/basic/driver.cxx | 60 + odb-tests/qt/sqlite/basic/test.hxx | 27 + odb-tests/qt/sqlite/date-time/driver.cxx | 140 ++ odb-tests/qt/sqlite/date-time/test.hxx | 60 + odb-tests/qt/sqlite/template/driver.cxx | 43 + .../qt/sqlite/template/template-qt4-vc10.vcxproj | 180 ++ .../template/template-qt4-vc10.vcxproj.filters | 25 + .../qt/sqlite/template/template-qt4-vc11.vcxproj | 184 ++ .../template/template-qt4-vc11.vcxproj.filters | 25 + .../qt/sqlite/template/template-qt4-vc12.vcxproj | 188 ++ .../template/template-qt4-vc12.vcxproj.filters | 25 + .../qt/sqlite/template/template-qt4-vc8.vcproj | 354 ++++ .../qt/sqlite/template/template-qt4-vc9.vcproj | 361 ++++ .../qt/sqlite/template/template-qt5-vc10.vcxproj | 180 ++ .../template/template-qt5-vc10.vcxproj.filters | 25 + .../qt/sqlite/template/template-qt5-vc11.vcxproj | 184 ++ .../template/template-qt5-vc11.vcxproj.filters | 25 + .../qt/sqlite/template/template-qt5-vc12.vcxproj | 188 ++ .../template/template-qt5-vc12.vcxproj.filters | 25 + .../qt/sqlite/template/template-qt5-vc9.vcproj | 361 ++++ odb-tests/qt/sqlite/template/test.hxx | 25 + odb-tests/sqlite.testscript | 10 + odb-tests/sqlite/attach/buildfile | 32 + odb-tests/sqlite/attach/driver.cxx | 109 + odb-tests/sqlite/attach/test.hxx | 32 + odb-tests/sqlite/attach/testscript | 9 + odb-tests/sqlite/auto/buildfile | 32 + odb-tests/sqlite/auto/driver.cxx | 76 + odb-tests/sqlite/auto/test.hxx | 32 + odb-tests/sqlite/auto/testscript | 9 + odb-tests/sqlite/custom/buildfile | 31 + odb-tests/sqlite/custom/driver.cxx | 78 + odb-tests/sqlite/custom/test.hxx | 39 + odb-tests/sqlite/custom/testscript | 9 + odb-tests/sqlite/database/buildfile | 11 + odb-tests/sqlite/database/driver.cxx | 40 + odb-tests/sqlite/database/testscript | 6 + odb-tests/sqlite/native/buildfile | 12 + odb-tests/sqlite/native/driver.cxx | 74 + odb-tests/sqlite/native/testscript | 9 + odb-tests/sqlite/stream/buildfile | 31 + odb-tests/sqlite/stream/driver.cxx | 281 +++ odb-tests/sqlite/stream/test.hxx | 37 + odb-tests/sqlite/stream/testscript | 9 + odb-tests/sqlite/transaction/buildfile | 30 + odb-tests/sqlite/transaction/driver.cxx | 61 + odb-tests/sqlite/transaction/test.hxx | 26 + odb-tests/sqlite/transaction/testscript | 9 + odb-tests/sqlite/truncation/buildfile | 31 + odb-tests/sqlite/truncation/driver.cxx | 163 ++ odb-tests/sqlite/truncation/test.hxx | 46 + odb-tests/sqlite/truncation/testscript | 9 + odb-tests/sqlite/types/buildfile | 32 + odb-tests/sqlite/types/driver.cxx | 113 + odb-tests/sqlite/types/test.hxx | 125 ++ odb-tests/sqlite/types/testscript | 9 + odb-tests/sqlite/types/traits.hxx | 57 + oracle/custom/custom.sql | 53 - oracle/custom/driver.cxx | 77 - oracle/custom/test.hxx | 40 - oracle/custom/traits.hxx | 76 - oracle/database/driver.cxx | 33 - oracle/native/driver.cxx | 77 - oracle/template/driver.cxx | 40 - oracle/template/template-vc10.vcxproj | 180 -- oracle/template/template-vc10.vcxproj.filters | 25 - oracle/template/template-vc11.vcxproj | 184 -- oracle/template/template-vc11.vcxproj.filters | 25 - oracle/template/template-vc12.vcxproj | 188 -- oracle/template/template-vc12.vcxproj.filters | 25 - oracle/template/template-vc8.vcproj | 354 ---- oracle/template/template-vc9.vcproj | 361 ---- oracle/template/test.hxx | 25 - oracle/types/driver.cxx | 366 ---- oracle/types/test.hxx | 353 ---- oracle/types/traits.hxx | 192 -- pgsql-schema.testscript | 6 - pgsql.testscript | 12 - pgsql/buildfile | 6 - pgsql/bulk/buildfile | 40 - pgsql/bulk/driver.cxx | 361 ---- pgsql/bulk/test.hxx | 34 - pgsql/bulk/testscript | 18 - pgsql/custom/buildfile | 37 - pgsql/custom/driver.cxx | 125 -- pgsql/custom/query.hxx | 158 -- pgsql/custom/test.hxx | 86 - pgsql/custom/testscript | 11 - pgsql/custom/traits.hxx | 166 -- pgsql/database/buildfile | 11 - pgsql/database/driver.cxx | 44 - pgsql/database/testscript | 6 - pgsql/index/buildfile | 34 - pgsql/index/driver.cxx | 44 - pgsql/index/test.hxx | 19 - pgsql/index/testscript | 11 - pgsql/native/buildfile | 16 - pgsql/native/driver.cxx | 75 - pgsql/native/testscript | 9 - pgsql/truncation/buildfile | 35 - pgsql/truncation/driver.cxx | 163 -- pgsql/truncation/test.hxx | 46 - pgsql/truncation/testscript | 11 - pgsql/types/buildfile | 36 - pgsql/types/driver.cxx | 165 -- pgsql/types/test.hxx | 220 -- pgsql/types/testscript | 11 - pgsql/types/traits.hxx | 171 -- qt/common/basic/driver.cxx | 66 - qt/common/basic/test.hxx | 35 - qt/common/containers/basics/driver.cxx | 569 ----- qt/common/containers/basics/test.hxx | 224 -- qt/common/containers/change-tracking/driver.cxx | 643 ------ qt/common/containers/change-tracking/test.hxx | 46 - qt/common/smart-ptr/driver.cxx | 248 --- qt/common/smart-ptr/test.hxx | 77 - qt/common/template/driver.cxx | 43 - qt/common/template/template-qt4-vc10.vcxproj | 177 -- .../template/template-qt4-vc10.vcxproj.filters | 24 - qt/common/template/template-qt4-vc11.vcxproj | 181 -- .../template/template-qt4-vc11.vcxproj.filters | 24 - qt/common/template/template-qt4-vc12.vcxproj | 185 -- .../template/template-qt4-vc12.vcxproj.filters | 24 - qt/common/template/template-qt4-vc8.vcproj | 353 ---- qt/common/template/template-qt4-vc9.vcproj | 360 ---- qt/common/template/template-qt5-vc10.vcxproj | 177 -- .../template/template-qt5-vc10.vcxproj.filters | 24 - qt/common/template/template-qt5-vc11.vcxproj | 181 -- .../template/template-qt5-vc11.vcxproj.filters | 24 - qt/common/template/template-qt5-vc12.vcxproj | 185 -- .../template/template-qt5-vc12.vcxproj.filters | 24 - qt/common/template/template-qt5-vc9.vcproj | 360 ---- qt/common/template/test.hxx | 25 - qt/mssql/basic/driver.cxx | 65 - qt/mssql/basic/test.hxx | 46 - qt/mssql/date-time/driver.cxx | 94 - qt/mssql/date-time/test.hxx | 68 - qt/mssql/template/driver.cxx | 43 - qt/mssql/template/template-qt4-vc10.vcxproj | 180 -- .../template/template-qt4-vc10.vcxproj.filters | 25 - qt/mssql/template/template-qt4-vc11.vcxproj | 184 -- .../template/template-qt4-vc11.vcxproj.filters | 25 - qt/mssql/template/template-qt4-vc12.vcxproj | 188 -- .../template/template-qt4-vc12.vcxproj.filters | 25 - qt/mssql/template/template-qt4-vc8.vcproj | 354 ---- qt/mssql/template/template-qt4-vc9.vcproj | 361 ---- qt/mssql/template/template-qt5-vc10.vcxproj | 180 -- .../template/template-qt5-vc10.vcxproj.filters | 25 - qt/mssql/template/template-qt5-vc11.vcxproj | 184 -- .../template/template-qt5-vc11.vcxproj.filters | 25 - qt/mssql/template/template-qt5-vc12.vcxproj | 188 -- .../template/template-qt5-vc12.vcxproj.filters | 25 - qt/mssql/template/template-qt5-vc9.vcproj | 361 ---- qt/mssql/template/test.hxx | 25 - qt/mysql/basic/driver.cxx | 60 - qt/mysql/basic/test.hxx | 27 - qt/mysql/date-time/driver.cxx | 178 -- qt/mysql/date-time/test.hxx | 70 - qt/mysql/template/driver.cxx | 43 - qt/mysql/template/template-qt4-vc10.vcxproj | 180 -- .../template/template-qt4-vc10.vcxproj.filters | 25 - qt/mysql/template/template-qt4-vc11.vcxproj | 184 -- .../template/template-qt4-vc11.vcxproj.filters | 25 - qt/mysql/template/template-qt4-vc12.vcxproj | 188 -- .../template/template-qt4-vc12.vcxproj.filters | 25 - qt/mysql/template/template-qt4-vc8.vcproj | 354 ---- qt/mysql/template/template-qt4-vc9.vcproj | 361 ---- qt/mysql/template/template-qt5-vc10.vcxproj | 180 -- .../template/template-qt5-vc10.vcxproj.filters | 25 - qt/mysql/template/template-qt5-vc11.vcxproj | 184 -- .../template/template-qt5-vc11.vcxproj.filters | 25 - qt/mysql/template/template-qt5-vc12.vcxproj | 188 -- .../template/template-qt5-vc12.vcxproj.filters | 25 - qt/mysql/template/template-qt5-vc9.vcproj | 361 ---- qt/mysql/template/test.hxx | 25 - qt/oracle/basic/driver.cxx | 81 - qt/oracle/basic/test.hxx | 51 - qt/oracle/date-time/driver.cxx | 80 - qt/oracle/date-time/test.hxx | 45 - qt/oracle/template/driver.cxx | 43 - qt/oracle/template/template-qt4-vc10.vcxproj | 180 -- .../template/template-qt4-vc10.vcxproj.filters | 25 - qt/oracle/template/template-qt4-vc11.vcxproj | 184 -- .../template/template-qt4-vc11.vcxproj.filters | 25 - qt/oracle/template/template-qt4-vc12.vcxproj | 188 -- .../template/template-qt4-vc12.vcxproj.filters | 25 - qt/oracle/template/template-qt4-vc8.vcproj | 354 ---- qt/oracle/template/template-qt4-vc9.vcproj | 361 ---- qt/oracle/template/template-qt5-vc10.vcxproj | 180 -- .../template/template-qt5-vc10.vcxproj.filters | 25 - qt/oracle/template/template-qt5-vc11.vcxproj | 184 -- .../template/template-qt5-vc11.vcxproj.filters | 25 - qt/oracle/template/template-qt5-vc12.vcxproj | 188 -- .../template/template-qt5-vc12.vcxproj.filters | 25 - qt/oracle/template/template-qt5-vc9.vcproj | 361 ---- qt/oracle/template/test.hxx | 25 - qt/pgsql/basic/driver.cxx | 60 - qt/pgsql/basic/test.hxx | 27 - qt/pgsql/date-time/driver.cxx | 108 - qt/pgsql/date-time/test.hxx | 43 - qt/pgsql/template/driver.cxx | 43 - qt/pgsql/template/template-qt4-vc10.vcxproj | 180 -- .../template/template-qt4-vc10.vcxproj.filters | 25 - qt/pgsql/template/template-qt4-vc11.vcxproj | 184 -- .../template/template-qt4-vc11.vcxproj.filters | 25 - qt/pgsql/template/template-qt4-vc12.vcxproj | 188 -- .../template/template-qt4-vc12.vcxproj.filters | 25 - qt/pgsql/template/template-qt4-vc8.vcproj | 354 ---- qt/pgsql/template/template-qt4-vc9.vcproj | 361 ---- qt/pgsql/template/template-qt5-vc10.vcxproj | 180 -- .../template/template-qt5-vc10.vcxproj.filters | 25 - qt/pgsql/template/template-qt5-vc11.vcxproj | 184 -- .../template/template-qt5-vc11.vcxproj.filters | 25 - qt/pgsql/template/template-qt5-vc12.vcxproj | 188 -- .../template/template-qt5-vc12.vcxproj.filters | 25 - qt/pgsql/template/template-qt5-vc9.vcproj | 361 ---- qt/pgsql/template/test.hxx | 25 - qt/sqlite/basic/driver.cxx | 60 - qt/sqlite/basic/test.hxx | 27 - qt/sqlite/date-time/driver.cxx | 140 -- qt/sqlite/date-time/test.hxx | 60 - qt/sqlite/template/driver.cxx | 43 - qt/sqlite/template/template-qt4-vc10.vcxproj | 180 -- .../template/template-qt4-vc10.vcxproj.filters | 25 - qt/sqlite/template/template-qt4-vc11.vcxproj | 184 -- .../template/template-qt4-vc11.vcxproj.filters | 25 - qt/sqlite/template/template-qt4-vc12.vcxproj | 188 -- .../template/template-qt4-vc12.vcxproj.filters | 25 - qt/sqlite/template/template-qt4-vc8.vcproj | 354 ---- qt/sqlite/template/template-qt4-vc9.vcproj | 361 ---- qt/sqlite/template/template-qt5-vc10.vcxproj | 180 -- .../template/template-qt5-vc10.vcxproj.filters | 25 - qt/sqlite/template/template-qt5-vc11.vcxproj | 184 -- .../template/template-qt5-vc11.vcxproj.filters | 25 - qt/sqlite/template/template-qt5-vc12.vcxproj | 188 -- .../template/template-qt5-vc12.vcxproj.filters | 25 - qt/sqlite/template/template-qt5-vc9.vcproj | 361 ---- qt/sqlite/template/test.hxx | 25 - repositories.manifest | 44 - sqlite.testscript | 10 - sqlite/attach/buildfile | 32 - sqlite/attach/driver.cxx | 109 - sqlite/attach/test.hxx | 32 - sqlite/attach/testscript | 9 - sqlite/auto/buildfile | 32 - sqlite/auto/driver.cxx | 76 - sqlite/auto/test.hxx | 32 - sqlite/auto/testscript | 9 - sqlite/custom/buildfile | 31 - sqlite/custom/driver.cxx | 78 - sqlite/custom/test.hxx | 39 - sqlite/custom/testscript | 9 - sqlite/database/buildfile | 11 - sqlite/database/driver.cxx | 40 - sqlite/database/testscript | 6 - sqlite/native/buildfile | 12 - sqlite/native/driver.cxx | 74 - sqlite/native/testscript | 9 - sqlite/stream/buildfile | 31 - sqlite/stream/driver.cxx | 281 --- sqlite/stream/test.hxx | 37 - sqlite/stream/testscript | 9 - sqlite/transaction/buildfile | 30 - sqlite/transaction/driver.cxx | 61 - sqlite/transaction/test.hxx | 26 - sqlite/transaction/testscript | 9 - sqlite/truncation/buildfile | 31 - sqlite/truncation/driver.cxx | 163 -- sqlite/truncation/test.hxx | 46 - sqlite/truncation/testscript | 9 - sqlite/types/buildfile | 32 - sqlite/types/driver.cxx | 113 - sqlite/types/test.hxx | 125 -- sqlite/types/testscript | 9 - sqlite/types/traits.hxx | 57 - 1685 files changed, 90096 insertions(+), 90140 deletions(-) delete mode 100644 .gitignore delete mode 100644 GPLv2 delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 boost/common/multi-index/driver.cxx delete mode 100644 boost/common/multi-index/test.hxx delete mode 100644 boost/common/optional/driver.cxx delete mode 100644 boost/common/optional/test.hxx delete mode 100644 boost/common/smart-ptr/driver.cxx delete mode 100644 boost/common/smart-ptr/test.hxx delete mode 100644 boost/common/template/driver.cxx delete mode 100644 boost/common/template/template-vc10.vcxproj delete mode 100644 boost/common/template/template-vc10.vcxproj.filters delete mode 100644 boost/common/template/template-vc11.vcxproj delete mode 100644 boost/common/template/template-vc11.vcxproj.filters delete mode 100644 boost/common/template/template-vc12.vcxproj delete mode 100644 boost/common/template/template-vc12.vcxproj.filters delete mode 100644 boost/common/template/template-vc8.vcproj delete mode 100644 boost/common/template/template-vc9.vcproj delete mode 100644 boost/common/template/test.hxx delete mode 100644 boost/common/unordered/driver.cxx delete mode 100644 boost/common/unordered/test.hxx delete mode 100644 boost/common/uuid/driver.cxx delete mode 100644 boost/common/uuid/test.hxx delete mode 100644 boost/mssql/date-time/driver.cxx delete mode 100644 boost/mssql/date-time/test.hxx delete mode 100644 boost/mssql/template/driver.cxx delete mode 100644 boost/mssql/template/template-vc10.vcxproj delete mode 100644 boost/mssql/template/template-vc10.vcxproj.filters delete mode 100644 boost/mssql/template/template-vc11.vcxproj delete mode 100644 boost/mssql/template/template-vc11.vcxproj.filters delete mode 100644 boost/mssql/template/template-vc12.vcxproj delete mode 100644 boost/mssql/template/template-vc12.vcxproj.filters delete mode 100644 boost/mssql/template/template-vc8.vcproj delete mode 100644 boost/mssql/template/template-vc9.vcproj delete mode 100644 boost/mssql/template/test.hxx delete mode 100644 boost/mysql/date-time/driver.cxx delete mode 100644 boost/mysql/date-time/test.hxx delete mode 100644 boost/mysql/template/driver.cxx delete mode 100644 boost/mysql/template/template-vc10.vcxproj delete mode 100644 boost/mysql/template/template-vc10.vcxproj.filters delete mode 100644 boost/mysql/template/template-vc11.vcxproj delete mode 100644 boost/mysql/template/template-vc11.vcxproj.filters delete mode 100644 boost/mysql/template/template-vc12.vcxproj delete mode 100644 boost/mysql/template/template-vc12.vcxproj.filters delete mode 100644 boost/mysql/template/template-vc8.vcproj delete mode 100644 boost/mysql/template/template-vc9.vcproj delete mode 100644 boost/mysql/template/test.hxx delete mode 100644 boost/oracle/date-time/driver.cxx delete mode 100644 boost/oracle/date-time/test.hxx delete mode 100644 boost/oracle/template/driver.cxx delete mode 100644 boost/oracle/template/template-vc10.vcxproj delete mode 100644 boost/oracle/template/template-vc10.vcxproj.filters delete mode 100644 boost/oracle/template/template-vc11.vcxproj delete mode 100644 boost/oracle/template/template-vc11.vcxproj.filters delete mode 100644 boost/oracle/template/template-vc12.vcxproj delete mode 100644 boost/oracle/template/template-vc12.vcxproj.filters delete mode 100644 boost/oracle/template/template-vc8.vcproj delete mode 100644 boost/oracle/template/template-vc9.vcproj delete mode 100644 boost/oracle/template/test.hxx delete mode 100644 boost/pgsql/date-time/driver.cxx delete mode 100644 boost/pgsql/date-time/test.hxx delete mode 100644 boost/pgsql/template/driver.cxx delete mode 100644 boost/pgsql/template/template-vc10.vcxproj delete mode 100644 boost/pgsql/template/template-vc10.vcxproj.filters delete mode 100644 boost/pgsql/template/template-vc11.vcxproj delete mode 100644 boost/pgsql/template/template-vc11.vcxproj.filters delete mode 100644 boost/pgsql/template/template-vc12.vcxproj delete mode 100644 boost/pgsql/template/template-vc12.vcxproj.filters delete mode 100644 boost/pgsql/template/template-vc8.vcproj delete mode 100644 boost/pgsql/template/template-vc9.vcproj delete mode 100644 boost/pgsql/template/test.hxx delete mode 100644 boost/sqlite/date-time/driver.cxx delete mode 100644 boost/sqlite/date-time/test.hxx delete mode 100644 boost/sqlite/template/driver.cxx delete mode 100644 boost/sqlite/template/template-vc10.vcxproj delete mode 100644 boost/sqlite/template/template-vc10.vcxproj.filters delete mode 100644 boost/sqlite/template/template-vc11.vcxproj delete mode 100644 boost/sqlite/template/template-vc11.vcxproj.filters delete mode 100644 boost/sqlite/template/template-vc12.vcxproj delete mode 100644 boost/sqlite/template/template-vc12.vcxproj.filters delete mode 100644 boost/sqlite/template/template-vc8.vcproj delete mode 100644 boost/sqlite/template/template-vc9.vcproj delete mode 100644 boost/sqlite/template/test.hxx delete mode 100644 build/.gitignore delete mode 100644 build/bootstrap.build delete mode 100644 build/export.build delete mode 100644 build/root.build delete mode 100644 buildfile delete mode 100644 common/access/buildfile delete mode 100644 common/access/driver.cxx delete mode 100644 common/access/test.hxx delete mode 100644 common/access/testscript delete mode 100644 common/as/buildfile delete mode 100644 common/as/driver.cxx delete mode 100644 common/as/test.hxx delete mode 100644 common/as/testscript delete mode 100644 common/blob/buildfile delete mode 100644 common/blob/driver.cxx delete mode 100644 common/blob/test.hxx delete mode 100644 common/blob/testscript delete mode 100644 common/buildfile delete mode 100644 common/bulk/buildfile delete mode 100644 common/bulk/driver.cxx delete mode 100644 common/bulk/test.hxx delete mode 100644 common/bulk/testscript delete mode 100644 common/callback/buildfile delete mode 100644 common/callback/driver.cxx delete mode 100644 common/callback/test.hxx delete mode 100644 common/callback/testscript delete mode 100644 common/changelog/.gitignore delete mode 100644 common/changelog/add-column-mssql-diff.xml delete mode 100644 common/changelog/add-column-mssql-patch.xml delete mode 100644 common/changelog/add-column-mysql-diff.xml delete mode 100644 common/changelog/add-column-mysql-patch.xml delete mode 100644 common/changelog/add-column-oracle-diff.xml delete mode 100644 common/changelog/add-column-oracle-patch.xml delete mode 100644 common/changelog/add-column-pgsql-diff.xml delete mode 100644 common/changelog/add-column-pgsql-patch.xml delete mode 100644 common/changelog/add-column-sqlite-diff.xml delete mode 100644 common/changelog/add-column-sqlite-patch.xml delete mode 100644 common/changelog/add-column.hxx delete mode 100644 common/changelog/add-foreign-key-diff.xml delete mode 100644 common/changelog/add-foreign-key-mssql-diff.xml delete mode 100644 common/changelog/add-foreign-key-mssql-patch.xml delete mode 100644 common/changelog/add-foreign-key-mysql-diff.xml delete mode 100644 common/changelog/add-foreign-key-mysql-patch.xml delete mode 100644 common/changelog/add-foreign-key-oracle-diff.xml delete mode 100644 common/changelog/add-foreign-key-oracle-patch.xml delete mode 100644 common/changelog/add-foreign-key-pgsql-diff.xml delete mode 100644 common/changelog/add-foreign-key-pgsql-patch.xml delete mode 100644 common/changelog/add-foreign-key-sqlite-diff.xml delete mode 100644 common/changelog/add-foreign-key-sqlite-patch.xml delete mode 100644 common/changelog/add-foreign-key.hxx delete mode 100644 common/changelog/add-index-mssql-diff.xml delete mode 100644 common/changelog/add-index-mssql-patch.xml delete mode 100644 common/changelog/add-index-mysql-diff.xml delete mode 100644 common/changelog/add-index-mysql-patch.xml delete mode 100644 common/changelog/add-index-oracle-diff.xml delete mode 100644 common/changelog/add-index-oracle-patch.xml delete mode 100644 common/changelog/add-index-pgsql-diff.xml delete mode 100644 common/changelog/add-index-pgsql-patch.xml delete mode 100644 common/changelog/add-index-sqlite-diff.xml delete mode 100644 common/changelog/add-index-sqlite-patch.xml delete mode 100644 common/changelog/add-index.hxx delete mode 100644 common/changelog/add-table-mssql-diff.xml delete mode 100644 common/changelog/add-table-mssql-patch.xml delete mode 100644 common/changelog/add-table-mysql-diff.xml delete mode 100644 common/changelog/add-table-mysql-patch.xml delete mode 100644 common/changelog/add-table-oracle-diff.xml delete mode 100644 common/changelog/add-table-oracle-patch.xml delete mode 100644 common/changelog/add-table-pgsql-diff.xml delete mode 100644 common/changelog/add-table-pgsql-patch.xml delete mode 100644 common/changelog/add-table-sqlite-diff.xml delete mode 100644 common/changelog/add-table-sqlite-patch.xml delete mode 100644 common/changelog/add-table.hxx delete mode 100644 common/changelog/alter-column-mssql-diff.xml delete mode 100644 common/changelog/alter-column-mssql-patch.xml delete mode 100644 common/changelog/alter-column-mysql-diff.xml delete mode 100644 common/changelog/alter-column-mysql-patch.xml delete mode 100644 common/changelog/alter-column-oracle-diff.xml delete mode 100644 common/changelog/alter-column-oracle-patch.xml delete mode 100644 common/changelog/alter-column-pgsql-diff.xml delete mode 100644 common/changelog/alter-column-pgsql-patch.xml delete mode 100644 common/changelog/alter-column-sqlite-diff.xml delete mode 100644 common/changelog/alter-column-sqlite-patch.xml delete mode 100644 common/changelog/alter-column.hxx delete mode 100644 common/changelog/buildfile delete mode 100644 common/changelog/drop-column-mssql-diff.xml delete mode 100644 common/changelog/drop-column-mssql-patch.xml delete mode 100644 common/changelog/drop-column-mysql-diff.xml delete mode 100644 common/changelog/drop-column-mysql-patch.xml delete mode 100644 common/changelog/drop-column-oracle-diff.xml delete mode 100644 common/changelog/drop-column-oracle-patch.xml delete mode 100644 common/changelog/drop-column-pgsql-diff.xml delete mode 100644 common/changelog/drop-column-pgsql-patch.xml delete mode 100644 common/changelog/drop-column-sqlite-diff.xml delete mode 100644 common/changelog/drop-column-sqlite-patch.xml delete mode 100644 common/changelog/drop-column.hxx delete mode 100644 common/changelog/drop-foreign-key-mssql-diff.xml delete mode 100644 common/changelog/drop-foreign-key-mssql-patch.xml delete mode 100644 common/changelog/drop-foreign-key-mysql-diff.xml delete mode 100644 common/changelog/drop-foreign-key-mysql-patch.xml delete mode 100644 common/changelog/drop-foreign-key-oracle-diff.xml delete mode 100644 common/changelog/drop-foreign-key-oracle-patch.xml delete mode 100644 common/changelog/drop-foreign-key-pgsql-diff.xml delete mode 100644 common/changelog/drop-foreign-key-pgsql-patch.xml delete mode 100644 common/changelog/drop-foreign-key-sqlite-diff.xml delete mode 100644 common/changelog/drop-foreign-key-sqlite-patch.xml delete mode 100644 common/changelog/drop-foreign-key.hxx delete mode 100644 common/changelog/drop-index-mssql-diff.xml delete mode 100644 common/changelog/drop-index-mssql-patch.xml delete mode 100644 common/changelog/drop-index-mysql-diff.xml delete mode 100644 common/changelog/drop-index-mysql-patch.xml delete mode 100644 common/changelog/drop-index-oracle-diff.xml delete mode 100644 common/changelog/drop-index-oracle-patch.xml delete mode 100644 common/changelog/drop-index-pgsql-diff.xml delete mode 100644 common/changelog/drop-index-pgsql-patch.xml delete mode 100644 common/changelog/drop-index-sqlite-diff.xml delete mode 100644 common/changelog/drop-index-sqlite-patch.xml delete mode 100644 common/changelog/drop-index.hxx delete mode 100644 common/changelog/drop-table-mssql-diff.xml delete mode 100644 common/changelog/drop-table-mssql-patch.xml delete mode 100644 common/changelog/drop-table-mysql-diff.xml delete mode 100644 common/changelog/drop-table-mysql-patch.xml delete mode 100644 common/changelog/drop-table-oracle-diff.xml delete mode 100644 common/changelog/drop-table-oracle-patch.xml delete mode 100644 common/changelog/drop-table-pgsql-diff.xml delete mode 100644 common/changelog/drop-table-pgsql-patch.xml delete mode 100644 common/changelog/drop-table-sqlite-diff.xml delete mode 100644 common/changelog/drop-table-sqlite-patch.xml delete mode 100644 common/changelog/drop-table.hxx delete mode 120000 common/changelog/model-mssql-diff.xml delete mode 120000 common/changelog/model-mssql-patch.xml delete mode 100644 common/changelog/model-mssql.xml delete mode 120000 common/changelog/model-mysql-diff.xml delete mode 120000 common/changelog/model-mysql-patch.xml delete mode 100644 common/changelog/model-mysql.xml delete mode 120000 common/changelog/model-oracle-diff.xml delete mode 120000 common/changelog/model-oracle-patch.xml delete mode 100644 common/changelog/model-oracle.xml delete mode 120000 common/changelog/model-pgsql-diff.xml delete mode 120000 common/changelog/model-pgsql-patch.xml delete mode 100644 common/changelog/model-pgsql.xml delete mode 120000 common/changelog/model-sqlite-diff.xml delete mode 120000 common/changelog/model-sqlite-patch.xml delete mode 100644 common/changelog/model-sqlite.xml delete mode 100644 common/changelog/model.hxx delete mode 100644 common/changelog/testscript delete mode 100644 common/circular/multiple/.gitignore delete mode 100644 common/circular/multiple/buildfile delete mode 100644 common/circular/multiple/driver.cxx delete mode 100644 common/circular/multiple/test1.hxx delete mode 100644 common/circular/multiple/test2.hxx delete mode 100644 common/circular/multiple/testscript delete mode 100644 common/circular/single/buildfile delete mode 100644 common/circular/single/driver.cxx delete mode 100644 common/circular/single/test.hxx delete mode 100644 common/circular/single/testscript delete mode 100644 common/composite/buildfile delete mode 100644 common/composite/driver.cxx delete mode 100644 common/composite/test.hxx delete mode 100644 common/composite/testscript delete mode 100644 common/const-member/buildfile delete mode 100644 common/const-member/driver.cxx delete mode 100644 common/const-member/test.hxx delete mode 100644 common/const-member/testscript delete mode 100644 common/const-object/buildfile delete mode 100644 common/const-object/driver.cxx delete mode 100644 common/const-object/test.hxx delete mode 100644 common/const-object/testscript delete mode 100644 common/container/basics/buildfile delete mode 100644 common/container/basics/driver.cxx delete mode 100644 common/container/basics/test.hxx delete mode 100644 common/container/basics/testscript delete mode 100644 common/container/change-tracking/buildfile delete mode 100644 common/container/change-tracking/driver.cxx delete mode 100644 common/container/change-tracking/test.hxx delete mode 100644 common/container/change-tracking/testscript delete mode 100644 common/ctor/buildfile delete mode 100644 common/ctor/driver.cxx delete mode 100644 common/ctor/test.hxx delete mode 100644 common/ctor/testscript delete mode 100644 common/default/buildfile delete mode 100644 common/default/driver.cxx delete mode 100644 common/default/test.hxx delete mode 100644 common/default/testscript delete mode 100644 common/definition/.gitignore delete mode 100644 common/definition/buildfile delete mode 100644 common/definition/driver.cxx delete mode 100644 common/definition/test.hxx delete mode 100644 common/definition/testscript delete mode 100644 common/definition/time-mapping.hxx delete mode 100644 common/enum/buildfile delete mode 100644 common/enum/driver.cxx delete mode 100644 common/enum/test.hxx delete mode 100644 common/enum/testscript delete mode 100644 common/erase-query/buildfile delete mode 100644 common/erase-query/driver.cxx delete mode 100644 common/erase-query/test.hxx delete mode 100644 common/erase-query/testscript delete mode 100644 common/id/auto/buildfile delete mode 100644 common/id/auto/driver.cxx delete mode 100644 common/id/auto/test.hxx delete mode 100644 common/id/auto/testscript delete mode 100644 common/id/composite/buildfile delete mode 100644 common/id/composite/driver.cxx delete mode 100644 common/id/composite/test.hxx delete mode 100644 common/id/composite/testscript delete mode 100644 common/id/nested/buildfile delete mode 100644 common/id/nested/driver.cxx delete mode 100644 common/id/nested/test.hxx delete mode 100644 common/id/nested/testscript delete mode 100644 common/include/.gitignore delete mode 100644 common/include/buildfile delete mode 100644 common/include/driver.cxx delete mode 100644 common/include/obj1.hxx delete mode 100644 common/include/obj2.hxx delete mode 100644 common/include/obj3.hxx delete mode 100644 common/include/objs1.hxx delete mode 100644 common/include/objs2.hxx delete mode 100644 common/include/objs3.hxx delete mode 100644 common/include/objs4.hxx delete mode 100644 common/include/test1.hxx delete mode 100644 common/include/test2.hxx delete mode 100644 common/include/test3.hxx delete mode 100644 common/include/test4.hxx delete mode 100644 common/include/testscript delete mode 100644 common/index/buildfile delete mode 100644 common/index/driver.cxx delete mode 100644 common/index/test.hxx delete mode 100644 common/index/testscript delete mode 100644 common/inheritance/polymorphism/.gitignore delete mode 100644 common/inheritance/polymorphism/buildfile delete mode 100644 common/inheritance/polymorphism/driver.cxx delete mode 100644 common/inheritance/polymorphism/test1.hxx delete mode 100644 common/inheritance/polymorphism/test10.hxx delete mode 100644 common/inheritance/polymorphism/test11.hxx delete mode 100644 common/inheritance/polymorphism/test12.hxx delete mode 100644 common/inheritance/polymorphism/test13.hxx delete mode 100644 common/inheritance/polymorphism/test14.hxx delete mode 100644 common/inheritance/polymorphism/test15.hxx delete mode 100644 common/inheritance/polymorphism/test2.hxx delete mode 100644 common/inheritance/polymorphism/test3.hxx delete mode 100644 common/inheritance/polymorphism/test4.hxx delete mode 100644 common/inheritance/polymorphism/test5.hxx delete mode 100644 common/inheritance/polymorphism/test6.hxx delete mode 100644 common/inheritance/polymorphism/test7.hxx delete mode 100644 common/inheritance/polymorphism/test8.hxx delete mode 100644 common/inheritance/polymorphism/test9.hxx delete mode 100644 common/inheritance/polymorphism/testscript delete mode 100644 common/inheritance/reuse/buildfile delete mode 100644 common/inheritance/reuse/driver.cxx delete mode 100644 common/inheritance/reuse/test.hxx delete mode 100644 common/inheritance/reuse/testscript delete mode 100644 common/inheritance/transient/buildfile delete mode 100644 common/inheritance/transient/driver.cxx delete mode 100644 common/inheritance/transient/test.hxx delete mode 100644 common/inheritance/transient/testscript delete mode 100644 common/inverse/buildfile delete mode 100644 common/inverse/driver.cxx delete mode 100644 common/inverse/test.hxx delete mode 100644 common/inverse/testscript delete mode 100644 common/lazy-ptr/buildfile delete mode 100644 common/lazy-ptr/driver.cxx delete mode 100644 common/lazy-ptr/test.hxx delete mode 100644 common/lazy-ptr/testscript delete mode 100644 common/lifecycle/buildfile delete mode 100644 common/lifecycle/driver.cxx delete mode 100644 common/lifecycle/test.hxx delete mode 100644 common/lifecycle/testscript delete mode 100644 common/no-id/buildfile delete mode 100644 common/no-id/driver.cxx delete mode 100644 common/no-id/test.hxx delete mode 100644 common/no-id/testscript delete mode 100644 common/object/buildfile delete mode 100644 common/object/driver.cxx delete mode 100644 common/object/test.hxx delete mode 100644 common/object/testscript delete mode 100644 common/optimistic/buildfile delete mode 100644 common/optimistic/driver.cxx delete mode 100644 common/optimistic/test.hxx delete mode 100644 common/optimistic/testscript delete mode 100644 common/pragma/buildfile delete mode 100644 common/pragma/driver.cxx delete mode 100644 common/pragma/test.hxx delete mode 100644 common/pragma/testscript delete mode 100644 common/prepared/buildfile delete mode 100644 common/prepared/driver.cxx delete mode 100644 common/prepared/test.hxx delete mode 100644 common/prepared/testscript delete mode 100644 common/query/array/buildfile delete mode 100644 common/query/array/driver.cxx delete mode 100644 common/query/array/test.hxx delete mode 100644 common/query/array/testscript delete mode 100644 common/query/basics/buildfile delete mode 100644 common/query/basics/driver.cxx delete mode 100644 common/query/basics/test.hxx delete mode 100644 common/query/basics/testscript delete mode 100644 common/query/one/buildfile delete mode 100644 common/query/one/driver.cxx delete mode 100644 common/query/one/test.hxx delete mode 100644 common/query/one/testscript delete mode 100644 common/readonly/buildfile delete mode 100644 common/readonly/driver.cxx delete mode 100644 common/readonly/test.hxx delete mode 100644 common/readonly/testscript delete mode 100644 common/relationship/basics/buildfile delete mode 100644 common/relationship/basics/driver.cxx delete mode 100644 common/relationship/basics/test.hxx delete mode 100644 common/relationship/basics/testscript delete mode 100644 common/relationship/on-delete/buildfile delete mode 100644 common/relationship/on-delete/driver.cxx delete mode 100644 common/relationship/on-delete/test.hxx delete mode 100644 common/relationship/on-delete/testscript delete mode 100644 common/relationship/query/buildfile delete mode 100644 common/relationship/query/driver.cxx delete mode 100644 common/relationship/query/test.hxx delete mode 100644 common/relationship/query/testscript delete mode 100644 common/schema/embedded/basics/buildfile delete mode 100644 common/schema/embedded/basics/driver.cxx delete mode 100644 common/schema/embedded/basics/test.hxx delete mode 100644 common/schema/embedded/basics/testscript delete mode 100644 common/schema/embedded/order/.gitignore delete mode 100644 common/schema/embedded/order/buildfile delete mode 100644 common/schema/embedded/order/driver.cxx delete mode 100644 common/schema/embedded/order/test1.hxx delete mode 100644 common/schema/embedded/order/test2.hxx delete mode 100644 common/schema/embedded/order/testscript delete mode 100644 common/schema/namespace/buildfile delete mode 100644 common/schema/namespace/driver.cxx delete mode 100644 common/schema/namespace/test.hxx delete mode 100644 common/schema/namespace/testscript delete mode 100644 common/section/basics/buildfile delete mode 100644 common/section/basics/driver.cxx delete mode 100644 common/section/basics/test.hxx delete mode 100644 common/section/basics/testscript delete mode 100644 common/section/polymorphism/buildfile delete mode 100644 common/section/polymorphism/driver.cxx delete mode 100644 common/section/polymorphism/test.hxx delete mode 100644 common/section/polymorphism/testscript delete mode 100644 common/session/cache/buildfile delete mode 100644 common/session/cache/driver.cxx delete mode 100644 common/session/cache/test.hxx delete mode 100644 common/session/cache/testscript delete mode 100644 common/session/custom/buildfile delete mode 100644 common/session/custom/driver.cxx delete mode 100644 common/session/custom/session.cxx delete mode 100644 common/session/custom/session.hxx delete mode 100644 common/session/custom/session.txx delete mode 100644 common/session/custom/test.hxx delete mode 100644 common/session/custom/testscript delete mode 100644 common/statement/processing/buildfile delete mode 100644 common/statement/processing/driver.cxx delete mode 100644 common/statement/processing/testscript delete mode 100644 common/threads/buildfile delete mode 100644 common/threads/driver.cxx delete mode 100644 common/threads/test.hxx delete mode 100644 common/threads/testscript delete mode 100644 common/transaction/basics/buildfile delete mode 100644 common/transaction/basics/driver.cxx delete mode 100644 common/transaction/basics/testscript delete mode 100644 common/transaction/callback/buildfile delete mode 100644 common/transaction/callback/driver.cxx delete mode 100644 common/transaction/callback/testscript delete mode 100644 common/types/buildfile delete mode 100644 common/types/driver.cxx delete mode 100644 common/types/test.hxx delete mode 100644 common/types/testscript delete mode 100644 common/view/basics/buildfile delete mode 100644 common/view/basics/driver.cxx delete mode 100644 common/view/basics/test.hxx delete mode 100644 common/view/basics/testscript delete mode 100644 common/view/olv/.gitignore delete mode 100644 common/view/olv/buildfile delete mode 100644 common/view/olv/driver.cxx delete mode 100644 common/view/olv/test1.hxx delete mode 100644 common/view/olv/test2.hxx delete mode 100644 common/view/olv/test3.hxx delete mode 100644 common/view/olv/test4.hxx delete mode 100644 common/view/olv/test5.hxx delete mode 100644 common/view/olv/test6.hxx delete mode 100644 common/view/olv/test7.hxx delete mode 100644 common/view/olv/test8.hxx delete mode 100644 common/view/olv/test9.hxx delete mode 100644 common/view/olv/testscript delete mode 100644 common/virtual/buildfile delete mode 100644 common/virtual/driver.cxx delete mode 100644 common/virtual/test.hxx delete mode 100644 common/virtual/testscript delete mode 100644 common/wrapper/buildfile delete mode 100644 common/wrapper/driver.cxx delete mode 100644 common/wrapper/test.hxx delete mode 100644 common/wrapper/testscript delete mode 100644 database-options.testscript delete mode 100644 evolution/add-column/driver.cxx delete mode 100644 evolution/add-column/model.hxx delete mode 100644 evolution/add-column/test1.hxx delete mode 100644 evolution/add-column/test2.hxx delete mode 100644 evolution/add-column/test3.hxx delete mode 100644 evolution/add-foreign-key/driver.cxx delete mode 100644 evolution/add-foreign-key/model.hxx delete mode 100644 evolution/add-foreign-key/test1.hxx delete mode 100644 evolution/add-foreign-key/test2.hxx delete mode 100644 evolution/add-foreign-key/test3.hxx delete mode 100644 evolution/add-index/driver.cxx delete mode 100644 evolution/add-index/model.hxx delete mode 100644 evolution/add-index/test1.hxx delete mode 100644 evolution/add-index/test2.hxx delete mode 100644 evolution/add-index/test3.hxx delete mode 100644 evolution/add-table/driver.cxx delete mode 100644 evolution/add-table/model.hxx delete mode 100644 evolution/add-table/test1.hxx delete mode 100644 evolution/add-table/test2.hxx delete mode 100644 evolution/add-table/test3.hxx delete mode 100644 evolution/alter-column/driver.cxx delete mode 100644 evolution/alter-column/model.hxx delete mode 100644 evolution/alter-column/test1.hxx delete mode 100644 evolution/alter-column/test2.hxx delete mode 100644 evolution/alter-column/test3.hxx delete mode 100644 evolution/combined/driver.cxx delete mode 100644 evolution/combined/model.hxx delete mode 100644 evolution/combined/test1.hxx delete mode 100644 evolution/combined/test2.hxx delete mode 100644 evolution/combined/test3.hxx delete mode 100644 evolution/data/driver.cxx delete mode 100644 evolution/data/model.hxx delete mode 100644 evolution/data/test1.hxx delete mode 100644 evolution/data/test2.hxx delete mode 100644 evolution/data/test3.hxx delete mode 100644 evolution/drop-column/driver.cxx delete mode 100644 evolution/drop-column/model.hxx delete mode 100644 evolution/drop-column/test1.hxx delete mode 100644 evolution/drop-column/test2.hxx delete mode 100644 evolution/drop-column/test3.hxx delete mode 100644 evolution/drop-foreign-key/driver.cxx delete mode 100644 evolution/drop-foreign-key/model.hxx delete mode 100644 evolution/drop-foreign-key/test1.hxx delete mode 100644 evolution/drop-foreign-key/test2.hxx delete mode 100644 evolution/drop-foreign-key/test3.hxx delete mode 100644 evolution/drop-index/driver.cxx delete mode 100644 evolution/drop-index/model.hxx delete mode 100644 evolution/drop-index/test1.hxx delete mode 100644 evolution/drop-index/test2.hxx delete mode 100644 evolution/drop-index/test3.hxx delete mode 100644 evolution/drop-table/driver.cxx delete mode 100644 evolution/drop-table/model.hxx delete mode 100644 evolution/drop-table/test1.hxx delete mode 100644 evolution/drop-table/test2.hxx delete mode 100644 evolution/drop-table/test3.hxx delete mode 100644 evolution/embedded/driver.cxx delete mode 100644 evolution/embedded/model.hxx delete mode 100644 evolution/embedded/test1.hxx delete mode 100644 evolution/embedded/test2.hxx delete mode 100644 evolution/embedded/test3.hxx delete mode 100644 evolution/soft-add/driver.cxx delete mode 100644 evolution/soft-add/model.hxx delete mode 100644 evolution/soft-add/test1.hxx delete mode 100644 evolution/soft-add/test2.hxx delete mode 100644 evolution/soft-add/test3.hxx delete mode 100644 evolution/soft-delete/driver.cxx delete mode 100644 evolution/soft-delete/model.hxx delete mode 100644 evolution/soft-delete/test1.hxx delete mode 100644 evolution/soft-delete/test2.hxx delete mode 100644 evolution/soft-delete/test3.hxx delete mode 100644 evolution/template/driver.cxx delete mode 100644 evolution/template/model.hxx delete mode 100644 evolution/template/template-vc10.vcxproj delete mode 100644 evolution/template/template-vc10.vcxproj.filters delete mode 100644 evolution/template/template-vc11.vcxproj delete mode 100644 evolution/template/template-vc11.vcxproj.filters delete mode 100644 evolution/template/template-vc12.vcxproj delete mode 100644 evolution/template/template-vc12.vcxproj.filters delete mode 100644 evolution/template/template-vc8.vcproj delete mode 100644 evolution/template/template-vc9.vcproj delete mode 100644 evolution/template/test1.hxx delete mode 100644 evolution/template/test2.hxx delete mode 100644 evolution/template/test3.hxx delete mode 100644 evolution/version/driver.cxx delete mode 100644 evolution/version/model.hxx delete mode 100644 evolution/version/test1.hxx delete mode 100644 evolution/version/test2.hxx delete mode 100644 evolution/version/test3.hxx delete mode 100644 libcommon/.gitignore delete mode 100644 libcommon/buffer.hxx delete mode 100644 libcommon/buildfile delete mode 100644 libcommon/common.cxx delete mode 100644 libcommon/common.hxx delete mode 100644 libcommon/common.txx delete mode 100644 libcommon/concrete.hxx delete mode 100644 libcommon/config.hxx.in delete mode 100644 libcommon/export.hxx delete mode 100644 manifest delete mode 100644 mssql/custom/custom.sql delete mode 100644 mssql/custom/driver.cxx delete mode 100644 mssql/custom/query.hxx delete mode 100644 mssql/custom/test.hxx delete mode 100644 mssql/custom/traits.cxx delete mode 100644 mssql/custom/traits.hxx delete mode 100644 mssql/database/driver.cxx delete mode 100644 mssql/native/driver.cxx delete mode 100644 mssql/query/driver.cxx delete mode 100644 mssql/query/test.hxx delete mode 100644 mssql/stored-proc/driver.cxx delete mode 100644 mssql/stored-proc/test.hxx delete mode 100644 mssql/template/driver.cxx delete mode 100644 mssql/template/template-vc10.vcxproj delete mode 100644 mssql/template/template-vc10.vcxproj.filters delete mode 100644 mssql/template/template-vc11.vcxproj delete mode 100644 mssql/template/template-vc11.vcxproj.filters delete mode 100644 mssql/template/template-vc12.vcxproj delete mode 100644 mssql/template/template-vc12.vcxproj.filters delete mode 100644 mssql/template/template-vc8.vcproj delete mode 100644 mssql/template/template-vc9.vcproj delete mode 100644 mssql/template/test.hxx delete mode 100644 mssql/types/driver.cxx delete mode 100644 mssql/types/test.hxx delete mode 100644 mssql/types/traits.hxx delete mode 100644 mysql-schema.testscript delete mode 100644 mysql.testscript delete mode 100644 mysql/custom/buildfile delete mode 100644 mysql/custom/driver.cxx delete mode 100644 mysql/custom/query.hxx delete mode 100644 mysql/custom/test.hxx delete mode 100644 mysql/custom/testscript delete mode 100644 mysql/custom/traits.hxx delete mode 100644 mysql/database/buildfile delete mode 100644 mysql/database/driver.cxx delete mode 100644 mysql/database/testscript delete mode 100644 mysql/index/buildfile delete mode 100644 mysql/index/driver.cxx delete mode 100644 mysql/index/test.hxx delete mode 100644 mysql/index/testscript delete mode 100644 mysql/native/buildfile delete mode 100644 mysql/native/driver.cxx delete mode 100644 mysql/native/testscript delete mode 100644 mysql/truncation/buildfile delete mode 100644 mysql/truncation/driver.cxx delete mode 100644 mysql/truncation/test.hxx delete mode 100644 mysql/truncation/testscript delete mode 100644 mysql/types/buildfile delete mode 100644 mysql/types/driver.cxx delete mode 100644 mysql/types/test.hxx delete mode 100644 mysql/types/testscript delete mode 100644 mysql/types/traits.hxx create mode 100644 odb-tests/.gitignore create mode 100644 odb-tests/GPLv2 create mode 100644 odb-tests/LICENSE create mode 100644 odb-tests/README.md create mode 100644 odb-tests/boost/common/multi-index/driver.cxx create mode 100644 odb-tests/boost/common/multi-index/test.hxx create mode 100644 odb-tests/boost/common/optional/driver.cxx create mode 100644 odb-tests/boost/common/optional/test.hxx create mode 100644 odb-tests/boost/common/smart-ptr/driver.cxx create mode 100644 odb-tests/boost/common/smart-ptr/test.hxx create mode 100644 odb-tests/boost/common/template/driver.cxx create mode 100644 odb-tests/boost/common/template/template-vc10.vcxproj create mode 100644 odb-tests/boost/common/template/template-vc10.vcxproj.filters create mode 100644 odb-tests/boost/common/template/template-vc11.vcxproj create mode 100644 odb-tests/boost/common/template/template-vc11.vcxproj.filters create mode 100644 odb-tests/boost/common/template/template-vc12.vcxproj create mode 100644 odb-tests/boost/common/template/template-vc12.vcxproj.filters create mode 100644 odb-tests/boost/common/template/template-vc8.vcproj create mode 100644 odb-tests/boost/common/template/template-vc9.vcproj create mode 100644 odb-tests/boost/common/template/test.hxx create mode 100644 odb-tests/boost/common/unordered/driver.cxx create mode 100644 odb-tests/boost/common/unordered/test.hxx create mode 100644 odb-tests/boost/common/uuid/driver.cxx create mode 100644 odb-tests/boost/common/uuid/test.hxx create mode 100644 odb-tests/boost/mssql/date-time/driver.cxx create mode 100644 odb-tests/boost/mssql/date-time/test.hxx create mode 100644 odb-tests/boost/mssql/template/driver.cxx create mode 100644 odb-tests/boost/mssql/template/template-vc10.vcxproj create mode 100644 odb-tests/boost/mssql/template/template-vc10.vcxproj.filters create mode 100644 odb-tests/boost/mssql/template/template-vc11.vcxproj create mode 100644 odb-tests/boost/mssql/template/template-vc11.vcxproj.filters create mode 100644 odb-tests/boost/mssql/template/template-vc12.vcxproj create mode 100644 odb-tests/boost/mssql/template/template-vc12.vcxproj.filters create mode 100644 odb-tests/boost/mssql/template/template-vc8.vcproj create mode 100644 odb-tests/boost/mssql/template/template-vc9.vcproj create mode 100644 odb-tests/boost/mssql/template/test.hxx create mode 100644 odb-tests/boost/mysql/date-time/driver.cxx create mode 100644 odb-tests/boost/mysql/date-time/test.hxx create mode 100644 odb-tests/boost/mysql/template/driver.cxx create mode 100644 odb-tests/boost/mysql/template/template-vc10.vcxproj create mode 100644 odb-tests/boost/mysql/template/template-vc10.vcxproj.filters create mode 100644 odb-tests/boost/mysql/template/template-vc11.vcxproj create mode 100644 odb-tests/boost/mysql/template/template-vc11.vcxproj.filters create mode 100644 odb-tests/boost/mysql/template/template-vc12.vcxproj create mode 100644 odb-tests/boost/mysql/template/template-vc12.vcxproj.filters create mode 100644 odb-tests/boost/mysql/template/template-vc8.vcproj create mode 100644 odb-tests/boost/mysql/template/template-vc9.vcproj create mode 100644 odb-tests/boost/mysql/template/test.hxx create mode 100644 odb-tests/boost/oracle/date-time/driver.cxx create mode 100644 odb-tests/boost/oracle/date-time/test.hxx create mode 100644 odb-tests/boost/oracle/template/driver.cxx create mode 100644 odb-tests/boost/oracle/template/template-vc10.vcxproj create mode 100644 odb-tests/boost/oracle/template/template-vc10.vcxproj.filters create mode 100644 odb-tests/boost/oracle/template/template-vc11.vcxproj create mode 100644 odb-tests/boost/oracle/template/template-vc11.vcxproj.filters create mode 100644 odb-tests/boost/oracle/template/template-vc12.vcxproj create mode 100644 odb-tests/boost/oracle/template/template-vc12.vcxproj.filters create mode 100644 odb-tests/boost/oracle/template/template-vc8.vcproj create mode 100644 odb-tests/boost/oracle/template/template-vc9.vcproj create mode 100644 odb-tests/boost/oracle/template/test.hxx create mode 100644 odb-tests/boost/pgsql/date-time/driver.cxx create mode 100644 odb-tests/boost/pgsql/date-time/test.hxx create mode 100644 odb-tests/boost/pgsql/template/driver.cxx create mode 100644 odb-tests/boost/pgsql/template/template-vc10.vcxproj create mode 100644 odb-tests/boost/pgsql/template/template-vc10.vcxproj.filters create mode 100644 odb-tests/boost/pgsql/template/template-vc11.vcxproj create mode 100644 odb-tests/boost/pgsql/template/template-vc11.vcxproj.filters create mode 100644 odb-tests/boost/pgsql/template/template-vc12.vcxproj create mode 100644 odb-tests/boost/pgsql/template/template-vc12.vcxproj.filters create mode 100644 odb-tests/boost/pgsql/template/template-vc8.vcproj create mode 100644 odb-tests/boost/pgsql/template/template-vc9.vcproj create mode 100644 odb-tests/boost/pgsql/template/test.hxx create mode 100644 odb-tests/boost/sqlite/date-time/driver.cxx create mode 100644 odb-tests/boost/sqlite/date-time/test.hxx create mode 100644 odb-tests/boost/sqlite/template/driver.cxx create mode 100644 odb-tests/boost/sqlite/template/template-vc10.vcxproj create mode 100644 odb-tests/boost/sqlite/template/template-vc10.vcxproj.filters create mode 100644 odb-tests/boost/sqlite/template/template-vc11.vcxproj create mode 100644 odb-tests/boost/sqlite/template/template-vc11.vcxproj.filters create mode 100644 odb-tests/boost/sqlite/template/template-vc12.vcxproj create mode 100644 odb-tests/boost/sqlite/template/template-vc12.vcxproj.filters create mode 100644 odb-tests/boost/sqlite/template/template-vc8.vcproj create mode 100644 odb-tests/boost/sqlite/template/template-vc9.vcproj create mode 100644 odb-tests/boost/sqlite/template/test.hxx create mode 100644 odb-tests/build/.gitignore create mode 100644 odb-tests/build/bootstrap.build create mode 100644 odb-tests/build/export.build create mode 100644 odb-tests/build/root.build create mode 100644 odb-tests/buildfile create mode 100644 odb-tests/common/access/buildfile create mode 100644 odb-tests/common/access/driver.cxx create mode 100644 odb-tests/common/access/test.hxx create mode 100644 odb-tests/common/access/testscript create mode 100644 odb-tests/common/as/buildfile create mode 100644 odb-tests/common/as/driver.cxx create mode 100644 odb-tests/common/as/test.hxx create mode 100644 odb-tests/common/as/testscript create mode 100644 odb-tests/common/blob/buildfile create mode 100644 odb-tests/common/blob/driver.cxx create mode 100644 odb-tests/common/blob/test.hxx create mode 100644 odb-tests/common/blob/testscript create mode 100644 odb-tests/common/buildfile create mode 100644 odb-tests/common/bulk/buildfile create mode 100644 odb-tests/common/bulk/driver.cxx create mode 100644 odb-tests/common/bulk/test.hxx create mode 100644 odb-tests/common/bulk/testscript create mode 100644 odb-tests/common/callback/buildfile create mode 100644 odb-tests/common/callback/driver.cxx create mode 100644 odb-tests/common/callback/test.hxx create mode 100644 odb-tests/common/callback/testscript create mode 100644 odb-tests/common/changelog/.gitignore create mode 100644 odb-tests/common/changelog/add-column-mssql-diff.xml create mode 100644 odb-tests/common/changelog/add-column-mssql-patch.xml create mode 100644 odb-tests/common/changelog/add-column-mysql-diff.xml create mode 100644 odb-tests/common/changelog/add-column-mysql-patch.xml create mode 100644 odb-tests/common/changelog/add-column-oracle-diff.xml create mode 100644 odb-tests/common/changelog/add-column-oracle-patch.xml create mode 100644 odb-tests/common/changelog/add-column-pgsql-diff.xml create mode 100644 odb-tests/common/changelog/add-column-pgsql-patch.xml create mode 100644 odb-tests/common/changelog/add-column-sqlite-diff.xml create mode 100644 odb-tests/common/changelog/add-column-sqlite-patch.xml create mode 100644 odb-tests/common/changelog/add-column.hxx create mode 100644 odb-tests/common/changelog/add-foreign-key-diff.xml create mode 100644 odb-tests/common/changelog/add-foreign-key-mssql-diff.xml create mode 100644 odb-tests/common/changelog/add-foreign-key-mssql-patch.xml create mode 100644 odb-tests/common/changelog/add-foreign-key-mysql-diff.xml create mode 100644 odb-tests/common/changelog/add-foreign-key-mysql-patch.xml create mode 100644 odb-tests/common/changelog/add-foreign-key-oracle-diff.xml create mode 100644 odb-tests/common/changelog/add-foreign-key-oracle-patch.xml create mode 100644 odb-tests/common/changelog/add-foreign-key-pgsql-diff.xml create mode 100644 odb-tests/common/changelog/add-foreign-key-pgsql-patch.xml create mode 100644 odb-tests/common/changelog/add-foreign-key-sqlite-diff.xml create mode 100644 odb-tests/common/changelog/add-foreign-key-sqlite-patch.xml create mode 100644 odb-tests/common/changelog/add-foreign-key.hxx create mode 100644 odb-tests/common/changelog/add-index-mssql-diff.xml create mode 100644 odb-tests/common/changelog/add-index-mssql-patch.xml create mode 100644 odb-tests/common/changelog/add-index-mysql-diff.xml create mode 100644 odb-tests/common/changelog/add-index-mysql-patch.xml create mode 100644 odb-tests/common/changelog/add-index-oracle-diff.xml create mode 100644 odb-tests/common/changelog/add-index-oracle-patch.xml create mode 100644 odb-tests/common/changelog/add-index-pgsql-diff.xml create mode 100644 odb-tests/common/changelog/add-index-pgsql-patch.xml create mode 100644 odb-tests/common/changelog/add-index-sqlite-diff.xml create mode 100644 odb-tests/common/changelog/add-index-sqlite-patch.xml create mode 100644 odb-tests/common/changelog/add-index.hxx create mode 100644 odb-tests/common/changelog/add-table-mssql-diff.xml create mode 100644 odb-tests/common/changelog/add-table-mssql-patch.xml create mode 100644 odb-tests/common/changelog/add-table-mysql-diff.xml create mode 100644 odb-tests/common/changelog/add-table-mysql-patch.xml create mode 100644 odb-tests/common/changelog/add-table-oracle-diff.xml create mode 100644 odb-tests/common/changelog/add-table-oracle-patch.xml create mode 100644 odb-tests/common/changelog/add-table-pgsql-diff.xml create mode 100644 odb-tests/common/changelog/add-table-pgsql-patch.xml create mode 100644 odb-tests/common/changelog/add-table-sqlite-diff.xml create mode 100644 odb-tests/common/changelog/add-table-sqlite-patch.xml create mode 100644 odb-tests/common/changelog/add-table.hxx create mode 100644 odb-tests/common/changelog/alter-column-mssql-diff.xml create mode 100644 odb-tests/common/changelog/alter-column-mssql-patch.xml create mode 100644 odb-tests/common/changelog/alter-column-mysql-diff.xml create mode 100644 odb-tests/common/changelog/alter-column-mysql-patch.xml create mode 100644 odb-tests/common/changelog/alter-column-oracle-diff.xml create mode 100644 odb-tests/common/changelog/alter-column-oracle-patch.xml create mode 100644 odb-tests/common/changelog/alter-column-pgsql-diff.xml create mode 100644 odb-tests/common/changelog/alter-column-pgsql-patch.xml create mode 100644 odb-tests/common/changelog/alter-column-sqlite-diff.xml create mode 100644 odb-tests/common/changelog/alter-column-sqlite-patch.xml create mode 100644 odb-tests/common/changelog/alter-column.hxx create mode 100644 odb-tests/common/changelog/buildfile create mode 100644 odb-tests/common/changelog/drop-column-mssql-diff.xml create mode 100644 odb-tests/common/changelog/drop-column-mssql-patch.xml create mode 100644 odb-tests/common/changelog/drop-column-mysql-diff.xml create mode 100644 odb-tests/common/changelog/drop-column-mysql-patch.xml create mode 100644 odb-tests/common/changelog/drop-column-oracle-diff.xml create mode 100644 odb-tests/common/changelog/drop-column-oracle-patch.xml create mode 100644 odb-tests/common/changelog/drop-column-pgsql-diff.xml create mode 100644 odb-tests/common/changelog/drop-column-pgsql-patch.xml create mode 100644 odb-tests/common/changelog/drop-column-sqlite-diff.xml create mode 100644 odb-tests/common/changelog/drop-column-sqlite-patch.xml create mode 100644 odb-tests/common/changelog/drop-column.hxx create mode 100644 odb-tests/common/changelog/drop-foreign-key-mssql-diff.xml create mode 100644 odb-tests/common/changelog/drop-foreign-key-mssql-patch.xml create mode 100644 odb-tests/common/changelog/drop-foreign-key-mysql-diff.xml create mode 100644 odb-tests/common/changelog/drop-foreign-key-mysql-patch.xml create mode 100644 odb-tests/common/changelog/drop-foreign-key-oracle-diff.xml create mode 100644 odb-tests/common/changelog/drop-foreign-key-oracle-patch.xml create mode 100644 odb-tests/common/changelog/drop-foreign-key-pgsql-diff.xml create mode 100644 odb-tests/common/changelog/drop-foreign-key-pgsql-patch.xml create mode 100644 odb-tests/common/changelog/drop-foreign-key-sqlite-diff.xml create mode 100644 odb-tests/common/changelog/drop-foreign-key-sqlite-patch.xml create mode 100644 odb-tests/common/changelog/drop-foreign-key.hxx create mode 100644 odb-tests/common/changelog/drop-index-mssql-diff.xml create mode 100644 odb-tests/common/changelog/drop-index-mssql-patch.xml create mode 100644 odb-tests/common/changelog/drop-index-mysql-diff.xml create mode 100644 odb-tests/common/changelog/drop-index-mysql-patch.xml create mode 100644 odb-tests/common/changelog/drop-index-oracle-diff.xml create mode 100644 odb-tests/common/changelog/drop-index-oracle-patch.xml create mode 100644 odb-tests/common/changelog/drop-index-pgsql-diff.xml create mode 100644 odb-tests/common/changelog/drop-index-pgsql-patch.xml create mode 100644 odb-tests/common/changelog/drop-index-sqlite-diff.xml create mode 100644 odb-tests/common/changelog/drop-index-sqlite-patch.xml create mode 100644 odb-tests/common/changelog/drop-index.hxx create mode 100644 odb-tests/common/changelog/drop-table-mssql-diff.xml create mode 100644 odb-tests/common/changelog/drop-table-mssql-patch.xml create mode 100644 odb-tests/common/changelog/drop-table-mysql-diff.xml create mode 100644 odb-tests/common/changelog/drop-table-mysql-patch.xml create mode 100644 odb-tests/common/changelog/drop-table-oracle-diff.xml create mode 100644 odb-tests/common/changelog/drop-table-oracle-patch.xml create mode 100644 odb-tests/common/changelog/drop-table-pgsql-diff.xml create mode 100644 odb-tests/common/changelog/drop-table-pgsql-patch.xml create mode 100644 odb-tests/common/changelog/drop-table-sqlite-diff.xml create mode 100644 odb-tests/common/changelog/drop-table-sqlite-patch.xml create mode 100644 odb-tests/common/changelog/drop-table.hxx create mode 120000 odb-tests/common/changelog/model-mssql-diff.xml create mode 120000 odb-tests/common/changelog/model-mssql-patch.xml create mode 100644 odb-tests/common/changelog/model-mssql.xml create mode 120000 odb-tests/common/changelog/model-mysql-diff.xml create mode 120000 odb-tests/common/changelog/model-mysql-patch.xml create mode 100644 odb-tests/common/changelog/model-mysql.xml create mode 120000 odb-tests/common/changelog/model-oracle-diff.xml create mode 120000 odb-tests/common/changelog/model-oracle-patch.xml create mode 100644 odb-tests/common/changelog/model-oracle.xml create mode 120000 odb-tests/common/changelog/model-pgsql-diff.xml create mode 120000 odb-tests/common/changelog/model-pgsql-patch.xml create mode 100644 odb-tests/common/changelog/model-pgsql.xml create mode 120000 odb-tests/common/changelog/model-sqlite-diff.xml create mode 120000 odb-tests/common/changelog/model-sqlite-patch.xml create mode 100644 odb-tests/common/changelog/model-sqlite.xml create mode 100644 odb-tests/common/changelog/model.hxx create mode 100644 odb-tests/common/changelog/testscript create mode 100644 odb-tests/common/circular/multiple/.gitignore create mode 100644 odb-tests/common/circular/multiple/buildfile create mode 100644 odb-tests/common/circular/multiple/driver.cxx create mode 100644 odb-tests/common/circular/multiple/test1.hxx create mode 100644 odb-tests/common/circular/multiple/test2.hxx create mode 100644 odb-tests/common/circular/multiple/testscript create mode 100644 odb-tests/common/circular/single/buildfile create mode 100644 odb-tests/common/circular/single/driver.cxx create mode 100644 odb-tests/common/circular/single/test.hxx create mode 100644 odb-tests/common/circular/single/testscript create mode 100644 odb-tests/common/composite/buildfile create mode 100644 odb-tests/common/composite/driver.cxx create mode 100644 odb-tests/common/composite/test.hxx create mode 100644 odb-tests/common/composite/testscript create mode 100644 odb-tests/common/const-member/buildfile create mode 100644 odb-tests/common/const-member/driver.cxx create mode 100644 odb-tests/common/const-member/test.hxx create mode 100644 odb-tests/common/const-member/testscript create mode 100644 odb-tests/common/const-object/buildfile create mode 100644 odb-tests/common/const-object/driver.cxx create mode 100644 odb-tests/common/const-object/test.hxx create mode 100644 odb-tests/common/const-object/testscript create mode 100644 odb-tests/common/container/basics/buildfile create mode 100644 odb-tests/common/container/basics/driver.cxx create mode 100644 odb-tests/common/container/basics/test.hxx create mode 100644 odb-tests/common/container/basics/testscript create mode 100644 odb-tests/common/container/change-tracking/buildfile create mode 100644 odb-tests/common/container/change-tracking/driver.cxx create mode 100644 odb-tests/common/container/change-tracking/test.hxx create mode 100644 odb-tests/common/container/change-tracking/testscript create mode 100644 odb-tests/common/ctor/buildfile create mode 100644 odb-tests/common/ctor/driver.cxx create mode 100644 odb-tests/common/ctor/test.hxx create mode 100644 odb-tests/common/ctor/testscript create mode 100644 odb-tests/common/default/buildfile create mode 100644 odb-tests/common/default/driver.cxx create mode 100644 odb-tests/common/default/test.hxx create mode 100644 odb-tests/common/default/testscript create mode 100644 odb-tests/common/definition/.gitignore create mode 100644 odb-tests/common/definition/buildfile create mode 100644 odb-tests/common/definition/driver.cxx create mode 100644 odb-tests/common/definition/test.hxx create mode 100644 odb-tests/common/definition/testscript create mode 100644 odb-tests/common/definition/time-mapping.hxx create mode 100644 odb-tests/common/enum/buildfile create mode 100644 odb-tests/common/enum/driver.cxx create mode 100644 odb-tests/common/enum/test.hxx create mode 100644 odb-tests/common/enum/testscript create mode 100644 odb-tests/common/erase-query/buildfile create mode 100644 odb-tests/common/erase-query/driver.cxx create mode 100644 odb-tests/common/erase-query/test.hxx create mode 100644 odb-tests/common/erase-query/testscript create mode 100644 odb-tests/common/id/auto/buildfile create mode 100644 odb-tests/common/id/auto/driver.cxx create mode 100644 odb-tests/common/id/auto/test.hxx create mode 100644 odb-tests/common/id/auto/testscript create mode 100644 odb-tests/common/id/composite/buildfile create mode 100644 odb-tests/common/id/composite/driver.cxx create mode 100644 odb-tests/common/id/composite/test.hxx create mode 100644 odb-tests/common/id/composite/testscript create mode 100644 odb-tests/common/id/nested/buildfile create mode 100644 odb-tests/common/id/nested/driver.cxx create mode 100644 odb-tests/common/id/nested/test.hxx create mode 100644 odb-tests/common/id/nested/testscript create mode 100644 odb-tests/common/include/.gitignore create mode 100644 odb-tests/common/include/buildfile create mode 100644 odb-tests/common/include/driver.cxx create mode 100644 odb-tests/common/include/obj1.hxx create mode 100644 odb-tests/common/include/obj2.hxx create mode 100644 odb-tests/common/include/obj3.hxx create mode 100644 odb-tests/common/include/objs1.hxx create mode 100644 odb-tests/common/include/objs2.hxx create mode 100644 odb-tests/common/include/objs3.hxx create mode 100644 odb-tests/common/include/objs4.hxx create mode 100644 odb-tests/common/include/test1.hxx create mode 100644 odb-tests/common/include/test2.hxx create mode 100644 odb-tests/common/include/test3.hxx create mode 100644 odb-tests/common/include/test4.hxx create mode 100644 odb-tests/common/include/testscript create mode 100644 odb-tests/common/index/buildfile create mode 100644 odb-tests/common/index/driver.cxx create mode 100644 odb-tests/common/index/test.hxx create mode 100644 odb-tests/common/index/testscript create mode 100644 odb-tests/common/inheritance/polymorphism/.gitignore create mode 100644 odb-tests/common/inheritance/polymorphism/buildfile create mode 100644 odb-tests/common/inheritance/polymorphism/driver.cxx create mode 100644 odb-tests/common/inheritance/polymorphism/test1.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test10.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test11.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test12.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test13.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test14.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test15.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test2.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test3.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test4.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test5.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test6.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test7.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test8.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/test9.hxx create mode 100644 odb-tests/common/inheritance/polymorphism/testscript create mode 100644 odb-tests/common/inheritance/reuse/buildfile create mode 100644 odb-tests/common/inheritance/reuse/driver.cxx create mode 100644 odb-tests/common/inheritance/reuse/test.hxx create mode 100644 odb-tests/common/inheritance/reuse/testscript create mode 100644 odb-tests/common/inheritance/transient/buildfile create mode 100644 odb-tests/common/inheritance/transient/driver.cxx create mode 100644 odb-tests/common/inheritance/transient/test.hxx create mode 100644 odb-tests/common/inheritance/transient/testscript create mode 100644 odb-tests/common/inverse/buildfile create mode 100644 odb-tests/common/inverse/driver.cxx create mode 100644 odb-tests/common/inverse/test.hxx create mode 100644 odb-tests/common/inverse/testscript create mode 100644 odb-tests/common/lazy-ptr/buildfile create mode 100644 odb-tests/common/lazy-ptr/driver.cxx create mode 100644 odb-tests/common/lazy-ptr/test.hxx create mode 100644 odb-tests/common/lazy-ptr/testscript create mode 100644 odb-tests/common/lifecycle/buildfile create mode 100644 odb-tests/common/lifecycle/driver.cxx create mode 100644 odb-tests/common/lifecycle/test.hxx create mode 100644 odb-tests/common/lifecycle/testscript create mode 100644 odb-tests/common/no-id/buildfile create mode 100644 odb-tests/common/no-id/driver.cxx create mode 100644 odb-tests/common/no-id/test.hxx create mode 100644 odb-tests/common/no-id/testscript create mode 100644 odb-tests/common/object/buildfile create mode 100644 odb-tests/common/object/driver.cxx create mode 100644 odb-tests/common/object/test.hxx create mode 100644 odb-tests/common/object/testscript create mode 100644 odb-tests/common/optimistic/buildfile create mode 100644 odb-tests/common/optimistic/driver.cxx create mode 100644 odb-tests/common/optimistic/test.hxx create mode 100644 odb-tests/common/optimistic/testscript create mode 100644 odb-tests/common/pragma/buildfile create mode 100644 odb-tests/common/pragma/driver.cxx create mode 100644 odb-tests/common/pragma/test.hxx create mode 100644 odb-tests/common/pragma/testscript create mode 100644 odb-tests/common/prepared/buildfile create mode 100644 odb-tests/common/prepared/driver.cxx create mode 100644 odb-tests/common/prepared/test.hxx create mode 100644 odb-tests/common/prepared/testscript create mode 100644 odb-tests/common/query/array/buildfile create mode 100644 odb-tests/common/query/array/driver.cxx create mode 100644 odb-tests/common/query/array/test.hxx create mode 100644 odb-tests/common/query/array/testscript create mode 100644 odb-tests/common/query/basics/buildfile create mode 100644 odb-tests/common/query/basics/driver.cxx create mode 100644 odb-tests/common/query/basics/test.hxx create mode 100644 odb-tests/common/query/basics/testscript create mode 100644 odb-tests/common/query/one/buildfile create mode 100644 odb-tests/common/query/one/driver.cxx create mode 100644 odb-tests/common/query/one/test.hxx create mode 100644 odb-tests/common/query/one/testscript create mode 100644 odb-tests/common/readonly/buildfile create mode 100644 odb-tests/common/readonly/driver.cxx create mode 100644 odb-tests/common/readonly/test.hxx create mode 100644 odb-tests/common/readonly/testscript create mode 100644 odb-tests/common/relationship/basics/buildfile create mode 100644 odb-tests/common/relationship/basics/driver.cxx create mode 100644 odb-tests/common/relationship/basics/test.hxx create mode 100644 odb-tests/common/relationship/basics/testscript create mode 100644 odb-tests/common/relationship/on-delete/buildfile create mode 100644 odb-tests/common/relationship/on-delete/driver.cxx create mode 100644 odb-tests/common/relationship/on-delete/test.hxx create mode 100644 odb-tests/common/relationship/on-delete/testscript create mode 100644 odb-tests/common/relationship/query/buildfile create mode 100644 odb-tests/common/relationship/query/driver.cxx create mode 100644 odb-tests/common/relationship/query/test.hxx create mode 100644 odb-tests/common/relationship/query/testscript create mode 100644 odb-tests/common/schema/embedded/basics/buildfile create mode 100644 odb-tests/common/schema/embedded/basics/driver.cxx create mode 100644 odb-tests/common/schema/embedded/basics/test.hxx create mode 100644 odb-tests/common/schema/embedded/basics/testscript create mode 100644 odb-tests/common/schema/embedded/order/.gitignore create mode 100644 odb-tests/common/schema/embedded/order/buildfile create mode 100644 odb-tests/common/schema/embedded/order/driver.cxx create mode 100644 odb-tests/common/schema/embedded/order/test1.hxx create mode 100644 odb-tests/common/schema/embedded/order/test2.hxx create mode 100644 odb-tests/common/schema/embedded/order/testscript create mode 100644 odb-tests/common/schema/namespace/buildfile create mode 100644 odb-tests/common/schema/namespace/driver.cxx create mode 100644 odb-tests/common/schema/namespace/test.hxx create mode 100644 odb-tests/common/schema/namespace/testscript create mode 100644 odb-tests/common/section/basics/buildfile create mode 100644 odb-tests/common/section/basics/driver.cxx create mode 100644 odb-tests/common/section/basics/test.hxx create mode 100644 odb-tests/common/section/basics/testscript create mode 100644 odb-tests/common/section/polymorphism/buildfile create mode 100644 odb-tests/common/section/polymorphism/driver.cxx create mode 100644 odb-tests/common/section/polymorphism/test.hxx create mode 100644 odb-tests/common/section/polymorphism/testscript create mode 100644 odb-tests/common/session/cache/buildfile create mode 100644 odb-tests/common/session/cache/driver.cxx create mode 100644 odb-tests/common/session/cache/test.hxx create mode 100644 odb-tests/common/session/cache/testscript create mode 100644 odb-tests/common/session/custom/buildfile create mode 100644 odb-tests/common/session/custom/driver.cxx create mode 100644 odb-tests/common/session/custom/session.cxx create mode 100644 odb-tests/common/session/custom/session.hxx create mode 100644 odb-tests/common/session/custom/session.txx create mode 100644 odb-tests/common/session/custom/test.hxx create mode 100644 odb-tests/common/session/custom/testscript create mode 100644 odb-tests/common/statement/processing/buildfile create mode 100644 odb-tests/common/statement/processing/driver.cxx create mode 100644 odb-tests/common/statement/processing/testscript create mode 100644 odb-tests/common/threads/buildfile create mode 100644 odb-tests/common/threads/driver.cxx create mode 100644 odb-tests/common/threads/test.hxx create mode 100644 odb-tests/common/threads/testscript create mode 100644 odb-tests/common/transaction/basics/buildfile create mode 100644 odb-tests/common/transaction/basics/driver.cxx create mode 100644 odb-tests/common/transaction/basics/testscript create mode 100644 odb-tests/common/transaction/callback/buildfile create mode 100644 odb-tests/common/transaction/callback/driver.cxx create mode 100644 odb-tests/common/transaction/callback/testscript create mode 100644 odb-tests/common/types/buildfile create mode 100644 odb-tests/common/types/driver.cxx create mode 100644 odb-tests/common/types/test.hxx create mode 100644 odb-tests/common/types/testscript create mode 100644 odb-tests/common/view/basics/buildfile create mode 100644 odb-tests/common/view/basics/driver.cxx create mode 100644 odb-tests/common/view/basics/test.hxx create mode 100644 odb-tests/common/view/basics/testscript create mode 100644 odb-tests/common/view/olv/.gitignore create mode 100644 odb-tests/common/view/olv/buildfile create mode 100644 odb-tests/common/view/olv/driver.cxx create mode 100644 odb-tests/common/view/olv/test1.hxx create mode 100644 odb-tests/common/view/olv/test2.hxx create mode 100644 odb-tests/common/view/olv/test3.hxx create mode 100644 odb-tests/common/view/olv/test4.hxx create mode 100644 odb-tests/common/view/olv/test5.hxx create mode 100644 odb-tests/common/view/olv/test6.hxx create mode 100644 odb-tests/common/view/olv/test7.hxx create mode 100644 odb-tests/common/view/olv/test8.hxx create mode 100644 odb-tests/common/view/olv/test9.hxx create mode 100644 odb-tests/common/view/olv/testscript create mode 100644 odb-tests/common/virtual/buildfile create mode 100644 odb-tests/common/virtual/driver.cxx create mode 100644 odb-tests/common/virtual/test.hxx create mode 100644 odb-tests/common/virtual/testscript create mode 100644 odb-tests/common/wrapper/buildfile create mode 100644 odb-tests/common/wrapper/driver.cxx create mode 100644 odb-tests/common/wrapper/test.hxx create mode 100644 odb-tests/common/wrapper/testscript create mode 100644 odb-tests/database-options.testscript create mode 100644 odb-tests/evolution/add-column/driver.cxx create mode 100644 odb-tests/evolution/add-column/model.hxx create mode 100644 odb-tests/evolution/add-column/test1.hxx create mode 100644 odb-tests/evolution/add-column/test2.hxx create mode 100644 odb-tests/evolution/add-column/test3.hxx create mode 100644 odb-tests/evolution/add-foreign-key/driver.cxx create mode 100644 odb-tests/evolution/add-foreign-key/model.hxx create mode 100644 odb-tests/evolution/add-foreign-key/test1.hxx create mode 100644 odb-tests/evolution/add-foreign-key/test2.hxx create mode 100644 odb-tests/evolution/add-foreign-key/test3.hxx create mode 100644 odb-tests/evolution/add-index/driver.cxx create mode 100644 odb-tests/evolution/add-index/model.hxx create mode 100644 odb-tests/evolution/add-index/test1.hxx create mode 100644 odb-tests/evolution/add-index/test2.hxx create mode 100644 odb-tests/evolution/add-index/test3.hxx create mode 100644 odb-tests/evolution/add-table/driver.cxx create mode 100644 odb-tests/evolution/add-table/model.hxx create mode 100644 odb-tests/evolution/add-table/test1.hxx create mode 100644 odb-tests/evolution/add-table/test2.hxx create mode 100644 odb-tests/evolution/add-table/test3.hxx create mode 100644 odb-tests/evolution/alter-column/driver.cxx create mode 100644 odb-tests/evolution/alter-column/model.hxx create mode 100644 odb-tests/evolution/alter-column/test1.hxx create mode 100644 odb-tests/evolution/alter-column/test2.hxx create mode 100644 odb-tests/evolution/alter-column/test3.hxx create mode 100644 odb-tests/evolution/combined/driver.cxx create mode 100644 odb-tests/evolution/combined/model.hxx create mode 100644 odb-tests/evolution/combined/test1.hxx create mode 100644 odb-tests/evolution/combined/test2.hxx create mode 100644 odb-tests/evolution/combined/test3.hxx create mode 100644 odb-tests/evolution/data/driver.cxx create mode 100644 odb-tests/evolution/data/model.hxx create mode 100644 odb-tests/evolution/data/test1.hxx create mode 100644 odb-tests/evolution/data/test2.hxx create mode 100644 odb-tests/evolution/data/test3.hxx create mode 100644 odb-tests/evolution/drop-column/driver.cxx create mode 100644 odb-tests/evolution/drop-column/model.hxx create mode 100644 odb-tests/evolution/drop-column/test1.hxx create mode 100644 odb-tests/evolution/drop-column/test2.hxx create mode 100644 odb-tests/evolution/drop-column/test3.hxx create mode 100644 odb-tests/evolution/drop-foreign-key/driver.cxx create mode 100644 odb-tests/evolution/drop-foreign-key/model.hxx create mode 100644 odb-tests/evolution/drop-foreign-key/test1.hxx create mode 100644 odb-tests/evolution/drop-foreign-key/test2.hxx create mode 100644 odb-tests/evolution/drop-foreign-key/test3.hxx create mode 100644 odb-tests/evolution/drop-index/driver.cxx create mode 100644 odb-tests/evolution/drop-index/model.hxx create mode 100644 odb-tests/evolution/drop-index/test1.hxx create mode 100644 odb-tests/evolution/drop-index/test2.hxx create mode 100644 odb-tests/evolution/drop-index/test3.hxx create mode 100644 odb-tests/evolution/drop-table/driver.cxx create mode 100644 odb-tests/evolution/drop-table/model.hxx create mode 100644 odb-tests/evolution/drop-table/test1.hxx create mode 100644 odb-tests/evolution/drop-table/test2.hxx create mode 100644 odb-tests/evolution/drop-table/test3.hxx create mode 100644 odb-tests/evolution/embedded/driver.cxx create mode 100644 odb-tests/evolution/embedded/model.hxx create mode 100644 odb-tests/evolution/embedded/test1.hxx create mode 100644 odb-tests/evolution/embedded/test2.hxx create mode 100644 odb-tests/evolution/embedded/test3.hxx create mode 100644 odb-tests/evolution/soft-add/driver.cxx create mode 100644 odb-tests/evolution/soft-add/model.hxx create mode 100644 odb-tests/evolution/soft-add/test1.hxx create mode 100644 odb-tests/evolution/soft-add/test2.hxx create mode 100644 odb-tests/evolution/soft-add/test3.hxx create mode 100644 odb-tests/evolution/soft-delete/driver.cxx create mode 100644 odb-tests/evolution/soft-delete/model.hxx create mode 100644 odb-tests/evolution/soft-delete/test1.hxx create mode 100644 odb-tests/evolution/soft-delete/test2.hxx create mode 100644 odb-tests/evolution/soft-delete/test3.hxx create mode 100644 odb-tests/evolution/template/driver.cxx create mode 100644 odb-tests/evolution/template/model.hxx create mode 100644 odb-tests/evolution/template/template-vc10.vcxproj create mode 100644 odb-tests/evolution/template/template-vc10.vcxproj.filters create mode 100644 odb-tests/evolution/template/template-vc11.vcxproj create mode 100644 odb-tests/evolution/template/template-vc11.vcxproj.filters create mode 100644 odb-tests/evolution/template/template-vc12.vcxproj create mode 100644 odb-tests/evolution/template/template-vc12.vcxproj.filters create mode 100644 odb-tests/evolution/template/template-vc8.vcproj create mode 100644 odb-tests/evolution/template/template-vc9.vcproj create mode 100644 odb-tests/evolution/template/test1.hxx create mode 100644 odb-tests/evolution/template/test2.hxx create mode 100644 odb-tests/evolution/template/test3.hxx create mode 100644 odb-tests/evolution/version/driver.cxx create mode 100644 odb-tests/evolution/version/model.hxx create mode 100644 odb-tests/evolution/version/test1.hxx create mode 100644 odb-tests/evolution/version/test2.hxx create mode 100644 odb-tests/evolution/version/test3.hxx create mode 100644 odb-tests/libcommon/.gitignore create mode 100644 odb-tests/libcommon/buffer.hxx create mode 100644 odb-tests/libcommon/buildfile create mode 100644 odb-tests/libcommon/common.cxx create mode 100644 odb-tests/libcommon/common.hxx create mode 100644 odb-tests/libcommon/common.txx create mode 100644 odb-tests/libcommon/concrete.hxx create mode 100644 odb-tests/libcommon/config.hxx.in create mode 100644 odb-tests/libcommon/export.hxx create mode 100644 odb-tests/manifest create mode 100644 odb-tests/mssql/custom/custom.sql create mode 100644 odb-tests/mssql/custom/driver.cxx create mode 100644 odb-tests/mssql/custom/query.hxx create mode 100644 odb-tests/mssql/custom/test.hxx create mode 100644 odb-tests/mssql/custom/traits.cxx create mode 100644 odb-tests/mssql/custom/traits.hxx create mode 100644 odb-tests/mssql/database/driver.cxx create mode 100644 odb-tests/mssql/native/driver.cxx create mode 100644 odb-tests/mssql/query/driver.cxx create mode 100644 odb-tests/mssql/query/test.hxx create mode 100644 odb-tests/mssql/stored-proc/driver.cxx create mode 100644 odb-tests/mssql/stored-proc/test.hxx create mode 100644 odb-tests/mssql/template/driver.cxx create mode 100644 odb-tests/mssql/template/template-vc10.vcxproj create mode 100644 odb-tests/mssql/template/template-vc10.vcxproj.filters create mode 100644 odb-tests/mssql/template/template-vc11.vcxproj create mode 100644 odb-tests/mssql/template/template-vc11.vcxproj.filters create mode 100644 odb-tests/mssql/template/template-vc12.vcxproj create mode 100644 odb-tests/mssql/template/template-vc12.vcxproj.filters create mode 100644 odb-tests/mssql/template/template-vc8.vcproj create mode 100644 odb-tests/mssql/template/template-vc9.vcproj create mode 100644 odb-tests/mssql/template/test.hxx create mode 100644 odb-tests/mssql/types/driver.cxx create mode 100644 odb-tests/mssql/types/test.hxx create mode 100644 odb-tests/mssql/types/traits.hxx create mode 100644 odb-tests/mysql-schema.testscript create mode 100644 odb-tests/mysql.testscript create mode 100644 odb-tests/mysql/custom/buildfile create mode 100644 odb-tests/mysql/custom/driver.cxx create mode 100644 odb-tests/mysql/custom/query.hxx create mode 100644 odb-tests/mysql/custom/test.hxx create mode 100644 odb-tests/mysql/custom/testscript create mode 100644 odb-tests/mysql/custom/traits.hxx create mode 100644 odb-tests/mysql/database/buildfile create mode 100644 odb-tests/mysql/database/driver.cxx create mode 100644 odb-tests/mysql/database/testscript create mode 100644 odb-tests/mysql/index/buildfile create mode 100644 odb-tests/mysql/index/driver.cxx create mode 100644 odb-tests/mysql/index/test.hxx create mode 100644 odb-tests/mysql/index/testscript create mode 100644 odb-tests/mysql/native/buildfile create mode 100644 odb-tests/mysql/native/driver.cxx create mode 100644 odb-tests/mysql/native/testscript create mode 100644 odb-tests/mysql/truncation/buildfile create mode 100644 odb-tests/mysql/truncation/driver.cxx create mode 100644 odb-tests/mysql/truncation/test.hxx create mode 100644 odb-tests/mysql/truncation/testscript create mode 100644 odb-tests/mysql/types/buildfile create mode 100644 odb-tests/mysql/types/driver.cxx create mode 100644 odb-tests/mysql/types/test.hxx create mode 100644 odb-tests/mysql/types/testscript create mode 100644 odb-tests/mysql/types/traits.hxx create mode 100644 odb-tests/oracle/custom/custom.sql create mode 100644 odb-tests/oracle/custom/driver.cxx create mode 100644 odb-tests/oracle/custom/test.hxx create mode 100644 odb-tests/oracle/custom/traits.hxx create mode 100644 odb-tests/oracle/database/driver.cxx create mode 100644 odb-tests/oracle/native/driver.cxx create mode 100644 odb-tests/oracle/template/driver.cxx create mode 100644 odb-tests/oracle/template/template-vc10.vcxproj create mode 100644 odb-tests/oracle/template/template-vc10.vcxproj.filters create mode 100644 odb-tests/oracle/template/template-vc11.vcxproj create mode 100644 odb-tests/oracle/template/template-vc11.vcxproj.filters create mode 100644 odb-tests/oracle/template/template-vc12.vcxproj create mode 100644 odb-tests/oracle/template/template-vc12.vcxproj.filters create mode 100644 odb-tests/oracle/template/template-vc8.vcproj create mode 100644 odb-tests/oracle/template/template-vc9.vcproj create mode 100644 odb-tests/oracle/template/test.hxx create mode 100644 odb-tests/oracle/types/driver.cxx create mode 100644 odb-tests/oracle/types/test.hxx create mode 100644 odb-tests/oracle/types/traits.hxx create mode 100644 odb-tests/pgsql-schema.testscript create mode 100644 odb-tests/pgsql.testscript create mode 100644 odb-tests/pgsql/buildfile create mode 100644 odb-tests/pgsql/bulk/buildfile create mode 100644 odb-tests/pgsql/bulk/driver.cxx create mode 100644 odb-tests/pgsql/bulk/test.hxx create mode 100644 odb-tests/pgsql/bulk/testscript create mode 100644 odb-tests/pgsql/custom/buildfile create mode 100644 odb-tests/pgsql/custom/driver.cxx create mode 100644 odb-tests/pgsql/custom/query.hxx create mode 100644 odb-tests/pgsql/custom/test.hxx create mode 100644 odb-tests/pgsql/custom/testscript create mode 100644 odb-tests/pgsql/custom/traits.hxx create mode 100644 odb-tests/pgsql/database/buildfile create mode 100644 odb-tests/pgsql/database/driver.cxx create mode 100644 odb-tests/pgsql/database/testscript create mode 100644 odb-tests/pgsql/index/buildfile create mode 100644 odb-tests/pgsql/index/driver.cxx create mode 100644 odb-tests/pgsql/index/test.hxx create mode 100644 odb-tests/pgsql/index/testscript create mode 100644 odb-tests/pgsql/native/buildfile create mode 100644 odb-tests/pgsql/native/driver.cxx create mode 100644 odb-tests/pgsql/native/testscript create mode 100644 odb-tests/pgsql/truncation/buildfile create mode 100644 odb-tests/pgsql/truncation/driver.cxx create mode 100644 odb-tests/pgsql/truncation/test.hxx create mode 100644 odb-tests/pgsql/truncation/testscript create mode 100644 odb-tests/pgsql/types/buildfile create mode 100644 odb-tests/pgsql/types/driver.cxx create mode 100644 odb-tests/pgsql/types/test.hxx create mode 100644 odb-tests/pgsql/types/testscript create mode 100644 odb-tests/pgsql/types/traits.hxx create mode 100644 odb-tests/qt/common/basic/driver.cxx create mode 100644 odb-tests/qt/common/basic/test.hxx create mode 100644 odb-tests/qt/common/containers/basics/driver.cxx create mode 100644 odb-tests/qt/common/containers/basics/test.hxx create mode 100644 odb-tests/qt/common/containers/change-tracking/driver.cxx create mode 100644 odb-tests/qt/common/containers/change-tracking/test.hxx create mode 100644 odb-tests/qt/common/smart-ptr/driver.cxx create mode 100644 odb-tests/qt/common/smart-ptr/test.hxx create mode 100644 odb-tests/qt/common/template/driver.cxx create mode 100644 odb-tests/qt/common/template/template-qt4-vc10.vcxproj create mode 100644 odb-tests/qt/common/template/template-qt4-vc10.vcxproj.filters create mode 100644 odb-tests/qt/common/template/template-qt4-vc11.vcxproj create mode 100644 odb-tests/qt/common/template/template-qt4-vc11.vcxproj.filters create mode 100644 odb-tests/qt/common/template/template-qt4-vc12.vcxproj create mode 100644 odb-tests/qt/common/template/template-qt4-vc12.vcxproj.filters create mode 100644 odb-tests/qt/common/template/template-qt4-vc8.vcproj create mode 100644 odb-tests/qt/common/template/template-qt4-vc9.vcproj create mode 100644 odb-tests/qt/common/template/template-qt5-vc10.vcxproj create mode 100644 odb-tests/qt/common/template/template-qt5-vc10.vcxproj.filters create mode 100644 odb-tests/qt/common/template/template-qt5-vc11.vcxproj create mode 100644 odb-tests/qt/common/template/template-qt5-vc11.vcxproj.filters create mode 100644 odb-tests/qt/common/template/template-qt5-vc12.vcxproj create mode 100644 odb-tests/qt/common/template/template-qt5-vc12.vcxproj.filters create mode 100644 odb-tests/qt/common/template/template-qt5-vc9.vcproj create mode 100644 odb-tests/qt/common/template/test.hxx create mode 100644 odb-tests/qt/mssql/basic/driver.cxx create mode 100644 odb-tests/qt/mssql/basic/test.hxx create mode 100644 odb-tests/qt/mssql/date-time/driver.cxx create mode 100644 odb-tests/qt/mssql/date-time/test.hxx create mode 100644 odb-tests/qt/mssql/template/driver.cxx create mode 100644 odb-tests/qt/mssql/template/template-qt4-vc10.vcxproj create mode 100644 odb-tests/qt/mssql/template/template-qt4-vc10.vcxproj.filters create mode 100644 odb-tests/qt/mssql/template/template-qt4-vc11.vcxproj create mode 100644 odb-tests/qt/mssql/template/template-qt4-vc11.vcxproj.filters create mode 100644 odb-tests/qt/mssql/template/template-qt4-vc12.vcxproj create mode 100644 odb-tests/qt/mssql/template/template-qt4-vc12.vcxproj.filters create mode 100644 odb-tests/qt/mssql/template/template-qt4-vc8.vcproj create mode 100644 odb-tests/qt/mssql/template/template-qt4-vc9.vcproj create mode 100644 odb-tests/qt/mssql/template/template-qt5-vc10.vcxproj create mode 100644 odb-tests/qt/mssql/template/template-qt5-vc10.vcxproj.filters create mode 100644 odb-tests/qt/mssql/template/template-qt5-vc11.vcxproj create mode 100644 odb-tests/qt/mssql/template/template-qt5-vc11.vcxproj.filters create mode 100644 odb-tests/qt/mssql/template/template-qt5-vc12.vcxproj create mode 100644 odb-tests/qt/mssql/template/template-qt5-vc12.vcxproj.filters create mode 100644 odb-tests/qt/mssql/template/template-qt5-vc9.vcproj create mode 100644 odb-tests/qt/mssql/template/test.hxx create mode 100644 odb-tests/qt/mysql/basic/driver.cxx create mode 100644 odb-tests/qt/mysql/basic/test.hxx create mode 100644 odb-tests/qt/mysql/date-time/driver.cxx create mode 100644 odb-tests/qt/mysql/date-time/test.hxx create mode 100644 odb-tests/qt/mysql/template/driver.cxx create mode 100644 odb-tests/qt/mysql/template/template-qt4-vc10.vcxproj create mode 100644 odb-tests/qt/mysql/template/template-qt4-vc10.vcxproj.filters create mode 100644 odb-tests/qt/mysql/template/template-qt4-vc11.vcxproj create mode 100644 odb-tests/qt/mysql/template/template-qt4-vc11.vcxproj.filters create mode 100644 odb-tests/qt/mysql/template/template-qt4-vc12.vcxproj create mode 100644 odb-tests/qt/mysql/template/template-qt4-vc12.vcxproj.filters create mode 100644 odb-tests/qt/mysql/template/template-qt4-vc8.vcproj create mode 100644 odb-tests/qt/mysql/template/template-qt4-vc9.vcproj create mode 100644 odb-tests/qt/mysql/template/template-qt5-vc10.vcxproj create mode 100644 odb-tests/qt/mysql/template/template-qt5-vc10.vcxproj.filters create mode 100644 odb-tests/qt/mysql/template/template-qt5-vc11.vcxproj create mode 100644 odb-tests/qt/mysql/template/template-qt5-vc11.vcxproj.filters create mode 100644 odb-tests/qt/mysql/template/template-qt5-vc12.vcxproj create mode 100644 odb-tests/qt/mysql/template/template-qt5-vc12.vcxproj.filters create mode 100644 odb-tests/qt/mysql/template/template-qt5-vc9.vcproj create mode 100644 odb-tests/qt/mysql/template/test.hxx create mode 100644 odb-tests/qt/oracle/basic/driver.cxx create mode 100644 odb-tests/qt/oracle/basic/test.hxx create mode 100644 odb-tests/qt/oracle/date-time/driver.cxx create mode 100644 odb-tests/qt/oracle/date-time/test.hxx create mode 100644 odb-tests/qt/oracle/template/driver.cxx create mode 100644 odb-tests/qt/oracle/template/template-qt4-vc10.vcxproj create mode 100644 odb-tests/qt/oracle/template/template-qt4-vc10.vcxproj.filters create mode 100644 odb-tests/qt/oracle/template/template-qt4-vc11.vcxproj create mode 100644 odb-tests/qt/oracle/template/template-qt4-vc11.vcxproj.filters create mode 100644 odb-tests/qt/oracle/template/template-qt4-vc12.vcxproj create mode 100644 odb-tests/qt/oracle/template/template-qt4-vc12.vcxproj.filters create mode 100644 odb-tests/qt/oracle/template/template-qt4-vc8.vcproj create mode 100644 odb-tests/qt/oracle/template/template-qt4-vc9.vcproj create mode 100644 odb-tests/qt/oracle/template/template-qt5-vc10.vcxproj create mode 100644 odb-tests/qt/oracle/template/template-qt5-vc10.vcxproj.filters create mode 100644 odb-tests/qt/oracle/template/template-qt5-vc11.vcxproj create mode 100644 odb-tests/qt/oracle/template/template-qt5-vc11.vcxproj.filters create mode 100644 odb-tests/qt/oracle/template/template-qt5-vc12.vcxproj create mode 100644 odb-tests/qt/oracle/template/template-qt5-vc12.vcxproj.filters create mode 100644 odb-tests/qt/oracle/template/template-qt5-vc9.vcproj create mode 100644 odb-tests/qt/oracle/template/test.hxx create mode 100644 odb-tests/qt/pgsql/basic/driver.cxx create mode 100644 odb-tests/qt/pgsql/basic/test.hxx create mode 100644 odb-tests/qt/pgsql/date-time/driver.cxx create mode 100644 odb-tests/qt/pgsql/date-time/test.hxx create mode 100644 odb-tests/qt/pgsql/template/driver.cxx create mode 100644 odb-tests/qt/pgsql/template/template-qt4-vc10.vcxproj create mode 100644 odb-tests/qt/pgsql/template/template-qt4-vc10.vcxproj.filters create mode 100644 odb-tests/qt/pgsql/template/template-qt4-vc11.vcxproj create mode 100644 odb-tests/qt/pgsql/template/template-qt4-vc11.vcxproj.filters create mode 100644 odb-tests/qt/pgsql/template/template-qt4-vc12.vcxproj create mode 100644 odb-tests/qt/pgsql/template/template-qt4-vc12.vcxproj.filters create mode 100644 odb-tests/qt/pgsql/template/template-qt4-vc8.vcproj create mode 100644 odb-tests/qt/pgsql/template/template-qt4-vc9.vcproj create mode 100644 odb-tests/qt/pgsql/template/template-qt5-vc10.vcxproj create mode 100644 odb-tests/qt/pgsql/template/template-qt5-vc10.vcxproj.filters create mode 100644 odb-tests/qt/pgsql/template/template-qt5-vc11.vcxproj create mode 100644 odb-tests/qt/pgsql/template/template-qt5-vc11.vcxproj.filters create mode 100644 odb-tests/qt/pgsql/template/template-qt5-vc12.vcxproj create mode 100644 odb-tests/qt/pgsql/template/template-qt5-vc12.vcxproj.filters create mode 100644 odb-tests/qt/pgsql/template/template-qt5-vc9.vcproj create mode 100644 odb-tests/qt/pgsql/template/test.hxx create mode 100644 odb-tests/qt/sqlite/basic/driver.cxx create mode 100644 odb-tests/qt/sqlite/basic/test.hxx create mode 100644 odb-tests/qt/sqlite/date-time/driver.cxx create mode 100644 odb-tests/qt/sqlite/date-time/test.hxx create mode 100644 odb-tests/qt/sqlite/template/driver.cxx create mode 100644 odb-tests/qt/sqlite/template/template-qt4-vc10.vcxproj create mode 100644 odb-tests/qt/sqlite/template/template-qt4-vc10.vcxproj.filters create mode 100644 odb-tests/qt/sqlite/template/template-qt4-vc11.vcxproj create mode 100644 odb-tests/qt/sqlite/template/template-qt4-vc11.vcxproj.filters create mode 100644 odb-tests/qt/sqlite/template/template-qt4-vc12.vcxproj create mode 100644 odb-tests/qt/sqlite/template/template-qt4-vc12.vcxproj.filters create mode 100644 odb-tests/qt/sqlite/template/template-qt4-vc8.vcproj create mode 100644 odb-tests/qt/sqlite/template/template-qt4-vc9.vcproj create mode 100644 odb-tests/qt/sqlite/template/template-qt5-vc10.vcxproj create mode 100644 odb-tests/qt/sqlite/template/template-qt5-vc10.vcxproj.filters create mode 100644 odb-tests/qt/sqlite/template/template-qt5-vc11.vcxproj create mode 100644 odb-tests/qt/sqlite/template/template-qt5-vc11.vcxproj.filters create mode 100644 odb-tests/qt/sqlite/template/template-qt5-vc12.vcxproj create mode 100644 odb-tests/qt/sqlite/template/template-qt5-vc12.vcxproj.filters create mode 100644 odb-tests/qt/sqlite/template/template-qt5-vc9.vcproj create mode 100644 odb-tests/qt/sqlite/template/test.hxx create mode 100644 odb-tests/sqlite.testscript create mode 100644 odb-tests/sqlite/attach/buildfile create mode 100644 odb-tests/sqlite/attach/driver.cxx create mode 100644 odb-tests/sqlite/attach/test.hxx create mode 100644 odb-tests/sqlite/attach/testscript create mode 100644 odb-tests/sqlite/auto/buildfile create mode 100644 odb-tests/sqlite/auto/driver.cxx create mode 100644 odb-tests/sqlite/auto/test.hxx create mode 100644 odb-tests/sqlite/auto/testscript create mode 100644 odb-tests/sqlite/custom/buildfile create mode 100644 odb-tests/sqlite/custom/driver.cxx create mode 100644 odb-tests/sqlite/custom/test.hxx create mode 100644 odb-tests/sqlite/custom/testscript create mode 100644 odb-tests/sqlite/database/buildfile create mode 100644 odb-tests/sqlite/database/driver.cxx create mode 100644 odb-tests/sqlite/database/testscript create mode 100644 odb-tests/sqlite/native/buildfile create mode 100644 odb-tests/sqlite/native/driver.cxx create mode 100644 odb-tests/sqlite/native/testscript create mode 100644 odb-tests/sqlite/stream/buildfile create mode 100644 odb-tests/sqlite/stream/driver.cxx create mode 100644 odb-tests/sqlite/stream/test.hxx create mode 100644 odb-tests/sqlite/stream/testscript create mode 100644 odb-tests/sqlite/transaction/buildfile create mode 100644 odb-tests/sqlite/transaction/driver.cxx create mode 100644 odb-tests/sqlite/transaction/test.hxx create mode 100644 odb-tests/sqlite/transaction/testscript create mode 100644 odb-tests/sqlite/truncation/buildfile create mode 100644 odb-tests/sqlite/truncation/driver.cxx create mode 100644 odb-tests/sqlite/truncation/test.hxx create mode 100644 odb-tests/sqlite/truncation/testscript create mode 100644 odb-tests/sqlite/types/buildfile create mode 100644 odb-tests/sqlite/types/driver.cxx create mode 100644 odb-tests/sqlite/types/test.hxx create mode 100644 odb-tests/sqlite/types/testscript create mode 100644 odb-tests/sqlite/types/traits.hxx delete mode 100644 oracle/custom/custom.sql delete mode 100644 oracle/custom/driver.cxx delete mode 100644 oracle/custom/test.hxx delete mode 100644 oracle/custom/traits.hxx delete mode 100644 oracle/database/driver.cxx delete mode 100644 oracle/native/driver.cxx delete mode 100644 oracle/template/driver.cxx delete mode 100644 oracle/template/template-vc10.vcxproj delete mode 100644 oracle/template/template-vc10.vcxproj.filters delete mode 100644 oracle/template/template-vc11.vcxproj delete mode 100644 oracle/template/template-vc11.vcxproj.filters delete mode 100644 oracle/template/template-vc12.vcxproj delete mode 100644 oracle/template/template-vc12.vcxproj.filters delete mode 100644 oracle/template/template-vc8.vcproj delete mode 100644 oracle/template/template-vc9.vcproj delete mode 100644 oracle/template/test.hxx delete mode 100644 oracle/types/driver.cxx delete mode 100644 oracle/types/test.hxx delete mode 100644 oracle/types/traits.hxx delete mode 100644 pgsql-schema.testscript delete mode 100644 pgsql.testscript delete mode 100644 pgsql/buildfile delete mode 100644 pgsql/bulk/buildfile delete mode 100644 pgsql/bulk/driver.cxx delete mode 100644 pgsql/bulk/test.hxx delete mode 100644 pgsql/bulk/testscript delete mode 100644 pgsql/custom/buildfile delete mode 100644 pgsql/custom/driver.cxx delete mode 100644 pgsql/custom/query.hxx delete mode 100644 pgsql/custom/test.hxx delete mode 100644 pgsql/custom/testscript delete mode 100644 pgsql/custom/traits.hxx delete mode 100644 pgsql/database/buildfile delete mode 100644 pgsql/database/driver.cxx delete mode 100644 pgsql/database/testscript delete mode 100644 pgsql/index/buildfile delete mode 100644 pgsql/index/driver.cxx delete mode 100644 pgsql/index/test.hxx delete mode 100644 pgsql/index/testscript delete mode 100644 pgsql/native/buildfile delete mode 100644 pgsql/native/driver.cxx delete mode 100644 pgsql/native/testscript delete mode 100644 pgsql/truncation/buildfile delete mode 100644 pgsql/truncation/driver.cxx delete mode 100644 pgsql/truncation/test.hxx delete mode 100644 pgsql/truncation/testscript delete mode 100644 pgsql/types/buildfile delete mode 100644 pgsql/types/driver.cxx delete mode 100644 pgsql/types/test.hxx delete mode 100644 pgsql/types/testscript delete mode 100644 pgsql/types/traits.hxx delete mode 100644 qt/common/basic/driver.cxx delete mode 100644 qt/common/basic/test.hxx delete mode 100644 qt/common/containers/basics/driver.cxx delete mode 100644 qt/common/containers/basics/test.hxx delete mode 100644 qt/common/containers/change-tracking/driver.cxx delete mode 100644 qt/common/containers/change-tracking/test.hxx delete mode 100644 qt/common/smart-ptr/driver.cxx delete mode 100644 qt/common/smart-ptr/test.hxx delete mode 100644 qt/common/template/driver.cxx delete mode 100644 qt/common/template/template-qt4-vc10.vcxproj delete mode 100644 qt/common/template/template-qt4-vc10.vcxproj.filters delete mode 100644 qt/common/template/template-qt4-vc11.vcxproj delete mode 100644 qt/common/template/template-qt4-vc11.vcxproj.filters delete mode 100644 qt/common/template/template-qt4-vc12.vcxproj delete mode 100644 qt/common/template/template-qt4-vc12.vcxproj.filters delete mode 100644 qt/common/template/template-qt4-vc8.vcproj delete mode 100644 qt/common/template/template-qt4-vc9.vcproj delete mode 100644 qt/common/template/template-qt5-vc10.vcxproj delete mode 100644 qt/common/template/template-qt5-vc10.vcxproj.filters delete mode 100644 qt/common/template/template-qt5-vc11.vcxproj delete mode 100644 qt/common/template/template-qt5-vc11.vcxproj.filters delete mode 100644 qt/common/template/template-qt5-vc12.vcxproj delete mode 100644 qt/common/template/template-qt5-vc12.vcxproj.filters delete mode 100644 qt/common/template/template-qt5-vc9.vcproj delete mode 100644 qt/common/template/test.hxx delete mode 100644 qt/mssql/basic/driver.cxx delete mode 100644 qt/mssql/basic/test.hxx delete mode 100644 qt/mssql/date-time/driver.cxx delete mode 100644 qt/mssql/date-time/test.hxx delete mode 100644 qt/mssql/template/driver.cxx delete mode 100644 qt/mssql/template/template-qt4-vc10.vcxproj delete mode 100644 qt/mssql/template/template-qt4-vc10.vcxproj.filters delete mode 100644 qt/mssql/template/template-qt4-vc11.vcxproj delete mode 100644 qt/mssql/template/template-qt4-vc11.vcxproj.filters delete mode 100644 qt/mssql/template/template-qt4-vc12.vcxproj delete mode 100644 qt/mssql/template/template-qt4-vc12.vcxproj.filters delete mode 100644 qt/mssql/template/template-qt4-vc8.vcproj delete mode 100644 qt/mssql/template/template-qt4-vc9.vcproj delete mode 100644 qt/mssql/template/template-qt5-vc10.vcxproj delete mode 100644 qt/mssql/template/template-qt5-vc10.vcxproj.filters delete mode 100644 qt/mssql/template/template-qt5-vc11.vcxproj delete mode 100644 qt/mssql/template/template-qt5-vc11.vcxproj.filters delete mode 100644 qt/mssql/template/template-qt5-vc12.vcxproj delete mode 100644 qt/mssql/template/template-qt5-vc12.vcxproj.filters delete mode 100644 qt/mssql/template/template-qt5-vc9.vcproj delete mode 100644 qt/mssql/template/test.hxx delete mode 100644 qt/mysql/basic/driver.cxx delete mode 100644 qt/mysql/basic/test.hxx delete mode 100644 qt/mysql/date-time/driver.cxx delete mode 100644 qt/mysql/date-time/test.hxx delete mode 100644 qt/mysql/template/driver.cxx delete mode 100644 qt/mysql/template/template-qt4-vc10.vcxproj delete mode 100644 qt/mysql/template/template-qt4-vc10.vcxproj.filters delete mode 100644 qt/mysql/template/template-qt4-vc11.vcxproj delete mode 100644 qt/mysql/template/template-qt4-vc11.vcxproj.filters delete mode 100644 qt/mysql/template/template-qt4-vc12.vcxproj delete mode 100644 qt/mysql/template/template-qt4-vc12.vcxproj.filters delete mode 100644 qt/mysql/template/template-qt4-vc8.vcproj delete mode 100644 qt/mysql/template/template-qt4-vc9.vcproj delete mode 100644 qt/mysql/template/template-qt5-vc10.vcxproj delete mode 100644 qt/mysql/template/template-qt5-vc10.vcxproj.filters delete mode 100644 qt/mysql/template/template-qt5-vc11.vcxproj delete mode 100644 qt/mysql/template/template-qt5-vc11.vcxproj.filters delete mode 100644 qt/mysql/template/template-qt5-vc12.vcxproj delete mode 100644 qt/mysql/template/template-qt5-vc12.vcxproj.filters delete mode 100644 qt/mysql/template/template-qt5-vc9.vcproj delete mode 100644 qt/mysql/template/test.hxx delete mode 100644 qt/oracle/basic/driver.cxx delete mode 100644 qt/oracle/basic/test.hxx delete mode 100644 qt/oracle/date-time/driver.cxx delete mode 100644 qt/oracle/date-time/test.hxx delete mode 100644 qt/oracle/template/driver.cxx delete mode 100644 qt/oracle/template/template-qt4-vc10.vcxproj delete mode 100644 qt/oracle/template/template-qt4-vc10.vcxproj.filters delete mode 100644 qt/oracle/template/template-qt4-vc11.vcxproj delete mode 100644 qt/oracle/template/template-qt4-vc11.vcxproj.filters delete mode 100644 qt/oracle/template/template-qt4-vc12.vcxproj delete mode 100644 qt/oracle/template/template-qt4-vc12.vcxproj.filters delete mode 100644 qt/oracle/template/template-qt4-vc8.vcproj delete mode 100644 qt/oracle/template/template-qt4-vc9.vcproj delete mode 100644 qt/oracle/template/template-qt5-vc10.vcxproj delete mode 100644 qt/oracle/template/template-qt5-vc10.vcxproj.filters delete mode 100644 qt/oracle/template/template-qt5-vc11.vcxproj delete mode 100644 qt/oracle/template/template-qt5-vc11.vcxproj.filters delete mode 100644 qt/oracle/template/template-qt5-vc12.vcxproj delete mode 100644 qt/oracle/template/template-qt5-vc12.vcxproj.filters delete mode 100644 qt/oracle/template/template-qt5-vc9.vcproj delete mode 100644 qt/oracle/template/test.hxx delete mode 100644 qt/pgsql/basic/driver.cxx delete mode 100644 qt/pgsql/basic/test.hxx delete mode 100644 qt/pgsql/date-time/driver.cxx delete mode 100644 qt/pgsql/date-time/test.hxx delete mode 100644 qt/pgsql/template/driver.cxx delete mode 100644 qt/pgsql/template/template-qt4-vc10.vcxproj delete mode 100644 qt/pgsql/template/template-qt4-vc10.vcxproj.filters delete mode 100644 qt/pgsql/template/template-qt4-vc11.vcxproj delete mode 100644 qt/pgsql/template/template-qt4-vc11.vcxproj.filters delete mode 100644 qt/pgsql/template/template-qt4-vc12.vcxproj delete mode 100644 qt/pgsql/template/template-qt4-vc12.vcxproj.filters delete mode 100644 qt/pgsql/template/template-qt4-vc8.vcproj delete mode 100644 qt/pgsql/template/template-qt4-vc9.vcproj delete mode 100644 qt/pgsql/template/template-qt5-vc10.vcxproj delete mode 100644 qt/pgsql/template/template-qt5-vc10.vcxproj.filters delete mode 100644 qt/pgsql/template/template-qt5-vc11.vcxproj delete mode 100644 qt/pgsql/template/template-qt5-vc11.vcxproj.filters delete mode 100644 qt/pgsql/template/template-qt5-vc12.vcxproj delete mode 100644 qt/pgsql/template/template-qt5-vc12.vcxproj.filters delete mode 100644 qt/pgsql/template/template-qt5-vc9.vcproj delete mode 100644 qt/pgsql/template/test.hxx delete mode 100644 qt/sqlite/basic/driver.cxx delete mode 100644 qt/sqlite/basic/test.hxx delete mode 100644 qt/sqlite/date-time/driver.cxx delete mode 100644 qt/sqlite/date-time/test.hxx delete mode 100644 qt/sqlite/template/driver.cxx delete mode 100644 qt/sqlite/template/template-qt4-vc10.vcxproj delete mode 100644 qt/sqlite/template/template-qt4-vc10.vcxproj.filters delete mode 100644 qt/sqlite/template/template-qt4-vc11.vcxproj delete mode 100644 qt/sqlite/template/template-qt4-vc11.vcxproj.filters delete mode 100644 qt/sqlite/template/template-qt4-vc12.vcxproj delete mode 100644 qt/sqlite/template/template-qt4-vc12.vcxproj.filters delete mode 100644 qt/sqlite/template/template-qt4-vc8.vcproj delete mode 100644 qt/sqlite/template/template-qt4-vc9.vcproj delete mode 100644 qt/sqlite/template/template-qt5-vc10.vcxproj delete mode 100644 qt/sqlite/template/template-qt5-vc10.vcxproj.filters delete mode 100644 qt/sqlite/template/template-qt5-vc11.vcxproj delete mode 100644 qt/sqlite/template/template-qt5-vc11.vcxproj.filters delete mode 100644 qt/sqlite/template/template-qt5-vc12.vcxproj delete mode 100644 qt/sqlite/template/template-qt5-vc12.vcxproj.filters delete mode 100644 qt/sqlite/template/template-qt5-vc9.vcproj delete mode 100644 qt/sqlite/template/test.hxx delete mode 100644 repositories.manifest delete mode 100644 sqlite.testscript delete mode 100644 sqlite/attach/buildfile delete mode 100644 sqlite/attach/driver.cxx delete mode 100644 sqlite/attach/test.hxx delete mode 100644 sqlite/attach/testscript delete mode 100644 sqlite/auto/buildfile delete mode 100644 sqlite/auto/driver.cxx delete mode 100644 sqlite/auto/test.hxx delete mode 100644 sqlite/auto/testscript delete mode 100644 sqlite/custom/buildfile delete mode 100644 sqlite/custom/driver.cxx delete mode 100644 sqlite/custom/test.hxx delete mode 100644 sqlite/custom/testscript delete mode 100644 sqlite/database/buildfile delete mode 100644 sqlite/database/driver.cxx delete mode 100644 sqlite/database/testscript delete mode 100644 sqlite/native/buildfile delete mode 100644 sqlite/native/driver.cxx delete mode 100644 sqlite/native/testscript delete mode 100644 sqlite/stream/buildfile delete mode 100644 sqlite/stream/driver.cxx delete mode 100644 sqlite/stream/test.hxx delete mode 100644 sqlite/stream/testscript delete mode 100644 sqlite/transaction/buildfile delete mode 100644 sqlite/transaction/driver.cxx delete mode 100644 sqlite/transaction/test.hxx delete mode 100644 sqlite/transaction/testscript delete mode 100644 sqlite/truncation/buildfile delete mode 100644 sqlite/truncation/driver.cxx delete mode 100644 sqlite/truncation/test.hxx delete mode 100644 sqlite/truncation/testscript delete mode 100644 sqlite/types/buildfile delete mode 100644 sqlite/types/driver.cxx delete mode 100644 sqlite/types/test.hxx delete mode 100644 sqlite/types/testscript delete mode 100644 sqlite/types/traits.hxx diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e3bbf5b..0000000 --- a/.gitignore +++ /dev/null @@ -1,41 +0,0 @@ -# Compiler/linker output. -# -*.d -*.t -*.i -*.i.* -*.ii -*.ii.* -*.o -*.obj -*.gcm -*.pcm -*.ifc -*.so -*.dylib -*.dll -*.a -*.lib -*.exp -*.pdb -*.ilk -*.exe -*.exe.dlls/ -*.exe.manifest -*.pc - -# Test executables. -# -driver - -# ODB-generated files. -# -test-odb.?xx -test-odb-*.?xx -test.sql -test-*.sql - -# Testscript output directories (can be symlinks). -# -test -test-driver diff --git a/GPLv2 b/GPLv2 deleted file mode 100644 index 3912109..0000000 --- a/GPLv2 +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 9d92da1..0000000 --- a/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2009-2024 Code Synthesis Tools CC. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License version 2 as -published by the Free Software Foundation. - -For more information on ODB licensing as well as for answers to -some of the common licensing questions, visit the ODB License -page: - -http://www.codesynthesis.com/products/odb/license.xhtml - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/README.md b/README.md deleted file mode 100644 index 24d3bf7..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# odb-tests - tests for ODB compiler - -This package contains tests for `odb`, object-relational mapping (ORM) -compiler for C++. diff --git a/boost/common/multi-index/driver.cxx b/boost/common/multi-index/driver.cxx deleted file mode 100644 index a077008..0000000 --- a/boost/common/multi-index/driver.cxx +++ /dev/null @@ -1,189 +0,0 @@ -// file : boost/common/multi-index/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Boost multi-index container persistence. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - { - using namespace odb; - - assert (odb::access::container_traits::kind == ck_ordered); - assert (odb::access::container_traits::kind == ck_ordered); - assert (odb::access::container_traits::kind == ck_set); - - assert (odb::access::container_traits::kind == ck_ordered); - assert (odb::access::container_traits::kind == ck_ordered); - assert (odb::access::container_traits::kind == ck_set); - } - - try - { - auto_ptr db (create_database (argc, argv)); - - for (unsigned short i (0); i < 2; ++i) - { - object empty ("empty"), med ("medium"), full ("full"); - - // - // empty - // - - // - // med - // - med.il.push_back (234); - med.il.push_back (123); - - med.iv.push_back (234); - med.iv.push_back (123); - - med.is.insert (234); - med.is.insert (123); - - med.ils.push_back (234); - med.ils.push_back (123); - - med.csv.insert (comp (234, "bcd")); - med.csv.insert (comp (123, "abc")); - - med.css.insert (comp (234, "bcd")); - med.css.insert (comp (123, "abc")); - - // - // full - // - full.il.push_back (2345); - full.il.push_back (1234); - full.il.push_back (3456); - - full.iv.push_back (2345); - full.iv.push_back (1234); - full.iv.push_back (3456); - - full.is.insert (2345); - full.is.insert (1234); - full.is.insert (3456); - - full.ils.push_back (2345); - full.ils.push_back (1234); - full.ils.push_back (3456); - - full.csv.insert (comp (234, "bcde")); - full.csv.insert (comp (123, "abcd")); - full.csv.insert (comp (234, "cdef")); - - full.css.insert (comp (234, "bcde")); - full.css.insert (comp (123, "abcd")); - full.css.insert (comp (234, "cdef")); - - // persist - // - { - transaction t (db->begin ()); - db->persist (empty); - db->persist (med); - db->persist (full); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - auto_ptr e (db->load ("empty")); - auto_ptr m (db->load ("medium")); - auto_ptr f (db->load ("full")); - t.commit (); - - assert (empty == *e); - assert (med == *m); - assert (full == *f); - } - - // empty - // - empty.il.push_back (12); - empty.iv.push_back (12); - empty.is.insert (12); - empty.ils.push_back (12); - empty.csv.insert (comp (12, "ab")); - empty.css.insert (comp (12, "ab")); - - // med - // - med.il.clear (); - med.iv.clear (); - med.is.clear (); - med.ils.clear (); - med.csv.clear (); - med.css.clear (); - - // full - // - full.il.push_back (4567); - full.iv.push_back (4567); - full.is.insert (4567); - full.ils.push_back (4567); - full.csv.insert (comp (4567, "defg")); - full.css.insert (comp (4567, "defg")); - - // update - // - { - transaction t (db->begin ()); - db->update (empty); - db->update (med); - db->update (full); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - auto_ptr e (db->load ("empty")); - auto_ptr m (db->load ("medium")); - auto_ptr f (db->load ("full")); - t.commit (); - - assert (empty == *e); - assert (med == *m); - assert (full == *f); - } - - // erase - // - if (i == 0) - { - transaction t (db->begin ()); - db->erase ("empty"); - db->erase ("medium"); - db->erase ("full"); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/boost/common/multi-index/test.hxx b/boost/common/multi-index/test.hxx deleted file mode 100644 index 22b9ea4..0000000 --- a/boost/common/multi-index/test.hxx +++ /dev/null @@ -1,113 +0,0 @@ -// file : boost/common/multi-index/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include -#include -#include -#include - -#include - -namespace mi = boost::multi_index; - -#pragma db value -struct comp -{ - comp () {} - comp (int n, const std::string& s) : num (n), str (s) {} - - #pragma db column("number") - int num; - std::string str; -}; - -inline bool -operator== (const comp& x, const comp& y) -{ - return x.num == y.num && x.str == y.str; -} - -typedef -mi::multi_index_container< - int, - mi::indexed_by > -> int_lst; - -typedef -mi::multi_index_container< - int, - mi::indexed_by > -> int_vec; - -typedef -mi::multi_index_container< - int, - mi::indexed_by > > -> int_set; - -typedef -mi::multi_index_container< - int, - mi::indexed_by< - mi::sequenced<>, - mi::ordered_unique > - > -> int_lst_set; - -typedef -mi::multi_index_container< - comp, - mi::indexed_by< - mi::ordered_unique >, - mi::random_access<> - > -> comp_set_vec; - -typedef -mi::multi_index_container< - comp, - mi::indexed_by< - mi::ordered_unique >, - mi::ordered_unique > - > -> comp_set_set; - -#pragma db object -struct object -{ - object () {} - object (const std::string& id): id (id) {} - - #pragma db id - std::string id; - - int_lst il; - int_lst iv; - int_set is; - - int_lst_set ils; - comp_set_vec csv; - comp_set_set css; -}; - -inline bool -operator== (const object& x, const object& y) -{ - return - x.id == y.id && - - x.il == y.il && - x.iv == y.iv && - x.is == y.is && - - x.ils == y.ils && - x.csv == y.csv && - x.css == y.css; -} - -#endif // TEST_HXX diff --git a/boost/common/optional/driver.cxx b/boost/common/optional/driver.cxx deleted file mode 100644 index c2e3079..0000000 --- a/boost/common/optional/driver.cxx +++ /dev/null @@ -1,74 +0,0 @@ -// file : boost/common/optional/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test boost::optional persistence. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - { - object o1 (1); - object o2 (2); - o2.str = "abc"; - - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr o1 (db->load (1)); - auto_ptr o2 (db->load (2)); - t.commit (); - - assert (!o1->str); - assert (o2->str && *o2->str == "abc"); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - { - result r (db->query (query::str.is_null ())); - assert (!r.empty ()); - } - - { - result r (db->query (query::str == "abc")); - assert (!r.empty ()); - } - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/boost/common/optional/test.hxx b/boost/common/optional/test.hxx deleted file mode 100644 index 65d951e..0000000 --- a/boost/common/optional/test.hxx +++ /dev/null @@ -1,31 +0,0 @@ -// file : boost/common/optional/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; - - boost::optional str; -}; - -#endif // TEST_HXX diff --git a/boost/common/smart-ptr/driver.cxx b/boost/common/smart-ptr/driver.cxx deleted file mode 100644 index 4bc6366..0000000 --- a/boost/common/smart-ptr/driver.cxx +++ /dev/null @@ -1,202 +0,0 @@ -// file : boost/common/smart-ptr/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test boost smart pointers. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; - -using namespace odb::boost; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - using boost::shared_ptr; - - try - { - auto_ptr db (create_database (argc, argv)); - - shared_ptr c1 (new cont (1)); - { - transaction t (db->begin ()); - db->persist (c1); - t.commit (); - } - - // Test comparison operators. - // - { - assert (lazy_shared_ptr () == lazy_shared_ptr ()); - assert (lazy_shared_ptr () != lazy_shared_ptr (c1)); - assert (lazy_shared_ptr (c1) == lazy_shared_ptr (c1)); - - lazy_shared_ptr lc1 (*db, 1); - assert (lc1 != lazy_shared_ptr ()); - assert (lc1 == lazy_shared_ptr (*db, c1)); - - shared_ptr c2 (new cont (2)); - assert (lc1 != lazy_shared_ptr (*db, c2)); - } - - // Test swap. - // - { - lazy_shared_ptr lx (*db, 1), ly; - assert (lx == lazy_shared_ptr (*db, c1)); - - swap (lx, ly); - assert (lx == lazy_shared_ptr ()); - assert (ly == lazy_shared_ptr (*db, c1)); - } - - // Test assignment from auto_ptr. - // - { - cont* p = new cont (3); - auto_ptr a (p); - lazy_shared_ptr l; - l = a; - - assert (l.get() == p); - assert (!a.get ()); - } - - shared_ptr o1 (new obj (1)); - shared_ptr o2 (new obj (2)); - shared_ptr o3 (new obj (3)); - shared_ptr o4 (new obj (4)); - shared_ptr c2 (new cont (2)); - - o1->c = c1; - o2->c = c1; - o3->c = c2; - o4->c = c2; - - // Persist. - // - { - transaction t (db->begin ()); - - db->persist (o1); - db->persist (o2); - db->persist (o3); - db->persist (o4); - db->persist (c2); - - t.commit (); - } - - // Load. - // - { - session s; - transaction t (db->begin ()); - - shared_ptr c (db->load (1)); - shared_ptr o (db->load (1)); - - // Ensure that lazy pointers are present but not loaded. - // - assert (c->o.size () == 2); - assert (!c->o[0].loaded ()); - assert (!c->o[1].loaded ()); - assert (!o->c.loaded ()); - - // Ensure that the correct object IDs were loaded. - // - assert (c->o[0].object_id () == 1); - assert (c->o[1].object_id () == 2); - assert (o->c.object_id () == 1); - - // Load the lazy pointer targets ensuring that the loaded - // targets correspond to the cached session objects. - // - shared_ptr cl (o->c.load ()); - shared_ptr ol (c->o[0].load ()); - - assert (c->o[0].loaded ()); - assert (o->c.loaded ()); - - assert (cl == c); - assert (ol == o); - - t.commit (); - } - - // Test lazy weak locking and reloading. - // - { - // No session. - // - transaction t (db->begin ()); - shared_ptr c (db->load (1)); - - // Lock. - // - assert (!c->o[1].loaded ()); - lazy_shared_ptr l (c->o[1].lock ()); - assert (!l.loaded ()); - assert (l.object_id () == c->o[1].object_id ()); - - // Reload. - // - assert (!c->o[1].loaded ()); - - shared_ptr ol (c->o[1].load ()); - assert (c->o[1].loaded ()); - - ol.reset (); - assert (!c->o[1].loaded ()); - - ol = c->o[1].load (); - assert (c->o[1].loaded ()); - - t.commit (); - } - - // - // Test shared_ptr as a value wrapper. - // - - { - obj2 o1 (1); - obj2 o2 (2); - o2.str.reset (new string ("abc")); - - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - shared_ptr o1 (db->load (1)); - shared_ptr o2 (db->load (2)); - t.commit (); - - assert (!o1->str); - assert (o2->str && *o2->str == "abc"); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/boost/common/smart-ptr/test.hxx b/boost/common/smart-ptr/test.hxx deleted file mode 100644 index 26d7109..0000000 --- a/boost/common/smart-ptr/test.hxx +++ /dev/null @@ -1,82 +0,0 @@ -// file : boost/common/smart-ptr/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -#include -#include - -struct obj; - -using boost::shared_ptr; -using odb::boost::lazy_shared_ptr; -using odb::boost::lazy_weak_ptr; - -#pragma db object -struct cont -{ - cont () - { - } - - cont (unsigned long id) - : id (id) - { - } - - #pragma db id - unsigned long id; - - typedef std::vector > obj_list; - - #pragma db inverse(c) value_not_null - obj_list o; -}; - -#pragma db object -struct obj -{ - obj () - { - } - - obj (unsigned long id) - : id (id) - { - } - - #pragma db id - unsigned long id; - - #pragma db not_null - lazy_shared_ptr c; -}; - -// Test shared_ptr as a value wrapper. -// -#pragma db object -struct obj2 -{ - obj2 () - { - } - - obj2 (unsigned long id) - : id (id) - { - } - - #pragma db id - unsigned long id; - - #pragma db null - shared_ptr str; -}; - -#endif // TEST_HXX diff --git a/boost/common/template/driver.cxx b/boost/common/template/driver.cxx deleted file mode 100644 index 43e28c0..0000000 --- a/boost/common/template/driver.cxx +++ /dev/null @@ -1,39 +0,0 @@ -// file : boost/common/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/boost/common/template/template-vc10.vcxproj b/boost/common/template/template-vc10.vcxproj deleted file mode 100644 index 3c606f9..0000000 --- a/boost/common/template/template-vc10.vcxproj +++ /dev/null @@ -1,177 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - - -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/boost/common/template/template-vc10.vcxproj.filters b/boost/common/template/template-vc10.vcxproj.filters deleted file mode 100644 index f3ee658..0000000 --- a/boost/common/template/template-vc10.vcxproj.filters +++ /dev/null @@ -1,24 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test-odb.cxx) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/common/template/template-vc11.vcxproj b/boost/common/template/template-vc11.vcxproj deleted file mode 100644 index 83d20c5..0000000 --- a/boost/common/template/template-vc11.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - - -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/boost/common/template/template-vc11.vcxproj.filters b/boost/common/template/template-vc11.vcxproj.filters deleted file mode 100644 index f3ee658..0000000 --- a/boost/common/template/template-vc11.vcxproj.filters +++ /dev/null @@ -1,24 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test-odb.cxx) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/common/template/template-vc12.vcxproj b/boost/common/template/template-vc12.vcxproj deleted file mode 100644 index fd147f7..0000000 --- a/boost/common/template/template-vc12.vcxproj +++ /dev/null @@ -1,185 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - - -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/boost/common/template/template-vc12.vcxproj.filters b/boost/common/template/template-vc12.vcxproj.filters deleted file mode 100644 index f3ee658..0000000 --- a/boost/common/template/template-vc12.vcxproj.filters +++ /dev/null @@ -1,24 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test-odb.cxx) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/common/template/template-vc8.vcproj b/boost/common/template/template-vc8.vcproj deleted file mode 100644 index e0ac609..0000000 --- a/boost/common/template/template-vc8.vcproj +++ /dev/null @@ -1,353 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx) -__file_entries__(extra_headers) - - - - - diff --git a/boost/common/template/template-vc9.vcproj b/boost/common/template/template-vc9.vcproj deleted file mode 100644 index b8bf4bc..0000000 --- a/boost/common/template/template-vc9.vcproj +++ /dev/null @@ -1,360 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx) -__file_entries__(extra_headers) - - - - - diff --git a/boost/common/template/test.hxx b/boost/common/template/test.hxx deleted file mode 100644 index 1d2a5f3..0000000 --- a/boost/common/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : boost/common/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/boost/common/unordered/driver.cxx b/boost/common/unordered/driver.cxx deleted file mode 100644 index eda5891..0000000 --- a/boost/common/unordered/driver.cxx +++ /dev/null @@ -1,212 +0,0 @@ -// file : boost/common/unordered/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Boost unordered containers persistence. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - for (unsigned short i (0); i < 2; ++i) - { - object empty ("empty"), med ("medium"), full ("full"); - - // - // empty - // - - // - // med - // - - // set - // - med.ns.insert (123); - med.ns.insert (234); - - med.ss.insert ("aaa"); - med.ss.insert ("bbbb"); - - med.cms.insert (comp (123, "aaa")); - med.cms.insert (comp (234, "bbbb")); - - // map - // - med.nsm[123] = "aaa"; - med.nsm[234] = "bbbb"; - - med.snm["aaa"] = 123; - med.snm["bbbb"] = 234; - - med.ncm[123] = comp (123, "aaa"); - med.ncm[234] = comp (234, "bbbb"); - - med.csmm.insert ( - comp_str_multimap::value_type (comp (123, "aaa"), "aaa")); - med.csmm.insert ( - comp_str_multimap::value_type (comp (234, "bbbb"), "bbbb")); - - // - // full - // - - // set - // - full.ns.insert (1234); - full.ns.insert (2345); - full.ns.insert (3456); - - full.ss.insert ("aaaa"); - full.ss.insert ("bbbbb"); - full.ss.insert ("cccccc"); - - full.cms.insert (comp (1234, "aaaa")); - full.cms.insert (comp (2345, "bbbbb")); - full.cms.insert (comp (3456, "cccccc")); - - // map - // - full.nsm[1234] = "aaaa"; - full.nsm[2345] = "bbbbb"; - full.nsm[3456] = "cccccc"; - - full.snm["aaaa"] = 1234; - full.snm["bbbbb"] = 2345; - full.snm["cccccc"] = 3456; - - full.ncm[1234] = comp (1234, "aaaa"); - full.ncm[2345] = comp (2345, "bbbbb"); - full.ncm[3456] = comp (3456, "cccccc"); - - full.csmm.insert ( - comp_str_multimap::value_type (comp (1234, "aaaa"), "aaaa")); - full.csmm.insert ( - comp_str_multimap::value_type (comp (2345, "bbbbb"), "bbbbb")); - full.csmm.insert ( - comp_str_multimap::value_type (comp (3456, "cccccc"), "cccccc")); - - // persist - // - { - transaction t (db->begin ()); - db->persist (empty); - db->persist (med); - db->persist (full); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - auto_ptr e (db->load ("empty")); - auto_ptr m (db->load ("medium")); - auto_ptr f (db->load ("full")); - t.commit (); - - assert (empty == *e); - assert (med == *m); - assert (full == *f); - } - - // empty - // - empty.ns.insert (12); - empty.ss.insert ("aa"); - empty.cms.insert (comp (12, "aa")); - - empty.nsm[12] = "aa"; - empty.snm["aa"] = 12; - empty.ncm[12] = comp (12, "aa"); - empty.csmm.insert ( - comp_str_multimap::value_type (comp (12, "aa"), "aa")); - - // med - // - med.ns.clear (); - med.ss.clear (); - med.cms.clear (); - - med.nsm.clear (); - med.snm.clear (); - med.ncm.clear (); - med.csmm.clear (); - - // full - // - full.ns.insert (4567); - full.ss.insert ("ddddddd"); - full.cms.insert (comp (4567, "ddddddd")); - - full.nsm[3456] += 'c'; - full.nsm[4567] = "ddddddd"; - full.snm["cccccc"]++; - full.snm["ddddddd"] = 4567; - full.ncm[3456].num++; - full.ncm[3456].str += 'c'; - full.ncm[4567] = comp (4567, "ddddddd"); - full.csmm.find (comp (3456, "cccccc"))->second += "c"; - full.csmm.insert ( - comp_str_multimap::value_type (comp (4567, "ddddddd"), "ddddddd")); - - // update - // - { - transaction t (db->begin ()); - db->update (empty); - db->update (med); - db->update (full); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - auto_ptr e (db->load ("empty")); - auto_ptr m (db->load ("medium")); - auto_ptr f (db->load ("full")); - t.commit (); - - assert (empty == *e); - assert (med == *m); - assert (full == *f); - } - - // erase - // - if (i == 0) - { - transaction t (db->begin ()); - db->erase ("empty"); - db->erase ("medium"); - db->erase ("full"); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/boost/common/unordered/test.hxx b/boost/common/unordered/test.hxx deleted file mode 100644 index cd77845..0000000 --- a/boost/common/unordered/test.hxx +++ /dev/null @@ -1,113 +0,0 @@ -// file : boost/common/unordered/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include -#include - -#include - -#pragma db value -struct comp -{ - comp () {} - comp (int n, const std::string& s) : num (n), str (s) {} - - #pragma db column("number") - int num; - std::string str; -}; - -inline bool -operator== (const comp& x, const comp& y) -{ - return x.num == y.num && x.str == y.str; -} - -inline bool -operator!= (const comp& x, const comp& y) -{ - return !(x == y); -} - -inline bool -operator< (const comp& x, const comp& y) -{ - return x.num != y.num ? x.num < y.num : x.str < y.str; -} - -inline std::size_t -hash_value (const comp& x) -{ - std::size_t seed = 0; - boost::hash_combine (seed, x.num); - boost::hash_combine (seed, x.str); - return seed; -} - -using boost::unordered_set; -using boost::unordered_multiset; - -typedef unordered_set num_set; -typedef unordered_set str_set; -typedef unordered_multiset comp_multiset; - -using boost::unordered_map; -using boost::unordered_multimap; - -typedef unordered_map num_str_map; -typedef unordered_map str_num_map; -typedef unordered_map num_comp_map; -typedef unordered_multimap comp_str_multimap; - -#pragma db object -struct object -{ - object () - { - } - - object (const std::string& id) - : id (id) - { - } - - - #pragma db id - std::string id; - - // set - // - num_set ns; - str_set ss; - comp_multiset cms; - - // map - // - num_str_map nsm; - str_num_map snm; - num_comp_map ncm; - comp_str_multimap csmm; -}; - -inline bool -operator== (const object& x, const object& y) -{ - return - x.id == y.id && - - x.ns == y.ns && - x.ss == y.ss && - x.cms == y.cms && - - x.nsm == y.nsm && - x.snm == y.snm && - x.ncm == y.ncm && - x.csmm == y.csmm; -} - -#endif // TEST_HXX diff --git a/boost/common/uuid/driver.cxx b/boost/common/uuid/driver.cxx deleted file mode 100644 index aed3390..0000000 --- a/boost/common/uuid/driver.cxx +++ /dev/null @@ -1,69 +0,0 @@ -// file : boost/common/uuid/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Boost UUID persistence. -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace boost::uuids; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - object o (1); - o.uuid_ = random_generator() (); - o.null_ = nil_uuid (); - o.zero_ = nil_uuid (); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (o.id_)); - t.commit (); - - assert (*p == o); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::uuid == o.uuid_)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->id_ == o.id_); - assert (++i == r.end ()); - t.commit (); - } - - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/boost/common/uuid/test.hxx b/boost/common/uuid/test.hxx deleted file mode 100644 index 82ed95b..0000000 --- a/boost/common/uuid/test.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// file : boost/common/uuid/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object -struct object -{ - object () {} - object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - typedef boost::uuids::uuid uuid; - - uuid uuid_; - uuid null_; - - #pragma db not_null - uuid zero_; - - bool operator== (const object& x) const - { - return id_ == x.id_ && - uuid_ == x.uuid_ && - null_ == x.null_ && - zero_ == x.zero_; - } -}; - -#endif // TEST_HXX diff --git a/boost/mssql/date-time/driver.cxx b/boost/mssql/date-time/driver.cxx deleted file mode 100644 index e97a276..0000000 --- a/boost/mssql/date-time/driver.cxx +++ /dev/null @@ -1,158 +0,0 @@ -// file : boost/mssql/date-time/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test boost date/time type persistence. SQL Server version. -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; - -using namespace boost::gregorian; -using namespace boost::posix_time; - -using namespace odb::core; - -bool -test_invalid_special_value (object&, auto_ptr&); - -bool -test_out_of_range_value (object&, auto_ptr&); - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - object o; - - // Test all valid date-time mappings. - // -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - o.dates.push_back (day_clock::local_day ()); - o.dates.push_back (date (not_a_date_time)); - o.dates.push_back (date (max_date_time)); - o.dates.push_back (date (min_date_time)); - - o.times.push_back (second_clock::local_time ()); - o.times.push_back (not_a_date_time); - o.times.push_back (min_date_time); - o.times.push_back (ptime (max_date_time)); -#endif - - // In DATETIME fractional seconds are rounded to .000, .003, or .007. - // - o.times_dt.push_back (ptime (date (2012, 1, 13), - time_duration (11, 57, 13, 7000))); - - // SMALLDATETIME doesn't have seconds (always 0). - // - o.times_sdt.push_back (ptime (date (2012, 1, 13), - time_duration (11, 57, 0, 0))); - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - o.durations.push_back (time_duration (1, 2, 3, 123456)); - o.durations.push_back (not_a_date_time); -#endif - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (*ol == o); - } - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - // Test invalid date mappings. - // - { - object sv1, sv2; - sv1.dates.push_back (date (neg_infin)); - sv2.dates.push_back (date (pos_infin)); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - // Test invalid ptime mappings. - // - { - object sv1, sv2; - sv1.times.push_back (neg_infin); - sv2.times.push_back (pos_infin); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - // Test invalid time_duration mappings. - // - { - object sv1, sv2, or1; - sv1.durations.push_back (pos_infin); - sv2.durations.push_back (neg_infin); - or1.durations.push_back (time_duration (50, 2, 3, 123456700)); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - - try - { - db->persist (or1); - assert (false); - } - catch (const odb::boost::date_time::value_out_of_range&) - { - } - - t.commit (); - } -#endif - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} - -bool -test_invalid_special_value (object& x, auto_ptr& db) -{ - try - { - db->persist (x); - return false; - } - catch (const odb::boost::date_time::special_value&) - { - } - - return true; -} diff --git a/boost/mssql/date-time/test.hxx b/boost/mssql/date-time/test.hxx deleted file mode 100644 index ed2276b..0000000 --- a/boost/mssql/date-time/test.hxx +++ /dev/null @@ -1,58 +0,0 @@ -// file : boost/mssql/date-time/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include -#include - -#include - -#pragma db object -struct object -{ - object () - { - } - - #pragma db id auto - unsigned long id; - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - std::vector dates; - - std::vector times; -#endif - - #pragma db value_type("DATETIME") - std::vector times_dt; - - #pragma db value_type("SMALLDATETIME") - std::vector times_sdt; - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - std::vector durations; -#endif - - bool - operator== (const object& x) const - { - return - id == x.id -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - && dates == x.dates - && times == x.times -#endif - && times_dt == x.times_dt - && times_sdt == x.times_sdt -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - && durations == x.durations -#endif - ; - } -}; - -#endif // TEST_HXX diff --git a/boost/mssql/template/driver.cxx b/boost/mssql/template/driver.cxx deleted file mode 100644 index 37614c4..0000000 --- a/boost/mssql/template/driver.cxx +++ /dev/null @@ -1,39 +0,0 @@ -// file : boost/mssql/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/boost/mssql/template/template-vc10.vcxproj b/boost/mssql/template/template-vc10.vcxproj deleted file mode 100644 index dcb625e..0000000 --- a/boost/mssql/template/template-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/mssql/template/template-vc10.vcxproj.filters b/boost/mssql/template/template-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/mssql/template/template-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/mssql/template/template-vc11.vcxproj b/boost/mssql/template/template-vc11.vcxproj deleted file mode 100644 index d5951f1..0000000 --- a/boost/mssql/template/template-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/mssql/template/template-vc11.vcxproj.filters b/boost/mssql/template/template-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/mssql/template/template-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/mssql/template/template-vc12.vcxproj b/boost/mssql/template/template-vc12.vcxproj deleted file mode 100644 index e0cb56f..0000000 --- a/boost/mssql/template/template-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/mssql/template/template-vc12.vcxproj.filters b/boost/mssql/template/template-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/mssql/template/template-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/mssql/template/template-vc8.vcproj b/boost/mssql/template/template-vc8.vcproj deleted file mode 100644 index 6d1c40b..0000000 --- a/boost/mssql/template/template-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/boost/mssql/template/template-vc9.vcproj b/boost/mssql/template/template-vc9.vcproj deleted file mode 100644 index 422fbd7..0000000 --- a/boost/mssql/template/template-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/boost/mssql/template/test.hxx b/boost/mssql/template/test.hxx deleted file mode 100644 index 753498f..0000000 --- a/boost/mssql/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : boost/mssql/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/boost/mysql/date-time/driver.cxx b/boost/mysql/date-time/driver.cxx deleted file mode 100644 index 8959f0c..0000000 --- a/boost/mysql/date-time/driver.cxx +++ /dev/null @@ -1,218 +0,0 @@ -// file : boost/mysql/date-time/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test boost date/time type persistence. MySQL version. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; - -using namespace boost::gregorian; -using namespace boost::posix_time; - -using namespace odb::core; - -bool -test_invalid_special_value (object&, auto_ptr&); - -bool -test_out_of_range_value (object&, auto_ptr&); - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - mysql_version v; - { - transaction t (db->begin ()); - db->query ().begin ().load (v); - t.commit (); - } - - // If we are running against MySQL 5.6.4 or later alter the tables - // to allow sub-second precision. - // - bool fs (v.major > 5 || - (v.major == 5 && (v.minor > 6 || - (v.minor == 6 && v.release >= 4)))); - if (fs) - { - transaction t (db->begin ()); - - db->execute ("ALTER TABLE `boost_mysql_dt_object_durations`" \ - " MODIFY COLUMN `value` TIME(6)"); - - db->execute ("ALTER TABLE `boost_mysql_dt_object_times`" \ - " MODIFY COLUMN `value` DATETIME(6)"); - - db->execute ("ALTER TABLE `boost_mysql_dt_object_timestamps`" \ - " MODIFY COLUMN `value` TIMESTAMP(6) NULL"); - - t.commit (); - } - - object o; - - // Test all valid date-time mappings. - // - o.dates.push_back (day_clock::local_day ()); - o.dates.push_back (date (not_a_date_time)); - o.dates.push_back (date (max_date_time)); - o.dates.push_back (date (min_date_time)); - - if (fs) - o.times.push_back (microsec_clock::local_time ()); - else - o.times.push_back (second_clock::local_time ()); - o.times.push_back (not_a_date_time); - o.times.push_back (min_date_time); - - // MySQL prior to 5.6.4 does not support fraction seconds. Construct - // with zero fractional seconds so that comparison test does not fail - // for invalid reasons. - // - o.times.push_back ( - ptime ( - date (max_date_time), - time_duration ( - ptime (max_date_time).time_of_day ().hours (), - ptime (max_date_time).time_of_day ().minutes (), - ptime (max_date_time).time_of_day ().seconds ()))); - - if (fs) - o.timestamps.push_back (microsec_clock::local_time ()); - else - o.timestamps.push_back (second_clock::local_time ()); - o.timestamps.push_back (not_a_date_time); - - o.durations.push_back (time_duration (1, 2, 3)); - if (fs) - o.durations.back () += time_duration (microseconds (123456)); - o.durations.push_back (time_duration (-1, 2, 3)); - o.durations.push_back (not_a_date_time); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (*ol == o); - } - - { - // Test invalid date mappings. - // - object sv1, sv2; - sv1.dates.push_back (date (neg_infin)); - sv2.dates.push_back (date (pos_infin)); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - - { - // Test invalid ptime (DATETIME) mappings. - // - object sv1, sv2; - sv1.times.push_back (neg_infin); - sv2.times.push_back (pos_infin); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - { - // Test invalid ptime (TIMESTAMP) mappings. - // - object or1, or2, sv1, sv2; - or1.timestamps.push_back (min_date_time); - or2.timestamps.push_back (max_date_time); - sv1.timestamps.push_back (neg_infin); - sv2.timestamps.push_back (pos_infin); - - transaction t (db->begin ()); - assert (test_out_of_range_value (or1, db)); - assert (test_out_of_range_value (or2, db)); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - { - // Test invalid time_duration mappings. - // - object or1, or2, sv1, sv2; - or1.durations.push_back (time_duration (850, 0, 0)); - or2.durations.push_back (time_duration (-850, 0, 0)); - sv1.durations.push_back (pos_infin); - sv2.durations.push_back (neg_infin); - - transaction t (db->begin ()); - assert (test_out_of_range_value (or1, db)); - assert (test_out_of_range_value (or2, db)); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} - -bool -test_invalid_special_value (object& x, auto_ptr& db) -{ - try - { - db->persist (x); - return false; - } - catch (const odb::boost::date_time::special_value&) - { - } - - return true; -} - -bool -test_out_of_range_value (object& x, auto_ptr& db) -{ - try - { - db->persist (x); - return false; - } - catch (const odb::boost::date_time::value_out_of_range&) - { - } - - return true; -} diff --git a/boost/mysql/date-time/test.hxx b/boost/mysql/date-time/test.hxx deleted file mode 100644 index bf73b09..0000000 --- a/boost/mysql/date-time/test.hxx +++ /dev/null @@ -1,65 +0,0 @@ -// file : boost/mysql/date-time/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include -#include - -#include - -#pragma db object -struct object -{ - object () - { - } - - bool - operator== (const object& x) const - { - return - id == x.id && - dates == x.dates && - times == x.times && - timestamps == x.timestamps && - durations == x.durations; - } - - #pragma db id auto - unsigned long id; - - std::vector dates; - std::vector times; - - // Make timestamp NULL-able to suppress the auto-initialization and - // auto-update characteristics of the TIMESTAMP datatype, and to - // allow NULL values. - // - #pragma db value_type ("TIMESTAMP") value_null - std::vector timestamps; - - std::vector durations; -}; - -// MySQL server version view. -// -#pragma db view query( \ - "SELECT " \ - "CAST(SUBSTRING_INDEX(@@version, '.', 1) AS UNSIGNED)," \ - "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '.', 2), '.', -1) AS UNSIGNED)," \ - "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '-', 1), '.', -1) AS UNSIGNED)," \ - "@@protocol_version") -struct mysql_version -{ - unsigned int major; - unsigned int minor; - unsigned int release; - - unsigned int protocol; -}; - -#endif // TEST_HXX diff --git a/boost/mysql/template/driver.cxx b/boost/mysql/template/driver.cxx deleted file mode 100644 index 1164950..0000000 --- a/boost/mysql/template/driver.cxx +++ /dev/null @@ -1,39 +0,0 @@ -// file : boost/mysql/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/boost/mysql/template/template-vc10.vcxproj b/boost/mysql/template/template-vc10.vcxproj deleted file mode 100644 index 3137abc..0000000 --- a/boost/mysql/template/template-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/mysql/template/template-vc10.vcxproj.filters b/boost/mysql/template/template-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/mysql/template/template-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/mysql/template/template-vc11.vcxproj b/boost/mysql/template/template-vc11.vcxproj deleted file mode 100644 index bc4b5a4..0000000 --- a/boost/mysql/template/template-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/mysql/template/template-vc11.vcxproj.filters b/boost/mysql/template/template-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/mysql/template/template-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/mysql/template/template-vc12.vcxproj b/boost/mysql/template/template-vc12.vcxproj deleted file mode 100644 index e7d70bc..0000000 --- a/boost/mysql/template/template-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/mysql/template/template-vc12.vcxproj.filters b/boost/mysql/template/template-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/mysql/template/template-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/mysql/template/template-vc8.vcproj b/boost/mysql/template/template-vc8.vcproj deleted file mode 100644 index 2ef0383..0000000 --- a/boost/mysql/template/template-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/boost/mysql/template/template-vc9.vcproj b/boost/mysql/template/template-vc9.vcproj deleted file mode 100644 index b60c7e2..0000000 --- a/boost/mysql/template/template-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/boost/mysql/template/test.hxx b/boost/mysql/template/test.hxx deleted file mode 100644 index 7c97ca2..0000000 --- a/boost/mysql/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : boost/mysql/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/boost/oracle/date-time/driver.cxx b/boost/oracle/date-time/driver.cxx deleted file mode 100644 index 82294c7..0000000 --- a/boost/oracle/date-time/driver.cxx +++ /dev/null @@ -1,136 +0,0 @@ -// file : boost/oracle/date-time/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test boost date/time type persistence. Oracle version. -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; - -using namespace boost::gregorian; -using namespace boost::posix_time; - -using namespace odb::core; - -bool -test_invalid_special_value (object&, auto_ptr&); - -bool -test_out_of_range_value (object&, auto_ptr&); - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - object o; - - // Test all valid date-time mappings. - // - o.dates.push_back (day_clock::local_day ()); - o.dates.push_back (date (not_a_date_time)); - o.dates.push_back (date (max_date_time)); - o.dates.push_back (date (min_date_time)); - - o.times.push_back (second_clock::local_time ()); - o.times.push_back (not_a_date_time); - o.times.push_back (min_date_time); - o.times.push_back (ptime (max_date_time)); - - o.times_d.push_back (ptime (date (2012, 6, 27), - time_duration (14, 17, 05, 0))); - o.times_d.push_back (not_a_date_time); - - o.durations.push_back (time_duration (1, 2, 3, 123456)); - o.durations.push_back (time_duration (-1, 2, 3)); - o.durations.push_back (not_a_date_time); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (*ol == o); - } - - // Test invalid date mappings. - // - { - object sv1, sv2; - sv1.dates.push_back (date (neg_infin)); - sv2.dates.push_back (date (pos_infin)); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - // Test invalid ptime mappings. - // - { - object sv1, sv2; - sv1.times.push_back (neg_infin); - sv2.times.push_back (pos_infin); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - // Test invalid time_duration mappings. - // - { - object sv1, sv2; - sv1.durations.push_back (pos_infin); - sv2.durations.push_back (neg_infin); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} - -bool -test_invalid_special_value (object& x, auto_ptr& db) -{ - try - { - db->persist (x); - return false; - } - catch (const odb::boost::date_time::special_value&) - { - } - - return true; -} diff --git a/boost/oracle/date-time/test.hxx b/boost/oracle/date-time/test.hxx deleted file mode 100644 index 5eaab88..0000000 --- a/boost/oracle/date-time/test.hxx +++ /dev/null @@ -1,42 +0,0 @@ -// file : boost/oracle/date-time/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include -#include - -#include - -#pragma db object -struct object -{ - object () - { - } - - bool - operator== (const object& x) const - { - return - id == x.id && - dates == x.dates && - times == x.times && - times_d == x.times_d && - durations == x.durations; - } - - #pragma db id auto - unsigned long id; - - std::vector dates; - std::vector times; - #pragma db value_type("DATE") - std::vector times_d; - std::vector durations; -}; - -#endif // TEST_HXX diff --git a/boost/oracle/template/driver.cxx b/boost/oracle/template/driver.cxx deleted file mode 100644 index 892b58f..0000000 --- a/boost/oracle/template/driver.cxx +++ /dev/null @@ -1,39 +0,0 @@ -// file : boost/oracle/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/boost/oracle/template/template-vc10.vcxproj b/boost/oracle/template/template-vc10.vcxproj deleted file mode 100644 index 0c93020..0000000 --- a/boost/oracle/template/template-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/oracle/template/template-vc10.vcxproj.filters b/boost/oracle/template/template-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/oracle/template/template-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/oracle/template/template-vc11.vcxproj b/boost/oracle/template/template-vc11.vcxproj deleted file mode 100644 index 4df5f5b..0000000 --- a/boost/oracle/template/template-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/oracle/template/template-vc11.vcxproj.filters b/boost/oracle/template/template-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/oracle/template/template-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/oracle/template/template-vc12.vcxproj b/boost/oracle/template/template-vc12.vcxproj deleted file mode 100644 index 0b942bc..0000000 --- a/boost/oracle/template/template-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/oracle/template/template-vc12.vcxproj.filters b/boost/oracle/template/template-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/oracle/template/template-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/oracle/template/template-vc8.vcproj b/boost/oracle/template/template-vc8.vcproj deleted file mode 100644 index c13f330..0000000 --- a/boost/oracle/template/template-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/boost/oracle/template/template-vc9.vcproj b/boost/oracle/template/template-vc9.vcproj deleted file mode 100644 index a3061ee..0000000 --- a/boost/oracle/template/template-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/boost/oracle/template/test.hxx b/boost/oracle/template/test.hxx deleted file mode 100644 index 141b6cd..0000000 --- a/boost/oracle/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : boost/oracle/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/boost/pgsql/date-time/driver.cxx b/boost/pgsql/date-time/driver.cxx deleted file mode 100644 index 94fcc46..0000000 --- a/boost/pgsql/date-time/driver.cxx +++ /dev/null @@ -1,157 +0,0 @@ -// file : boost/pgsql/date-time/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test boost date/time type persistence. PostgreSQL version. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; - -using namespace boost::gregorian; -using namespace boost::posix_time; - -using namespace odb::core; - -bool -test_invalid_special_value (object&, auto_ptr&); - -bool -test_out_of_range_value (object&, auto_ptr&); - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - object o; - - // Test all valid date-time mappings. - // - o.dates.push_back (day_clock::local_day ()); - o.dates.push_back (date (not_a_date_time)); - o.dates.push_back (date (max_date_time)); - o.dates.push_back (date (min_date_time)); - - o.times.push_back (microsec_clock::local_time ()); - o.times.push_back (not_a_date_time); - o.times.push_back (pos_infin); - o.times.push_back (neg_infin); - o.times.push_back (ptime (date (max_date_time), - time_duration (16, 23, 0, 123456))); - o.times.push_back (ptime (date (min_date_time), - time_duration (3, 14, 7, 123456))); - o.times.push_back (ptime (date (1969, 12, 31), // Before PG epoch. - time_duration (23, 59, 59, 123000))); - - o.durations.push_back (time_duration (0, 0, 0)); - o.durations.push_back (time_duration (12, 3, 4, 123456)); - o.durations.push_back (time_duration (23, 59, 59, 123456)); - o.durations.push_back (not_a_date_time); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (*ol == o); - } - - { - // Test invalid date mappings. - // - object sv1, sv2; - sv1.dates.push_back (date (neg_infin)); - sv2.dates.push_back (date (pos_infin)); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - { - // Test invalid ptime mappings. - // - // object sv1, sv2; - // sv1.times.push_back (neg_infin); - // sv2.times.push_back (pos_infin); - - // transaction t (db->begin ()); - // assert (test_invalid_special_value (sv1, db)); - // assert (test_invalid_special_value (sv2, db)); - // t.commit (); - } - - { - // Test invalid time_duration mappings. - // - // object or1, sv1, sv2; - // or1.durations.push_back (time_duration (0, 0, -1)); - // sv1.durations.push_back (pos_infin); - // sv2.durations.push_back (neg_infin); - - // transaction t (db->begin ()); - // assert (test_out_of_range_value (or1, db)); - // assert (test_invalid_special_value (sv1, db)); - // assert (test_invalid_special_value (sv2, db)); - // t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} - -bool -test_invalid_special_value (object& x, auto_ptr& db) -{ - try - { - db->persist (x); - return false; - } - catch (const odb::boost::date_time::special_value&) - { - } - - return true; -} - -bool -test_out_of_range_value (object& x, auto_ptr& db) -{ - try - { - db->persist (x); - return false; - } - catch (const odb::boost::date_time::value_out_of_range&) - { - } - - return true; -} diff --git a/boost/pgsql/date-time/test.hxx b/boost/pgsql/date-time/test.hxx deleted file mode 100644 index 0b08093..0000000 --- a/boost/pgsql/date-time/test.hxx +++ /dev/null @@ -1,39 +0,0 @@ -// file : boost/pgsql/date-time/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include -#include - -#include - -#pragma db object -struct object -{ - object () - { - } - - bool - operator== (const object& x) const - { - return - id == x.id && - dates == x.dates && - times == x.times && - durations == x.durations; - } - - #pragma db id auto - unsigned long id; - - std::vector dates; - std::vector times; - std::vector durations; -}; - -#endif // TEST_HXX diff --git a/boost/pgsql/template/driver.cxx b/boost/pgsql/template/driver.cxx deleted file mode 100644 index ed2d8a4..0000000 --- a/boost/pgsql/template/driver.cxx +++ /dev/null @@ -1,39 +0,0 @@ -// file : boost/pgsql/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/boost/pgsql/template/template-vc10.vcxproj b/boost/pgsql/template/template-vc10.vcxproj deleted file mode 100644 index 7bc0243..0000000 --- a/boost/pgsql/template/template-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/pgsql/template/template-vc10.vcxproj.filters b/boost/pgsql/template/template-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/pgsql/template/template-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/pgsql/template/template-vc11.vcxproj b/boost/pgsql/template/template-vc11.vcxproj deleted file mode 100644 index 9f8d2f0..0000000 --- a/boost/pgsql/template/template-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/pgsql/template/template-vc11.vcxproj.filters b/boost/pgsql/template/template-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/pgsql/template/template-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/pgsql/template/template-vc12.vcxproj b/boost/pgsql/template/template-vc12.vcxproj deleted file mode 100644 index acbfc37..0000000 --- a/boost/pgsql/template/template-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/pgsql/template/template-vc12.vcxproj.filters b/boost/pgsql/template/template-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/pgsql/template/template-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/pgsql/template/template-vc8.vcproj b/boost/pgsql/template/template-vc8.vcproj deleted file mode 100644 index 65773c9..0000000 --- a/boost/pgsql/template/template-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/boost/pgsql/template/template-vc9.vcproj b/boost/pgsql/template/template-vc9.vcproj deleted file mode 100644 index db49496..0000000 --- a/boost/pgsql/template/template-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/boost/pgsql/template/test.hxx b/boost/pgsql/template/test.hxx deleted file mode 100644 index 56eda31..0000000 --- a/boost/pgsql/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : boost/pgsql/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/boost/sqlite/date-time/driver.cxx b/boost/sqlite/date-time/driver.cxx deleted file mode 100644 index 97a7a0c..0000000 --- a/boost/sqlite/date-time/driver.cxx +++ /dev/null @@ -1,208 +0,0 @@ -// file : boost/sqlite/date-time/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test boost date/time type persistence. SQLite version. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; - -using namespace boost::gregorian; -using namespace boost::posix_time; - -using namespace odb::core; - -bool -test_invalid_special_value (object&, auto_ptr&); - -bool -test_out_of_range_value (object&, auto_ptr&); - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - object o; - - // Test all valid date-time mappings. - // - o.dates.push_back (day_clock::local_day ()); - o.dates.push_back (date (not_a_date_time)); - o.dates.push_back (date (max_date_time)); - o.dates.push_back (date (min_date_time)); - - o.times.push_back (second_clock::local_time ()); - o.times.push_back (not_a_date_time); - o.times.push_back (min_date_time); - o.times.push_back (max_date_time); - - o.durations.push_back (time_duration (123, 4, 5)); - o.durations.push_back (not_a_date_time); - - o.u_dates.push_back (day_clock::local_day ()); - o.u_dates.push_back (date (not_a_date_time)); - - // Boost seems to handle 64 bit std::time_t incorrectly. - // Insert 32 bit minimum and maximum UNIX time values for now. - // - // o.u_dates.push_back (date (max_date_time)); - // o.u_dates.push_back (date (min_date_time)); - // - o.u_dates.push_back (date (2038, 1, 19)); - o.u_dates.push_back (date (1901, 12, 14)); - - o.u_times.push_back (second_clock::local_time ()); - o.u_times.push_back (not_a_date_time); - o.u_times.push_back (ptime (date (1930, 1, 1), time_duration (0, 0, 0))); - - o.s_durations.push_back (time_duration (123, 4, 5)); - o.s_durations.push_back (time_duration (-12, 3, 4)); - o.s_durations.push_back (not_a_date_time); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (*ol == o); - } - - { - // Test invalid date mappings. - // - object sv1, sv2; - sv1.dates.push_back (date (neg_infin)); - sv2.dates.push_back (date (pos_infin)); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - { - // Test invalid ptime mappings. - // - object sv1, sv2; - sv1.times.push_back (neg_infin); - sv2.times.push_back (pos_infin); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - { - // Test invalid time_duration mappings. - // - object or1, sv1, sv2; - or1.durations.push_back (time_duration (0, 0, -1)); - sv1.durations.push_back (pos_infin); - sv2.durations.push_back (neg_infin); - - transaction t (db->begin ()); - assert (test_out_of_range_value (or1, db)); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - { - // Test invalid UNIX date mappings. - // - object sv1, sv2; - sv1.u_dates.push_back (date (neg_infin)); - sv2.u_dates.push_back (date (pos_infin)); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - // Test invalid UNIX times mappings. - // - { - object sv1, sv2; - sv1.u_times.push_back (pos_infin); - sv2.u_times.push_back (neg_infin); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - - // Test invalid "seconds" duration mappings. - // - { - object sv1, sv2; - sv1.s_durations.push_back (pos_infin); - sv2.s_durations.push_back (neg_infin); - - transaction t (db->begin ()); - assert (test_invalid_special_value (sv1, db)); - assert (test_invalid_special_value (sv2, db)); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} - -bool -test_invalid_special_value (object& x, auto_ptr& db) -{ - try - { - db->persist (x); - return false; - } - catch (const odb::boost::date_time::special_value&) - { - } - - return true; -} - -bool -test_out_of_range_value (object& x, auto_ptr& db) -{ - try - { - db->persist (x); - return false; - } - catch (const odb::boost::date_time::value_out_of_range&) - { - } - - return true; -} diff --git a/boost/sqlite/date-time/test.hxx b/boost/sqlite/date-time/test.hxx deleted file mode 100644 index 924ce27..0000000 --- a/boost/sqlite/date-time/test.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// file : boost/sqlite/date-time/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include -#include - -#include - -#pragma db object -struct object -{ - object () - { - } - - bool - operator== (const object& x) const - { - return - id == x.id && - dates == x.dates && - times == x.times && - durations == x.durations && - u_dates == x.u_dates && - u_times == x.u_times && - s_durations == x.s_durations; - } - - #pragma db id auto - unsigned long id; - - std::vector dates; - std::vector times; - std::vector durations; - - // Dates as UNIX time. - // - #pragma db value_type("INTEGER") - std::vector u_dates; - - // Times as UNIX time. - // - #pragma db value_type("INTEGER") - std::vector u_times; - - // Durations as seconds. - // - #pragma db value_type("INTEGER") - std::vector s_durations; -}; - -#endif // TEST_HXX diff --git a/boost/sqlite/template/driver.cxx b/boost/sqlite/template/driver.cxx deleted file mode 100644 index 3e51eef..0000000 --- a/boost/sqlite/template/driver.cxx +++ /dev/null @@ -1,39 +0,0 @@ -// file : boost/sqlite/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/boost/sqlite/template/template-vc10.vcxproj b/boost/sqlite/template/template-vc10.vcxproj deleted file mode 100644 index f94df08..0000000 --- a/boost/sqlite/template/template-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/sqlite/template/template-vc10.vcxproj.filters b/boost/sqlite/template/template-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/sqlite/template/template-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/sqlite/template/template-vc11.vcxproj b/boost/sqlite/template/template-vc11.vcxproj deleted file mode 100644 index 1c1a279..0000000 --- a/boost/sqlite/template/template-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/sqlite/template/template-vc11.vcxproj.filters b/boost/sqlite/template/template-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/sqlite/template/template-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/sqlite/template/template-vc12.vcxproj b/boost/sqlite/template/template-vc12.vcxproj deleted file mode 100644 index 034b16c..0000000 --- a/boost/sqlite/template/template-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/boost/sqlite/template/template-vc12.vcxproj.filters b/boost/sqlite/template/template-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/boost/sqlite/template/template-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/boost/sqlite/template/template-vc8.vcproj b/boost/sqlite/template/template-vc8.vcproj deleted file mode 100644 index df92637..0000000 --- a/boost/sqlite/template/template-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/boost/sqlite/template/template-vc9.vcproj b/boost/sqlite/template/template-vc9.vcproj deleted file mode 100644 index 32fb152..0000000 --- a/boost/sqlite/template/template-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/boost/sqlite/template/test.hxx b/boost/sqlite/template/test.hxx deleted file mode 100644 index b9daed6..0000000 --- a/boost/sqlite/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : boost/sqlite/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/build/.gitignore b/build/.gitignore deleted file mode 100644 index 4a730a3..0000000 --- a/build/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -config.build -root/ -bootstrap/ diff --git a/build/bootstrap.build b/build/bootstrap.build deleted file mode 100644 index 2fb5824..0000000 --- a/build/bootstrap.build +++ /dev/null @@ -1,9 +0,0 @@ -# file : build/bootstrap.build -# license : GNU GPL v2; see accompanying LICENSE file - -project = odb-tests - -using version -using config -using dist -using test diff --git a/build/export.build b/build/export.build deleted file mode 100644 index 3c073d3..0000000 --- a/build/export.build +++ /dev/null @@ -1,9 +0,0 @@ -# file : build/export.build -# license : GNU GPL v2; see accompanying LICENSE file - -$out_root/ -{ - include libcommon/ -} - -export $out_root/libcommon/$import.target diff --git a/build/root.build b/build/root.build deleted file mode 100644 index 5336399..0000000 --- a/build/root.build +++ /dev/null @@ -1,270 +0,0 @@ -# file : build/root.build -# license : GNU GPL v2; see accompanying LICENSE file - -cxx.std = latest - -using cxx - -hxx{*}: extension = hxx -ixx{*}: extension = ixx -txx{*}: extension = txx -cxx{*}: extension = cxx - -# List of the identifiers of the databases to compile and run the tests -# against. The valid identifiers are mysql, sqlite, pgsql, oracle, and mssql. -# -# @@ TODO: change to string_set once available. -# -config [strings] config.odb_tests.database - -assert ($defined(config.odb_tests.database) && \ - $size($config.odb_tests.database) > 0) \ -'at least one database must be configured via config.odb_tests.database variable' - -databases = $config.odb_tests.database - -mysql = false -sqlite = false -pgsql = false -oracle = false -mssql = false - -for db: $databases -{ - switch $db - { - case 'mysql' - mysql = true - - case 'sqlite' - sqlite = true - - case 'pgsql' - pgsql = true - - case 'oracle' - oracle = true - - case 'mssql' - mssql = true - - default - fail "invalid database '$db' specified in config.odb_tests.database value" - } -} - -# If true, then build and run the test drivers in the dynamic multi-database -# mode. -# -config [bool] config.odb_tests.multi_database ?= ($size($databases) > 1) -multi = $config.odb_tests.multi_database - -assert ($multi || $size($databases) == 1) \ -'only one database can be configured if config.odb_tests.multi_database value is false' - -# Database connections. -# - -# PostgreSQL -# -# The database user. Note that the named user must be allowed to connect to -# the database server without specifying credentials. -# -config [string] config.odb_tests.pgsql.user ?= 'odb_test' - -# The database name. Note that it WILL BE MODIFIED by the tests. -# -config [string] config.odb_tests.pgsql.database ?= 'odb_test' - -# The database host. Leaving this variable undefined results in using -# Unix-domain sockets. Machines without Unix-domain sockets will connect to -# localhost. -# -config [string] config.odb_tests.pgsql.host - -# The database port or the socket file name extension for Unix-domain -# connections. -# -config [string] config.odb_tests.pgsql.port - -# If true, then assume that libodb-pgsql supports the bulk operations. -# -# Note: config.odb_tests.pgsql.bulk_default is reflected from manifest. -# -config [bool] config.odb_tests.pgsql.bulk_default ?= false -config [bool] config.odb_tests.pgsql.bulk ?= ($cxx.target.class != 'windows' && \ - $config.odb_tests.pgsql.bulk_default) -pgsql_bulk = $config.odb_tests.pgsql.bulk - -# MySQL -# -# The database user. -# -config [string] config.odb_tests.mysql.user ?= 'odb_test' - -# The database password. -# -config [string] config.odb_tests.mysql.passwd - -# The database name. Note that it WILL BE MODIFIED by the tests. -# -config [string] config.odb_tests.mysql.database ?= 'odb_test' - -# The database host. -# -config [string] config.odb_tests.mysql.host - -# The database port. -# -config [uint64] config.odb_tests.mysql.port - -# The database socket path. -# -config [path] config.odb_tests.mysql.socket - -define sql: file -sql{*}: extension = sql - -define xml: file -xml{*}: extension = xml - -if ($build.mode != 'skeleton') -{ - if ($cxx.target.system == 'win32-msvc') - cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS - - switch $cxx.class - { - case 'gcc' - { - cxx.coptions += -Wno-unknown-pragmas - } - case 'msvc' - { - cxx.coptions += /wd4068 /wd4251 /wd4275 /wd4800 - } - } - - # @@ BUILD2 Clang issues the following warnings while compile the - # odb-generated headers: - # - # In file included from odb-tests/common/view/olv/test1-odb-sqlite.cxx:10: - # odb-tests/common/view/olv/test1-odb-sqlite.hxx:68:80: warning: instantiation of variable 'odb::query_columns>::id' required here, but no definition is available [-Wundefined-var-template] - # 68 | id (query_columns< ::test1::object1, id_common, typename A::common_traits >::id, - # | ^ - # odb-tests/common/view/olv/test1-odb.hxx:91:21: note: forward declaration of template entity is here - # 91 | static id_type_ id; - # | ^ - # odb-tests/common/view/olv/test1-odb-sqlite.hxx:68:80: note: add an explicit instantiation declaration to suppress this warning if 'odb::query_columns>::id' is explicitly instantiated in another translation unit - # 68 | id (query_columns< ::test1::object1, id_common, typename A::common_traits >::id, - # - # Note: -Wno-undefined-var-template is temporarily added to suppress them. - # - if ($cxx.id.type == 'clang') - cxx.coptions += -Wno-undefined-var-template - - # Import odb that we are testing. - # - import! [metadata] odb = odb%exe{odb} - - # Import the mysql client for creating the database schemas, etc. - # - if $mysql - { - import! mysql_client = mysql%exe{mysql} - testscript{*}: mysql_client = $mysql_client - } - - # Import the psql client for creating the database schemas, etc. - # - if $pgsql - { - import! pgsql_client = psql%exe{psql} - testscript{*}: pgsql_client = $pgsql_client - } - - # Note that we need ((-.+)?) instead of just (-.+)? because we use this - # capture as a back-reference in the pattern. - # - [rule_name=odb_compile] \ - : hxx{~'/\1/'} libue{~'/.+-meta/'} $odb - {{ - pops = $cxx.lib_poptions($<[1]) - depdb hash $pops - - hp = $path($>[0]) - bn = $base($leaf($hp)) - db = $regex.replace($bn, '.+-odb(-(.+))?', '\2') - - if ($db == '') # *-odb.?xx target group? - db = ($multi ? 'common' : $databases[0]) - end - - # If the external SQL schema file will be generated, then add it as a - # dynamic target group member. - # - # @@ BUILD2 Probably we should add support for --generate-dep ODB compiler - # option. Then presumably this will be take care of automatically. - # - # We assume that the '--generate-schema' and '--schema-format' strings - # will never appear as standalone option values. - # - if ($db != 'common' && $regex.find_match($odb_options, '--generate-schema')) - schema_format = ($db == 'sqlite' ? 'embedded' : 'sql') - - for o: $odb_options - if ($o == '--schema-format') - schema_format = [null] # Indicate that the schema format comes next. - elif ($schema_format == [null]) - schema_format = $o - end - end - else - schema_format = '' - end - - t = ($schema_format == 'sql' \ - ? $directory($hp)/$regex.replace($bn, '(.+)-odb(-.+)?', '\1\2').sql \ - : '') - - depdb dyndep --dyn-target --target-what 'generated schema' --format lines \ - -- echo "$t" - - $odb --std c++11 \ - ($multi ? --multi-database dynamic : ) \ - --database $db \ - --output-dir $out_base \ - $odb_options \ - "-I$src_base" \ - $pops \ - $path($<[0]) - }} - - # Every exe{} in this project is by default a test. - # - exe{*}: test = true - - # Specify the test target for cross-testing. - # - test.target = $cxx.target -} - -# The helper targets which can be used as prerequisites of test drivers -# which require either a specific database client or multiple clients for -# all the enabled databases. -# -alias{mysql-client}: $mysql_client: -{ - include = $mysql - clean = false -} - -alias{pgsql-client}: $pgsql_client: -{ - include = $pgsql - clean = false -} - -alias{database-client}: alias{mysql-client pgsql-client} diff --git a/buildfile b/buildfile deleted file mode 100644 index 2acd9fc..0000000 --- a/buildfile +++ /dev/null @@ -1,10 +0,0 @@ -# file : buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -./: libcommon/ common/ doc{README.md} legal{GPLv2 LICENSE} manifest - -./: mysql/: include = ($mysql && !$multi) -./: sqlite/: include = ($sqlite && !$multi) -./: pgsql/: include = ($pgsql && !$multi) - -./: testscript{*}: include = adhoc diff --git a/common/access/buildfile b/common/access/buildfile deleted file mode 100644 index f1264d9..0000000 --- a/common/access/buildfile +++ /dev/null @@ -1,45 +0,0 @@ -# file : common/access/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix access_ \ - --generate-schema \ - --accessor-regex '#(.+)#Get\u\1#' \ - --modifier-regex '#(.+)#Set\u\1#' - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -# @@ BUILD2: Eventually we should be able to mark it as test.input once -# this is supported for testscript tests. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/access/driver.cxx b/common/access/driver.cxx deleted file mode 100644 index b40e73c..0000000 --- a/common/access/driver.cxx +++ /dev/null @@ -1,262 +0,0 @@ -// file : common/access/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test accessor/modifier expressions. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test basic accessor/modifier functionality. - // - { - using namespace test1; - - object o (1, 623, 723); - o.i1 () = 123; - o.i2 (223); - o.i3 () = 323; - o.i4 () = 423; - o.set_i5 (523); - o.s1 ("1bc"); - memcpy (o.b1 (), "123456789012345", 16); - o.b2 ("123456789012345"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id ())); - t.commit (); - - assert (o == *p); - } - } - - // Test composite accessor/modifier functionality. - // - { - using namespace test2; - - object o (1); - - o.v1 () = value (1123, 1234); - o.v2 (value (2123, 2234)); - o.v3_i1 (3123); - o.v3_i2 (3223); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id ())); - t.commit (); - - assert (o == *p); - } - } - - // Test object pointer accessor/modifier functionality. - // - { - using namespace test3; - - object2 o (1); - o.p1 ().reset (new object1 (1)); - o.p2 (object1_ptr (new object1 (2))); - - { - transaction t (db->begin ()); - const object1_ptr& ptr (o.p1 ()); - db->persist (ptr); - db->persist (o.p2 ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id ())); - t.commit (); - - assert (p->p1 ()->id () == o.p1 ()->id () && - p->p2 ()->id () == o.p2 ()->id ()); - } - } - - // Test container accessor/modifier functionality. - // - { - using namespace test4; - - object o (1); - o.c1 ().push_back (1123); - o.c1 ().push_back (1124); - o.c1 ().push_back (1125); - - { - std::vector v; - v.push_back (2123); - v.push_back (2124); - v.push_back (2125); - o.c2 (v); - } - - o.v1 ().c1 ().push_back (1123); - o.v1 ().c1 ().push_back (1124); - o.v1 ().c1 ().push_back (1125); - - { - std::vector v; - v.push_back (2123); - v.push_back (2124); - v.push_back (2125); - o.v1 ().c2 (v); - } - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id ())); - t.commit (); - - assert (o == *p); - } - } - - // Test id accessor/modifier functionality. - // - { - using namespace test5; - - object1 o1; - object2 o2; - object3 o3; - object4 o4; - o4.id (uuid ("\x60\x1D\x17\xF0-\x60\x05-\x47\x23-\x95\x37-" - "\xC1\xF8\x94\x41\x2B\xEC")); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - db->persist (o4); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id ())); - unique_ptr p2 (db->load (o2.id ())); - unique_ptr p3 (db->load (o3.id_)); - unique_ptr p4 (db->load (o4.id ())); - t.commit (); - } - } - - // Test version accessor/modifier functionality. - // - { - using namespace test6; - - object1 o1 (1); - object2 o2; - object3 o3 (1); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - - assert (o1.version () == 1); - assert (o2.version () == 1); - assert (o3.version_ == 1); - } - - { - transaction t (db->begin ()); - db->update (o1); - db->update (o2); - db->update (o3); - t.commit (); - - assert (o1.version () == 2); - assert (o2.version () == 2); - assert (o3.version_ == 2); - } - } - - // Test basic accessor/modifier functionality. - // - { - using namespace test7; - - object o (1); - o.i1 () = 123; - o.set_i2 (223); - o.setI3 (323); - o.seti4 (423); - o.i5 () = 523; - o.i6 () = 623; - o.SetI7 (723); - memcpy (o.b1 (), "123456789012345", 16); - o.b2 ("123456789012345"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id_)); - t.commit (); - - assert (o == *p); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/access/test.hxx b/common/access/test.hxx deleted file mode 100644 index 3a3424d..0000000 --- a/common/access/test.hxx +++ /dev/null @@ -1,592 +0,0 @@ -// file : common/access/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include // std::memcpy, std::memcmp, std::memset -#include // std::unique_ptr -#include // std::move - -#include - -#ifdef ODB_COMPILER -# if defined(ODB_DATABASE_MYSQL) -# define BINARY16_TYPE "BINARY(16)" -# elif defined(ODB_DATABASE_SQLITE) -# define BINARY16_TYPE "BLOB" -# elif defined(ODB_DATABASE_PGSQL) -# define BINARY16_TYPE "BYTEA" -# elif defined(ODB_DATABASE_ORACLE) -# define BINARY16_TYPE "RAW(16)" -# elif defined(ODB_DATABASE_MSSQL) -# define BINARY16_TYPE "BINARY(16)" -# elif defined(ODB_DATABASE_COMMON) -# define BINARY16_TYPE "" -# else -# error unknown database -# endif -#endif - -// Test basic accessor/modifier functionality. -// -#pragma db namespace table("t1_") -namespace test1 -{ - #pragma db object - struct object - { - object (): i6_ (0), i7_ (0) {} - object (unsigned long id, int i6, int i7): id_ (id), i6_ (i6), i7_ (i7) {} - - public: - unsigned long id () const {return id_;} - void id (unsigned long id) {id_ = id;} - private: - #pragma db id access(id) - unsigned long id_; - - public: - int i1 () const {return i1_;} - int& i1 () {return i1_;} - private: - #pragma db access(i1) - int i1_; - - public: - int i2 () const {return i2_;} - void i2 (int i2) {i2_ = i2;} - private: - #pragma db access(i2) - int i2_; - - // Prefer reference modifier. - // - public: - int i3 () const {return i3_;} - int& i3 () {return i3_;} - void i3 (int i3); - private: - #pragma db access(i3) - int i3_; - - // Prefer reference modifier (reverse function order). - // - public: - int i4 () const {return i4_;} - void i4 (int i4); - int& i4 () {return i4_;} - private: - #pragma db access(i4) - int i4_; - - public: - int get_i5 () const {return i5_;} - void set_i5 (int i5) {i5_ = i5;} - private: - #pragma db get(get_i5) set(set_i5) - int i5_; - - // Const member via reference. - // - public: - const int& i6 () const {return i6_;} - private: - #pragma db get(i6) set(const_cast (this.i6 ())) - const int i6_; - - // Const member via modifier. - // - public: - int i7 () const {return i7_;} - void i7 (int i7) const {const_cast (i7_) = i7;} - private: - #pragma db access(i7) - const int i7_; - - public: - const char* s1 () const {return s1_.c_str ();} - void s1 (const char* s1) {s1_ = s1;} - //std::string s1 () const {return s1_;} - //void s1 (std::string s1) {s1_ = s1;} - private: - #pragma db get(s1) set(s1((?).c_str ())) - //#pragma db access(s1) - std::string s1_; - - // Array member via ref. - // - public: - const char* b1 () const {return b1_;} - char* b1 () {return b1_;} - private: - #pragma db type(BINARY16_TYPE) access(b1) - char b1_[16]; - - // Array member via modifier. - // - public: - const char* b2 () const {return b2_;} - void b2 (const char* b2) {std::memcpy (b2_, b2, sizeof (b2_));} - private: - #pragma db type(BINARY16_TYPE) access(b2) - char b2_[16]; - - public: - bool operator== (const object& o) const - { - return id_ == o.id_ && - i1_ == o.i1_ && - i2_ == o.i2_ && - i3_ == o.i3_ && - i4_ == o.i4_ && - i5_ == o.i5_ && - i6_ == o.i6_ && - i7_ == o.i7_ && - s1_ == o.s1_ && - std::memcmp (b1_, o.b1_, sizeof (b1_)) == 0 && - std::memcmp (b2_, o.b2_, sizeof (b2_)) == 0; - } - }; -} - -// Test composite accessor/modifier functionality. -// -#pragma db namespace table("t2_") -namespace test2 -{ - #pragma db value - struct value - { - value () {} - value (int i1, int i2): i1_ (i1), i2_ (i2) {} - - bool operator== (const value& v) const - { - return i1_ == v.i1_ && i2_ == v.i2_; - } - - public: - int i1 () const {return i1_;} - int& i1 () {return i1_;} - private: - #pragma db access(i1) - int i1_; - - public: - int i2 () const {return i2_;} - void i2 (int i2) {i2_ = i2;} - private: - #pragma db access(i2) - int i2_; - }; - - #pragma db object - struct object - { - object () {} - object (unsigned long id): id_ (id) {} - - bool operator== (const object& o) const - { - return id_ == o.id_ && - v1_ == o.v1_ && - v2_ == o.v2_ && - v3_ == o.v3_; - } - - public: - unsigned long id () const {return id_;} - void id (unsigned long id) {id_ = id;} - private: - #pragma db id access(id) - unsigned long id_; - - public: - const value& v1 () const {return v1_;} - value& v1 () {return v1_;} - private: - #pragma db access(v1) - value v1_; - - public: - const value& v2 () const {return v2_;} - void v2 (const value& v2) {v2_ = v2;} - private: - #pragma db access(v2) - value v2_; - - public: - int v3_i1 () const {return v3_.i1 ();} - int v3_i2 () const {return v3_.i2 ();} - void v3_i1 (int i1) {v3_.i1 () = i1;} - void v3_i2 (int i2) {v3_.i2 (i2);} - private: - #pragma db get(test2::value (this.v3_i1 (), this.v3_i2 ())) \ - set(this.v3_i1 ((?).i1 ()); this.v3_i2 ((?).i2 ())) - value v3_; - }; -} - -// Test object pointer accessor/modifier functionality. -// -#pragma db namespace table("t3_") -namespace test3 -{ - struct object1; - - typedef std::unique_ptr object1_ptr; - - #pragma db object pointer(object1_ptr) - struct object1 - { - object1 () {} - object1 (unsigned long id): id_ (id) {} - - public: - unsigned long id () const {return id_;} - void id (unsigned long id) {id_ = id;} - private: - #pragma db id access(id) - unsigned long id_; - }; - - #pragma db object - struct object2 - { - object2 () {} - object2 (unsigned long id): id_ (id) {} - - public: - unsigned long id () const {return id_;} - void id (unsigned long id) {id_ = id;} - private: - #pragma db id access(id) - unsigned long id_; - - public: - const object1_ptr& p1 () const {return p1_;} - object1_ptr& p1 () {return p1_;} - private: - #pragma db access(p1) - object1_ptr p1_; - - public: - const object1_ptr& p2 () const {return p2_;} - - void p2 (object1_ptr p2) {p2_ = std::move (p2);} - - private: - #pragma db get(p2) set(p2 (std::move (?))) - - object1_ptr p2_; - }; -} - -// Test container accessor/modifier functionality. -// -#pragma db namespace table("t4_") -namespace test4 -{ - #pragma db value - struct value - { - value (): c3_ (3, 999) {} - value (int v): c1_ (3, v), c2_ (3, v + 1), c3_ (3, v + 2) {} - - bool operator== (const value& v) const - { - return c1_ == v.c1_ && c2_ == v.c2_ && c3_ == v.c3_; - } - - public: - const std::vector& c1 () const {return c1_;} - std::vector& c1 () {return c1_;} - private: - #pragma db access(c1) - std::vector c1_; - - public: - const std::vector& c2 () const {return c2_;} - void c2 (const std::vector& c2) {c2_ = c2;} - private: - #pragma db access(c2) - std::vector c2_; - - public: - const std::vector c3_; - }; - - #pragma db object - struct object - { - object () {} - object (unsigned long id): id_ (id), c3_ (3, 3123), v2_ (2123) {} - - bool operator== (const object& o) const - { - return id_ == o.id_ && - c1_ == o.c1_ && - c2_ == o.c2_ && - c3_ == o.c3_ && - v1_ == o.v1_ && - v2_ == o.v2_; - } - - public: - unsigned long id () const {return id_;} - void id (unsigned long id) {id_ = id;} - private: - #pragma db id access(id) - unsigned long id_; - - public: - const std::vector& c1 () const {return c1_;} - std::vector& c1 () {return c1_;} - private: - #pragma db access(c1) - std::vector c1_; - - public: - const std::vector& c2 () const {return c2_;} - void c2 (const std::vector& c2) {c2_ = c2;} - private: - #pragma db access(c2) - std::vector c2_; - - public: - const std::vector& c3 () const {return c3_;} - private: - #pragma db get(c3) set(const_cast&> (this.c3 ())) - const std::vector c3_; - - public: - const value& v1 () const {return v1_;} - value& v1 () {return v1_;} - private: - #pragma db access(v1) - value v1_; - - public: - const value v2_; - }; -} - -// Test id accessor/modifier functionality. -// -#pragma db namespace table("t5_") -namespace test5 -{ - #pragma db object - struct object1 - { - object1 (): id_ (0) {} - - public: - unsigned long id () const {return id_;} - void id (unsigned long id) {id_ = id;} - private: - #pragma db id auto access(id) - unsigned long id_; - }; - - #pragma db object - struct object2 - { - object2 (): id_ (0) {} - - public: - unsigned long id () const {return id_;} - unsigned long& id () {return id_;} - private: - #pragma db id auto access(id) - unsigned long id_; - }; - - #pragma db object - struct object3 - { - object3 (): id_ (0) {} - - #pragma db id auto - const unsigned long id_; - }; - - #pragma db value - struct uuid - { - uuid () {std::memset (data_, 0, sizeof (data_));} - explicit uuid (const char* d) {data (d);} - - public: - const char* data () const {return data_;} - void data (const char* d) {std::memcpy (data_, d, sizeof (data_));} - private: - #pragma db type(BINARY16_TYPE) column("") access(data) - char data_[16]; - }; - - #pragma db object - struct object4 - { - public: - const uuid& id () const {return id_;} - void id (const uuid& id) {id_ = id;} - private: - #pragma db id access(id) - uuid id_; - }; -} - -// Test version accessor/modifier functionality. -// -#pragma db namespace table("t6_") -namespace test6 -{ - #pragma db object optimistic - struct object1 - { - object1 (unsigned long id = 0): id_ (id), version_ (0) {} - - #pragma db id - unsigned long id_; - - public: - unsigned long version () const {return version_;} - void version (unsigned long version) {version_ = version;} - private: - #pragma db version access(version) - unsigned long version_; - }; - - #pragma db object optimistic - struct object2 - { - object2 (): version_ (0) {} - - #pragma db id auto - unsigned long id_; - - public: - unsigned long version () const {return version_;} - unsigned long& version () {return version_;} - private: - #pragma db version access(version) - unsigned long version_; - }; - - #pragma db object optimistic - struct object3 - { - object3 (unsigned long id = 0): id_ (id), version_ (0) {} - - #pragma db id - unsigned long id_; - - #pragma db version - const unsigned long version_; - }; -} - -// Test automatic discovery of accessor/modifier functions. -// -#pragma db namespace table("t7_") -namespace test7 -{ - #pragma db object - struct object - { - object () {} - object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - public: - int i1 () const {return i1_;} - int& i1 () {return i1_;} - private: - int i1_; - - public: - const int& get_i2 () const {return i2_;} - void set_i2 (int i2) {i2_ = i2;} - private: - int i2_; - - public: - const int& getI3 () const {return i3_;} - void setI3 (const int& i3) {i3_ = i3;} - private: - int i3_; - - public: - int geti4 () const {return i4;} - int seti4 (int v) {int r (i4); i4 = v; return r;} - private: - int i4; - - // Prefer reference modifier. - // - public: - int i5 () const {return i5_;} - int& i5 () {return i5_;} - void i5 (int i5); - private: - int i5_; - - // Prefer reference modifier (reverse function order). - // - public: - int i6 () const {return i6_;} - void i6 (int i6); - int& i6 () {return i6_;} - private: - int i6_; - - // Custom accessor/modifier regex. - // - public: - int GetI7 () const {return i7_;} - void SetI7 (int i7) {i7_ = i7;} - private: - int i7_; - - // Array member via ref. - // - public: - const char* b1 () const {return b1_;} - char* b1 () {return b1_;} - private: - #pragma db type(BINARY16_TYPE) - char b1_[16]; - - // Array member via modifier. - // - public: - const char* b2 () const {return b2_;} - void b2 (const char* b2) {std::memcpy (b2_, b2, sizeof (b2_));} - private: - #pragma db type(BINARY16_TYPE) - char b2_[16]; - - public: - bool operator== (const object& o) const - { - return id_ == o.id_ && - i1_ == o.i1_ && - i2_ == o.i2_ && - i3_ == o.i3_ && - i4 == o.i4 && - i5_ == o.i5_ && - i6_ == o.i6_ && - i7_ == o.i7_ && - std::memcmp (b1_, o.b1_, sizeof (b1_)) == 0 && - std::memcmp (b2_, o.b2_, sizeof (b2_)) == 0; - } - }; -} - -#endif // TEST_HXX diff --git a/common/access/testscript b/common/access/testscript deleted file mode 100644 index 04f0ec0..0000000 --- a/common/access/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/access/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/as/buildfile b/common/as/buildfile deleted file mode 100644 index dcdc961..0000000 --- a/common/as/buildfile +++ /dev/null @@ -1,49 +0,0 @@ -# file : common/as/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix as_ \ - --generate-schema \ - --generate-query \ - --generate-session - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# @@ BUILD@ Temporarily suppress the following warning: -# -# test-odb.cxx(6234): warning C4244: 'argument': conversion from 'id_type::value_type' to 'test5::version_type::value_type', possible loss of data -# -if ($cxx.class == 'msvc') - cxx.coptions += /wd4244 - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/as/driver.cxx b/common/as/driver.cxx deleted file mode 100644 index 578eb23..0000000 --- a/common/as/driver.cxx +++ /dev/null @@ -1,348 +0,0 @@ -// file : common/as/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test C++ type mapping (#pragma map type as ...). -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test basic type mapping functionality. - // - { - using namespace test1; - - object o1 (true, green, 123, 234); - o1.m[false] = 123; - o1.v.push_back (o1.ip); - o1.cv.push_back (red); - o1.cv.push_back (green); - - object o2 (false, blue, 234, 456); - o2.m[true] = 234; - o2.v.push_back (o2.ip); - o2.cv.push_back (green); - o2.cv.push_back (blue); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - - o1.b = false; - o1.c = blue; - o1.ip.first++; - o1.ip.second--; - o1.m[false]++; - o1.m[true] = 234; - o1.v.back () = o1.ip; - o1.cv.modify_front () = green; - o1.cv.push_back (red); - - o2.b = true; - o2.c = red; - o2.ip.first--; - o2.ip.second++; - o2.m[true]--; - o2.m[false] = 345; - o2.v.push_back (o2.ip); - o2.cv.pop_back (); - - { - transaction t (db->begin ()); - db->update (o1); - db->update (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - } - - // Test wrapped simple type mapping. - // - { - using namespace test2; - - object o1; - o1.v.push_back (null_bool ()); - o1.v.push_back (false); - - object o2; - o2.b = true; - o2.v.push_back (true); - o2.v.push_back (null_bool ()); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - - o1.b = false; - o1.v[0] = true; - o1.v[1].reset (); - - o2.b.reset (); - o2.v.push_back (false); - - { - transaction t (db->begin ()); - db->update (o1); - db->update (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - } - - // Test wrapped composite type mapping. - // - { - using namespace test3; - - object o1; - o1.ip = intp (0, 0); // NULL - o1.npv.push_back (o1.np); - o1.ipv.push_back (o1.ip); - - object o2; - o2.np = intp (123, 234); - o1.ip = intp (234, 123); - o2.npv.push_back (o2.np); - o2.ipv.push_back (o2.ip); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - - o1.np = o1.npv[0] = intp (234, 456); - o1.ip = o1.ipv.modify_at (0) = intp (456, 234); - - o2.np.reset (); - o2.npv[0].reset (); - o2.ip = o2.ipv.modify_at (0) = intp (0, 0); // NULL - - { - transaction t (db->begin ()); - db->update (o1); - db->update (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - } - - // Test id type mapping. - // - { - using namespace test4; - - object o1 (123); - o1.v.push_back (1); - o1.v.push_back (2); - o1.v.push_back (3); - - object o2 (234); - o2.v.push_back (3); - o2.v.push_back (2); - o2.v.push_back (1); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - - o1.i++; - o1.v.pop_back (); - o1.v.modify_front ()++; - - o2.i--; - o2.v.clear (); - o2.v.push_back (4); - - { - transaction t (db->begin ()); - db->update (o1); - db->update (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - } - - // Test version type mapping. - // - { - using namespace test5; - - object o1 (100, 123); - object o2 (200, 234); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - - assert (*p1 == o1); - assert (*p2 == o2); - - p1->i--; - p2->i++; - - db->update (*p1); - db->update (*p2); - - t.commit (); - } - - { - transaction t (db->begin ()); - - for (;;) - { - o1.i++; - o2.i--; - - try - { - - db->update (o1); - db->update (o2); - break; - } - catch (const odb::object_changed&) - { - db->reload (o1); - db->reload (o2); - } - } - - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/as/test.hxx b/common/as/test.hxx deleted file mode 100644 index 963abeb..0000000 --- a/common/as/test.hxx +++ /dev/null @@ -1,270 +0,0 @@ -// file : common/as/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include -#include // pair - -#include -#include -#include - -// Test basic type mapping functionality. -// -#pragma db namespace table("t1_") -namespace test1 -{ - enum color {red, green, blue}; - - inline const char* - color_to_string (color c) - { - return c == red ? "RED" : (c == green ? "GREEN" : "BLUE"); - } - - inline color - string_to_color (const std::string& s) - { - return s == "RED" ? red : (s == "GREEN" ? green : blue); - } - - #pragma db map type(color) as(std::string) \ - to(test1::color_to_string (?)) \ - from(test1::string_to_color (?)) - - typedef std::pair intp; - - #pragma db value - struct comp - { - comp () {} - comp (int n1_, int n2_): n1 (n1_), n2 (n2_) {} - - int n1; - int n2; - }; - - #pragma db map type(intp) as(comp) \ - to(test1::comp ((?).first, (?).second)) \ - from(test1::intp ((?).n1, (?).n2)) - - #pragma db object - struct object - { - // Class-scope mapping. - // - #pragma db map type(bool) as(std::string) \ - to((?) ? "true" : "false") \ - from((?) == "true") - - #pragma db id auto - unsigned long id; - - bool b; - color c; - intp ip; - - std::map m; - std::vector v; - odb::vector cv; - - object () {} - object (bool b_, color c_, int n1, int n2): b (b_), c (c_), ip (n1, n2) {} - }; - - inline bool - operator== (const object& x, const object y) - { - return - x.b == y.b && - x.c == y.c && - x.ip == y.ip && - x.m == y.m && - x.v == y.v && - x.cv == y.cv; - } -} - -// Test wrapped simple type mapping. -// -#pragma db namespace table("t2_") -namespace test2 -{ - #pragma db map type(bool) as(std::string) \ - to((?) ? "true" : "false") \ - from((?) == "true") - - typedef odb::nullable null_bool; - typedef odb::nullable null_string; - - /* - #pragma db map type(null_bool) as(null_string) \ - to((?) \ - ? test2::null_string (*(?) ? "true" : "false") \ - : test2::null_string ()) \ - from((?) \ - ? test2::null_bool (*(?) == "true") \ - : test2::null_bool ()) - */ - - #pragma db map type(null_bool) as(std::string) \ - to((?) ? (*(?) ? "true" : "false") : "null") \ - from((?) != "null" \ - ? test2::null_bool ((?) == "true") \ - : test2::null_bool ()) - - #pragma db object - struct object - { - #pragma db id auto - unsigned long id; - - odb::nullable b; - std::vector > v; - }; - - inline bool - operator== (const object& x, const object y) - { - return x.b == y.b && x.v == y.v; - } -} - -// Test wrapped simple type mapping. -// -#pragma db namespace table("t3_") -namespace test3 -{ - typedef std::pair intp; - - #pragma db value - struct comp - { - comp () {} - comp (int n1_, int n2_): n1 (n1_), n2 (n2_) {} - - int n1; - int n2; - }; - - typedef odb::nullable null_intp; - typedef odb::nullable null_comp; - - #pragma db map type(null_intp) as(null_comp) \ - to((?) \ - ? test3::null_comp (test3::comp ((?)->first, (?)->second)) \ - : test3::null_comp ()) \ - from((?) \ - ? test3::null_intp (test3::intp ((?)->n1, (?)->n2)) \ - : test3::null_intp ()) - - // Map int pair with both members equal 0 to NULL comp. - // - #pragma db map type(intp) as(null_comp) \ - to((?).first != 0 || (?).second != 0 \ - ? test3::null_comp (test3::comp ((?).first, (?).second)) \ - : test3::null_comp ()) \ - from((?) \ - ? test3::intp (test3::intp ((?)->n1, (?)->n2)) \ - : test3::intp (0, 0)) - - #pragma db object - struct object - { - #pragma db id auto - unsigned long id; - - odb::nullable np; - intp ip; - - std::vector > npv; - odb::vector ipv; - }; - - inline bool - operator== (const object& x, const object y) - { - return x.np == y.np && x.ip == y.ip && x.npv == y.npv && x.ipv == y.ipv; - } -} - -// Test id type mapping. -// -struct id_type -{ - typedef unsigned long value_type; - value_type value; - - id_type (value_type v = 0): value (v) {} - operator value_type () const {return value;} -}; - -#pragma db map type(id_type) as(id_type::value_type) - -#pragma db namespace table("t4_") -namespace test4 -{ - #pragma db object - struct object - { - #pragma db id auto - id_type id; - - int i; - odb::vector v; - - object () {} - object (int i_): i (i_) {} - }; - - inline bool - operator== (const object& x, const object y) - { - return x.id == y.id && x.i == y.i && x.v == y.v; - } -} - -// Test version type mapping. -// -#pragma db namespace table("t5_") -namespace test5 -{ - struct version_type - { - typedef unsigned short value_type; - value_type value; - - version_type (value_type v = 0): value (v) {} - operator value_type () const {return value;} - version_type& operator++ () {value++; return *this;} - }; - - #pragma db map type(version_type) as(id_type::value_type) - - #pragma db object optimistic - struct object - { - #pragma db id - id_type id; - - #pragma db version - version_type v; - - int i; - - object () {} - object (id_type id_, int i_): id (id_), i (i_) {} - }; - - inline bool - operator== (const object& x, const object y) - { - return x.id == y.id && x.v == y.v && x.i == y.i; - } -} - -#endif // TEST_HXX diff --git a/common/as/testscript b/common/as/testscript deleted file mode 100644 index 12d9753..0000000 --- a/common/as/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/as/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/blob/buildfile b/common/blob/buildfile deleted file mode 100644 index cc6d164..0000000 --- a/common/blob/buildfile +++ /dev/null @@ -1,40 +0,0 @@ -# file : common/blob/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix blob_ \ - --generate-schema - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/blob/driver.cxx b/common/blob/driver.cxx deleted file mode 100644 index 269f415..0000000 --- a/common/blob/driver.cxx +++ /dev/null @@ -1,76 +0,0 @@ -// file : common/blob/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test BLOB mapping. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - const char data[] = - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" - "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" - "cccccccccccccccccccccccccccccccccccccccccccccccc" - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" - "dddddddddddddddddddddddddddddddddddddddddddddddd" - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" - "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" - "ffffffffffffffffffffffffffffffffffffffffffffffff"; - - const unsigned char* udata = reinterpret_cast (data); - - object o (1); - o.vc.assign (data, data + sizeof (data)); - o.vuc.assign (udata, udata + sizeof (data)); - memcpy (o.c, data, sizeof (data)); - memcpy (o.uc, udata, sizeof (data)); - memcpy (o.a.data (), data, sizeof (data)); - memcpy (o.ua.data (), udata, sizeof (data)); - o.cont.push_back (1); - o.cont.push_back (2); - o.cont.push_back (3); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/blob/test.hxx b/common/blob/test.hxx deleted file mode 100644 index 9602ca2..0000000 --- a/common/blob/test.hxx +++ /dev/null @@ -1,71 +0,0 @@ -// file : common/blob/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include // std::memcmp - -#include - -#ifdef ODB_COMPILER -# if defined(ODB_DATABASE_PGSQL) -# define BLOB_TYPE "BYTEA" -# elif defined(ODB_DATABASE_MSSQL) -//# define BLOB_TYPE "VARBINARY(1024)" -# define BLOB_TYPE "VARBINARY(max)" -# else -//# define BLOB_TYPE "RAW(1024)" -# define BLOB_TYPE "BLOB" -# endif -#endif - -#pragma db object -struct object -{ - object () {} - object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db type(BLOB_TYPE) - std::vector vc; - - #pragma db type(BLOB_TYPE) - std::vector vuc; - - #pragma db type(BLOB_TYPE) - char c[1024]; - - #pragma db type(BLOB_TYPE) - unsigned char uc[1024]; - - #pragma db type(BLOB_TYPE) - std::array a; - - #pragma db type(BLOB_TYPE) - std::array ua; - - // Make sure we can still use std::vector and std::array - // as containers. - // - std::vector cont; -}; - -inline bool -operator== (const object& x, const object& y) -{ - return x.id_ == y.id_ - && x.vc == y.vc - && x.vuc == y.vuc - && std::memcmp (x.c, y.c, sizeof (x.c)) == 0 - && std::memcmp (x.uc, y.uc, sizeof (x.uc)) == 0 - && x.a == y.a - && x.ua == y.ua - && x.cont == y.cont; -} - -#endif // TEST_HXX diff --git a/common/blob/testscript b/common/blob/testscript deleted file mode 100644 index 4fb9955..0000000 --- a/common/blob/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/blob/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/buildfile b/common/buildfile deleted file mode 100644 index cb9c748..0000000 --- a/common/buildfile +++ /dev/null @@ -1,6 +0,0 @@ -# file : common/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -./: {*/ -bulk/} - -./: bulk/: include = (!$pgsql || $pgsql_bulk || $size($databases) != 1) diff --git a/common/bulk/buildfile b/common/bulk/buildfile deleted file mode 100644 index 417eb22..0000000 --- a/common/bulk/buildfile +++ /dev/null @@ -1,49 +0,0 @@ -# file : common/bulk/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert (!$pgsql || $pgsql_bulk || $size($databases) != 1) \ -"bulk operations are disabled for pgsql which is specified as single database" - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases -{ - if ($db != 'pgsql' || $pgsql_bulk) - import libs += libodb-$db%lib{odb-$db} -} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: \ - include = ($multi && ($db != 'pgsql' || $pgsql_bulk)) - - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix bulk_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/bulk/driver.cxx b/common/bulk/driver.cxx deleted file mode 100644 index 23b49ad..0000000 --- a/common/bulk/driver.cxx +++ /dev/null @@ -1,1203 +0,0 @@ -// file : common/bulk/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test bulk database operations. -// - -#include // std::unique_ptr -#include -#include -#include - -#include -#include - -#include - -#include // DATABASE_* -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -// Sun CC with non-standard STL does not have iterator_traits in which -// case we assume iterator is just a pointer. -// -template ::value_type -#else - typename T = typename odb::details::meta::remove_pointer::result -#endif - > -struct element_traits; - -template -struct element_traits -{ - typedef T type; - typedef T* pointer; - typedef std::unique_ptr unique_ptr; - - static T& ref (T& x) {return x;} - static T* ptr (T* p) {return p;} -}; - -template -struct element_traits -{ - typedef T type; - typedef T* pointer; - typedef std::unique_ptr unique_ptr; - - static T& ref (T* p) {return *p;} - static T* ptr (T* p) {return p;} -}; - -template -struct element_traits > -{ - typedef T type; - typedef std::unique_ptr pointer; - typedef std::unique_ptr unique_ptr; - - static T& ref (const unique_ptr& p) {return *p;} - static T* ptr (const unique_ptr& p) {return p.get ();} -}; - -template -void -persist (const unique_ptr& db, I b, I e, bool cont = true) -{ - typedef element_traits traits; - typedef typename traits::type type; - typedef typename traits::unique_ptr unique_ptr; - - { - transaction t (db->begin ()); - db->persist (b, e, cont); - t.commit (); - } - - // Verify we can load the objects via their ids. - // - { - transaction t (db->begin ()); - - for (I i (b); i != e; ++i) - { - type& x (traits::ref (*i)); - unique_ptr p (db->load (x.id)); - assert (p->n == x.n && p->s == x.s); - } - - t.commit (); - } -} - -template -void -try_persist (const unique_ptr& db, I b, I e, bool cont = true) -{ - try - { - persist (db, b, e, cont); - assert (false); - } - catch (const multiple_exceptions& e) - { - cout << e.what () << endl << endl; - } -} - -template -void -update (const unique_ptr& db, I b, I e, - bool modify = true, bool cont = true) -{ - typedef element_traits traits; - typedef typename traits::type type; - typedef typename traits::unique_ptr unique_ptr; - - if (modify) - { - for (I i (b); i != e; ++i) - { - type& x (traits::ref (*i)); - x.n++; - x.s[0]++; - } - } - - { - transaction t (db->begin ()); - db->update (b, e, cont); - t.commit (); - } - - // Verify changes. - // - { - transaction t (db->begin ()); - - for (I i (b); i != e; ++i) - { - type& x (traits::ref (*i)); - unique_ptr p (db->load (x.id)); - assert (p->n == x.n && p->s == x.s); - } - - t.commit (); - } -} - -template -void -try_update (const unique_ptr& db, I b, I e, bool cont = true) -{ - try - { - update (db, b, e, false, cont); - assert (false); - } - catch (const multiple_exceptions& e) - { - cout << e.what () << endl << endl; - } -} - -template -void -erase (const unique_ptr& db, I b, I e) -{ - typedef element_traits traits; - typedef typename traits::type type; - - { - transaction t (db->begin ()); - db->erase (b, e); - t.commit (); - } - - // Verify the objects are gone. - // - { - transaction t (db->begin ()); - - for (I i (b); i != e; ++i) - { - type& x (traits::ref (*i)); - typename traits::pointer p (db->find (x.id)); - assert (traits::ptr (p) == 0); - } - - t.commit (); - } -} - -template -void -erase_id (const unique_ptr& db, I b, I e, bool cont = true) -{ - typedef element_traits traits; - typedef T type; - - { - transaction t (db->begin ()); - db->erase (b, e, cont); - t.commit (); - } - - // Verify the objects are gone. - // - { - transaction t (db->begin ()); - - for (I i (b); i != e; ++i) - assert (traits::ptr (db->find (*i)) == 0); - - t.commit (); - } -} - -template -void -try_erase (const unique_ptr& db, const A& a, bool cont = true) -{ - try - { - erase_id (db, a, a + sizeof (a) / sizeof (a[0]), cont); - assert (false); - } - catch (const multiple_exceptions& e) - { - cout << e.what () << endl << endl; - } -} - - -template -void -test (const unique_ptr& db, I b, I e) -{ - persist (db, b, e); - update (db, b, e); - erase (db, b, e); -} - -template -vector -fill (std::size_t count) -{ - vector r; - - unsigned int n (1); - std::string s ("a"); - - for (size_t i (0); i != count; ++i) - { - r.push_back (T (n, s)); - n++; - s[0] = (s[0] == 'z' ? 'a' : s[0] + 1); - } - - return r; -} - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - -#if !defined(MULTI_DATABASE) && \ - (defined(DATABASE_ORACLE) || \ - defined(DATABASE_MSSQL) || \ - defined(DATABASE_PGSQL)) - - // Test database class API with various forms of containers - // and elements (test #6 is a copy). - // - { - using namespace test1; - - { - object a[2]; - a[0] = object (1, "a"); - a[1] = object (2, "b"); - test (db, a, a + sizeof (a) / sizeof (a[0])); - } - - { - vector v; - v.push_back (object (1, "a")); - v.push_back (object (2, "b")); - test (db, v.begin (), v.end ()); - } - - { - object o1 (1, "a"); - object o2 (2, "b"); - object* a[2] = {&o1, &o2}; - test (db, a, a + sizeof (a) / sizeof (a[0])); - } - - { - object o1 (1, "a"); - object o2 (2, "b"); - vector v; - v.push_back (&o1); - v.push_back (&o2); - test (db, v.begin (), v.end ()); - } - - { - vector> v; - v.push_back (unique_ptr (new unique_object (1, "a"))); - v.push_back (unique_ptr (new unique_object (2, "b"))); - test (db, v.begin (), v.end ()); - } - - { - vector v; - v.push_back (object (1, "a")); - v.push_back (object (2, "b")); - persist (db, v.begin (), v.end ()); - - unsigned long id[2] = {v[0].id, v[1].id}; - erase_id (db, id, id + sizeof (id) / sizeof (id[0])); - } - - { - vector v; - v.push_back (object (1, "a")); - v.push_back (object (2, "b")); - persist (db, v.begin (), v.end ()); - - vector id; - id.push_back (v[0].id); - id.push_back (v[1].id); - erase_id (db, id.begin (), id.end ()); - } - } - - // Test various batch sizes. - // - { - using namespace test1; - - { - vector v; // 0 - test (db, v.begin (), v.end ()); - } - - { - vector v (fill (1)); // 1 - test (db, v.begin (), v.end ()); - } - - { - vector v (fill (2)); // batch - 1 - test (db, v.begin (), v.end ()); - } - - { - vector v (fill (3)); // batch - test (db, v.begin (), v.end ()); - } - - { - vector v (fill (4)); // batch + 1 - test (db, v.begin (), v.end ()); - } - - { - vector v (fill (5)); // 2 * batch - 1 - test (db, v.begin (), v.end ()); - } - - { - vector v (fill (6)); // 2 * batch - test (db, v.begin (), v.end ()); - } - - { - vector v (fill (100)); // 100 - test (db, v.begin (), v.end ()); - } - } - - // Test object with manually assigned id. - // - { - using namespace test2; - - { - vector v; - v.push_back (object ("1", 1, "a")); - v.push_back (object ("2", 2, "b")); - test (db, v.begin (), v.end ()); - } - - { - typedef unique_ptr unique_ptr; - - vector v; - v.push_back (unique_ptr (new unique_object ("1", 1, "a"))); - v.push_back (unique_ptr (new unique_object ("2", 2, "b"))); - test (db, v.begin (), v.end ()); - } - - // Test const objects. - // - - { - const object a[1]; - const object* e (a + sizeof (a) / sizeof (a[0])); - - transaction t (db->begin ()); - db->persist (a, e); - db->erase (a, e); - t.commit (); - } - - { - object o1 ("1", 1, "a"); - object o2 ("2", 2, "b"); - - vector v; - v.push_back (&o1); - v.push_back (&o2); - - transaction t (db->begin ()); - db->persist (v.begin (), v.end ()); - db->erase (v.begin (), v.end ()); - t.commit (); - } - } - - // Test failure. - // - { - using namespace test3; - - vector v; - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - v.push_back (object (8, 8)); - v.push_back (object (9, 9)); - v.push_back (object (10, 10)); - v.push_back (object (11, 11)); - - persist (db, v.begin (), v.end ()); - - // persist - // - { - { - vector v; // 1 - v.push_back (object (6, 6)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // 2 - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // batch - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - v.push_back (object (8, 8)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // batch + 1 - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - v.push_back (object (8, 8)); - v.push_back (object (9, 9)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // 2 x batch - 1 - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - v.push_back (object (8, 8)); - v.push_back (object (9, 9)); - v.push_back (object (10, 10)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // 2 x batch - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - v.push_back (object (8, 8)); - v.push_back (object (9, 9)); - v.push_back (object (10, 10)); - v.push_back (object (11, 11)); - try_persist (db, v.begin (), v.end ()); - } - - // Mixture of success and failure. - // - - { - vector v; // 1 - v.push_back (object (0, 0)); - v.push_back (object (6, 6)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // 1 - v.push_back (object (6, 6)); - v.push_back (object (0, 0)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // 2 - v.push_back (object (0, 0)); - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // 2 - v.push_back (object (6, 6)); - v.push_back (object (0, 0)); - v.push_back (object (7, 7)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // 2 - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - v.push_back (object (0, 0)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // batch - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - v.push_back (object (0, 0)); - v.push_back (object (8, 8)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // batch - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - v.push_back (object (8, 8)); - v.push_back (object (0, 0)); - try_persist (db, v.begin (), v.end ()); - } - - { - vector v; // mixture - v.push_back (object (0, 0)); - v.push_back (object (6, 6)); - v.push_back (object (1, 1)); - v.push_back (object (7, 7)); - v.push_back (object (2, 2)); - v.push_back (object (8, 8)); - v.push_back (object (3, 3)); - try_persist (db, v.begin (), v.end ()); - } - - // Test stopping after failure. - // - { - vector v; // batch - v.push_back (object (0, 0)); - v.push_back (object (1, 1)); - v.push_back (object (6, 6)); - v.push_back (object (2, 2)); - v.push_back (object (3, 3)); - try_persist (db, v.begin (), v.end (), false); - } - } - - // update - // - { - { - vector v; // 1 - v.push_back (object (0, 0)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // 2 - v.push_back (object (0, 0)); - v.push_back (object (1, 1)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // batch - v.push_back (object (0, 0)); - v.push_back (object (1, 1)); - v.push_back (object (2, 2)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // batch + 1 - v.push_back (object (0, 0)); - v.push_back (object (1, 1)); - v.push_back (object (2, 2)); - v.push_back (object (3, 3)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // 2 x batch - 1 - v.push_back (object (0, 0)); - v.push_back (object (1, 1)); - v.push_back (object (2, 2)); - v.push_back (object (3, 3)); - v.push_back (object (4, 4)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // 2 x batch - v.push_back (object (0, 0)); - v.push_back (object (1, 1)); - v.push_back (object (2, 2)); - v.push_back (object (3, 3)); - v.push_back (object (4, 4)); - v.push_back (object (5, 5)); - try_update (db, v.begin (), v.end ()); - } - - // Mixture of success and failure. - // - - { - vector v; // 1 - v.push_back (object (6, 6)); - v.push_back (object (0, 0)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // 1 - v.push_back (object (0, 0)); - v.push_back (object (6, 6)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // 2 - v.push_back (object (6, 6)); - v.push_back (object (0, 0)); - v.push_back (object (1, 1)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // 2 - v.push_back (object (0, 0)); - v.push_back (object (6, 6)); - v.push_back (object (1, 1)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // 2 - v.push_back (object (0, 0)); - v.push_back (object (1, 1)); - v.push_back (object (6, 6)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // batch - v.push_back (object (0, 0)); - v.push_back (object (1, 1)); - v.push_back (object (6, 6)); - v.push_back (object (2, 2)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // batch - v.push_back (object (0, 0)); - v.push_back (object (1, 1)); - v.push_back (object (2, 2)); - v.push_back (object (6, 6)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // mixture - v.push_back (object (0, 0)); - v.push_back (object (6, 6)); - v.push_back (object (2, 2)); - v.push_back (object (7, 7)); - v.push_back (object (3, 3)); - v.push_back (object (8, 8)); - v.push_back (object (4, 4)); - try_update (db, v.begin (), v.end ()); - } - - { - vector v; // mixture - v.push_back (object (0, 0)); - v.push_back (object (2, 2)); - v.push_back (object (3, 3)); - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - v.push_back (object (8, 8)); - v.push_back (object (4, 4)); - try_update (db, v.begin (), v.end ()); - } - - // Test stopping after failure. - // - { - vector v; // batch - v.push_back (object (6, 6)); - v.push_back (object (7, 7)); - v.push_back (object (0, 0)); - v.push_back (object (8, 8)); - v.push_back (object (9, 9)); - try_update (db, v.begin (), v.end (), false); - } - - // Test a database exception (unique constraint violation) - // - try - { - v[0].n++; - v[2].n++; - - update (db, v.begin (), v.begin () + 3, false); - assert (false); - } - catch (const multiple_exceptions& e) - { -#ifndef DATABASE_PGSQL - assert (e.attempted () == 3 && e.failed () == 2); - assert (e[0] != 0 && e[1] == 0 && e[2] != 0); -#else - // In PosgreSQL no further statements are attempted after the first - // failure. - // - assert (e.attempted () == 1 && e.failed () == 1); - assert (e[0] != 0); -#endif - } - } - - // erase - // - { - { - unsigned long a[] = {0}; // 1 - try_erase (db, a); - } - - { - unsigned long a[] = {0, 1}; // 2 - try_erase (db, a); - } - - { - unsigned long a[] = {0, 1, 2}; // batch - try_erase (db, a); - } - - { - unsigned long a[] = {0, 1, 2, 3}; // batch + 1 - try_erase (db, a); - } - - { - unsigned long a[] = {0, 1, 2, 3, 4}; // 2 x batch - 1 - try_erase (db, a); - } - - { - unsigned long a[] = {0, 1, 2, 3, 4, 5}; // 2 x batch - try_erase (db, a); - } - - // Mixture of success and failure. - // - - { - unsigned long a[] = {6, 0}; // 2 - try_erase (db, a); - } - - { - unsigned long a[] = {0, 6}; // 2 - try_erase (db, a); - } - - { - unsigned long a[] = {6, 0, 1}; // batch - try_erase (db, a); - } - - { - unsigned long a[] = {0, 6, 1}; // batch - try_erase (db, a); - } - - { - unsigned long a[] = {0, 1, 6}; // batch - try_erase (db, a); - } - - { - unsigned long a[] = {6, 0, 1, 2}; // batch + 1 - try_erase (db, a); - } - - { - unsigned long a[] = {0, 6, 1, 2}; // batch + 1 - try_erase (db, a); - } - - { - unsigned long a[] = {0, 1, 6, 2}; // batch + 1 - try_erase (db, a); - } - - { - unsigned long a[] = {0, 1, 2, 6}; // batch + 1 - try_erase (db, a); - } - - { - unsigned long a[] = {6, 0, 7, 1, 8, 2, 9, 3}; // mixture - try_erase (db, a); - } - - { - unsigned long a[] = {0, 1, 2, 6, 7, 8, 3, 4, 5, 9}; // mixture - try_erase (db, a); - } - - // Test stopping after failure. - // - { - unsigned long a[] = {6, 7, 0, 8, 9}; - try_erase (db, a, false); - } - } - - erase (db, v.begin (), v.end ()); - } - - // Test a large batch. - // - { - using namespace test4; - - vector v (fill (5000)); - test (db, v.begin (), v.end ()); - } - - // Test object without id. - // - { - using namespace test5; - - vector v; - v.push_back (object (1, "a")); - v.push_back (object (2, "b")); - - { - transaction t (db->begin ()); - db->persist (v.begin (), v.end ()); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query ("ORDER BY" + query::n)); - result::iterator i (r.begin ()); - - assert (i != r.end () && i->n == 1 && i->s == "a"); - assert (++i != r.end () && i->n == 2 && i->s == "b"); - assert (++i == r.end ()); - - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase_query (); - t.commit (); - } - } - - // Test API with persistent class template instantiations (copy of - // test #1). - { - using namespace test6; - - // Make sure we can still call the non-bulk API. - // - { - object o (0, "z"); - transaction t (db->begin ()); - db->persist (o); - db->update (o); - db->reload (o); - db->erase (o); - t.commit (); - } - - - // The rest is a copy of test #1. - // - { - object a[2]; - a[0] = object (1, "a"); - a[1] = object (2, "b"); - test (db, a, a + sizeof (a) / sizeof (a[0])); - } - - { - vector v; - v.push_back (object (1, "a")); - v.push_back (object (2, "b")); - test (db, v.begin (), v.end ()); - } - - { - object o1 (1, "a"); - object o2 (2, "b"); - object* a[2] = {&o1, &o2}; - test (db, a, a + sizeof (a) / sizeof (a[0])); - } - - { - object o1 (1, "a"); - object o2 (2, "b"); - vector v; - v.push_back (&o1); - v.push_back (&o2); - test (db, v.begin (), v.end ()); - } - - { - vector> v; - v.push_back (unique_ptr (new unique_object (1, "a"))); - v.push_back (unique_ptr (new unique_object (2, "b"))); - test (db, v.begin (), v.end ()); - } - - { - vector v; - v.push_back (object (1, "a")); - v.push_back (object (2, "b")); - persist (db, v.begin (), v.end ()); - - unsigned long id[2] = {v[0].id, v[1].id}; - erase_id (db, id, id + sizeof (id) / sizeof (id[0])); - } - - { - vector v; - v.push_back (object (1, "a")); - v.push_back (object (2, "b")); - persist (db, v.begin (), v.end ()); - - vector id; - id.push_back (v[0].id); - id.push_back (v[1].id); - erase_id (db, id.begin (), id.end ()); - } - } - - // Test optimistic concurrency. - // - { - using namespace test7; - - std::vector v (fill (4)); - - // persist - // - { - transaction t (db->begin ()); - db->persist (v.begin (), v.end ()); - t.commit (); - - assert (v[0].v != 0 && - v[1].v != 0 && - v[2].v != 0 && - v[3].v != 0); - } - - // update - // - { - std::vector c (v); - - transaction t (db->begin ()); - db->update (v.begin (), v.end ()); - t.commit (); - - assert (v[0].v > c[0].v && - v[1].v > c[1].v && - v[2].v > c[2].v && - v[3].v > c[3].v); - } - - { - object o2 (v[1]); - object o4 (v[3]); - - o2.n++; - o4.n++; - - transaction t (db->begin ()); - db->update (o2); - db->update (o4); - t.commit (); - } - - try - { - // Some updates may succeed spoiling the version for erase tests. - // - std::vector c (v); - - transaction t (db->begin ()); - db->update (c.begin (), c.end ()); - assert (false); - } - catch (const multiple_exceptions& e) - { - cout << e.what () << endl << endl; - } - - // erase - // - try - { - transaction t (db->begin ()); - db->erase (v.begin (), v.end ()); - assert (false); - } - catch (const multiple_exceptions& e) - { - cout << e.what () << endl << endl; - } - - { - transaction t (db->begin ()); - db->reload (v[1]); - db->reload (v[3]); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (v.begin (), v.end ()); - t.commit (); - } - } - - // Test SQL Server optimistic concurrency with ROWVERSION. - // -#ifdef DATABASE_MSSQL - { - using namespace test8; - - std::vector v (fill (4)); - - v[0].id = 1; - v[1].id = 2; - v[2].id = 3; - v[3].id = 4; - - - // persist - // - { - transaction t (db->begin ()); - db->persist (v.begin (), v.end ()); - t.commit (); - - assert (v[0].v != 0 && - v[1].v != 0 && - v[2].v != 0 && - v[3].v != 0); - - //cerr << v[0].v << endl - // << v[1].v << endl - // << v[2].v << endl - // << v[3].v << endl; - } - - // update - // - - /* - { - std::vector c (v); - - transaction t (db->begin ()); - db->update (v.begin (), v.end ()); - t.commit (); - - assert (v[0].v > c[0].v && - v[1].v > c[1].v && - v[2].v > c[2].v && - v[3].v > c[3].v); - } - */ - - { - object o2 (v[1]); - object o4 (v[3]); - - o2.n++; - o4.n++; - - transaction t (db->begin ()); - db->update (o2); - db->update (o4); - t.commit (); - } - - /* - try - { - transaction t (db->begin ()); - db->update (v.begin (), v.end ()); - assert (false); - } - catch (const multiple_exceptions& e) - { - cout << e.what () << endl << endl; - } - */ - - // erase - // - try - { - transaction t (db->begin ()); - db->erase (v.begin (), v.end ()); - assert (false); - } - catch (const multiple_exceptions& e) - { - assert (e.attempted () == 4 && e.failed () == 4); - } - - { - transaction t (db->begin ()); - db->reload (v[1]); - db->reload (v[3]); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (v.begin (), v.end ()); - t.commit (); - } - } -#endif - -#endif - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/bulk/test.hxx b/common/bulk/test.hxx deleted file mode 100644 index 71755f2..0000000 --- a/common/bulk/test.hxx +++ /dev/null @@ -1,211 +0,0 @@ -// file : common/bulk/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include // std::unique_ptr - -#include - -// Test basic functionality. -// -#pragma db namespace table("t1_") -namespace test1 -{ - #pragma db object bulk(3) session - struct object - { - object (unsigned int n_ = 0, std::string s_ = "") - : id (0), n (n_), s (s_) {} - - #pragma db id auto - unsigned long id; - - unsigned int n; - - #pragma db oracle:type("CLOB") mssql:type("VARCHAR(max)") // Long data. - std::string s; - }; - - #pragma db object bulk(3) pointer(std::unique_ptr) - struct unique_object - { - unique_object (unsigned int n_ = 0, std::string s_ = "") - : id (0), n (n_), s (s_) {} - - #pragma db id auto - unsigned long id; - - unsigned int n; - std::string s; - }; -} - -// Test object with manually assigned id. -// -#pragma db namespace table("t2_") -namespace test2 -{ - #pragma db object bulk(3) session - struct object - { - // Can't use empty id because of Oracle. - // - object (std::string id_ = "!", unsigned int n_ = 0, std::string s_ = "") - : id (id_), n (n_), s (s_) {} - - #pragma db id - std::string id; - - unsigned int n; - std::string s; - }; - -#pragma db object bulk(3) pointer(std::unique_ptr) - struct unique_object - { - unique_object (std::string id_ = "", - unsigned int n_ = 0, - std::string s_ = "") - : id (id_), n (n_), s (s_) {} - - #pragma db id - std::string id; - - unsigned int n; - std::string s; - }; -} - -// Test failure. -// -#pragma db namespace table("t3_") -namespace test3 -{ - #pragma db object bulk(3) - struct object - { - object (unsigned long id_ = 0, unsigned int n_ = 0) - : id (id_), n (n_), s ("abc") {} - - #pragma db id - unsigned long id; - - #pragma db unique - unsigned int n; - std::string s; - }; -} - -// Test a large batch. -// -#pragma db namespace table("t4_") -namespace test4 -{ - #pragma db object bulk(3000) - struct object - { - object (unsigned int n_ = 0, std::string s_ = "") - : id (0), n (n_), s (s_) {} - - #pragma db id auto - unsigned long id; - - unsigned int n; - - #pragma db oracle:type("CLOB") mssql:type("VARCHAR(max)") // Long data. - std::string s; - }; -} - -// Test object without id. -// -#pragma db namespace table("t5_") -namespace test5 -{ - #pragma db object no_id bulk(3) - struct object - { - object (unsigned int n_ = 0, std::string s_ = ""): n (n_), s (s_) {} - - unsigned int n; - std::string s; - }; -} - -// Test API with persistent class template instantiations. -// -#pragma db namespace table("t6_") -namespace test6 -{ - template - struct object_template - { - object_template (unsigned int n_ = 0, std::string s_ = "") - : id (0), n (n_), s (s_) {} - - unsigned long id; - unsigned int n; - std::string s; - }; - - typedef object_template<1> object; - - #pragma db object(object) bulk(3) - #pragma db member(object::id) id auto - - typedef object_template<3> unique_object; - - #pragma db object(unique_object) bulk(3) pointer(std::unique_ptr) - #pragma db member(unique_object::id) id auto -} - -// Test optimistic concurrency. -// -#pragma db namespace table("t7_") -namespace test7 -{ - #pragma db object optimistic bulk(3) - struct object - { - object (unsigned int n_ = 0, std::string s_ = "") - : id (0), v (0), n (n_), s (s_) {} - - #pragma db id auto - unsigned long long id; - - #pragma db version - unsigned long long v; - - unsigned int n; - std::string s; - }; -} - -// Test SQL Server optimistic concurrency with ROWVERSION. -// -#if defined(ODB_DATABASE_MSSQL) || defined(DATABASE_MSSQL) -#pragma db namespace table("t8_") -namespace test8 -{ - #pragma db object optimistic bulk(3) - struct object - { - object (unsigned int n_ = 0, std::string s_ = "") - : id (0), v (0), n (n_), s (s_) {} - - #pragma db id - unsigned long long id; - - #pragma db version type("ROWVERSION") - unsigned long long v; - - unsigned int n; - std::string s; - }; -} -#endif - -#endif // TEST_HXX diff --git a/common/bulk/testscript b/common/bulk/testscript deleted file mode 100644 index e7567c9..0000000 --- a/common/bulk/testscript +++ /dev/null @@ -1,503 +0,0 @@ -# file : common/bulk/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -+cat <=output - multiple exceptions, 1 element attempted, 1 failed: - [0] object already persistent - - multiple exceptions, 2 elements attempted, 2 failed: - [0] object already persistent - [1] object already persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0] object already persistent - [1] object already persistent - [2] object already persistent - - multiple exceptions, 4 elements attempted, 4 failed: - [0] object already persistent - [1] object already persistent - [2] object already persistent - [3] object already persistent - - multiple exceptions, 5 elements attempted, 5 failed: - [0] object already persistent - [1] object already persistent - [2] object already persistent - [3] object already persistent - [4] object already persistent - - multiple exceptions, 6 elements attempted, 6 failed: - [0] object already persistent - [1] object already persistent - [2] object already persistent - [3] object already persistent - [4] object already persistent - [5] object already persistent - - multiple exceptions, 2 elements attempted, 1 failed: - [1] object already persistent - - multiple exceptions, 2 elements attempted, 1 failed: - [0] object already persistent - - multiple exceptions, 3 elements attempted, 2 failed: - [1] object already persistent - [2] object already persistent - - multiple exceptions, 3 elements attempted, 2 failed: - [0] object already persistent - [2] object already persistent - - multiple exceptions, 3 elements attempted, 2 failed: - [0] object already persistent - [1] object already persistent - - multiple exceptions, 4 elements attempted, 3 failed: - [0] object already persistent - [1] object already persistent - [3] object already persistent - - multiple exceptions, 4 elements attempted, 3 failed: - [0] object already persistent - [1] object already persistent - [2] object already persistent - - multiple exceptions, 7 elements attempted, 3 failed: - [1] object already persistent - [3] object already persistent - [5] object already persistent - - multiple exceptions, 3 elements attempted, 1 failed: - [2] object already persistent - - multiple exceptions, 1 element attempted, 1 failed: - [0] object not persistent - - multiple exceptions, 2 elements attempted, 2 failed: - [0] object not persistent - [1] object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - - multiple exceptions, 4 elements attempted, 4 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - - multiple exceptions, 5 elements attempted, 5 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - [4] object not persistent - - multiple exceptions, 6 elements attempted, 6 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - [4] object not persistent - [5] object not persistent - - multiple exceptions, 2 elements attempted, 2 failed: - [0-1] (some) object not persistent - - multiple exceptions, 2 elements attempted, 2 failed: - [0-1] (some) object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0-2] (some) object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0-2] (some) object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0-2] (some) object not persistent - - multiple exceptions, 4 elements attempted, 4 failed: - [0-2] (some) object not persistent - [3] object not persistent - - multiple exceptions, 4 elements attempted, 3 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - - multiple exceptions, 7 elements attempted, 7 failed: - [0-5] (some) object not persistent - [6] object not persistent - - multiple exceptions, 7 elements attempted, 4 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [6] object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0-2] (some) object not persistent - - multiple exceptions, 1 element attempted, 1 failed: - [0] object not persistent - - multiple exceptions, 2 elements attempted, 2 failed: - [0] object not persistent - [1] object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - - multiple exceptions, 4 elements attempted, 4 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - - multiple exceptions, 5 elements attempted, 5 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - [4] object not persistent - - multiple exceptions, 6 elements attempted, 6 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - [4] object not persistent - [5] object not persistent - - multiple exceptions, 2 elements attempted, 2 failed: - [0-1] (some) object not persistent - - multiple exceptions, 2 elements attempted, 2 failed: - [0-1] (some) object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0-2] (some) object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0-2] (some) object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0-2] (some) object not persistent - - multiple exceptions, 4 elements attempted, 4 failed: - [0-2] (some) object not persistent - [3] object not persistent - - multiple exceptions, 4 elements attempted, 4 failed: - [0-2] (some) object not persistent - [3] object not persistent - - multiple exceptions, 4 elements attempted, 4 failed: - [0-2] (some) object not persistent - [3] object not persistent - - multiple exceptions, 4 elements attempted, 3 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - - multiple exceptions, 8 elements attempted, 8 failed: - [0-7] (some) object not persistent - - multiple exceptions, 10 elements attempted, 6 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [6] object not persistent - [7] object not persistent - [8] object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0-2] (some) object not persistent - - multiple exceptions, 4 elements attempted, 4 failed: - [0-2] (some) object changed concurrently - [3] object changed concurrently - - multiple exceptions, 4 elements attempted, 4 failed: - [0-2] (some) object changed concurrently - [3] object changed concurrently - - EOI - -+cat <=pgsql-output - multiple exceptions, 1 element attempted, 1 failed: - [0] object already persistent - - multiple exceptions, 1 element attempted, 1 failed, fatal: - [0] object already persistent - - multiple exceptions, 1 element attempted, 1 failed, fatal: - [0] object already persistent - - multiple exceptions, 1 element attempted, 1 failed, fatal: - [0] object already persistent - - multiple exceptions, 1 element attempted, 1 failed, fatal: - [0] object already persistent - - multiple exceptions, 1 element attempted, 1 failed, fatal: - [0] object already persistent - - multiple exceptions, 2 elements attempted, 1 failed: - [1] object already persistent - - multiple exceptions, 1 element attempted, 1 failed, fatal: - [0] object already persistent - - multiple exceptions, 2 elements attempted, 1 failed, fatal: - [1] object already persistent - - multiple exceptions, 1 element attempted, 1 failed, fatal: - [0] object already persistent - - multiple exceptions, 1 element attempted, 1 failed, fatal: - [0] object already persistent - - multiple exceptions, 1 element attempted, 1 failed, fatal: - [0] object already persistent - - multiple exceptions, 1 element attempted, 1 failed, fatal: - [0] object already persistent - - multiple exceptions, 2 elements attempted, 1 failed, fatal: - [1] object already persistent - - multiple exceptions, 3 elements attempted, 1 failed: - [2] object already persistent - - multiple exceptions, 1 element attempted, 1 failed: - [0] object not persistent - - multiple exceptions, 2 elements attempted, 2 failed: - [0] object not persistent - [1] object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - - multiple exceptions, 4 elements attempted, 4 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - - multiple exceptions, 5 elements attempted, 5 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - [4] object not persistent - - multiple exceptions, 6 elements attempted, 6 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - [4] object not persistent - [5] object not persistent - - multiple exceptions, 2 elements attempted, 1 failed: - [1] object not persistent - - multiple exceptions, 2 elements attempted, 1 failed: - [0] object not persistent - - multiple exceptions, 3 elements attempted, 2 failed: - [1] object not persistent - [2] object not persistent - - multiple exceptions, 3 elements attempted, 2 failed: - [0] object not persistent - [2] object not persistent - - multiple exceptions, 3 elements attempted, 2 failed: - [0] object not persistent - [1] object not persistent - - multiple exceptions, 4 elements attempted, 3 failed: - [0] object not persistent - [1] object not persistent - [3] object not persistent - - multiple exceptions, 4 elements attempted, 3 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - - multiple exceptions, 7 elements attempted, 4 failed: - [0] object not persistent - [2] object not persistent - [4] object not persistent - [6] object not persistent - - multiple exceptions, 7 elements attempted, 4 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [6] object not persistent - - multiple exceptions, 3 elements attempted, 1 failed: - [2] object not persistent - - multiple exceptions, 1 element attempted, 1 failed: - [0] object not persistent - - multiple exceptions, 2 elements attempted, 2 failed: - [0] object not persistent - [1] object not persistent - - multiple exceptions, 3 elements attempted, 3 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - - multiple exceptions, 4 elements attempted, 4 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - - multiple exceptions, 5 elements attempted, 5 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - [4] object not persistent - - multiple exceptions, 6 elements attempted, 6 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [3] object not persistent - [4] object not persistent - [5] object not persistent - - multiple exceptions, 2 elements attempted, 1 failed: - [1] object not persistent - - multiple exceptions, 2 elements attempted, 1 failed: - [0] object not persistent - - multiple exceptions, 3 elements attempted, 2 failed: - [1] object not persistent - [2] object not persistent - - multiple exceptions, 3 elements attempted, 2 failed: - [0] object not persistent - [2] object not persistent - - multiple exceptions, 3 elements attempted, 2 failed: - [0] object not persistent - [1] object not persistent - - multiple exceptions, 4 elements attempted, 3 failed: - [1] object not persistent - [2] object not persistent - [3] object not persistent - - multiple exceptions, 4 elements attempted, 3 failed: - [0] object not persistent - [2] object not persistent - [3] object not persistent - - multiple exceptions, 4 elements attempted, 3 failed: - [0] object not persistent - [1] object not persistent - [3] object not persistent - - multiple exceptions, 4 elements attempted, 3 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - - multiple exceptions, 8 elements attempted, 4 failed: - [1] object not persistent - [3] object not persistent - [5] object not persistent - [7] object not persistent - - multiple exceptions, 10 elements attempted, 6 failed: - [0] object not persistent - [1] object not persistent - [2] object not persistent - [6] object not persistent - [7] object not persistent - [8] object not persistent - - multiple exceptions, 3 elements attempted, 1 failed: - [2] object not persistent - - multiple exceptions, 4 elements attempted, 2 failed: - [1] object changed concurrently - [3] object changed concurrently - - multiple exceptions, 4 elements attempted, 2 failed: - [1] object changed concurrently - [3] object changed concurrently - - EOI - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if ($pgsql && $pgsql_bulk) -{ - .include ../../pgsql.testscript - - $create_schema; - - # Query the PostgreSQL server version and only run the test if it is 7.4 or - # above. - # - $pgsql_client_cmd --tuples-only -c 'SELECT VERSION()' | \ - sed -n -e 's/.*PostgreSQL (\d+\.\d+).*/\1/p' | \ - set version [string]; - - if ("$version" == "") - exit "unable to obtain PostgreSQL server version" - end; - - sed -n -e 's/(.+)\..+/\1/p' <"$version" | set major_version [uint64]; - sed -n -e 's/.+\.(.+)/\1/p' <"$version" | set minor_version [uint64]; - - if (($major_version == 7 && minor_version >= 4) || $major_version > 7) - if $multi - $* # Noop. - else - $* >>>../pgsql-output - end - end -} diff --git a/common/callback/buildfile b/common/callback/buildfile deleted file mode 100644 index 2ecc3b8..0000000 --- a/common/callback/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/callback/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix callback_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/callback/driver.cxx b/common/callback/driver.cxx deleted file mode 100644 index 80513c6..0000000 --- a/common/callback/driver.cxx +++ /dev/null @@ -1,184 +0,0 @@ -// file : common/callback/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test database operation callbacks. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -const char* events[] = -{ - "pre_persist", - "post_persist", - "pre_load", - "post_load", - "pre_update", - "post_update", - "pre_erase", - "post_erase" -}; - -void object:: -db_callback (callback_event e, database& db) -{ - cout << " " << events[e] << " " << id_ << endl; - - // Test custom recursive loading. - // - if (e == callback_event::post_load && ref != 0) - { - robj = db.load (ref); - cout << " " << id_ << ' ' << ref << ' ' << robj->id_ << endl; - } -} - -void object:: -db_callback (callback_event e, database&) const -{ - cout << " " << events[e] << " " << id_ << " const" << endl; -} - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Persist. - // - cout << "persist" << endl; - { - object o1 (1, 1); - object const o2 (2, 2); - transaction t (db->begin ()); - db->persist (o1); - db->persist (&o2); - t.commit (); - } - cout << "***" << endl; - - // Load. - // - cout << "load" << endl; - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - object o2; - db->load (2, o2); - t.commit (); - } - cout << "***" << endl; - - // Query. - // - cout << "query" << endl; - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query ((query::id < 3) + "ORDER BY" + query::id)); - - for (result::iterator i (r.begin ()); i != r.end (); ++i) - { - if (i->id_ > 3) // Load. - break; - } - - t.commit (); - } - cout << "***" << endl; - - // Update. - // - cout << "update" << endl; - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - unique_ptr o2 (db->load (2)); - o1->data++; - o2->data++; - db->update (o1.get ()); - db->update (static_cast (*o2)); - t.commit (); - } - cout << "***" << endl; - - // Erase. - // - cout << "erase" << endl; - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - unique_ptr o2 (db->load (2)); - db->erase (static_cast (o1.get ())); - db->erase (*o2); - t.commit (); - } - cout << "***" << endl; - - // Delayed (recursive) load. - // - cout << "delayed load" << endl; - { - { - object o1 (1, 1); - object o2 (2, 2); - object o3 (3, 3); - object o4 (4, 4); - - o1.pobj = &o2; - o1.ref = 4; - - o2.pobj = &o3; - o2.ref = 4; - - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - db->persist (o4); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - object* o2 (o1->pobj); - - cout << o1->id_ << ' ' << o1->ref << ' ' << o1->robj->id_ << endl; - cout << o2->id_ << ' ' << o2->ref << ' ' << o2->robj->id_ << endl; - - delete o1->robj; - delete o2->robj; - - delete o2->pobj; - delete o2; - t.commit (); - } - } - cout << "***" << endl; - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/callback/test.hxx b/common/callback/test.hxx deleted file mode 100644 index bd30907..0000000 --- a/common/callback/test.hxx +++ /dev/null @@ -1,43 +0,0 @@ -// file : common/callback/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object callback(db_callback) -struct object -{ - object (unsigned long id, unsigned long d) - : id_ (id), data (d), pobj (0), robj (0), ref (0) - { - } - - object () - : id_ (0), pobj (0), robj (0) - { - } - - #pragma db id - unsigned long id_; - - unsigned long data; - - object* pobj; - - // Test custom recursive loading. - // - #pragma db transient - object* robj; - unsigned long ref; // Unless 0, reference to another object. - - void - db_callback (odb::callback_event, odb::database&); - - void - db_callback (odb::callback_event, odb::database&) const; -}; - -#endif // TEST_HXX diff --git a/common/callback/testscript b/common/callback/testscript deleted file mode 100644 index c7d03ee..0000000 --- a/common/callback/testscript +++ /dev/null @@ -1,100 +0,0 @@ -# file : common/callback/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -+cat <=output - persist - pre_persist 1 const - post_persist 1 const - pre_persist 2 const - post_persist 2 const - *** - load - pre_load 0 - post_load 1 - pre_load 0 - post_load 2 - *** - query - pre_load 0 - post_load 1 - pre_load 0 - post_load 2 - *** - update - pre_load 0 - post_load 1 - pre_load 0 - post_load 2 - pre_update 1 const - post_update 1 const - pre_update 2 const - post_update 2 const - *** - erase - pre_load 0 - post_load 1 - pre_load 0 - post_load 2 - pre_erase 1 const - post_erase 1 const - pre_erase 2 const - post_erase 2 const - *** - delayed load - pre_persist 1 const - post_persist 1 const - pre_persist 2 const - post_persist 2 const - pre_persist 3 const - post_persist 3 const - pre_persist 4 const - post_persist 4 const - pre_load 0 - pre_load 0 - pre_load 0 - post_load 3 - post_load 2 - pre_load 0 - post_load 4 - 2 4 4 - post_load 1 - pre_load 0 - post_load 4 - 1 4 4 - 1 4 4 - 2 4 4 - *** - EOI - -test.redirects += >>>../output - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/changelog/.gitignore b/common/changelog/.gitignore deleted file mode 100644 index 5352a2b..0000000 --- a/common/changelog/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Generate ODB options file. -# -odb.options diff --git a/common/changelog/add-column-mssql-diff.xml b/common/changelog/add-column-mssql-diff.xml deleted file mode 100644 index 4f9ba09..0000000 --- a/common/changelog/add-column-mssql-diff.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-column-mssql-patch.xml b/common/changelog/add-column-mssql-patch.xml deleted file mode 100644 index 4f396d9..0000000 --- a/common/changelog/add-column-mssql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-column-mysql-diff.xml b/common/changelog/add-column-mysql-diff.xml deleted file mode 100644 index 992306d..0000000 --- a/common/changelog/add-column-mysql-diff.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-column-mysql-patch.xml b/common/changelog/add-column-mysql-patch.xml deleted file mode 100644 index 14f3f01..0000000 --- a/common/changelog/add-column-mysql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-column-oracle-diff.xml b/common/changelog/add-column-oracle-diff.xml deleted file mode 100644 index fa1dac6..0000000 --- a/common/changelog/add-column-oracle-diff.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-column-oracle-patch.xml b/common/changelog/add-column-oracle-patch.xml deleted file mode 100644 index 38fb8d6..0000000 --- a/common/changelog/add-column-oracle-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-column-pgsql-diff.xml b/common/changelog/add-column-pgsql-diff.xml deleted file mode 100644 index 9524d9d..0000000 --- a/common/changelog/add-column-pgsql-diff.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-column-pgsql-patch.xml b/common/changelog/add-column-pgsql-patch.xml deleted file mode 100644 index 7f7d9a0..0000000 --- a/common/changelog/add-column-pgsql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-column-sqlite-diff.xml b/common/changelog/add-column-sqlite-diff.xml deleted file mode 100644 index b59cc72..0000000 --- a/common/changelog/add-column-sqlite-diff.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-column-sqlite-patch.xml b/common/changelog/add-column-sqlite-patch.xml deleted file mode 100644 index fbe4428..0000000 --- a/common/changelog/add-column-sqlite-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-column.hxx b/common/changelog/add-column.hxx deleted file mode 100644 index 54eab42..0000000 --- a/common/changelog/add-column.hxx +++ /dev/null @@ -1,20 +0,0 @@ -// file : common/changelog/add-column.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ADD_COLUMN_HXX -#define ADD_COLUMN_HXX - -#pragma db model version(BVER, CVER, open) - -#pragma db object -struct object -{ - #pragma db id auto - int id; - -#if CVER > 1 - int num; -#endif -}; - -#endif // ADD_COLUMN_HXX diff --git a/common/changelog/add-foreign-key-diff.xml b/common/changelog/add-foreign-key-diff.xml deleted file mode 100644 index d4f29ad..0000000 --- a/common/changelog/add-foreign-key-diff.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/add-foreign-key-mssql-diff.xml b/common/changelog/add-foreign-key-mssql-diff.xml deleted file mode 100644 index 76ebce3..0000000 --- a/common/changelog/add-foreign-key-mssql-diff.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/add-foreign-key-mssql-patch.xml b/common/changelog/add-foreign-key-mssql-patch.xml deleted file mode 100644 index 6d75709..0000000 --- a/common/changelog/add-foreign-key-mssql-patch.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/add-foreign-key-mysql-diff.xml b/common/changelog/add-foreign-key-mysql-diff.xml deleted file mode 100644 index acdfd5b..0000000 --- a/common/changelog/add-foreign-key-mysql-diff.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/add-foreign-key-mysql-patch.xml b/common/changelog/add-foreign-key-mysql-patch.xml deleted file mode 100644 index adc9081..0000000 --- a/common/changelog/add-foreign-key-mysql-patch.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/add-foreign-key-oracle-diff.xml b/common/changelog/add-foreign-key-oracle-diff.xml deleted file mode 100644 index 6bd8bc3..0000000 --- a/common/changelog/add-foreign-key-oracle-diff.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/add-foreign-key-oracle-patch.xml b/common/changelog/add-foreign-key-oracle-patch.xml deleted file mode 100644 index 7aa01ea..0000000 --- a/common/changelog/add-foreign-key-oracle-patch.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/add-foreign-key-pgsql-diff.xml b/common/changelog/add-foreign-key-pgsql-diff.xml deleted file mode 100644 index 793b009..0000000 --- a/common/changelog/add-foreign-key-pgsql-diff.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/add-foreign-key-pgsql-patch.xml b/common/changelog/add-foreign-key-pgsql-patch.xml deleted file mode 100644 index a256831..0000000 --- a/common/changelog/add-foreign-key-pgsql-patch.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/add-foreign-key-sqlite-diff.xml b/common/changelog/add-foreign-key-sqlite-diff.xml deleted file mode 100644 index 1510470..0000000 --- a/common/changelog/add-foreign-key-sqlite-diff.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/add-foreign-key-sqlite-patch.xml b/common/changelog/add-foreign-key-sqlite-patch.xml deleted file mode 100644 index 1c2d0ea..0000000 --- a/common/changelog/add-foreign-key-sqlite-patch.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/add-foreign-key.hxx b/common/changelog/add-foreign-key.hxx deleted file mode 100644 index 2a43eea..0000000 --- a/common/changelog/add-foreign-key.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// file : common/changelog/add-foreign-key.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ADD_FOREIGN_KEY_HXX -#define ADD_FOREIGN_KEY_HXX - -#pragma db model version(BVER, CVER, open) - -struct object1; - -#pragma db object -struct object -{ - #pragma db id auto - int id; - -#if CVER > 1 - object1* o1; -#endif -}; - -#pragma db object -struct object1 -{ - #pragma db id - int id; -}; - -#endif // ADD_FOREIGN_KEY_HXX diff --git a/common/changelog/add-index-mssql-diff.xml b/common/changelog/add-index-mssql-diff.xml deleted file mode 100644 index 58c623f..0000000 --- a/common/changelog/add-index-mssql-diff.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-index-mssql-patch.xml b/common/changelog/add-index-mssql-patch.xml deleted file mode 100644 index 2b10e65..0000000 --- a/common/changelog/add-index-mssql-patch.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-index-mysql-diff.xml b/common/changelog/add-index-mysql-diff.xml deleted file mode 100644 index a54a7e3..0000000 --- a/common/changelog/add-index-mysql-diff.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-index-mysql-patch.xml b/common/changelog/add-index-mysql-patch.xml deleted file mode 100644 index a2454b8..0000000 --- a/common/changelog/add-index-mysql-patch.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-index-oracle-diff.xml b/common/changelog/add-index-oracle-diff.xml deleted file mode 100644 index 80f8ecc..0000000 --- a/common/changelog/add-index-oracle-diff.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-index-oracle-patch.xml b/common/changelog/add-index-oracle-patch.xml deleted file mode 100644 index a9bafea..0000000 --- a/common/changelog/add-index-oracle-patch.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-index-pgsql-diff.xml b/common/changelog/add-index-pgsql-diff.xml deleted file mode 100644 index 3988643..0000000 --- a/common/changelog/add-index-pgsql-diff.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-index-pgsql-patch.xml b/common/changelog/add-index-pgsql-patch.xml deleted file mode 100644 index e9c564c..0000000 --- a/common/changelog/add-index-pgsql-patch.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-index-sqlite-diff.xml b/common/changelog/add-index-sqlite-diff.xml deleted file mode 100644 index c1f7fdc..0000000 --- a/common/changelog/add-index-sqlite-diff.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-index-sqlite-patch.xml b/common/changelog/add-index-sqlite-patch.xml deleted file mode 100644 index b9512e0..0000000 --- a/common/changelog/add-index-sqlite-patch.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-index.hxx b/common/changelog/add-index.hxx deleted file mode 100644 index 645cee2..0000000 --- a/common/changelog/add-index.hxx +++ /dev/null @@ -1,24 +0,0 @@ -// file : common/changelog/add-index.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ADD_INDEX_HXX -#define ADD_INDEX_HXX - -#pragma db model version(BVER, CVER, open) - -#pragma db object -struct object -{ - #pragma db id auto - int id; - - int x; - -#if CVER > 1 - int y; - #pragma db index ("xy_i") unique member(x) member(y, "DESC") -#endif - -}; - -#endif // ADD_INDEX_HXX diff --git a/common/changelog/add-table-mssql-diff.xml b/common/changelog/add-table-mssql-diff.xml deleted file mode 100644 index 8bf0e30..0000000 --- a/common/changelog/add-table-mssql-diff.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-table-mssql-patch.xml b/common/changelog/add-table-mssql-patch.xml deleted file mode 100644 index 9dd41f3..0000000 --- a/common/changelog/add-table-mssql-patch.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-table-mysql-diff.xml b/common/changelog/add-table-mysql-diff.xml deleted file mode 100644 index 57f741b..0000000 --- a/common/changelog/add-table-mysql-diff.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-table-mysql-patch.xml b/common/changelog/add-table-mysql-patch.xml deleted file mode 100644 index 0db1e9f..0000000 --- a/common/changelog/add-table-mysql-patch.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-table-oracle-diff.xml b/common/changelog/add-table-oracle-diff.xml deleted file mode 100644 index 70ec7c6..0000000 --- a/common/changelog/add-table-oracle-diff.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-table-oracle-patch.xml b/common/changelog/add-table-oracle-patch.xml deleted file mode 100644 index 969c2e0..0000000 --- a/common/changelog/add-table-oracle-patch.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-table-pgsql-diff.xml b/common/changelog/add-table-pgsql-diff.xml deleted file mode 100644 index 9b48062..0000000 --- a/common/changelog/add-table-pgsql-diff.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-table-pgsql-patch.xml b/common/changelog/add-table-pgsql-patch.xml deleted file mode 100644 index b04a933..0000000 --- a/common/changelog/add-table-pgsql-patch.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-table-sqlite-diff.xml b/common/changelog/add-table-sqlite-diff.xml deleted file mode 100644 index 573bc69..0000000 --- a/common/changelog/add-table-sqlite-diff.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-table-sqlite-patch.xml b/common/changelog/add-table-sqlite-patch.xml deleted file mode 100644 index 3506410..0000000 --- a/common/changelog/add-table-sqlite-patch.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/add-table.hxx b/common/changelog/add-table.hxx deleted file mode 100644 index a22e206..0000000 --- a/common/changelog/add-table.hxx +++ /dev/null @@ -1,34 +0,0 @@ -// file : common/changelog/add-table.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ADD_TABLE_HXX -#define ADD_TABLE_HXX - -#include - -#pragma db model version(BVER, CVER, open) - -struct object1; - -#if CVER > 1 -#pragma db object -struct object -{ - #pragma db id auto - int id; - int num; - - std::vector nums; - object1* o1; -}; -#endif - -#pragma db object -struct object1 -{ - #pragma db id - int id; - int num; -}; - -#endif // ADD_TABLE_HXX diff --git a/common/changelog/alter-column-mssql-diff.xml b/common/changelog/alter-column-mssql-diff.xml deleted file mode 100644 index 6c1fb6a..0000000 --- a/common/changelog/alter-column-mssql-diff.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/alter-column-mssql-patch.xml b/common/changelog/alter-column-mssql-patch.xml deleted file mode 100644 index 15db347..0000000 --- a/common/changelog/alter-column-mssql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/alter-column-mysql-diff.xml b/common/changelog/alter-column-mysql-diff.xml deleted file mode 100644 index 39ad6ef..0000000 --- a/common/changelog/alter-column-mysql-diff.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/alter-column-mysql-patch.xml b/common/changelog/alter-column-mysql-patch.xml deleted file mode 100644 index 0131466..0000000 --- a/common/changelog/alter-column-mysql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/alter-column-oracle-diff.xml b/common/changelog/alter-column-oracle-diff.xml deleted file mode 100644 index d41d333..0000000 --- a/common/changelog/alter-column-oracle-diff.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/alter-column-oracle-patch.xml b/common/changelog/alter-column-oracle-patch.xml deleted file mode 100644 index 0e0794d..0000000 --- a/common/changelog/alter-column-oracle-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/alter-column-pgsql-diff.xml b/common/changelog/alter-column-pgsql-diff.xml deleted file mode 100644 index fd97fa0..0000000 --- a/common/changelog/alter-column-pgsql-diff.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/alter-column-pgsql-patch.xml b/common/changelog/alter-column-pgsql-patch.xml deleted file mode 100644 index dade1a3..0000000 --- a/common/changelog/alter-column-pgsql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/alter-column-sqlite-diff.xml b/common/changelog/alter-column-sqlite-diff.xml deleted file mode 100644 index 7ecea06..0000000 --- a/common/changelog/alter-column-sqlite-diff.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/alter-column-sqlite-patch.xml b/common/changelog/alter-column-sqlite-patch.xml deleted file mode 100644 index de2762e..0000000 --- a/common/changelog/alter-column-sqlite-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/alter-column.hxx b/common/changelog/alter-column.hxx deleted file mode 100644 index 02f091d..0000000 --- a/common/changelog/alter-column.hxx +++ /dev/null @@ -1,21 +0,0 @@ -// file : common/changelog/alter-column.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef ALTER_COLUMN_HXX -#define ALTER_COLUMN_HXX - -#pragma db model version(BVER, CVER, open) - -#pragma db object -struct object -{ - #pragma db id auto - int id; - -#if CVER > 1 - #pragma db null -#endif - int num; -}; - -#endif // ALTER_COLUMN_HXX diff --git a/common/changelog/buildfile b/common/changelog/buildfile deleted file mode 100644 index 04e0685..0000000 --- a/common/changelog/buildfile +++ /dev/null @@ -1,30 +0,0 @@ -# file : common/changelog/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -./: file{odb.options} xml{*} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the below ad hoc recipe. -# -libue{test-meta}: $libodb - -file{odb.options}: libue{test-meta} -{{ - pops = $cxx.lib_poptions($<[0]) - depdb hash $pops - - f = $path($>[0]) - rm -f $f - - for o: $pops - echo $o >+$f - end -}} - -# Testscript's run-time prerequisites. -# -testscript@./: test = $odb - -./: $odb: clean = false diff --git a/common/changelog/drop-column-mssql-diff.xml b/common/changelog/drop-column-mssql-diff.xml deleted file mode 100644 index f2bab96..0000000 --- a/common/changelog/drop-column-mssql-diff.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-column-mssql-patch.xml b/common/changelog/drop-column-mssql-patch.xml deleted file mode 100644 index 32402a3..0000000 --- a/common/changelog/drop-column-mssql-patch.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-column-mysql-diff.xml b/common/changelog/drop-column-mysql-diff.xml deleted file mode 100644 index 2bb321d..0000000 --- a/common/changelog/drop-column-mysql-diff.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-column-mysql-patch.xml b/common/changelog/drop-column-mysql-patch.xml deleted file mode 100644 index 6572ebe..0000000 --- a/common/changelog/drop-column-mysql-patch.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-column-oracle-diff.xml b/common/changelog/drop-column-oracle-diff.xml deleted file mode 100644 index e920a12..0000000 --- a/common/changelog/drop-column-oracle-diff.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-column-oracle-patch.xml b/common/changelog/drop-column-oracle-patch.xml deleted file mode 100644 index b113664..0000000 --- a/common/changelog/drop-column-oracle-patch.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-column-pgsql-diff.xml b/common/changelog/drop-column-pgsql-diff.xml deleted file mode 100644 index d2e91ba..0000000 --- a/common/changelog/drop-column-pgsql-diff.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-column-pgsql-patch.xml b/common/changelog/drop-column-pgsql-patch.xml deleted file mode 100644 index 06cc73d..0000000 --- a/common/changelog/drop-column-pgsql-patch.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-column-sqlite-diff.xml b/common/changelog/drop-column-sqlite-diff.xml deleted file mode 100644 index 1c9d138..0000000 --- a/common/changelog/drop-column-sqlite-diff.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-column-sqlite-patch.xml b/common/changelog/drop-column-sqlite-patch.xml deleted file mode 100644 index 6887530..0000000 --- a/common/changelog/drop-column-sqlite-patch.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-column.hxx b/common/changelog/drop-column.hxx deleted file mode 100644 index 3de237d..0000000 --- a/common/changelog/drop-column.hxx +++ /dev/null @@ -1,20 +0,0 @@ -// file : common/changelog/drop-column.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef DROP_COLUMN_HXX -#define DROP_COLUMN_HXX - -#pragma db model version(BVER, CVER, open) - -#pragma db object -struct object -{ - #pragma db id auto - int id; - -#if CVER == 1 - int num; -#endif -}; - -#endif // DROP_COLUMN_HXX diff --git a/common/changelog/drop-foreign-key-mssql-diff.xml b/common/changelog/drop-foreign-key-mssql-diff.xml deleted file mode 100644 index da3ce73..0000000 --- a/common/changelog/drop-foreign-key-mssql-diff.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/drop-foreign-key-mssql-patch.xml b/common/changelog/drop-foreign-key-mssql-patch.xml deleted file mode 100644 index cd1a372..0000000 --- a/common/changelog/drop-foreign-key-mssql-patch.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/drop-foreign-key-mysql-diff.xml b/common/changelog/drop-foreign-key-mysql-diff.xml deleted file mode 100644 index aa179f2..0000000 --- a/common/changelog/drop-foreign-key-mysql-diff.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/drop-foreign-key-mysql-patch.xml b/common/changelog/drop-foreign-key-mysql-patch.xml deleted file mode 100644 index 67f026e..0000000 --- a/common/changelog/drop-foreign-key-mysql-patch.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/drop-foreign-key-oracle-diff.xml b/common/changelog/drop-foreign-key-oracle-diff.xml deleted file mode 100644 index aa407d3..0000000 --- a/common/changelog/drop-foreign-key-oracle-diff.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/drop-foreign-key-oracle-patch.xml b/common/changelog/drop-foreign-key-oracle-patch.xml deleted file mode 100644 index 56253f0..0000000 --- a/common/changelog/drop-foreign-key-oracle-patch.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/drop-foreign-key-pgsql-diff.xml b/common/changelog/drop-foreign-key-pgsql-diff.xml deleted file mode 100644 index 9a6259a..0000000 --- a/common/changelog/drop-foreign-key-pgsql-diff.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/drop-foreign-key-pgsql-patch.xml b/common/changelog/drop-foreign-key-pgsql-patch.xml deleted file mode 100644 index df024b4..0000000 --- a/common/changelog/drop-foreign-key-pgsql-patch.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/drop-foreign-key-sqlite-diff.xml b/common/changelog/drop-foreign-key-sqlite-diff.xml deleted file mode 100644 index 6f9f994..0000000 --- a/common/changelog/drop-foreign-key-sqlite-diff.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/drop-foreign-key-sqlite-patch.xml b/common/changelog/drop-foreign-key-sqlite-patch.xml deleted file mode 100644 index 6e63218..0000000 --- a/common/changelog/drop-foreign-key-sqlite-patch.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - -
- - - - - -
-
-
diff --git a/common/changelog/drop-foreign-key.hxx b/common/changelog/drop-foreign-key.hxx deleted file mode 100644 index ba3005f..0000000 --- a/common/changelog/drop-foreign-key.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// file : common/changelog/drop-foreign-key.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef DROP_FOREIGN_KEY_HXX -#define DROP_FOREIGN_KEY_HXX - -#pragma db model version(BVER, CVER, open) - -struct object1; - -#pragma db object -struct object -{ - #pragma db id auto - int id; - -#if CVER == 1 - object1* o1; -#endif -}; - -#pragma db object -struct object1 -{ - #pragma db id - int id; -}; - -#endif // DROP_FOREIGN_KEY_HXX diff --git a/common/changelog/drop-index-mssql-diff.xml b/common/changelog/drop-index-mssql-diff.xml deleted file mode 100644 index ac95db5..0000000 --- a/common/changelog/drop-index-mssql-diff.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-index-mssql-patch.xml b/common/changelog/drop-index-mssql-patch.xml deleted file mode 100644 index 4f396d9..0000000 --- a/common/changelog/drop-index-mssql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-index-mysql-diff.xml b/common/changelog/drop-index-mysql-diff.xml deleted file mode 100644 index f8c95ef..0000000 --- a/common/changelog/drop-index-mysql-diff.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-index-mysql-patch.xml b/common/changelog/drop-index-mysql-patch.xml deleted file mode 100644 index 14f3f01..0000000 --- a/common/changelog/drop-index-mysql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-index-oracle-diff.xml b/common/changelog/drop-index-oracle-diff.xml deleted file mode 100644 index d174802..0000000 --- a/common/changelog/drop-index-oracle-diff.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-index-oracle-patch.xml b/common/changelog/drop-index-oracle-patch.xml deleted file mode 100644 index 38fb8d6..0000000 --- a/common/changelog/drop-index-oracle-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-index-pgsql-diff.xml b/common/changelog/drop-index-pgsql-diff.xml deleted file mode 100644 index 375a3d8..0000000 --- a/common/changelog/drop-index-pgsql-diff.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-index-pgsql-patch.xml b/common/changelog/drop-index-pgsql-patch.xml deleted file mode 100644 index 7f7d9a0..0000000 --- a/common/changelog/drop-index-pgsql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-index-sqlite-diff.xml b/common/changelog/drop-index-sqlite-diff.xml deleted file mode 100644 index bf54f9d..0000000 --- a/common/changelog/drop-index-sqlite-diff.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-index-sqlite-patch.xml b/common/changelog/drop-index-sqlite-patch.xml deleted file mode 100644 index fbe4428..0000000 --- a/common/changelog/drop-index-sqlite-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-index.hxx b/common/changelog/drop-index.hxx deleted file mode 100644 index 08fecba..0000000 --- a/common/changelog/drop-index.hxx +++ /dev/null @@ -1,21 +0,0 @@ -// file : common/changelog/drop-index.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef DROP_INDEX_HXX -#define DROP_INDEX_HXX - -#pragma db model version(BVER, CVER, open) - -#pragma db object -struct object -{ - #pragma db id auto - int id; - -#if CVER == 1 - #pragma db index -#endif - int num; -}; - -#endif // DROP_INDEX_HXX diff --git a/common/changelog/drop-table-mssql-diff.xml b/common/changelog/drop-table-mssql-diff.xml deleted file mode 100644 index 399d8bc..0000000 --- a/common/changelog/drop-table-mssql-diff.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - -
-
-
diff --git a/common/changelog/drop-table-mssql-patch.xml b/common/changelog/drop-table-mssql-patch.xml deleted file mode 100644 index c5dda75..0000000 --- a/common/changelog/drop-table-mssql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-table-mysql-diff.xml b/common/changelog/drop-table-mysql-diff.xml deleted file mode 100644 index 3ccd553..0000000 --- a/common/changelog/drop-table-mysql-diff.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - -
-
-
diff --git a/common/changelog/drop-table-mysql-patch.xml b/common/changelog/drop-table-mysql-patch.xml deleted file mode 100644 index 250bd20..0000000 --- a/common/changelog/drop-table-mysql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-table-oracle-diff.xml b/common/changelog/drop-table-oracle-diff.xml deleted file mode 100644 index 589d64b..0000000 --- a/common/changelog/drop-table-oracle-diff.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - -
-
-
diff --git a/common/changelog/drop-table-oracle-patch.xml b/common/changelog/drop-table-oracle-patch.xml deleted file mode 100644 index 5f222dc..0000000 --- a/common/changelog/drop-table-oracle-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-table-pgsql-diff.xml b/common/changelog/drop-table-pgsql-diff.xml deleted file mode 100644 index 168ec46..0000000 --- a/common/changelog/drop-table-pgsql-diff.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - -
-
-
diff --git a/common/changelog/drop-table-pgsql-patch.xml b/common/changelog/drop-table-pgsql-patch.xml deleted file mode 100644 index ebb7000..0000000 --- a/common/changelog/drop-table-pgsql-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-table-sqlite-diff.xml b/common/changelog/drop-table-sqlite-diff.xml deleted file mode 100644 index 6a258c4..0000000 --- a/common/changelog/drop-table-sqlite-diff.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - -
-
-
diff --git a/common/changelog/drop-table-sqlite-patch.xml b/common/changelog/drop-table-sqlite-patch.xml deleted file mode 100644 index 45c6f00..0000000 --- a/common/changelog/drop-table-sqlite-patch.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - -
-
-
diff --git a/common/changelog/drop-table.hxx b/common/changelog/drop-table.hxx deleted file mode 100644 index 2919e52..0000000 --- a/common/changelog/drop-table.hxx +++ /dev/null @@ -1,34 +0,0 @@ -// file : common/changelog/drop-table.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef DROP_TABLE_HXX -#define DROP_TABLE_HXX - -#include - -#pragma db model version(BVER, CVER, open) - -struct object1; - -#if CVER == 1 -#pragma db object -struct object -{ - #pragma db id auto - int id; - int num; - - std::vector nums; - object1* o1; -}; -#endif - -#pragma db object -struct object1 -{ - #pragma db id - int id; - int num; -}; - -#endif // DROP_TABLE_HXX diff --git a/common/changelog/model-mssql-diff.xml b/common/changelog/model-mssql-diff.xml deleted file mode 120000 index e1f812d..0000000 --- a/common/changelog/model-mssql-diff.xml +++ /dev/null @@ -1 +0,0 @@ -model-mssql.xml \ No newline at end of file diff --git a/common/changelog/model-mssql-patch.xml b/common/changelog/model-mssql-patch.xml deleted file mode 120000 index e1f812d..0000000 --- a/common/changelog/model-mssql-patch.xml +++ /dev/null @@ -1 +0,0 @@ -model-mssql.xml \ No newline at end of file diff --git a/common/changelog/model-mssql.xml b/common/changelog/model-mssql.xml deleted file mode 100644 index 509a210..0000000 --- a/common/changelog/model-mssql.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - -
-
-
diff --git a/common/changelog/model-mysql-diff.xml b/common/changelog/model-mysql-diff.xml deleted file mode 120000 index 9100280..0000000 --- a/common/changelog/model-mysql-diff.xml +++ /dev/null @@ -1 +0,0 @@ -model-mysql.xml \ No newline at end of file diff --git a/common/changelog/model-mysql-patch.xml b/common/changelog/model-mysql-patch.xml deleted file mode 120000 index 9100280..0000000 --- a/common/changelog/model-mysql-patch.xml +++ /dev/null @@ -1 +0,0 @@ -model-mysql.xml \ No newline at end of file diff --git a/common/changelog/model-mysql.xml b/common/changelog/model-mysql.xml deleted file mode 100644 index ffbcf8d..0000000 --- a/common/changelog/model-mysql.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - -
-
-
diff --git a/common/changelog/model-oracle-diff.xml b/common/changelog/model-oracle-diff.xml deleted file mode 120000 index 36e4479..0000000 --- a/common/changelog/model-oracle-diff.xml +++ /dev/null @@ -1 +0,0 @@ -model-oracle.xml \ No newline at end of file diff --git a/common/changelog/model-oracle-patch.xml b/common/changelog/model-oracle-patch.xml deleted file mode 120000 index 36e4479..0000000 --- a/common/changelog/model-oracle-patch.xml +++ /dev/null @@ -1 +0,0 @@ -model-oracle.xml \ No newline at end of file diff --git a/common/changelog/model-oracle.xml b/common/changelog/model-oracle.xml deleted file mode 100644 index 1824690..0000000 --- a/common/changelog/model-oracle.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - -
-
-
diff --git a/common/changelog/model-pgsql-diff.xml b/common/changelog/model-pgsql-diff.xml deleted file mode 120000 index b39ce26..0000000 --- a/common/changelog/model-pgsql-diff.xml +++ /dev/null @@ -1 +0,0 @@ -model-pgsql.xml \ No newline at end of file diff --git a/common/changelog/model-pgsql-patch.xml b/common/changelog/model-pgsql-patch.xml deleted file mode 120000 index b39ce26..0000000 --- a/common/changelog/model-pgsql-patch.xml +++ /dev/null @@ -1 +0,0 @@ -model-pgsql.xml \ No newline at end of file diff --git a/common/changelog/model-pgsql.xml b/common/changelog/model-pgsql.xml deleted file mode 100644 index 13aee6b..0000000 --- a/common/changelog/model-pgsql.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - -
-
-
diff --git a/common/changelog/model-sqlite-diff.xml b/common/changelog/model-sqlite-diff.xml deleted file mode 120000 index 3454f51..0000000 --- a/common/changelog/model-sqlite-diff.xml +++ /dev/null @@ -1 +0,0 @@ -model-sqlite.xml \ No newline at end of file diff --git a/common/changelog/model-sqlite-patch.xml b/common/changelog/model-sqlite-patch.xml deleted file mode 120000 index 3454f51..0000000 --- a/common/changelog/model-sqlite-patch.xml +++ /dev/null @@ -1 +0,0 @@ -model-sqlite.xml \ No newline at end of file diff --git a/common/changelog/model-sqlite.xml b/common/changelog/model-sqlite.xml deleted file mode 100644 index d0199ed..0000000 --- a/common/changelog/model-sqlite.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - -
-
-
diff --git a/common/changelog/model.hxx b/common/changelog/model.hxx deleted file mode 100644 index aa8891a..0000000 --- a/common/changelog/model.hxx +++ /dev/null @@ -1,46 +0,0 @@ -// file : common/changelog/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_HXX -#define MODEL_HXX - -#include - -#pragma db model version(1, 1, open) - -#pragma db value -struct value -{ - int x; - int y; -}; - -struct object1; - -#pragma db object -struct object -{ - #pragma db id auto - int id; - - #pragma db null default(0) options("DUMMY=1") - int num; - - #pragma db index unique member(num, "DESC") method("BTREE") options("DUMMY=1") - - #pragma db index - value v; // Multi-column. - - std::vector nums; - object1* o1; -}; - -#pragma db object -struct object1 -{ - #pragma db id - value id; // Multi-column. - int num; -}; - -#endif // MODEL_HXX diff --git a/common/changelog/testscript b/common/changelog/testscript deleted file mode 100644 index 9368938..0000000 --- a/common/changelog/testscript +++ /dev/null @@ -1,66 +0,0 @@ -# file : common/changelog/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -headers = [paths] $path_search($src_base/*.hxx) - -odb_options = --generate-schema-only \ - --schema-format sql \ - --suppress-migration \ - --options-file $out_base/odb.options - -: mysql -: -if $mysql -{ - odb_options += --database 'mysql' --changelog-dir $~ - - for h: $headers - n = $base($leaf($h)) - - $* $odb_options -DBVER=1 -DCVER=1 --init-changelog $h &$(n).xml &$(n).sql - - $* $odb_options -DBVER=1 -DCVER=2 $h - diff $src_base/$n-mysql-diff.xml $(n).xml - - $* $odb_options -DBVER=2 -DCVER=3 $h - diff $src_base/$n-mysql-patch.xml $(n).xml - end -} - -: sqlite -: -if $sqlite -{ - odb_options += --database 'sqlite' --changelog-dir $~ - - for h: $headers - n = $base($leaf($h)) - - $* $odb_options -DBVER=1 -DCVER=1 --init-changelog $h &$(n).xml &$(n).sql - - $* $odb_options -DBVER=1 -DCVER=2 $h - diff $src_base/$n-sqlite-diff.xml $(n).xml - - $* $odb_options -DBVER=2 -DCVER=3 $h - diff $src_base/$n-sqlite-patch.xml $(n).xml - end -} - -: pgsql -: -if $pgsql -{ - odb_options += --database 'pgsql' --changelog-dir $~ - - for h: $headers - n = $base($leaf($h)) - - $* $odb_options -DBVER=1 -DCVER=1 --init-changelog $h &$(n).xml &$(n).sql - - $* $odb_options -DBVER=1 -DCVER=2 $h - diff $src_base/$n-pgsql-diff.xml $(n).xml - - $* $odb_options -DBVER=2 -DCVER=3 $h - diff $src_base/$n-pgsql-patch.xml $(n).xml - end -} diff --git a/common/circular/multiple/.gitignore b/common/circular/multiple/.gitignore deleted file mode 100644 index 5d39d39..0000000 --- a/common/circular/multiple/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# ODB-generated files. -# -test1-odb.?xx -test1-odb-*.?xx -test2-odb.?xx -test2-odb-*.?xx diff --git a/common/circular/multiple/buildfile b/common/circular/multiple/buildfile deleted file mode 100644 index b060cb5..0000000 --- a/common/circular/multiple/buildfile +++ /dev/null @@ -1,49 +0,0 @@ -# file : common/circular/multiple/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -hs = test1 test2 - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -for h: $hs -{ - exe{driver}: {hxx ixx cxx}{$h-odb} - - <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} - - for db: $databases - { - exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi - <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} - } -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix circular_m_ \ - --generate-schema \ - --generate-query \ - --schema-format embedded - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/circular/multiple/driver.cxx b/common/circular/multiple/driver.cxx deleted file mode 100644 index 4887ac2..0000000 --- a/common/circular/multiple/driver.cxx +++ /dev/null @@ -1,69 +0,0 @@ -// file : common/circular/multiple/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test cases of circular dependencies between persistent classes, multiple -// files version. -// - -#include // std::unique_ptr -#include - -#include -#include -#include -#include - -#include - -#include "test1.hxx" -#include "test2.hxx" - -#include "test2-odb.hxx" -#include "test1-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv, false)); - - // Create the database schema. - // - { - connection_ptr c (db->connection ()); - - // Temporarily disable foreign key constraints for MySQL and SQLite. - // For these databases this is the only way to drop circularly- - // dependant tables. - // - if (db->id () == odb::id_mysql) - c->execute ("SET FOREIGN_KEY_CHECKS=0"); - else if (db->id () == odb::id_sqlite) - c->execute ("PRAGMA foreign_keys=OFF"); - - transaction t (c->begin ()); - schema_catalog::create_schema (*db); - t.commit (); - - if (db->id () == odb::id_mysql) - c->execute ("SET FOREIGN_KEY_CHECKS=1"); - else if (db->id () == odb::id_sqlite) - c->execute ("PRAGMA foreign_keys=ON"); - } - - query bq (query::d->id != 0); - query dq (query::b->id != 0); - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/circular/multiple/test1.hxx b/common/circular/multiple/test1.hxx deleted file mode 100644 index 36df963..0000000 --- a/common/circular/multiple/test1.hxx +++ /dev/null @@ -1,27 +0,0 @@ -// file : common/circular/multiple/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#include - -#pragma db object -struct derived; - -#pragma db object polymorphic -struct base -{ - virtual ~base () {} - - #pragma db id - unsigned long id_; - - derived* d_; -}; - -#ifdef ODB_COMPILER -# include "test2.hxx" -#endif - -#endif // TEST1_HXX diff --git a/common/circular/multiple/test2.hxx b/common/circular/multiple/test2.hxx deleted file mode 100644 index 49e9ed2..0000000 --- a/common/circular/multiple/test2.hxx +++ /dev/null @@ -1,17 +0,0 @@ -// file : common/circular/multiple/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#include - -#include "test1.hxx" - -#pragma db object -struct derived: base -{ - base* b_; -}; - -#endif // TEST2_HXX diff --git a/common/circular/multiple/testscript b/common/circular/multiple/testscript deleted file mode 100644 index 6a05dc6..0000000 --- a/common/circular/multiple/testscript +++ /dev/null @@ -1,31 +0,0 @@ -# file : common/circular/multiple/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $* -} diff --git a/common/circular/single/buildfile b/common/circular/single/buildfile deleted file mode 100644 index 740ce91..0000000 --- a/common/circular/single/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/circular/single/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix circular_s_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/circular/single/driver.cxx b/common/circular/single/driver.cxx deleted file mode 100644 index 9bcb135..0000000 --- a/common/circular/single/driver.cxx +++ /dev/null @@ -1,40 +0,0 @@ -// file : common/circular/single/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test cases of circular dependencies between persistent classes, single -// file version. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - query bq (query::d->id != 0); - query dq (query::b->id != 0); - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/circular/single/test.hxx b/common/circular/single/test.hxx deleted file mode 100644 index 7f95dea..0000000 --- a/common/circular/single/test.hxx +++ /dev/null @@ -1,28 +0,0 @@ -// file : common/circular/single/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -struct derived; - -#pragma db object polymorphic -struct base -{ - virtual ~base () {} - - #pragma db id - unsigned long id_; - - derived* d_; -}; - -#pragma db object -struct derived: base -{ - base* b_; -}; - -#endif // TEST_HXX diff --git a/common/circular/single/testscript b/common/circular/single/testscript deleted file mode 100644 index b870306..0000000 --- a/common/circular/single/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/circular/single/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/composite/buildfile b/common/composite/buildfile deleted file mode 100644 index 0a60638..0000000 --- a/common/composite/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/composite/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_comp_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/composite/driver.cxx b/common/composite/driver.cxx deleted file mode 100644 index 06b24b2..0000000 --- a/common/composite/driver.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// file : common/composite/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test composite value types. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -#undef NDEBUG -#include - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test basic composite functionality. - // - for (unsigned short i (0); i < 2; ++i) - { - using namespace test1; - - person p (1); - p.name_.first = "Joe"; - p.name_.last = "Dirt"; - p.name_.title = "Mr"; - p.name_.alias.first = "Anthony"; - p.name_.alias.last = "Clean"; - p.name_.nick = "Squeaky"; - p.name_.flags.nick = true; - p.name_.flags.alias = false; - p.age_ = 32; - - // persist - // - { - transaction t (db->begin ()); - db->persist (p); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (1)); - t.commit (); - - assert (p == *p1); - } - - p.name_.title = "Mrs"; - p.name_.alias.first = "Anthonia"; - p.name_.flags.nick = false; - p.name_.flags.alias = true; - - // update - // - { - transaction t (db->begin ()); - db->update (p); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (1)); - t.commit (); - - assert (p == *p1); - } - - typedef odb::query query; - typedef odb::result result; - - // query - // - { - transaction t (db->begin ()); - - result r (db->query (query::name.first == "Joe")); - - assert (!r.empty ()); - assert (*r.begin () == p); - assert (size (r) == 1); - - t.commit (); - } - - // query - // - { - transaction t (db->begin ()); - - result r (db->query (query::name.flags.alias)); - - assert (!r.empty ()); - assert (*r.begin () == p); - assert (size (r) == 1); - - t.commit (); - } - - // erase - // - if (i == 0) - { - transaction t (db->begin ()); - db->erase (1); - t.commit (); - } - } - - // Test composite class template instantiation. - // - { - using namespace test2; - - object o (1); - - o.comp_.num = 123; - o.comp_.str = "abc"; - o.comp_.vec.push_back (int_str_pair (123, "abc")); - o.comp_.vec.push_back (int_str_pair (234, "bcd")); - o.comp_.vec.push_back (int_str_pair (345, "cde")); - - o.pair_.first = 123; - o.pair_.second = "abc"; - - o.vec_.push_back (int_str_pair (123, "abc")); - o.vec_.push_back (int_str_pair (234, "bcd")); - o.vec_.push_back (int_str_pair (345, "cde")); - - // persist - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - } - - // Test empty column name. - // - { - using namespace test3; - - object o (1); - o.c_.str = "abc"; - - // persist - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - } - - // Test composite definition inside object. - { - using namespace test4; - - object o (1); - o.str ("abc"); - o.x (123); - o.y (234); - - // persist - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/composite/test.hxx b/common/composite/test.hxx deleted file mode 100644 index 13b2025..0000000 --- a/common/composite/test.hxx +++ /dev/null @@ -1,250 +0,0 @@ -// file : common/composite/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include // std::pair - -#include - -// Test basic composite functionality. -// -#pragma db namespace table("t1_") -namespace test1 -{ - #pragma db value - struct name - { - std::string first; - std::string last; - }; - - #pragma db value - struct name_title - { - std::string title; - }; - - #pragma db value - struct name_title_ex: name_title - { - // Test value types without data members. - }; - - #pragma db value - struct name_flags - { - bool nick; - bool alias; - }; - - #pragma db value - struct name_ex: name, name_title_ex - { - name alias; - std::string nick; - - #pragma db column("show_") - name_flags flags; - }; - - #pragma db object - struct person - { - person () {} - person (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db column("") - name_ex name_; - - unsigned short age_; - }; - - inline bool - operator== (const person& x, const person& y) - { - return x.id_ == y.id_ && - x.name_.first == y.name_.first&& - x.name_.last == y.name_.last && - x.name_.title == y.name_.title && - x.name_.alias.first == y.name_.alias.first && - x.name_.alias.last == y.name_.alias.last && - x.name_.nick == y.name_.nick && - x.name_.flags.nick == y.name_.flags.nick && - x.name_.flags.alias == y.name_.flags.alias && - x.age_ == y.age_; - } -} - -// Test composite class template instantiation. -// -#pragma db namespace table("t2_") -namespace test2 -{ - template - struct comp - { - I num; - S str; - std::vector > vec; - }; - - template - inline bool - operator== (const comp& x, const comp& y) - { - return x.num == y.num && x.str == y.str && x.vec == y.vec; - } - - typedef std::pair int_str_pair; - #pragma db value(int_str_pair) - - // Make sure we use the name that was specified in the pragma. - // -#ifdef ODB_COMPILER - typedef comp int_str_comp1; -#endif - - typedef comp int_str_comp; - #pragma db value(int_str_comp) - - #pragma db object - struct object - { - object () {} - object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - comp comp_; - std::pair pair_; - std::vector vec_; - }; - - inline bool - operator== (const object& x, const object& y) - { - return x.id_ == y.id_ && - x.comp_ == y.comp_ && - x.pair_ == y.pair_ && - x.vec_ == y.vec_; - } -} - -// Test empty column name. -// -#pragma db namespace table("t3_") -namespace test3 -{ - #pragma db value - struct comp - { - #pragma db column("") - std::string str; - }; - - #pragma db object - struct object - { - object () {} - object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - comp c_; - }; - - inline bool - operator== (const object& x, const object& y) - { - return x.id_ == y.id_ && x.c_.str == y.c_.str; - } -} - -// Test composite definition inside object. -// -#pragma db namespace table("t4_") -namespace test4 -{ - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - unsigned long id () const {return id_;} - - void str (const std::string& s) {c_.str = s;} - const std::string& str () const {return c_.str;} - - void x (int i) {p_.first = i;} - int x () const {return p_.first;} - - void y (int i) {p_.second = i;} - int y () const {return p_.second;} - - private: - friend class odb::access; - - #pragma db id - unsigned long id_; - - #pragma db value - struct comp - { - std::string str; - }; - - comp c_; - - typedef std::pair int_pair; - #pragma db value(int_pair) - - int_pair p_; - }; - - inline bool - operator== (const object& x, const object& y) - { - return x.id () == y.id () && x.str () == y.str () && - x.x () == y.x () && x.y () == y.y (); - } -} - -// Test composite name clashes in query columns (compilation test) -// -#pragma db namespace table("t5_") -namespace test5 -{ - // Class-member conflict. - // - #pragma db value - struct value {int value_;}; - - // Class-class conflict. - // - #pragma db value - struct inner {int value;}; - - #pragma db value - struct outer {inner value;}; - - #pragma db object - struct object - { - #pragma db id - int id; - - outer value; - test5::value v; - }; -} - -#endif // TEST_HXX diff --git a/common/composite/testscript b/common/composite/testscript deleted file mode 100644 index 0747507..0000000 --- a/common/composite/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/composite/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/const-member/buildfile b/common/const-member/buildfile deleted file mode 100644 index 868f7fd..0000000 --- a/common/const-member/buildfile +++ /dev/null @@ -1,40 +0,0 @@ -# file : common/const-member/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix constm_ \ - --generate-schema - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/const-member/driver.cxx b/common/const-member/driver.cxx deleted file mode 100644 index 0c71dfa..0000000 --- a/common/const-member/driver.cxx +++ /dev/null @@ -1,119 +0,0 @@ -// file : common/const-member/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test const data members. The readonly test tests that const -// members are automatically treated as read-only. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Const ids. - // - { - const_id o (1); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - db->load (1, o); - t.commit (); - assert (o.id == 1); - } - } - - { - { - const_auto_id o; - transaction t (db->begin ()); - db->persist (o); - t.commit (); - assert (o.id == 1); - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (1)); - t.commit (); - assert (o->id == 1); - } - } - - // Container. - // - { - container o (1, 1); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (1)); - t.commit (); - - assert (o->ccom.vec.size () == 1 && o->ccom.vec[0] == 1 && - o->ccom.cvec.size () == 1 && o->ccom.cvec[0] == 1 && - o->cvec.size () == 1 && o->cvec[0] == 1); - } - } - - // Wrapper. - // - { - wrapper o (1, "abc", 1); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (1)); - t.commit (); - - assert (*o->str == "abc" && - o->com->str == "abc" && o->com->num == 1 && - o->com->vec.size () == 1 && o->com->vec[0] == 1 && - o->vec->size () == 1 && (*o->vec)[0] == 1); - } - } - - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/const-member/test.hxx b/common/const-member/test.hxx deleted file mode 100644 index ab75c55..0000000 --- a/common/const-member/test.hxx +++ /dev/null @@ -1,109 +0,0 @@ -// file : common/const-member/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include // std::auto_ptr - -#include - -// Const ids. -// -#pragma db object -struct const_id -{ - const_id (unsigned long i): id (i) {} - const_id (): id (0) {} - - #pragma db id - const unsigned long id; -}; - -#pragma db object -struct const_auto_id -{ - const_auto_id (): id (0) {} - - #pragma db id auto - const unsigned long id; -}; - -// Container. -// -#pragma db value -struct container_value -{ - container_value (unsigned long x) - { - vec.push_back (x); - const_cast&> (cvec).push_back (x); - } - - container_value () {} - - std::vector vec; - const std::vector cvec; -}; - -#pragma db object -struct container -{ - container (unsigned long i, unsigned long x) - : id (i), ccom (x) - { - const_cast&> (cvec).push_back (x); - } - - container () {} - - #pragma db id - unsigned long id; - - const container_value ccom; - const std::vector cvec; -}; - -// Wrapper. -// -#pragma db value -struct wrapped_value -{ - wrapped_value (const std::string& s, unsigned long n) - : str (s), num (n) - { - vec.push_back (n); - } - - wrapped_value () {} - - const std::string str; - unsigned long num; - std::vector vec; -}; - -#pragma db object -struct wrapper -{ - wrapper (unsigned long i, const std::string& s, unsigned long n) - : id (i), - str (new std::string (s)), - com (new wrapped_value (s, n)), - vec (new std::vector) - { - const_cast&> (*vec).push_back (n); - } - - wrapper () {} - - #pragma db id - unsigned long id; - - const std::unique_ptr str; - const std::unique_ptr com; - const std::unique_ptr> vec; -}; - -#endif // TEST_HXX diff --git a/common/const-member/testscript b/common/const-member/testscript deleted file mode 100644 index c81d856..0000000 --- a/common/const-member/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/const-member/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/const-object/buildfile b/common/const-object/buildfile deleted file mode 100644 index 853c831..0000000 --- a/common/const-object/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/const-object/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix consto_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/const-object/driver.cxx b/common/const-object/driver.cxx deleted file mode 100644 index 7ef48ee..0000000 --- a/common/const-object/driver.cxx +++ /dev/null @@ -1,216 +0,0 @@ -// file : common/const-object/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test database operations with const objects. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - aggr a (1); - aggr ca_ (2); // o1 and o2 are NULL - const aggr& ca (ca_); - - obj1* o1 (new obj1 (1)); - obj1* co1_ (new obj1 (2)); - const obj1* co1 (co1_); - a.o1 = co1; - - unique_ptr o2 (new obj2 (1)); - obj2* co2_ (new obj2 (2)); - a.o2.reset (co2_); - unique_ptr& co2 (a.o2); - - // persist via references - // - { - transaction t (db->begin ()); - db->persist (*o1); - db->persist (*co1); - db->persist (*o2); - db->persist (*co2); - db->persist (a); - db->persist (ca); - t.commit (); - } - - // persist via pointers - // - o1->id += 2; - co1_->id += 2; - o2->id += 2; - co2_->id += 2; - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (co1); - db->persist (o2); - db->persist (co2); - t.commit (); - } - - // load & compare - // - { - transaction t (db->begin ()); - - unique_ptr a (db->load (1)); - unique_ptr ca (db->load (2)); - - t.commit (); - - assert (a->o1->id == 2); - assert (a->o2->id == 2); - - assert (ca->o1 == 0); - assert (ca->o2.get () == 0); - } - - // update via references - // - { - transaction t (db->begin ()); - db->update (*o1); - db->update (*co1); - db->update (*o2); - db->update (*co2); - db->update (a); - db->update (ca); - t.commit (); - } - - // update via pointers - // - { - transaction t (db->begin ()); - db->update (o1); - db->update (co1); - db->update (o2); - db->update (co2); - t.commit (); - } - - // query - // - typedef odb::query query1; - typedef odb::query query2; - - typedef odb::result result1; - typedef odb::result result2; - - { - transaction t (db->begin ()); - result1 r1 (db->query (query1::id < 3)); - // odb::result ur (r1); // error - size_t n1 (0); - - for (result1::iterator i (r1.begin ()); i != r1.end (); ++i) - { - // i->f (); // error - i->cf (); - // obj1* p (i.load ()); // error - const obj1* p (i.load ()); - obj1 o (0); - i.load (o); - assert (p->id == o.id); - delete p; - n1++; - } - - assert (n1 == 2); - - result2 r2 (db->query (query2::id < 3)); - size_t n2 (0); - - for (result2::iterator i (r2.begin ()); i != r2.end (); ++i) - { - // i->f (); // error - i->cf (); - //unique_ptr p (i.load ()); // error - unique_ptr p (i.load ()); - obj2 o (0); - i.load (o); - assert (p->id == o.id); - n2++; - } - - assert (n2 == 2); - - t.commit (); - } - - // erase via references - // - { - transaction t (db->begin ()); - db->erase (*o1); - db->erase (*co1); - db->erase (*o2); - db->erase (*co2); - db->erase (a); - db->erase (ca); - t.commit (); - } - - // erase via pointers - // - o1->id -= 2; - co1_->id -= 2; - o2->id -= 2; - co2_->id -= 2; - - { - transaction t (db->begin ()); - db->erase (o1); - db->erase (co1); - db->erase (o2); - db->erase (co2); - t.commit (); - } - - // Test session and const/non-const object handling - // - { - session s; - transaction t (db->begin ()); - - obj1 o1 (1); - const obj1& co1 (o1); - db->persist (co1); - - assert (db->load (1) == &o1); - - t.commit (); - } - - delete o1; - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/const-object/test.hxx b/common/const-object/test.hxx deleted file mode 100644 index 4e66231..0000000 --- a/common/const-object/test.hxx +++ /dev/null @@ -1,51 +0,0 @@ -// file : common/const-object/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object pointer (obj1*) session -struct obj1 -{ - obj1 () {} - obj1 (int i): id (i) {} - - #pragma db id - int id; - - void f () {} - void cf () const {} -}; - -#pragma db object pointer (std::unique_ptr) -struct obj2 -{ - obj2 () {} - obj2 (int i): id (i) {} - - #pragma db id - int id; - - void f () {} - void cf () const {} -}; - -#pragma db object -struct aggr -{ - aggr (int i): id (i), o1 (0) {} - aggr (): o1 (0) {} - ~aggr () {delete o1;} - - #pragma db id - int id; - - const obj1* o1; - - std::unique_ptr o2; -}; - -#endif // TEST_HXX diff --git a/common/const-object/testscript b/common/const-object/testscript deleted file mode 100644 index 3885e96..0000000 --- a/common/const-object/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/const-object/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/container/basics/buildfile b/common/container/basics/buildfile deleted file mode 100644 index f83444e..0000000 --- a/common/container/basics/buildfile +++ /dev/null @@ -1,40 +0,0 @@ -# file : common/container/basics/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_cont_bs_ \ - --generate-schema - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/container/basics/driver.cxx b/common/container/basics/driver.cxx deleted file mode 100644 index 14e1984..0000000 --- a/common/container/basics/driver.cxx +++ /dev/null @@ -1,523 +0,0 @@ -// file : common/container/basics/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test basic container persistence. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - for (unsigned short i (0); i < 2; ++i) - { - object empty ("empty"), med ("medium"), full ("full"); - - // - // empty - // - - empty.num = 0; - empty.str = ""; - - // array - // - empty.na[0] = 123; - empty.na[1] = 234; - empty.na[2] = 345; - - empty.sa[0] = "aaa"; - empty.sa[1] = "bbbb"; - empty.sa[2] = "ccccc"; - - empty.ca[0] = comp (123, "aaa"); - empty.ca[1] = comp (234, "bbbb"); - empty.ca[2] = comp (345, "ccccc"); - - - // - // med - // - - med.num = 999; - med.str = "xxx"; - - // vector - // - med.nv.push_back (123); - med.nv.push_back (234); - - med.sv.push_back ("aaa"); - med.sv.push_back ("bbbb"); - - med.cv.push_back (comp (123, "aaa")); - med.cv.push_back (comp (234, "bbbb")); - - med.uv.push_back (123); - med.uv.push_back (234); - - // list - // - med.sl.push_back ("aaa"); - med.sl.push_back ("bbbb"); - - // deque - // - med.nd.push_back (123); - med.nd.push_back (234); - - // set - // - med.ns.insert (123); - med.ns.insert (234); - - med.ss.insert ("aaa"); - med.ss.insert ("bbbb"); - - med.cs.insert (comp (123, "aaa")); - med.cs.insert (comp (234, "bbbb")); - - // map - // - med.nsm[123] = "aaa"; - med.nsm[234] = "bbbb"; - - med.snm["aaa"] = 123; - med.snm["bbbb"] = 234; - - med.ncm[123] = comp (123, "aaa"); - med.ncm[234] = comp (234, "bbbb"); - - med.csm[comp (123, "aaa")] = "aaa"; - med.csm[comp (234, "bbbb")] = "bbbb"; - - // array - // - med.na[0] = 123; - med.na[1] = 234; - med.na[2] = 345; - - med.sa[0] = "aaa"; - med.sa[1] = "bbbb"; - med.sa[2] = "ccccc"; - - med.ca[0] = comp (123, "aaa"); - med.ca[1] = comp (234, "bbbb"); - med.ca[2] = comp (345, "ccccc"); - - // forward_list - // - med.nfl.push_front (234); - med.nfl.push_front (123); - - med.sfl.push_front ("bbbb"); - med.sfl.push_front ("aaa"); - - med.cfl.push_front (comp (234, "bbbb")); - med.cfl.push_front (comp (123, "aaa")); - - // unordered_set - // - med.nus.insert (123); - med.nus.insert (234); - - med.sus.insert ("aaa"); - med.sus.insert ("bbbb"); - - med.cus.insert (comp (123, "aaa")); - med.cus.insert (comp (234, "bbbb")); - - // unordered_map - // - med.nsum[123] = "aaa"; - med.nsum[234] = "bbbb"; - - med.snum["aaa"] = 123; - med.snum["bbbb"] = 234; - - med.ncum[123] = comp (123, "aaa"); - med.ncum[234] = comp (234, "bbbb"); - - med.csum[comp (123, "aaa")] = "aaa"; - med.csum[comp (234, "bbbb")] = "bbbb"; - - // - // full - // - - full.num = 9999; - full.str = "xxxx"; - - // vector - // - full.nv.push_back (1234); - full.nv.push_back (2345); - full.nv.push_back (3456); - - full.sv.push_back ("aaaa"); - full.sv.push_back ("bbbbb"); - full.sv.push_back ("cccccc"); - - full.cv.push_back (comp (1234, "aaaa")); - full.cv.push_back (comp (2345, "bbbbb")); - full.cv.push_back (comp (3456, "cccccc")); - - full.uv.push_back (1234); - full.uv.push_back (2345); - full.uv.push_back (3456); - - // list - // - full.sl.push_back ("aaaa"); - full.sl.push_back ("bbbbb"); - full.sl.push_back ("cccccc"); - - // deque - // - full.nd.push_back (1234); - full.nd.push_back (2345); - full.nd.push_back (3456); - - // set - // - full.ns.insert (1234); - full.ns.insert (2345); - full.ns.insert (3456); - - full.ss.insert ("aaaa"); - full.ss.insert ("bbbbb"); - full.ss.insert ("cccccc"); - - full.cs.insert (comp (1234, "aaaa")); - full.cs.insert (comp (2345, "bbbbb")); - full.cs.insert (comp (3456, "cccccc")); - - // map - // - full.nsm[1234] = "aaaa"; - full.nsm[2345] = "bbbbb"; - full.nsm[3456] = "cccccc"; - - full.snm["aaaa"] = 1234; - full.snm["bbbbb"] = 2345; - full.snm["cccccc"] = 3456; - - full.ncm[1234] = comp (1234, "aaaa"); - full.ncm[2345] = comp (2345, "bbbbb"); - full.ncm[3456] = comp (3456, "cccccc"); - - full.csm[comp (1234, "aaaa")] = "aaaa"; - full.csm[comp (2345, "bbbbb")] = "bbbbb"; - full.csm[comp (3456, "cccccc")] = "cccccc"; - - // array - // - full.na[0] = 123; - full.na[1] = 234; - full.na[2] = 345; - - full.sa[0] = "aaa"; - full.sa[1] = "bbbb"; - full.sa[2] = "ccccc"; - - full.ca[0] = comp (123, "aaa"); - full.ca[1] = comp (234, "bbbb"); - full.ca[2] = comp (345, "ccccc"); - - // forward_list - // - full.nfl.push_front (345); - full.nfl.push_front (234); - full.nfl.push_front (123); - - full.sfl.push_front ("ccccc"); - full.sfl.push_front ("bbbb"); - full.sfl.push_front ("aaa"); - - full.cfl.push_front (comp (345, "ccccc")); - full.cfl.push_front (comp (234, "bbbb")); - full.cfl.push_front (comp (123, "aaa")); - - // unordered_set - // - full.nus.insert (1234); - full.nus.insert (2345); - full.nus.insert (3456); - - full.sus.insert ("aaaa"); - full.sus.insert ("bbbbb"); - full.sus.insert ("cccccc"); - - full.cus.insert (comp (1234, "aaaa")); - full.cus.insert (comp (2345, "bbbbb")); - full.cus.insert (comp (3456, "cccccc")); - - // unordered_map - // - full.nsum[1234] = "aaaa"; - full.nsum[2345] = "bbbbb"; - full.nsum[3456] = "cccccc"; - - full.snum["aaaa"] = 1234; - full.snum["bbbbb"] = 2345; - full.snum["cccccc"] = 3456; - - full.ncum[1234] = comp (1234, "aaaa"); - full.ncum[2345] = comp (2345, "bbbbb"); - full.ncum[3456] = comp (3456, "cccccc"); - - full.csum[comp (1234, "aaaa")] = "aaaa"; - full.csum[comp (2345, "bbbbb")] = "bbbbb"; - full.csum[comp (3456, "cccccc")] = "cccccc"; - - // persist - // - { - transaction t (db->begin ()); - db->persist (empty); - db->persist (med); - db->persist (full); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - unique_ptr e (db->load ("empty")); - unique_ptr m (db->load ("medium")); - unique_ptr f (db->load ("full")); - t.commit (); - - assert (empty == *e); - assert (med == *m); - assert (full == *f); - } - - // - // empty - // - - empty.num = 99; - empty.str = "xx"; - - empty.nv.push_back (12); - empty.sv.push_back ("aa"); - empty.cv.push_back (comp (12, "aa")); - empty.uv.push_back (12); - empty.sl.push_back ("aa"); - empty.nd.push_back (12); - - empty.ns.insert (12); - empty.ss.insert ("aa"); - empty.cs.insert (comp (12, "aa")); - - empty.nsm[12] = "aa"; - empty.snm["aa"] = 12; - empty.ncm[12] = comp (12, "aa"); - empty.csm[comp (12, "aa")] = "aa"; - - empty.nfl.push_front (12); - empty.sfl.push_front ("aa"); - empty.cfl.push_front (comp (12, "aa")); - - empty.nus.insert (12); - empty.sus.insert ("aa"); - empty.cus.insert (comp (12, "aa")); - - empty.nsum[12] = "aa"; - empty.snum["aa"] = 12; - empty.ncum[12] = comp (12, "aa"); - empty.csum[comp (12, "aa")] = "aa"; - - // - // med - // - - med.num = 0; - med.str = ""; - - med.nv.clear (); - med.sv.clear (); - med.cv.clear (); - med.uv.clear (); - - med.sl.clear (); - - med.nd.clear (); - - med.ns.clear (); - med.ss.clear (); - med.cs.clear (); - - med.nsm.clear (); - med.snm.clear (); - med.ncm.clear (); - med.csm.clear (); - - med.nfl.clear (); - med.sfl.clear (); - med.cfl.clear (); - - med.nus.clear (); - med.sus.clear (); - med.cus.clear (); - - med.nsum.clear (); - med.snum.clear (); - med.ncum.clear (); - med.csum.clear (); - - // - // full - // - - full.num++; - full.str += "x"; - - // vector - // - full.nv.back ()++; - full.nv.push_back (4567); - - full.sv.back () += "c"; - full.sv.push_back ("ddddddd"); - - full.cv.back ().num++; - full.cv.back ().str += "c"; - full.cv.push_back (comp (4567, "ddddddd")); - - full.uv.back ()++; - full.uv.push_back (4567); - - // list - // - full.sl.back () += "c"; - full.sl.push_back ("ddddddd"); - - // deque - // - full.nd.push_front (456); - - // set - // - full.ns.insert (4567); - full.ss.insert ("ddddddd"); - full.cs.insert (comp (4567, "ddddddd")); - - // map - // - full.nsm[3456] += 'c'; - full.nsm[4567] = "ddddddd"; - - full.snm["cccccc"]++; - full.snm["ddddddd"] = 4567; - - full.ncm[3456].num++; - full.ncm[3456].str += 'c'; - full.ncm[4567] = comp (4567, "ddddddd"); - - full.csm[comp (3456, "cccccc")] += "c"; - full.csm[comp (4567, "ddddddd")] = "ddddddd"; - - // array - // - full.na[0]++; - full.sa[0] += 'a'; - full.ca[0].num++; - full.ca[0].str += 'a'; - - // forward_list - // - full.nfl.front ()++; - full.nfl.push_front (4567); - - full.sfl.front () += 'a'; - full.sfl.push_front ("ddddddd"); - - full.cfl.front ().num++; - full.cfl.front ().str += 'a'; - full.cfl.push_front (comp (4567, "ddddddd")); - - // unordered_set - // - full.nus.insert (4567); - full.sus.insert ("ddddddd1"); // 1 is to preserve order in VC++ 10. - full.cus.insert (comp (4567, "ddddddd1")); - - // unordered_map - // - full.nsum[3456] += 'c'; - full.nsum[4567] = "ddddddd"; - - full.snum["cccccc"]++; - full.snum["ddddddd1"] = 4567; - - full.ncum[3456].num++; - full.ncum[3456].str += 'c'; - full.ncum[4567] = comp (4567, "ddddddd"); - - full.csum[comp (3456, "cccccc")] += "c"; - full.csum[comp (4567, "ddddddd1")] = "ddddddd"; - - // update - // - { - transaction t (db->begin ()); - db->update (empty); - db->update (med); - db->update (full); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - unique_ptr e (db->load ("empty")); - unique_ptr m (db->load ("medium")); - unique_ptr f (db->load ("full")); - t.commit (); - - assert (empty == *e); - assert (med == *m); - assert (full == *f); - } - - // erase - // - if (i == 0) - { - transaction t (db->begin ()); - db->erase ("empty"); - db->erase ("medium"); - db->erase ("full"); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/container/basics/test.hxx b/common/container/basics/test.hxx deleted file mode 100644 index e8e329e..0000000 --- a/common/container/basics/test.hxx +++ /dev/null @@ -1,245 +0,0 @@ -// file : common/container/basics/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#pragma db value -struct comp -{ - comp () {} - comp (int n, const std::string& s) : num (n), str (s) {} - - #pragma db column("number") - int num = 0; - std::string str; -}; - -inline bool -operator== (const comp& x, const comp& y) -{ - return x.num == y.num && x.str == y.str; -} - -inline bool -operator!= (const comp& x, const comp& y) -{ - return !(x == y); -} - -inline bool -operator< (const comp& x, const comp& y) -{ - return x.num != y.num ? x.num < y.num : x.str < y.str; -} - -typedef std::list str_list; -typedef std::deque num_deque; - -typedef std::vector num_vector; -typedef std::vector str_vector; - -typedef std::set num_set; -typedef std::set str_set; -typedef std::set comp_set; - -typedef std::map num_str_map; -typedef std::map str_num_map; -typedef std::map num_comp_map; -typedef std::map comp_str_map; - -struct comp_hash -{ - std::size_t - operator() (const comp& x) const {return nh (x.num) + sh (x.str);} - - std::hash nh; - std::hash sh; -}; - -typedef std::array num_array; -typedef std::array str_array; -typedef std::array comp_array; - -typedef std::forward_list num_flist; -typedef std::forward_list str_flist; -typedef std::forward_list comp_flist; - -typedef std::unordered_set num_uset; -typedef std::unordered_set str_uset; -typedef std::unordered_set comp_uset; - -typedef std::unordered_map num_str_umap; -typedef std::unordered_map str_num_umap; -typedef std::unordered_map num_comp_umap; -typedef std::unordered_map comp_str_umap; - -#pragma db value -struct cont_comp1 -{ - // This composite value does not have any columns. - // - num_vector sv; // Have the name "conflic" with the one in the object. -}; - -#pragma db value -struct cont_comp2 -{ - cont_comp2 (): num (777), str ("ggg") {} - - int num; - str_list sl; - std::string str; -}; - -#pragma db object -struct object -{ - object (): nv (comp1_.sv), sl (comp2_.sl) {} - object (const std::string& id) : id_ (id), nv (comp1_.sv), sl (comp2_.sl) {} - - #pragma db id - std::string id_; - - int num; - - cont_comp1 comp1_; - cont_comp2 comp2_; - - // vector - // - #pragma db transient - num_vector& nv; - - #pragma db table("object_strings") id_column ("obj_id") - str_vector sv; - - #pragma db value_column("") - std::vector cv; - - #pragma db unordered - num_vector uv; - - // list - // - #pragma db transient - str_list& sl; - - // deque - // - num_deque nd; - - // set - // - num_set ns; - str_set ss; - comp_set cs; - - // map - // - num_str_map nsm; - str_num_map snm; - num_comp_map ncm; - comp_str_map csm; - - // array - // - num_array na; - str_array sa; - comp_array ca; - - // forward_list - // - num_flist nfl; - str_flist sfl; - comp_flist cfl; - - // unordered_set - // - num_uset nus; - str_uset sus; - comp_uset cus; - - // unordered_map - // - num_str_umap nsum; - str_num_umap snum; - num_comp_umap ncum; - comp_str_umap csum; - - std::string str; -}; - -inline bool -operator== (const object& x, const object& y) -{ - if (x.uv.size () != y.uv.size ()) - return false; - - int xs (0), ys (0); - - for (num_vector::size_type i (0); i < x.uv.size (); ++i) - { - xs += x.uv[i]; - ys += y.uv[i]; - } - - return - x.id_ == y.id_ && - x.num == y.num && - - x.comp2_.num == y.comp2_.num && - x.comp2_.str == y.comp2_.str && - - x.nv == y.nv && - x.sv == y.sv && - x.cv == y.cv && - xs == ys && - - x.sl == y.sl && - - x.nd == y.nd && - - x.ns == y.ns && - x.ss == y.ss && - x.cs == y.cs && - - x.nsm == y.nsm && - x.snm == y.snm && - x.ncm == y.ncm && - x.csm == y.csm && - - x.na == y.na && - x.sa == y.sa && - x.ca == y.ca && - - x.nfl == y.nfl && - x.sfl == y.sfl && - x.cfl == y.cfl && - - x.nus == y.nus && - x.sus == y.sus && - x.cus == y.cus && - - x.nsum == y.nsum && - x.snum == y.snum && - x.ncum == y.ncum && - x.csum == y.csum && - - x.str == y.str; -} - -#endif // TEST_HXX diff --git a/common/container/basics/testscript b/common/container/basics/testscript deleted file mode 100644 index ea99498..0000000 --- a/common/container/basics/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/container/basics/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/container/change-tracking/buildfile b/common/container/change-tracking/buildfile deleted file mode 100644 index 1dda818..0000000 --- a/common/container/change-tracking/buildfile +++ /dev/null @@ -1,40 +0,0 @@ -# file : common/container/change-tracking/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_cont_changet_ \ - --generate-schema - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/container/change-tracking/driver.cxx b/common/container/change-tracking/driver.cxx deleted file mode 100644 index 4894ed9..0000000 --- a/common/container/change-tracking/driver.cxx +++ /dev/null @@ -1,729 +0,0 @@ -// file : common/container/change-tracking/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test change-tracking containers. -// - -#include // std::unique_ptr -#include // std::move -#include - -#include -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -struct counting_tracer: odb::tracer -{ - void - reset (transaction& tr) {u = i = d = s = t = 0; tr.tracer (*this);} - - virtual void - execute (odb::connection&, const char* stmt) - { - string p (stmt, 6); - if (p == "UPDATE") - u++; - else if (p == "INSERT") - i++; - else if (p == "DELETE") - d++; - else if (p == "SELECT") - s++; - t++; - } - - size_t u, i, d, s, t; -}; - -static counting_tracer tr; - -// Compilation test: instantiate all the functions. In C++11 mode only -// do this if we have a fairly conforming compiler that implements the -// complete std::vector interface. -// - -#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC -#if defined (__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 7 -struct item {}; -template class odb::vector; -template class odb::vector_iterator, - std::vector::iterator>; -template class odb::vector_iterator, - std::vector::reverse_iterator>; -#endif -#endif - -void -f (const std::vector&) {} - -int -main (int argc, char* argv[]) -{ - try - { - // Test extended interface. - // - { - typedef odb::vector vector; - - vector ov; - std::vector sv; - f (ov); // Implicit conversion to std::vector. - vector ov1 (sv); // Initialization from std::vector. - ov = sv; // Assignement from std::vector. - - // Container comparison. - // - if (ov != ov1 || - ov != sv || - sv != ov1) - ov.clear (); - - // Iterator comparison/conversion. - // - vector::const_iterator i (ov.begin ()); - if (i != ov.end ()) - i = ov.end (); - - // Things are just really borken in Sun CC, no matter which STL - // you use. - // -#ifndef __SUNPRO_CC - vector::const_reverse_iterator j (ov.rbegin ()); - if (j != ov.rend ()) - j = ov.rend (); -#endif - } - - unique_ptr db (create_database (argc, argv)); - - // Test traits logic. - // - { - object o ("1"); - o.i = 123; - o.s.push_back ("a"); - - assert (!o.s._tracking ()); - - // persist - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - assert (o.s._tracking ()); - - // load - // - { - transaction t (db->begin ()); - unique_ptr p (db->load ("1")); - assert (p->s._tracking ()); - t.commit (); - } - - // update - // - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - assert (o.s._tracking ()); - - // erase - // - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - - assert (!o.s._tracking ()); - } - - // Test change tracking. - // - object o ("1"); - o.i = 123; - o.s.push_back ("a"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // push_back/pop_back - // - { - o.s.push_back ("b"); // insert - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.i == 1 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.pop_back (); - o.s.push_back ("c"); // update - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 2 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.pop_back (); - for (int i (0); i != 1024; ++i) - o.s.push_back ("x"); // realloc - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 2 && tr.i == 1023 && tr.t == 1025); - assert (*db->load ("1") == o); - t.commit (); - } - - { - for (int i (0); i != 1024; ++i) - o.s.pop_back (); // delete - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.d == 1 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.push_back ("b"); - o.s.pop_back (); // no-op - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.t == 1); - assert (*db->load ("1") == o); - t.commit (); - } - - // insert - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.insert (o.s.begin (), "a1"); // insert front - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 3 && tr.i == 1 && tr.t == 4); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.insert (o.s.begin () + 1, "a2"); // insert middle - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 3 && tr.i == 1 && tr.t == 4); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.insert (o.s.end (), "b1"); // insert back - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.i == 1 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - // erase - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - o.s.push_back ("d"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.erase (o.s.begin ()); // erase front - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 4 && tr.d == 1 && tr.t == 5); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.erase (o.s.begin () + 1); // erase middle - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 2 && tr.d == 1 && tr.t == 3); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.erase (o.s.end () - 1); // erase back - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.d == 1 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - // modify - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - o.s.push_back ("d"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.modify (1) += 'b'; - o.s.modify_at (2) += 'c'; - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 3 && tr.t == 3); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.modify_front () += 'a'; - o.s.modify_back () += 'd'; - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 3 && tr.t == 3); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.begin ().modify () += 'a'; -#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC - o.s.rbegin ().modify () += 'c'; -#endif - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); -#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC - assert (tr.u == 3 && tr.t == 3); -#else - assert (tr.u == 2 && tr.t == 2); -#endif - assert (*db->load ("1") == o); - t.commit (); - } - -#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC - { - (o.s.rbegin () + 1).modify (1) += 'a'; - (o.s.rbegin () + 1).modify (-1) += 'c'; - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 3 && tr.t == 3); - assert (*db->load ("1") == o); - t.commit (); - } -#endif - - { - o.s.mbegin (); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 5 && tr.t == 5); - assert (*db->load ("1") == o); - t.commit (); - } - - // clear - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.clear (); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.d == 1 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - // assign - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.assign (4, "x"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 4 && tr.i == 1 && tr.t == 5); - assert (*db->load ("1") == o); - t.commit (); - } - - // resize - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.pop_back (); - o.s.resize (4, "x"); // expand - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 2 && tr.i == 1 && tr.t == 3); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.push_back ("y"); - o.s.resize (3); // shrink - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.d == 1 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - // Transaction rollback. - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - { - o.s.push_back ("d"); - - transaction t (db->begin ()); - db->update (o); - t.rollback (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.i == 4 && tr.d == 1 && tr.t == 6); - t.commit (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.t == 1); - t.commit (); - } - } - - // Armed copy. - // - { - unique_ptr c; - - { - o.s.pop_back (); - - transaction t (db->begin ()); - db->update (o); - c.reset (new object (o)); - t.rollback (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.i == 3 && tr.d == 1 && tr.t == 5); - t.commit (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.t == 1); - t.commit (); - } - } - - // Armed swap. - // - { - object c (o); - - { - o.s.push_back ("d"); - - transaction t (db->begin ()); - db->update (o); - assert (o.s._tracking () && !c.s._tracking ()); - c.s.swap (o.s); - assert (!o.s._tracking () && c.s._tracking ()); - t.rollback (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.i == 4 && tr.d == 1 && tr.t == 6); - t.commit (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.t == 1); - t.commit (); - } - } - - // Armed move. - // - { - unique_ptr c; - - { - o.s.pop_back (); - - transaction t (db->begin ()); - db->update (o); - assert (o.s._tracking ()); - c.reset (new object (std::move (o))); - assert (!o.s._tracking () && c->s._tracking ()); - t.rollback (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.i == 2 && tr.d == 1 && tr.t == 4); - t.commit (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.t == 1); - t.commit (); - } - } - - // Test mixing "smart" and "dumb" container (specifically, erase(obj)). - // - { - mix_object o (1); - o.ov.assign (3, 123); - o.sv.assign (3, 123); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test using change tracking container as inverse member. - // - { - inv_object1 o1; - inv_object2 o2; - o1.o2 = &o2; - - { - transaction t (db->begin ()); - db->persist (o2); - db->persist (o1); - t.commit (); - } - - assert (!o2.o1._tracking ()); - - { - session s; - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id_)); - unique_ptr p2 (db->load (o2.id_)); - assert (p2->o1[0] == p1.get ()); - assert (!p2->o1._tracking ()); - t.commit (); - } - } - - // Test read-only values. - { - ro_object o (1); - o.v.push_back (ro_value (1, 1)); - o.v.push_back (ro_value (2, 2)); - o.v.push_back (ro_value (3, 3)); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - o.v.erase (o.v.begin ()); - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - assert (db->load (1)->v == o.v); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/container/change-tracking/test.hxx b/common/container/change-tracking/test.hxx deleted file mode 100644 index 8e06f4a..0000000 --- a/common/container/change-tracking/test.hxx +++ /dev/null @@ -1,106 +0,0 @@ -// file : common/container/change-tracking/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include -#include // std::move - -#include -#include - -#pragma db object pointer(std::unique_ptr) -struct object -{ - object () {} - object (const std::string& id): id_ (id) {} - - object (const object& x): id_ (x.id_), i (x.i), s (x.s) {} - object (object&& x): id_ (std::move (x.id_)), i (x.i), s (std::move (x.s)) {} - - #pragma db id - std::string id_; - - unsigned int i; - - odb::vector s; - - inline bool - operator== (const object& o) const {return id_ == o.id_ && i == o.i && s == o.s;} -}; - -// Test mixing "smart" and "dumb" container (specifically, erase(obj)). -// -#pragma db object -struct mix_object -{ - mix_object () {} - mix_object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - odb::vector ov; - std::vector sv; -}; - -// Test using change tracking container as inverse member. -// -struct inv_object2; - -#pragma db object session -struct inv_object1 -{ - #pragma db id auto - unsigned long id_; - - inv_object2* o2; -}; - -#pragma db object session -struct inv_object2 -{ - #pragma db id auto - unsigned long id_; - - #pragma db inverse(o2) - odb::vector o1; -}; - -// Test read-only values (we still need to include them in the UPDATE -// statement). -// -#pragma db value -struct ro_value -{ - ro_value (int i_ = 0, int j_ = 0): i (i_), j (j_) {} - - #pragma db readonly - int i; - - #pragma db readonly - int j; -}; - -inline bool -operator== (const ro_value& x, const ro_value& y) -{ - return x.i == y.i && x.j == y.j; -} - -#pragma db object -struct ro_object -{ - ro_object () {} - ro_object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - odb::vector v; -}; - -#endif // TEST_HXX diff --git a/common/container/change-tracking/testscript b/common/container/change-tracking/testscript deleted file mode 100644 index 2169869..0000000 --- a/common/container/change-tracking/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/container/change-tracking/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/ctor/buildfile b/common/ctor/buildfile deleted file mode 100644 index a9892bc..0000000 --- a/common/ctor/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/ctor/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix ctor_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/ctor/driver.cxx b/common/ctor/driver.cxx deleted file mode 100644 index c9b445d..0000000 --- a/common/ctor/driver.cxx +++ /dev/null @@ -1,79 +0,0 @@ -// file : common/ctor/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test support for persistent objects without default constructors. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - typedef odb::query query; - typedef odb::result result; - - unique_ptr db (create_database (argc, argv)); - - person p1 ("John", "Doe", 30); - person p2 ("Jane", "Doe", 29); - person p3 ("Joe", "Dirt", 31); - - { - transaction t (db->begin ()); - - db->persist (p1); - db->persist (p2); - db->persist (p3); - - t.commit (); - } - - { - person p ("", "", 0); - - transaction t (db->begin ()); - - db->load (p1.id_, p); - - assert (p.first_ == p1.first_); - assert (p.last_ == p1.last_); - assert (p.age_ == p1.age_); - - result r (db->query (query::age < 30)); - - assert (!r.empty ()); - - result::iterator i (r.begin ()); - i.load (p); - assert (p.first_ == "Jane"); - assert (p.last_ == "Doe"); - assert (p.age_ == 29); - - assert (size (r) == 1); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/ctor/test.hxx b/common/ctor/test.hxx deleted file mode 100644 index 2a2becd..0000000 --- a/common/ctor/test.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// file : common/ctor/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object -struct person -{ - person (const std::string& first, - const std::string& last, - unsigned short age) - : first_ (first), last_ (last), age_ (age) - { - } - - #pragma db id auto - unsigned long id_; - - std::string first_; - std::string last_; - unsigned short age_; -}; - -#endif // TEST_HXX diff --git a/common/ctor/testscript b/common/ctor/testscript deleted file mode 100644 index 8946ddb..0000000 --- a/common/ctor/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/ctor/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/default/buildfile b/common/default/buildfile deleted file mode 100644 index e25bd08..0000000 --- a/common/default/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/default/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix default_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/default/driver.cxx b/common/default/driver.cxx deleted file mode 100644 index 2d3ef01..0000000 --- a/common/default/driver.cxx +++ /dev/null @@ -1,81 +0,0 @@ -// file : common/default/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test default values. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Insert an object using an ad-hoc SQL statement. This way - // we get all the default values. - // - { - transaction t (db->begin ()); - - if (db->id () != odb::id_oracle) - db->execute ("INSERT INTO default_object (obj_id) VALUES (1)"); - else - db->execute ("INSERT INTO \"default_object\" (\"obj_id\") VALUES (1)"); - - t.commit (); - } - - // Now load the object and check all the values. - // - { - transaction t (db->begin ()); - unique_ptr o (db->load (1)); - t.commit (); - - assert (o->b); - assert (o->pi == 1234); - assert (o->ni == -1234); - assert (o->zi == 0); - assert (o->pf == 1.234); - assert (o->nf == -1.234); - assert (o->zf == 0.0); - assert (o->sf == 1.123e+10); - assert (o->str == "Someone's string"); - assert (o->e == green); - } - - // Check the NULL default value using a query. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::null.is_null ())); - assert (!r.empty ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/default/test.hxx b/common/default/test.hxx deleted file mode 100644 index 7f35ed4..0000000 --- a/common/default/test.hxx +++ /dev/null @@ -1,67 +0,0 @@ -// file : common/default/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -enum color {red, green, blue}; - -#pragma db value(unsigned long) default(0) - -#pragma db object -struct object -{ - #pragma db id - unsigned long obj_id; - - // NULL. - // - #pragma db null default(null) - unsigned long null; - - // Boolean. - // - #pragma db default(true) - bool b; - - // Integers. - // - #pragma db default(1234) - unsigned long pi; - - #pragma db default(-1234) - long ni; - - // 0 default taken from the type. - unsigned long zi; - - // Floats. - // - #pragma db default(1.234) - double pf; - - #pragma db default(-1.234) - double nf; - - #pragma db default(0.0) - double zf; - - #pragma db default(1.123e+10) - double sf; - - // Strings. MySQL doesn't support default values on TEXT - // columns, so make the type VARCHAR. - // - #pragma db type("VARCHAR(64)") default("Someone's string") - std::string str; - - // Enums. - // - #pragma db default(green) - color e; -}; - -#endif // TEST_HXX diff --git a/common/default/testscript b/common/default/testscript deleted file mode 100644 index f29cef4..0000000 --- a/common/default/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/default/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/definition/.gitignore b/common/definition/.gitignore deleted file mode 100644 index 5838670..0000000 --- a/common/definition/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# ODB-generated files. -# -time-mapping-odb.?xx -time-mapping-odb-*.?xx -time-mapping.sql -time-mapping-*.sql diff --git a/common/definition/buildfile b/common/definition/buildfile deleted file mode 100644 index 09ad1db..0000000 --- a/common/definition/buildfile +++ /dev/null @@ -1,52 +0,0 @@ -# file : common/definition/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -hs = test time-mapping - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -for h: $hs -{ - exe{driver}: {hxx ixx cxx}{$h-odb} - - <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} - - for db: $databases - { - exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi - <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} - } -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix definition_ \ - --generate-schema - -<{hxx ixx cxx}{time-mapping-odb}>: odb_options = - -for db: $databases - {hxx ixx cxx}{time-mapping-odb-$db}: odb_options = - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/definition/driver.cxx b/common/definition/driver.cxx deleted file mode 100644 index 223eeaf..0000000 --- a/common/definition/driver.cxx +++ /dev/null @@ -1,56 +0,0 @@ -// file : common/definition/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test overriding composite value definition point. This is primarily -// useful to make composite values out of third-party types. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - object o; - o.time.tv_sec = 1; - o.time.tv_usec = 1000; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - t.commit (); - - assert (p->time.tv_sec == o.time.tv_sec && - p->time.tv_usec == o.time.tv_usec); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/definition/test.hxx b/common/definition/test.hxx deleted file mode 100644 index 38fc02a..0000000 --- a/common/definition/test.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// file : common/definition/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#ifdef _WIN32 -# include // timeval -#else -# include // timeval -#endif - -#include - -#include "time-mapping.hxx" - -#pragma db object -struct object -{ - #pragma db id auto - unsigned long id; - - timeval time; -}; - -#endif // TEST_HXX diff --git a/common/definition/testscript b/common/definition/testscript deleted file mode 100644 index c9dea6d..0000000 --- a/common/definition/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/definition/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/definition/time-mapping.hxx b/common/definition/time-mapping.hxx deleted file mode 100644 index 469cfb7..0000000 --- a/common/definition/time-mapping.hxx +++ /dev/null @@ -1,17 +0,0 @@ -// file : common/definition/time-mapping.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TIME_MAPPING_HXX -#define TIME_MAPPING_HXX - -#ifdef _WIN32 -# include // timeval -#else -# include // timeval -#endif - -#pragma db value(timeval) definition -#pragma db member(timeval::tv_sec) column("sec") -#pragma db member(timeval::tv_usec) column("usec") - -#endif // TIME_MAPPING_HXX diff --git a/common/enum/buildfile b/common/enum/buildfile deleted file mode 100644 index eb3a29a..0000000 --- a/common/enum/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/enum/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix enum_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/enum/driver.cxx b/common/enum/driver.cxx deleted file mode 100644 index ed3eb59..0000000 --- a/common/enum/driver.cxx +++ /dev/null @@ -1,84 +0,0 @@ -// file : common/enum/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test automatic C++ enum mapping. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - typedef odb::query query; - typedef odb::result result; - - unique_ptr db (create_database (argc, argv)); - - object o; - o.color_ = green; - o.taste_ = object::sweet; - o.position_ = object::left; - - o.gender_ = object::gender::female; - o.scale_ = object::scale::ten; - o.yesno_ = object::yesno::yes; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (o.id_)); - t.commit (); - - assert (o == *o1); - } - - { - transaction t (db->begin ()); - - result r1 (db->query (query::color == blue)); - result r2 (db->query (query::taste == object::sweet)); - result r3 (db->query (query::position == object::left)); - - assert (r1.empty ()); - assert (!r2.empty ()); - assert (!r3.empty ()); - - result r4 (db->query (query::gender == object::gender::female)); - result r5 (db->query (query::scale == object::scale::ten)); - result r6 (db->query (query::yesno == object::yesno::yes)); - - assert (!r4.empty ()); - assert (!r5.empty ()); - assert (!r6.empty ()); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/enum/test.hxx b/common/enum/test.hxx deleted file mode 100644 index a279112..0000000 --- a/common/enum/test.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// file : common/enum/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -enum color {red, green, blue}; - -#pragma db object -struct object -{ - #pragma db id auto - unsigned long id_; - - color color_; - enum taste {bitter, sweet, sour}; - taste taste_; - - enum position {left = -1, center = 0, right = 1}; - position position_; - - - enum class gender {male, female}; - enum class scale: unsigned char {one = 1, ten = 10, hundred = 100}; - enum class yesno: bool {no, yes}; - - gender gender_; - scale scale_; - yesno yesno_; -}; - -inline bool -operator == (const object& x, const object& y) -{ - return - x.id_ == y.id_ - && x.color_ == y.color_ - && x.taste_ == y.taste_ - && x.position_ == y.position_ - && x.gender_ == y.gender_ - && x.scale_ == y.scale_ - && x.yesno_ == y.yesno_; -} - -#endif // TEST_HXX diff --git a/common/enum/testscript b/common/enum/testscript deleted file mode 100644 index d2ca28c..0000000 --- a/common/enum/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/enum/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/erase-query/buildfile b/common/erase-query/buildfile deleted file mode 100644 index d833b6e..0000000 --- a/common/erase-query/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/erase-query/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix erase_query_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/erase-query/driver.cxx b/common/erase-query/driver.cxx deleted file mode 100644 index 6c11957..0000000 --- a/common/erase-query/driver.cxx +++ /dev/null @@ -1,181 +0,0 @@ -// file : common/erase-query/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test query-based erase. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -void -persist (database& db) -{ - object o1 (1); - object o2 (2); - object o3 (3); - object o4 (4); - - transaction t (db.begin ()); - db.persist (o1); - db.persist (o2); - db.persist (o3); - db.persist (o4); - t.commit (); -} - -int -main (int argc, char* argv[]) -{ - try - { - typedef odb::query query; - - unique_ptr db (create_database (argc, argv)); - - // erase_query() - // - persist (*db); - - { - transaction t (db->begin ()); - assert (db->erase_query () == 4); - t.commit (); - } - - // erase_query(const char*) - // - persist (*db); - - { - transaction t (db->begin ()); - - if (db->id () != odb::id_oracle) - assert (db->erase_query ( - "erase_query_object.id < 3") == 2); - else - assert (db->erase_query ( - "\"erase_query_object\".\"id\" < 3") == 2); - - db->erase_query (); - t.commit (); - } - - // erase_query(query) - // - persist (*db); - - { - transaction t (db->begin ()); - assert (db->erase_query (query::id == 2 || query::id == 4) == 2); - db->erase_query (); - t.commit (); - } - - // Test predicates involving object pointers (DELETE JOIN). - // - /* - { - object o11 (1); - object o12 (2); - object o13 (3); - object2 o2; - - o11.o2 = &o2; - o2.num = 123; - - o12.o1 = &o13; - o13.num = 123; - - transaction t (db->begin ()); - db->persist (o2); - db->persist (o13); - db->persist (o12); - db->persist (o11); - t.commit (); - } - - { - transaction t (db->begin ()); - assert (db->erase_query (query::o1::num == 123) == 1); - assert (db->erase_query (query::o2::num == 123) == 1); - db->erase_query (); - t.commit (); - } - */ - - // For now we can only do column-based tests, like is_null(). - // - { - object o11 (1); - object o12 (2); - object o13 (3); - object2 o2; - - o12.o2 = &o2; - - transaction t (db->begin ()); - db->persist (o2); - db->persist (o13); - db->persist (o12); - db->persist (o11); - t.commit (); - } - - { - transaction t (db->begin ()); - assert (db->erase_query (query::o2.is_null ()) == 2); - db->erase_query (); - t.commit (); - } - - // Make sure container data is deleted. - // - { - object o (1); - o.v.push_back (1); - o.v.push_back (2); - o.v.push_back (3); - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - assert (db->erase_query () == 1); - t.commit (); - } - - { - transaction t (db->begin ()); - - if (db->id () != odb::id_oracle) - assert (db->execute ("SELECT * FROM erase_query_object_v " - "WHERE object_id = 1") == 0); - else - assert (db->execute ("SELECT * FROM \"erase_query_object_v\" " - "WHERE \"object_id\" = 1") == 0); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/erase-query/test.hxx b/common/erase-query/test.hxx deleted file mode 100644 index 9e73f12..0000000 --- a/common/erase-query/test.hxx +++ /dev/null @@ -1,46 +0,0 @@ -// file : common/erase-query/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -struct object2; - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id), o1 (0), o2 (0) - { - } - - object () - : o1 (0), o2 (0) - { - } - - #pragma db id - unsigned long id_; - - std::vector v; - - int num; - - object* o1; - object2* o2; -}; - -#pragma db object -struct object2 -{ - #pragma db id auto - unsigned long id_; - - int num; -}; - -#endif // TEST_HXX diff --git a/common/erase-query/testscript b/common/erase-query/testscript deleted file mode 100644 index 90862ab..0000000 --- a/common/erase-query/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/erase-query/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/id/auto/buildfile b/common/id/auto/buildfile deleted file mode 100644 index c340200..0000000 --- a/common/id/auto/buildfile +++ /dev/null @@ -1,40 +0,0 @@ -# file : common/id/auto/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_id_auto_ \ - --generate-schema - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/id/auto/driver.cxx b/common/id/auto/driver.cxx deleted file mode 100644 index d294e69..0000000 --- a/common/id/auto/driver.cxx +++ /dev/null @@ -1,96 +0,0 @@ -// file : common/id/auto/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test automatic id assignment. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // object - // - { - unsigned long id1, id2, id3; - { - object o1 ("one"); - object o2 ("two"); - object o3 ("three"); - - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - - id1 = o1.id_; - id2 = o2.id_; - id3 = o3.id_; - - assert (id1 != id2); - assert (id1 != id3); - assert (id2 != id3); - } - - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (id1)); - unique_ptr o2 (db->load (id2)); - unique_ptr o3 (db->load (id3)); - t.commit (); - - assert (o1->id_ == id1 && o1->str_ == "one"); - assert (o2->id_ == id2 && o2->str_ == "two"); - assert (o3->id_ == id3 && o3->str_ == "three"); - } - } - - // auto_only - // - { - unsigned short id; - { - auto_only o; - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - id = o.id_; - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (id)); - t.commit (); - - assert (o->id_ == id); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/id/auto/test.hxx b/common/id/auto/test.hxx deleted file mode 100644 index 233c79f..0000000 --- a/common/id/auto/test.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// file : common/id/auto/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object -struct object -{ - object (const std::string& str) - : id_ (1), str_ (str) - { - } - - #pragma db auto id - unsigned long id_; - std::string str_; - -private: - object () - { - } - - friend class odb::access; -}; - -// Test the case where the object has just the auto id. -// -#pragma db object -struct auto_only -{ - #pragma db auto id pgsql:type("BIGINT") - unsigned short id_; -}; - -#endif // TEST_HXX diff --git a/common/id/auto/testscript b/common/id/auto/testscript deleted file mode 100644 index bb2a3a4..0000000 --- a/common/id/auto/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/id/auto/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/id/composite/buildfile b/common/id/composite/buildfile deleted file mode 100644 index 4bc9f9a..0000000 --- a/common/id/composite/buildfile +++ /dev/null @@ -1,42 +0,0 @@ -# file : common/id/composite/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_id_comp_ \ - --generate-schema \ - --generate-query \ - --generate-session - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/id/composite/driver.cxx b/common/id/composite/driver.cxx deleted file mode 100644 index 3d66101..0000000 --- a/common/id/composite/driver.cxx +++ /dev/null @@ -1,731 +0,0 @@ -// file : common/id/composite/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test composite object ids. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test 1. - // - { - using namespace test1; - - object o1 (scomp ("aaa", "bbb", "ccc"), 123); - o1.vec.push_back (scomp ("xxx", "xxx", "xxx")); - o1.vec.push_back (scomp ("yyy", "yyy", "yyy")); - - object o2 (scomp ("aaa", "bbb", "ccd"), 234); - o2.vec.push_back (scomp ("zzz", "", "zzz")); - - object o3 (scomp ("baa", "bbb", "ccc"), 345); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - unique_ptr p3 (db->load (o3.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - assert (*p3 == o3); - } - - // Update. - // - { - transaction t (db->begin ()); - unique_ptr p (db->load (o1.id)); - p->num++; - db->update (*p); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o1.id)); - t.commit (); - - assert (p->num == o1.num + 1); - } - - // Erase. - // - { - transaction t (db->begin ()); - db->erase (o1.id); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->find (o1.id)); - assert (p.get () == 0); - t.commit (); - } - } - - // Test 2. - // - { - using namespace test2; - - object2 o2 (ncomp (2, 0, 1)); - o2.o1 = new object1 (scomp ("o1", "o2", "aaa")); - - object3 o3 (ncomp (3, 0, 1)); - o3.o1.push_back (new object1 (scomp ("o1", "o3", "aaa"))); - o3.o1.push_back (new object1 (scomp ("o1", "o3", "bbb"))); - - object4 o4 (ncomp (4, 0, 1)); - o4.c.o2 = new object2 (ncomp (2, 4, 1)); - o4.c.o2->o1 = new object1 (scomp ("o1", "o2", "ccc")); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o2.o1); - db->persist (o2); - db->persist (o3.o1[0]); - db->persist (o3.o1[1]); - db->persist (o3); - db->persist (o4.c.o2->o1); - db->persist (o4.c.o2); - db->persist (o4); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - unique_ptr p2 (db->load (o2.id)); - unique_ptr p3 (db->load (o3.id)); - unique_ptr p4 (db->load (o4.id)); - t.commit (); - - assert (p2->o1->id == o2.o1->id); - assert (p3->o1.size () == o3.o1.size ()); - assert (p3->o1[0]->id == o3.o1[0]->id); - assert (p3->o1[1]->id == o3.o1[1]->id); - assert (p4->c.o2->id == o4.c.o2->id); - assert (p4->c.o2->o1->id == o4.c.o2->o1->id); - } - - // Update. - // - { - scomp id2, id3; - - { - transaction t (db->begin ()); - - unique_ptr p2 (db->load (o2.id)); - delete p2->o1; - p2->o1 = new object1 (scomp ("o1", "o2", "bbb")); - id2 = db->persist (p2->o1); - db->update (*p2); - - unique_ptr p3 (db->load (o3.id)); - delete p3->o1.back (); - p3->o1.pop_back (); - p3->o1.push_back (new object1 (scomp ("o1", "o3", "ccc"))); - id3 = db->persist (p3->o1.back ()); - db->update (*p3); - - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p2 (db->load (o2.id)); - unique_ptr p3 (db->load (o3.id)); - t.commit (); - - assert (p2->o1->id == id2); - assert (p3->o1.back ()->id == id3); - } - } - - // Query. - // - { - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - { - result r (db->query (query::o1->id.str3 == "bbb")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->id == o2.id); - assert (++i == r.end ()); - } - - { - // As id (dual interface). - // - result r (db->query (query::o1.str3 == "bbb")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->id == o2.id); - assert (++i == r.end ()); - } - - t.commit (); - } - - // Second level composite object pointer. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query (query::c.o2->o1.str3 == "ccc")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->id == o4.id); - assert (++i == r.end ()); - - t.commit (); - } - } - - // View. - // - { - transaction t (db->begin ()); - - { - typedef odb::query query; - typedef odb::result result; - - result r (db->query (query::object2::id.num2 == 0)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->num == 1 && i->str == "bbb"); - assert (++i == r.end ()); - } - - { - typedef odb::query query; - typedef odb::result result; - - result r (db->query ((query::object3::id.num2 == 0) + - "ORDER BY" + query::object1::id.str3)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->num == 1 && i->str == "aaa"); - assert (++i != r.end ()); - assert (i->num == 1 && i->str == "ccc"); - assert (++i == r.end ()); - } - - { - typedef odb::query query; - typedef odb::result result; - - result r (db->query (query::object4::id.num2 == 0)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->num4 == 1 && i->num2 == 1 && i->str == "ccc"); - assert (++i == r.end ()); - } - - t.commit (); - } - } - - // Test 3. - // - { - using namespace test3; - - object2 o2 (ncomp (2, 0, 1)); - o2.o1 = new object1 (scomp ("o1", "o2", "aaa")); - o2.o1->o2 = &o2; - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o2.o1); - db->persist (o2); - t.commit (); - } - - // Load. - // - { - session s; - transaction t (db->begin ()); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (p2->o1->o2->id == o2.id); - } - - // Query. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - { - session s; - - result r (db->query (query::o2->id.num2 == 0)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->id == o2.o1->id); - - i->o2->o1 = 0; - delete i->o2; - - assert (++i == r.end ()); - } - - t.commit (); - } - - // View. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query (query::object1::id.str2 == "o2")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->num == 1 && i->str == "aaa"); - assert (++i == r.end ()); - - t.commit (); - } - } - - // Test 4. - // - { - using namespace test4; - - object2 o2 (ncomp (2, 0, 1)); - - o2.o1.push_back (new object1 (scomp ("o1", "o2", "aaa"))); - o2.o1.back ()->o2 = &o2; - - o2.o1.push_back (new object1 (scomp ("o1", "o2", "bbb"))); - o2.o1.back ()->o2 = &o2; - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o2.o1[0]); - db->persist (o2.o1[1]); - db->persist (o2); - t.commit (); - } - - // Load. - // - { - session s; - transaction t (db->begin ()); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (p2->o1.size () == 2); - assert (p2->o1[0]->o2->id == o2.id); - assert (p2->o1[1]->o2->id == o2.id); - } - - // Query. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - { - session s; - - result r (db->query (query::o2->id.num2 == 0)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->id == o2.o1[0]->id); - i->o2->o1.clear (); - - assert (++i != r.end ()); - assert (i->id == o2.o1[1]->id); - - i->o2->o1.clear (); - delete i->o2; - - assert (++i == r.end ()); - } - - t.commit (); - } - - // View. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query (query::object1::id.str3 == "bbb")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->num == 1 && i->str == "bbb"); - assert (++i == r.end ()); - - t.commit (); - } - } - - // Test 5. - // - { - using namespace test5; - - object2 o2 (ncomp (2, 0, 1)); - - o2.o1.push_back (new object1 (scomp ("o1", "o2", "aaa"))); - o2.o1.back ()->o2 = &o2; - - o2.o1.push_back (new object1 (scomp ("o1", "o2", "bbb"))); - o2.o1.back ()->o2 = &o2; - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o2.o1[0]); - db->persist (o2.o1[1]); - db->persist (o2); - t.commit (); - } - - // Load. - // - { - session s; - transaction t (db->begin ()); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (p2->o1.size () == 2); - - assert (p2->o1[0]->id == o2.o1[0]->id); - assert (p2->o1[0]->o2->id == o2.id); - - assert (p2->o1[1]->id == o2.o1[1]->id); - assert (p2->o1[1]->o2->id == o2.id); - } - - // View. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query ((query::object2::id.num2 == 0) + - "ORDER BY" + query::object1::id.str3)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->num == 1 && i->str == "aaa"); - assert (++i != r.end ()); - assert (i->num == 1 && i->str == "bbb"); - assert (++i == r.end ()); - - t.commit (); - } - } - - // Test 6. - // - { - using namespace test6; - - object2 o2 (ncomp (2, 0, 1)); - - o2.o1.push_back (new object1 (scomp ("o1", "o2", "aaa"))); - o2.o1.back ()->o2.push_back (&o2); - - o2.o1.push_back (new object1 (scomp ("o1", "o2", "bbb"))); - o2.o1.back ()->o2.push_back (&o2); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o2.o1[0]); - db->persist (o2.o1[1]); - db->persist (o2); - t.commit (); - } - - // Load. - // - { - session s; - transaction t (db->begin ()); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (p2->o1.size () == 2); - - assert (p2->o1[0]->id == o2.o1[0]->id); - assert (p2->o1[0]->o2[0]->id == o2.id); - - assert (p2->o1[1]->id == o2.o1[1]->id); - assert (p2->o1[1]->o2[0]->id == o2.id); - } - - // View. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query ((query::object2::id.num2 == 0) + - "ORDER BY" + query::object1::id.str3)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->num == 1 && i->str == "aaa"); - assert (++i != r.end ()); - assert (i->num == 1 && i->str == "bbb"); - assert (++i == r.end ()); - - t.commit (); - } - } - - // Test 7. - // - { - using namespace test7; - - object o (scomp ("aaa", "bbb", "ccc"), 123); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - t.commit (); - - assert (*p == o); - } - - // Update. - // - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - p->num++; - db->update (*p); - - try - { - db->update (o); - assert (false); - } - catch (const object_changed&) - { - } - - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - t.commit (); - - assert (p->num == o.num + 1); - } - - // Erase. - // - { - transaction t (db->begin ()); - - try - { - db->update (o); - assert (false); - } - catch (const object_changed&) - { - } - - t.commit (); - } - } - - // Test 8. - // - { - using namespace test8; - - object2 o2a, o2b; - object3 o3; - - o2b.o1 = new object1 (scomp ("222", "aaa", "bbb"), 123); - o3.o1.push_back (0); - o3.o1.push_back (new object1 (scomp ("333", "aaa", "bbb"), 234)); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o2a); - db->persist (o2b); - db->persist (o2b.o1); - db->persist (o3); - db->persist (o3.o1[1]); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - unique_ptr p2a (db->load (o2a.id)); - unique_ptr p2b (db->load (o2b.id)); - unique_ptr p3 (db->load (o3.id)); - t.commit (); - - assert (p2a->o1 == 0); - assert (p2b->o1 != 0 && *p2b->o1 == *o2b.o1); - assert (p3->o1[0] == 0); - assert (p3->o1[1] != 0 && *p3->o1[1] == *o3.o1[1]); - } - - // Update. - // - { - object1* o1 (o3.o1[1]); - - o3.o1.clear (); - o3.o1.push_back (o2b.o1); - o3.o1.push_back (0); - - o2a.o1 = o1; - o2b.o1 = 0; - - transaction t (db->begin ()); - db->update (o2a); - db->update (o2b); - db->update (o3); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p2a (db->load (o2a.id)); - unique_ptr p2b (db->load (o2b.id)); - unique_ptr p3 (db->load (o3.id)); - t.commit (); - - assert (p2a->o1 != 0 && *p2a->o1 == *o2a.o1); - assert (p2b->o1 == 0); - assert (p3->o1[0] != 0 && *p3->o1[0] == *o3.o1[0]); - assert (p3->o1[1] == 0); - } - } - - // Test 9. - { - using namespace test9; - - object o (123, "abc"); - o.v.push_back (123); - - // persist - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - result r (db->query ()); - result::iterator i (r.begin ()); - assert (i != r.end () && o == *i && ++i == r.end ()); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/id/composite/test.hxx b/common/id/composite/test.hxx deleted file mode 100644 index 70856a6..0000000 --- a/common/id/composite/test.hxx +++ /dev/null @@ -1,519 +0,0 @@ -// file : common/id/composite/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -#pragma db value -struct scomp -{ - scomp () {} - scomp (const std::string& s1, const std::string& s2, const std::string& s3) - : str1 (s1), str2 (s2), str3 (s3) - { - } - - std::string str1; - std::string str2; - std::string str3; -}; - -inline bool -operator== (const scomp& x, const scomp& y) -{ - return x.str1 == y.str1 && x.str2 == y.str2 && x.str3 == y.str3; -} - -inline bool -operator< (const scomp& x, const scomp& y) -{ - return x.str1 < y.str1 || - (x.str1 == y.str1 && x.str2 < y.str2) || - (x.str1 == y.str1 && x.str2 == y.str2 && x.str3 < y.str3); -} - -#pragma db value -struct ncomp -{ - ncomp () {} - ncomp (unsigned short n1, unsigned short n2, unsigned short n3) - : num1 (n1), num2 (n2), num3 (n3) - { - } - - unsigned short num1; - unsigned short num2; - unsigned short num3; -}; - -inline bool -operator== (const ncomp& x, const ncomp& y) -{ - return x.num1 == y.num1 && x.num2 == y.num2 && x.num3 == y.num3; -} - -inline bool -operator< (const ncomp& x, const ncomp& y) -{ - return x.num1 < y.num1 || - (x.num1 == y.num1 && x.num2 < y.num2) || - (x.num1 == y.num1 && x.num2 == y.num2 && x.num3 < y.num3); -} - -// Test object with composite id, container. -// -#pragma db namespace table("t1_") -namespace test1 -{ - #pragma db object - struct object - { - object () {} - object (const scomp& i, unsigned long n): id (i), num (n) {} - - #pragma db id - scomp id; - - unsigned long num; - std::vector vec; - }; - - inline bool - operator== (const object& x, const object& y) - { - return x.id == y.id && x.num == y.num && x.vec == y.vec; - } -} - -// Test to-one and to-many relationships with composite id as well as -// queries and views. -// -#pragma db namespace table("t2_") -namespace test2 -{ - #pragma db object - struct object1 - { - object1 () {} - object1 (const scomp& i): id (i) {} - - #pragma db id - scomp id; - }; - - #pragma db object - struct object2 - { - object2 (): o1 (0) {} - object2 (const ncomp& i): id (i), o1 (0) {} - ~object2 () {delete o1;} - - #pragma db id - ncomp id; - - object1* o1; - }; - - #pragma db object - struct object3 - { - object3 () {} - object3 (const ncomp& i): id (i) {} - - ~object3 () - { - for (std::vector::iterator i (o1.begin ()); - i != o1.end (); ++i) - delete *i; - } - - #pragma db id - ncomp id; - - std::vector o1; - }; - - // Test second-level query pointer test as well as pointers in - // composite types. - // - #pragma db value - struct comp - { - comp (): o2 (0) {} - ~comp () {delete o2;} - - object2* o2; - }; - - #pragma db object - struct object4 - { - object4 () {} - object4 (const ncomp& i): id (i) {} - - #pragma db id - ncomp id; - - comp c; - }; - - #pragma db view object(object2) object(object1) - struct view2 - { - #pragma db column (object2::id.num3) - unsigned short num; - - #pragma db column (object1::id.str3) - std::string str; - }; - - #pragma db view object(object3) object(object1) - struct view3 - { - #pragma db column (object3::id.num3) - unsigned short num; - - #pragma db column (object1::id.str3) - std::string str; - }; - - #pragma db view object(object4) object(object2) object(object1) - struct view4 - { - #pragma db column (object4::id.num3) - unsigned short num4; - - #pragma db column (object2::id.num3) - unsigned short num2; - - #pragma db column (object1::id.str3) - std::string str; - }; -} - -// Test one-to-one(i) relationship with composite id. -// -#pragma db namespace table("t3_") -namespace test3 -{ - struct object2; - - #pragma db object - struct object1 - { - object1 () {} - object1 (const scomp& i): id (i) {} - - #pragma db id - scomp id; - - #pragma db inverse(o1) - object2* o2; - }; - - #pragma db object - struct object2 - { - object2 (): o1 (0) {} - object2 (const ncomp& i): id (i), o1 (0) {} - ~object2 () {delete o1;} - - #pragma db id - ncomp id; - - object1* o1; - }; - - #pragma db view object(object2) object(object1) - struct view - { - #pragma db column (object2::id.num3) - unsigned short num; - - #pragma db column (object1::id.str3) - std::string str; - }; -} - -// Test many-to-one(i) relationship with composite id. -// -#pragma db namespace table("t4_") -namespace test4 -{ - struct object2; - - #pragma db object - struct object1 - { - object1 () {} - object1 (const scomp& i): id (i) {} - - #pragma db id - scomp id; - - #pragma db inverse(o1) - object2* o2; - }; - - #pragma db object - struct object2 - { - object2 () {} - object2 (const ncomp& i): id (i) {} - - ~object2 () - { - for (std::vector::iterator i (o1.begin ()); - i != o1.end (); ++i) - delete *i; - } - - #pragma db id - ncomp id; - - std::vector o1; - }; - - #pragma db view object(object2) object(object1) - struct view - { - #pragma db column (object2::id.num3) - unsigned short num; - - #pragma db column (object1::id.str3) - std::string str; - }; -} - -// Test one-to-many(i) relationship with composite id. -// -#pragma db namespace table("t5_") -namespace test5 -{ - struct object2; - - #pragma db object - struct object1 - { - object1 () {} - object1 (const scomp& i): id (i) {} - - #pragma db id - scomp id; - - object2* o2; - }; - - #pragma db object - struct object2 - { - object2 () {} - object2 (const ncomp& i): id (i) {} - - ~object2 () - { - for (std::vector::iterator i (o1.begin ()); - i != o1.end (); ++i) - delete *i; - } - - #pragma db id - ncomp id; - - #pragma db inverse(o2) - std::vector o1; - }; - - #pragma db view object(object2) object(object1) - struct view - { - #pragma db column (object2::id.num3) - unsigned short num; - - #pragma db column (object1::id.str3) - std::string str; - }; -} - -// Test many-to-many(i) relationship with composite id. -// -#pragma db namespace table("t6_") -namespace test6 -{ - struct object2; - - #pragma db object - struct object1 - { - object1 () {} - object1 (const scomp& i): id (i) {} - - #pragma db id - scomp id; - - std::vector o2; - }; - - #pragma db object - struct object2 - { - object2 () {} - object2 (const ncomp& i): id (i) {} - - ~object2 () - { - for (std::vector::iterator i (o1.begin ()); - i != o1.end (); ++i) - delete *i; - } - - #pragma db id - ncomp id; - - #pragma db inverse(o2) - std::vector o1; - }; - - #pragma db view object(object2) object(object1) - struct view - { - #pragma db column (object2::id.num3) - unsigned short num; - - #pragma db column (object1::id.str3) - std::string str; - }; -} - -// Test object with composite id and version (optimistic concurrency). -// -#pragma db namespace table("t7_") -namespace test7 -{ - #pragma db object optimistic - struct object - { - object () {} - object (const scomp& i, unsigned long n): id (i), num (n) {} - - #pragma db id - scomp id; - - #pragma db version - unsigned long ver; - - unsigned long num; - }; - - inline bool - operator== (const object& x, const object& y) - { - return x.id == y.id && x.ver == y.ver && x.num == y.num; - } -} - -// Test composite NULL pointers. -// -#pragma db namespace table("t8_") -namespace test8 -{ - #pragma db object - struct object1 - { - object1 () {} - object1 (const scomp& i, unsigned long n): id (i), num (n) {} - - #pragma db id - scomp id; - - unsigned long num; - }; - - inline bool - operator== (const object1& x, const object1& y) - { - return x.id == y.id && x.num == y.num; - } - - #pragma db object - struct object2 - { - object2 (): o1 (0) {} - ~object2 () {delete o1;} - - #pragma db id auto - unsigned long id; - - object1* o1; - }; - - #pragma db object - struct object3 - { - ~object3 () - { - for (std::vector::iterator i (o1.begin ()); - i != o1.end (); ++i) - delete *i; - } - - #pragma db id auto - unsigned long id; - - std::vector o1; - }; -} - -// Test composite id definition inside object. -// -#pragma db namespace table("t9_") -namespace test9 -{ - #pragma db object - struct object - { - object (unsigned long n = 0, const std::string& s = "") - { - id_.num = n; - id_.str = s; - } - - unsigned long num () const {return id_.num;} - const std::string& str () const {return id_.str;} - - std::vector v; - - private: - friend class odb::access; - - #pragma db value - struct comp - { - unsigned long num; - std::string str; - - bool - operator< (const comp& x) const - { - return num < x.num || (num == x.num && str < x.str); - } - }; - - #pragma db id - comp id_; - }; - - inline bool - operator== (const object& x, const object& y) - { - return x.num () == y.num () && x.str () == y.str () && x.v == y.v; - } -} - - -#endif // TEST_HXX diff --git a/common/id/composite/testscript b/common/id/composite/testscript deleted file mode 100644 index f87d4bc..0000000 --- a/common/id/composite/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/id/composite/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/id/nested/buildfile b/common/id/nested/buildfile deleted file mode 100644 index 777cb65..0000000 --- a/common/id/nested/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/nested/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_id_nested_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/id/nested/driver.cxx b/common/id/nested/driver.cxx deleted file mode 100644 index 92a80f6..0000000 --- a/common/id/nested/driver.cxx +++ /dev/null @@ -1,266 +0,0 @@ -// file : common/id/nested/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test nested ids. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -struct failed {}; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - - // Simple nested id. - // - { - using namespace test1; - - object o1 (1, "a", 3); - o1.v.push_back (123); - - object o2 (4, "b", 6); - o2.v.push_back (234); - - object1 o (new object (10, "abc", 11)); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o.p); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id.y)); - unique_ptr p2 (db->load (o2.id.y)); - unique_ptr p (db->load (o.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - assert (*p == o); - } - - o1.z++; - o1.v.pop_back (); - o1.v.push_back (234); - - o2.z--; - o2.v.back ()++; - o2.v.push_back (123); - - delete o.p; - o.p = new object (20, "xyz", 11); - - { - transaction t (db->begin ()); - db->update (o1); - db->update (o2); - db->persist (o.p); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id.y)); - unique_ptr p2 (db->load (o2.id.y)); - unique_ptr p (db->load (o.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - assert (*p == o); - } - } - - // Composite nested id. - // - { - using namespace test2; - - object o1 (1, 2, "a", 123); - o1.v.push_back (123); - - object o2 (1, 3, "b", 234); - o2.v.push_back (234); - - object1 o (new object (2, 2, "abc", 123)); - o.p->v.push_back (345); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o.p); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id.c)); - unique_ptr p2 (db->load (o2.id.c)); - unique_ptr p (db->load (o.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - assert (*p == o); - } - - o1.z++; - o1.v.pop_back (); - o1.v.push_back (234); - - o2.z--; - o2.v.modify_back ()++; - o2.v.push_back (123); - - delete o.p; - o.p = new object (2, 3, "xyz", 234); - - { - transaction t (db->begin ()); - db->update (o1); - db->update (o2); - db->persist (o.p); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id.c)); - unique_ptr p2 (db->load (o2.id.c)); - unique_ptr p (db->load (o.id)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - assert (*p == o); - } - } - - // Custom/by-value access. - // - { - using namespace test3; - - object o1 (1, "a", 3); - object o2 (4, "b", 6); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id.y)); - unique_ptr p2 (db->load (o2.id.y)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - - o1.z++; - o2.z--; - - { - transaction t (db->begin ()); - db->update (o1); - db->update (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id.y)); - unique_ptr p2 (db->load (o2.id.y)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - } - - // Polymorphic. - // - { - using namespace test4; - - base o1 (1, "a"); - object o2 (2, "b", 1); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id.y)); - unique_ptr p2 (db->load (o2.id.y)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - - o2.z--; - - { - transaction t (db->begin ()); - db->update (o1); - db->update (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id.y)); - unique_ptr p2 (db->load (o2.id.y)); - t.commit (); - - assert (*p1 == o1); - assert (*p2 == o2); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/id/nested/test.hxx b/common/id/nested/test.hxx deleted file mode 100644 index 06ee6b8..0000000 --- a/common/id/nested/test.hxx +++ /dev/null @@ -1,217 +0,0 @@ -// file : common/id/nested/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include -#include - -// Simple nested id. -// -#pragma db namespace table("t1_") -namespace test1 -{ - #pragma db value - struct comp - { - int x; - std::string y; - }; - - #pragma db object - struct object - { - #pragma db id(y) - comp id; - - int z; - std::vector v; - - object () {} - object (int x, std::string y, int z_): z (z_) {id.x = x; id.y = y;} - }; - - inline bool - operator== (object a, object b) - { - return a.id.x == b.id.x && a.id.y == b.id.y && a.z == b.z && a.v == b.v; - } - - #pragma db object - struct object1 - { - #pragma db id auto - int id; - - object* p; - - object1 (object* p_ = 0): p (p_) {} - ~object1 () {delete p;} - }; - - inline bool - operator== (const object1& a, const object1& b) - { - return a.id == b.id && *a.p == *b.p; - } -} - -// Composite nested id. -// -#pragma db namespace table("t2_") -namespace test2 -{ - #pragma db value - struct comp1 - { - int x; - int y; - }; - - #pragma db value - struct comp2 - { - comp1 c; - std::string s; - }; - - #pragma db object - struct object - { - #pragma db id(c) - comp2 id; - - int z; - odb::vector v; - - object () {} - object (int x, int y, std::string s, int z_) - : z (z_) {id.c.x = x; id.c.y = y; id.s = s;} - }; - - inline bool - operator== (object a, object b) - { - return a.id.c.x == b.id.c.x && a.id.c.y == b.id.c.y && - a.id.s == b.id.s && a.z == b.z && a.v == b.v; - } - - #pragma db object - struct object1 - { - #pragma db id auto - int id; - - object* p; - - object1 (object* p_ = 0): p (p_) {} - ~object1 () {delete p;} - }; - - inline bool - operator== (const object1& a, const object1& b) - { - return a.id == b.id && *a.p == *b.p; - } - - // Multiple levels of nesting, just a compile test. - // - #pragma db object - struct object2 - { - #pragma db id(c.x) - comp2 id; - - int z; - }; -} - -// Custom/by-value access. -// -#pragma db namespace table("t3_") -namespace test3 -{ - #pragma db value - struct comp - { - int x; - - std::string get_y () const {return y;} - void set_y (std::string v) {y = v;} - - #pragma db get(get_y) set(set_y) - std::string y; - }; - - #pragma db object - struct object - { - comp get_id () const {return id;} - void set_id (comp v) {id = v;} - - #pragma db id(y) get(get_id) set(set_id) - comp id; - - int z; - - object () {} - object (int x, std::string y, int z_): z (z_) {id.x = x; id.y = y;} - }; - - inline bool - operator== (object a, object b) - { - return a.id.x == b.id.x && a.id.y == b.id.y && a.z == b.z; - } -} - -// Polymorphic. -// -#pragma db namespace table("t4_") -namespace test4 -{ - #pragma db value - struct comp - { - int x; - std::string y; - }; - - #pragma db object polymorphic - struct base - { - #pragma db id(y) - comp id; - - virtual ~base () {} - base () {} - base (int x, std::string y) {id.x = x; id.y = y;} - }; - - inline bool - operator== (const base& a, const base& b) - { - return a.id.x == b.id.x && a.id.y == b.id.y; - } - - #pragma db object - struct object: base - { - int z; - - object () {} - object (int x, std::string y, int z_): base (x, y), z (z_) {} - }; - - inline bool - operator== (const object& a, const object& b) - { - return a.id.x == b.id.x && a.id.y == b.id.y && a.z == b.z; - } -} - -#endif // TEST_HXX diff --git a/common/id/nested/testscript b/common/id/nested/testscript deleted file mode 100644 index 89e8d7a..0000000 --- a/common/id/nested/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/nested/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/include/.gitignore b/common/include/.gitignore deleted file mode 100644 index d52f166..0000000 --- a/common/include/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# ODB-generated files. -# -obj1-odb.?xx -obj1-odb-*.?xx -obj2-odb.?xx -obj2-odb-*.?xx -obj3-odb.?xx -obj3-odb-*.?xx - -test1-odb.?xx -test1-odb-*.?xx -test2-odb.?xx -test2-odb-*.?xx -test3-odb.?xx -test3-odb-*.?xx -test4-odb.?xx -test4-odb-*.?xx diff --git a/common/include/buildfile b/common/include/buildfile deleted file mode 100644 index 6db878c..0000000 --- a/common/include/buildfile +++ /dev/null @@ -1,51 +0,0 @@ -# file : common/include/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -hs = obj1 obj2 obj3 test1 test2 test3 test4 - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -for h: $hs -{ - exe{driver}: {hxx ixx cxx}{$h-odb} - - <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} - - for db: $databases - { - exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi - <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} - } -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). Also see driver.cxx for the details on -# the -I options usage. -# -odb_options = --table-prefix include_ \ - "-I$out_base" \ - "-I$src_base/.." \ - "-I$src_base/../.." - -cxx.poptions =+ "-I$out_base" "-I$src_base" \ - "-I$out_base/../.." "-I$src_base/../.." - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/include/driver.cxx b/common/include/driver.cxx deleted file mode 100644 index 561746a..0000000 --- a/common/include/driver.cxx +++ /dev/null @@ -1,42 +0,0 @@ -// file : common/include/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test inclusion of -odb files (compilation test). -// -// The setup of this test is as follows: the ODB compiler has two -// additional include directories in its search path: .. and ../.. -// while the C++ compiler has only ../.. . This way, if a ..-based -// path is used in the generated code, the C++ compilation will -// fail. -// - -#include -#include - -#include -#include - -#include - -#include "test1.hxx" -#include "test1-odb.hxx" - -#include "test2.hxx" -#include "test2-odb.hxx" - -#include "test3.hxx" -#include "test3-odb.hxx" - -#include "test4.hxx" -#include "test4-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main () -{ -} diff --git a/common/include/obj1.hxx b/common/include/obj1.hxx deleted file mode 100644 index 33ae0d6..0000000 --- a/common/include/obj1.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : common/include/obj1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef OBJ1_HXX -#define OBJ1_HXX - -#include - -#pragma db object -struct object1 -{ - object1 (unsigned long id) - : id_ (id) - { - } - - object1 () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // OBJ1_HXX diff --git a/common/include/obj2.hxx b/common/include/obj2.hxx deleted file mode 100644 index 2f20f58..0000000 --- a/common/include/obj2.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : common/include/obj2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef OBJ2_HXX -#define OBJ2_HXX - -#include - -#pragma db object -struct object2 -{ - object2 (unsigned long id) - : id_ (id) - { - } - - object2 () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // OBJ2_HXX diff --git a/common/include/obj3.hxx b/common/include/obj3.hxx deleted file mode 100644 index 432145b..0000000 --- a/common/include/obj3.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : common/include/obj3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef OBJ3_HXX -#define OBJ3_HXX - -#include - -#pragma db object -struct object3 -{ - object3 (unsigned long id) - : id_ (id) - { - } - - object3 () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // OBJ3_HXX diff --git a/common/include/objs1.hxx b/common/include/objs1.hxx deleted file mode 100644 index 6e949e2..0000000 --- a/common/include/objs1.hxx +++ /dev/null @@ -1,13 +0,0 @@ -// file : common/include/objs1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef OBJS1_HXX -#define OBJS1_HXX - -#ifdef ODB_COMPILER -# include -# include -# include -#endif - -#endif // OBJS1_HXX diff --git a/common/include/objs2.hxx b/common/include/objs2.hxx deleted file mode 100644 index 4f8133b..0000000 --- a/common/include/objs2.hxx +++ /dev/null @@ -1,13 +0,0 @@ -// file : common/include/objs2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef OBJS2_HXX -#define OBJS2_HXX - -#ifdef ODB_COMPILER -# include "include/obj1.hxx" -# include "include/obj2.hxx" -# include "include/obj3.hxx" -#endif - -#endif // OBJS2_HXX diff --git a/common/include/objs3.hxx b/common/include/objs3.hxx deleted file mode 100644 index 2f7aaff..0000000 --- a/common/include/objs3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : common/include/objs3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef OBJS3_HXX -#define OBJS3_HXX - -#include "../include/obj1.hxx" -#include "../include/obj2.hxx" -#include "../include/obj3.hxx" - -#endif // OBJS3_HXX diff --git a/common/include/objs4.hxx b/common/include/objs4.hxx deleted file mode 100644 index d766fe6..0000000 --- a/common/include/objs4.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : common/include/objs1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef OBJS4_HXX -#define OBJS4_HXX - -#include -#include -#include - -#endif // OBJS4_HXX diff --git a/common/include/test1.hxx b/common/include/test1.hxx deleted file mode 100644 index 1914ddb..0000000 --- a/common/include/test1.hxx +++ /dev/null @@ -1,16 +0,0 @@ -// file : common/include/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -// Test include directive parsing. -// -#include"obj1.hxx" - - # include \ - - -/*comment*/ # /*comment*/ include /* comment */ "obj3.hxx" // comment - -#endif // TEST1_HXX diff --git a/common/include/test2.hxx b/common/include/test2.hxx deleted file mode 100644 index 6017ac4..0000000 --- a/common/include/test2.hxx +++ /dev/null @@ -1,15 +0,0 @@ -// file : common/include/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -// Test preference of includes from the main file. -// -#include "objs1.hxx" - -#include "obj1.hxx" -#include "obj2.hxx" -#include "obj3.hxx" - -#endif // TEST2_HXX diff --git a/common/include/test3.hxx b/common/include/test3.hxx deleted file mode 100644 index e55ecdb..0000000 --- a/common/include/test3.hxx +++ /dev/null @@ -1,12 +0,0 @@ -// file : common/include/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -// Test preference of longer (more qualified) paths. -// -#include "objs2.hxx" -#include "objs3.hxx" - -#endif // TEST3_HXX diff --git a/common/include/test4.hxx b/common/include/test4.hxx deleted file mode 100644 index b58e679..0000000 --- a/common/include/test4.hxx +++ /dev/null @@ -1,12 +0,0 @@ -// file : common/include/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -// Test preference of <> over "". -// -#include "objs2.hxx" -#include "objs4.hxx" - -#endif // TEST3_HXX diff --git a/common/include/testscript b/common/include/testscript deleted file mode 100644 index 089f7a1..0000000 --- a/common/include/testscript +++ /dev/null @@ -1,31 +0,0 @@ -# file : common/include/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* &!odb-test.db -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $* -} diff --git a/common/index/buildfile b/common/index/buildfile deleted file mode 100644 index 535bd26..0000000 --- a/common/index/buildfile +++ /dev/null @@ -1,40 +0,0 @@ -# file : common/index/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix index_ \ - --generate-schema - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/index/driver.cxx b/common/index/driver.cxx deleted file mode 100644 index 7a22a7c..0000000 --- a/common/index/driver.cxx +++ /dev/null @@ -1,44 +0,0 @@ -// file : common/index/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test index creation with db pragma index. See also database-specific -// tests. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - // This is just a schema creation test. - // - unique_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/index/test.hxx b/common/index/test.hxx deleted file mode 100644 index f27783f..0000000 --- a/common/index/test.hxx +++ /dev/null @@ -1,142 +0,0 @@ -// file : common/index/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -// Test basic functionality. -// -#pragma db namespace table("t1_") -namespace test1 -{ - #pragma db object - struct object - { - #pragma db id auto - unsigned long id_; - - #pragma db index - int i1; - - #pragma db unique - int i2; - - #pragma db unique index - int i3; - - int i4; - #pragma db index unique member(i4) - - int i5; - #pragma db index type("UNIQUE") member(i5) - - int i6; - #pragma db index("object_i6_index") member(i6) - - int i7; - int i8; - int i9; - - int i10; - #pragma db index member(i10, "ASC") - }; - - #pragma db index(object) member(i7) - #pragma db index(object::"object_i8_index") member(i8) -} - -#pragma db index(test1::object::"object_i9_index") member(i9) - -// Test composite indexes. -// -#pragma db namespace table("t2_") -namespace test2 -{ - #pragma db value - struct nested - { - int x; - int y; - }; - - #pragma db value - struct comp - { - int x; - int y; - nested n; - }; - - #pragma db object - struct object - { - #pragma db id auto - unsigned long id_; - - int i1a; - int i1b; - #pragma db index("object_i1_i") member(i1a) member(i1b) - - int i2a; - int i2b; - #pragma db index("object_i2_i") members(i2a, i2b) - - #pragma db index - comp c1; - - #pragma db index column("") - comp c2; - - comp c3; - #pragma db index member(c3.x) - #pragma db index member(c3.y) - - comp c4; - #pragma db index("object_c4_i") members(c4.x, c4.y, c4.n.x) - - comp c5; - int i5; - #pragma db index("object_ci5_i") member(c5) member(i5) - }; -} - -// Test container indexes. -// -#pragma db namespace table("t3_") -namespace test3 -{ - #pragma db value - struct id - { - int x; - int y; - }; - - #pragma db value - struct comp - { - int x; - std::vector v; - }; - - #pragma db object - struct object - { - #pragma db id - id id_; - - std::vector v; - #pragma db index unique member(v.id) - #pragma db index("object_v_index_index") member(v.index) - - comp c; - #pragma db index("object_c_v_id_index") member(c.v.id) - #pragma db index unique member(c.v.index) - }; -} - -#endif // TEST_HXX diff --git a/common/index/testscript b/common/index/testscript deleted file mode 100644 index cbce341..0000000 --- a/common/index/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/index/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/inheritance/polymorphism/.gitignore b/common/inheritance/polymorphism/.gitignore deleted file mode 100644 index f183a6f..0000000 --- a/common/inheritance/polymorphism/.gitignore +++ /dev/null @@ -1,76 +0,0 @@ -# ODB-generated files. -# -test1-odb.?xx -test1-odb-*.?xx -test1.sql -test1-*.sql - -test2-odb.?xx -test2-odb-*.?xx -test2.sql -test2-*.sql - -test3-odb.?xx -test3-odb-*.?xx -test3.sql -test3-*.sql - -test4-odb.?xx -test4-odb-*.?xx -test4.sql -test4-*.sql - -test5-odb.?xx -test5-odb-*.?xx -test5.sql -test5-*.sql - -test6-odb.?xx -test6-odb-*.?xx -test6.sql -test6-*.sql - -test7-odb.?xx -test7-odb-*.?xx -test7.sql -test7-*.sql - -test8-odb.?xx -test8-odb-*.?xx -test8.sql -test8-*.sql - -test9-odb.?xx -test9-odb-*.?xx -test9.sql -test9-*.sql - -test10-odb.?xx -test10-odb-*.?xx -test10.sql -test10-*.sql - -test11-odb.?xx -test11-odb-*.?xx -test11.sql -test11-*.sql - -test12-odb.?xx -test12-odb-*.?xx -test12.sql -test12-*.sql - -test13-odb.?xx -test13-odb-*.?xx -test13.sql -test13-*.sql - -test14-odb.?xx -test14-odb-*.?xx -test14.sql -test14-*.sql - -test15-odb.?xx -test15-odb-*.?xx -test15.sql -test15-*.sql diff --git a/common/inheritance/polymorphism/buildfile b/common/inheritance/polymorphism/buildfile deleted file mode 100644 index 846eb12..0000000 --- a/common/inheritance/polymorphism/buildfile +++ /dev/null @@ -1,52 +0,0 @@ -# file : common/inheritance/polymorphism/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -hs = test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 \ - test12 test13 test14 test15 - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -for h: $hs -{ - exe{driver}: {hxx ixx cxx}{$h-odb} - - <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} - - for db: $databases - { - exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi - <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} - } -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix inhrt_p_ \ - --generate-schema \ - --generate-query \ - --generate-prepared - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc - -testscript@./: schemas = $hs diff --git a/common/inheritance/polymorphism/driver.cxx b/common/inheritance/polymorphism/driver.cxx deleted file mode 100644 index 12f4666..0000000 --- a/common/inheritance/polymorphism/driver.cxx +++ /dev/null @@ -1,2093 +0,0 @@ -// file : common/inheritance/polymorphism/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test polymorphic object inheritance. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test1.hxx" -#include "test2.hxx" -#include "test3.hxx" -#include "test4.hxx" -#include "test5.hxx" -#include "test6.hxx" -#include "test7.hxx" -#include "test8.hxx" -#include "test9.hxx" -#include "test10.hxx" -#include "test11.hxx" -#include "test12.hxx" -#include "test13.hxx" -#include "test14.hxx" -#include "test15.hxx" - -#include "test1-odb.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" -#include "test4-odb.hxx" -#include "test5-odb.hxx" -#include "test6-odb.hxx" -#include "test7-odb.hxx" -#include "test8-odb.hxx" -#include "test9-odb.hxx" -#include "test10-odb.hxx" -#include "test11-odb.hxx" -#include "test12-odb.hxx" -#include "test13-odb.hxx" -#include "test14-odb.hxx" -#include "test15-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -const char* events[] = -{ - "pre_persist", - "post_persist", - "pre_load", - "post_load", - "pre_update", - "post_update", - "pre_erase", - "post_erase" -}; - -namespace test6 -{ - void base:: - db_callback (callback_event e, database&) - { - cout << "base " << events[e] << " " << id << endl; - } - - void base:: - db_callback (callback_event e, database&) const - { - cout << "base " << events[e] << " " << id << " const" << endl; - } - - void derived:: - db_callback (callback_event e, database&) const - { - cout << "derived " << events[e] << " " << id << " const" << endl; - } -} - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test 1: basic polymorphism functionality. - // - { - using namespace test1; - - root r (1, 1); - base b (2, 2, "bbb"); - derived d (3, 3, "ddd"); - - r.strs.push_back ("a"); - r.strs.push_back ("aa"); - r.strs.push_back ("aaa"); - - b.nums.push_back (21); - b.nums.push_back (22); - b.nums.push_back (23); - b.strs.push_back ("b"); - b.strs.push_back ("bb"); - b.strs.push_back ("bbb"); - - d.nums.push_back (31); - d.nums.push_back (32); - d.nums.push_back (33); - d.strs.push_back ("d"); - d.strs.push_back ("dd"); - d.strs.push_back ("ddd"); - - { - transaction t (db->begin ()); - - // Static persist. - // - db->persist (r); - db->persist (b); - - // Dynamic persist. - // - root& r (d); - db->persist (r); - - t.commit (); - } - - // Static load. - // - { - transaction t (db->begin ()); - unique_ptr pr (db->load (r.id)); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - t.commit (); - - assert (*pr == r); - assert (*pb == b); - assert (*pd == d); - } - - // Dynamic load. - // - { - transaction t (db->begin ()); - unique_ptr pb (db->load (b.id)); - unique_ptr pd1 (db->load (d.id)); - unique_ptr pd2 (db->load (d.id)); - t.commit (); - - assert (*pb == b); - assert (*pd1 == d); - assert (*pd2 == d); - } - - // Invalid load. - // - { - transaction t (db->begin ()); - - try - { - unique_ptr p (db->load (r.id)); - assert (false); - } - catch (const object_not_persistent&) {} - - try - { - unique_ptr p (db->load (b.id)); - assert (false); - } - catch (const object_not_persistent&) {} - - t.commit (); - } - - // Static load into existing instance. - // - { - transaction t (db->begin ()); - root r1; - db->load (r.id, r1); - base b1; - db->load (b.id, b1); - derived d1; - db->load (d.id, d1); - t.commit (); - - assert (r1 == r); - assert (b1 == b); - assert (d1 == d); - } - - // Dynamic load into existing instance. - // - { - transaction t (db->begin ()); - base b1; - db->load (b.id, static_cast (b1)); - derived d1; - db->load (d.id, static_cast (d1)); - t.commit (); - - assert (b1 == b); - assert (d1 == d); - } - - // Invalid load into existing instance. - // - { - transaction t (db->begin ()); - - try - { - base b; - db->load (r.id, static_cast (b)); - assert (false); - } - catch (const object_not_persistent&) {} - - try - { - derived d; - db->load (b.id, static_cast (d)); - assert (false); - } - catch (const object_not_persistent&) {} - - t.commit (); - } - - // Slicing load. - // - { - transaction t (db->begin ()); - root b1; - db->load (b.id, b1); - base d1; - db->load (d.id, d1); - t.commit (); - - assert (b1 == static_cast (b)); - assert (d1 == static_cast (d)); - } - - // Static reload. - // - { - transaction t (db->begin ()); - root r1; - r1.id = r.id; - db->reload (r1); - base b1; - b1.id = b.id; - db->reload (b1); - derived d1; - d1.id = d.id; - db->reload (d1); - t.commit (); - - assert (r1 == r); - assert (b1 == b); - assert (d1 == d); - } - - // Dynamic reload. - // - { - transaction t (db->begin ()); - base b1; - b1.id = b.id; - db->reload (static_cast (b1)); - derived d1; - d1.id = d.id; - db->reload (static_cast (d1)); - t.commit (); - - assert (b1 == b); - assert (d1 == d); - } - - // Invalid reload. - // - { - transaction t (db->begin ()); - - try - { - base b; - b.id = r.id; - db->reload (static_cast (b)); - assert (false); - } - catch (const object_not_persistent&) {} - - try - { - derived d; - d.id = b.id; - db->reload (static_cast (d)); - assert (false); - } - catch (const object_not_persistent&) {} - - t.commit (); - } - - // Slicing reload. - // - { - transaction t (db->begin ()); - root b1; - b1.id = b.id; - db->reload (b1); - base d1; - d1.id = d.id; - db->reload (d1); - t.commit (); - - assert (b1 == static_cast (b)); - assert (d1 == static_cast (d)); - } - - // Query. - // - { - typedef odb::query root_query; - typedef odb::result root_result; - - typedef odb::query base_query; - typedef odb::result base_result; - - typedef odb::result derived_result; - - transaction t (db->begin ()); - - // Test loading via root. - // - { - root_result qr (db->query ("ORDER BY" + root_query::id)); - root_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && *i == r); - assert (++i != e && *i == b); - assert (++i != e && *i == d); - assert (++i == e); - } - - // Test loading via base. - // - { - base_result qr (db->query ("ORDER BY" + base_query::id)); - base_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && *i == b); - assert (++i != e && *i == d); - assert (++i == e); - } - - // Test loading via derived. - // - { - derived_result qr (db->query ()); - derived_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && *i == d); - assert (++i == e); - } - - // Test loading into an existing instance. - // - { - root_result qr (db->query ()); - - unsigned short mask (0); - - for (root_result::iterator i (qr.begin ()); i != qr.end (); ++i) - { - string ds (i.discriminator ()); - - if (ds == "test1::root") - { - root r1; - i.load (r1); - assert (r1 == r); - mask |= 1; - } - else if (ds == "test1::base") - { - base b1; - i.load (b1); - assert (b1 == b); - mask |= 2; - } - else if (ds == "test1::derived") - { - derived d1; - i.load (d1); - assert (d1 == d); - mask |= 4; - } - else - assert (false); - } - - assert (mask == 7); - } - - // Test query conditions with columns from multiple tables. - // - { - base_result qr ( - db->query ( - base_query::num == 3 && base_query::str == "ddd")); - - base_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && *i == d); - assert (++i == e); - } - - // Test discriminator access. - // - { - base_result qr (db->query (base_query::id == 3)); - base_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && i.discriminator () == "test1::derived"); - assert (++i == e); - } - - // Test loading of an object from the same hierarchy during - // query result iteration (tests image copying via change - // callbacks in some databases). - // - { - base_result qr (db->query ()); - - unsigned short mask (0); - - for (base_result::iterator i (qr.begin ()); i != qr.end (); ++i) - { - string ds (i.discriminator ()); - - if (ds == "test1::base") - { - unique_ptr d1 (db->load (d.id)); - assert (*d1 == d); - assert (*i == b); - mask |= 1; - } - else if (ds == "test1::derived") - { - unique_ptr b1 (db->load (b.id)); - assert (*b1 == b); - assert (*i == d); - mask |= 2; - } - } - - assert (mask == 3); - } - - t.commit (); - } - - // Views. - // - { - typedef odb::query root_query; - typedef odb::result root_result; - - typedef odb::query base_query; - typedef odb::result base_result; - - typedef odb::result derived_result; - - transaction t (db->begin ()); - - // root - // - { - root_result qr (db->query ("ORDER BY" + root_query::id)); - root_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && i->typeid_ == "test1::root" && i->num == r.num); - assert (++i != e && i->typeid_ == "test1::base" && i->num == b.num); - assert (++i != e && i->typeid_ == "test1::derived" && i->num == d.num); - assert (++i == e); - } - - // base - // - { - base_result qr (db->query ("ORDER BY" + base_query::id)); - base_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && - i->id == b.id && i->num == b.num && i->str == b.str); - assert (++i != e && - i->id == d.id && i->num == d.num && i->str == d.str); - assert (++i == e); - } - - // derived - // - { - derived_result qr (db->query ()); - derived_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && - i->num == d.num && i->str == d.str && - i->dnum == d.dnum && i->dstr == d.dstr); - assert (++i == e); - } - - t.commit (); - } - - // Update. - // - r.num++; - r.strs.push_back ("aaaa"); - - b.num++; - b.str += "b"; - b.nums.push_back (24); - b.strs.push_back ("bbbb"); - - d.num++; - d.str += "d"; - d.dnum++; - d.dstr += "d"; - d.nums.push_back (34); - d.strs.push_back ("dddd"); - - { - transaction t (db->begin ()); - - // Static update. - // - db->update (r); - db->update (b); - - // Dynamic update. - // - root& r (d); - db->update (r); - - t.commit (); - } - - // Verify update. - // - { - transaction t (db->begin ()); - unique_ptr pr (db->load (r.id)); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - t.commit (); - - assert (*pr == r); - assert (*pb == b); - assert (*pd == d); - } - - // Invalid erase via id. - // - { - transaction t (db->begin ()); - - try - { - db->erase (r.id); - assert (false); - } - catch (const object_not_persistent&) {} - - try - { - db->erase (b.id); - assert (false); - } - catch (const object_not_persistent&) {} - - t.commit (); - } - - // Static erase via id. - // - { - transaction t (db->begin ()); - db->erase (r.id); - db->erase (b.id); - t.commit (); - } - - // Dynamic erase via id. - // - { - transaction t (db->begin ()); - db->erase (d.id); - t.commit (); - } - - { - transaction t (db->begin ()); - db->persist (r); - db->persist (b); - db->persist (d); - t.commit (); - } - - // Static erase via object. - // - { - transaction t (db->begin ()); - db->erase (r); - db->erase (b); - t.commit (); - } - - // Dynamic erase via object. - // - { - const root& r (d); - transaction t (db->begin ()); - db->erase (r); - t.commit (); - } - } - - // Test 2: inverse object pointers in polymorhic bases. - // - { - using namespace test2; - - derived d (1, "d", 1); - root_pointer rp (&d); - base_pointer bp (&d); - - { - transaction t (db->begin ()); - db->persist (rp); - db->persist (bp); - - d.rp.reset (*db, &rp); - d.bp.reset (*db, &bp); - - db->persist (d); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - unique_ptr pb (db->load (d.id)); - unique_ptr pr (db->load (d.id)); - t.commit (); - - assert (pd->rp.object_id () == rp.id && - pd->bp.object_id () == bp.id); - - derived* p (dynamic_cast (pb.get ())); - assert (p != 0 && - p->rp.object_id () == rp.id && - p->bp.object_id () == bp.id); - - p = dynamic_cast (pr.get ()); - assert (p != 0 && - p->rp.object_id () == rp.id && - p->bp.object_id () == bp.id); - } - - // Query. - // - { - typedef odb::query base_query; - typedef odb::result base_result; - - transaction t (db->begin ()); - - // Test query conditions with columns in pointed-to objects from - // multiple tables. - // - { - base_result qr ( - db->query ( - base_query::rp->id == rp.id && - base_query::bp->id == bp.id)); - - base_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && i.discriminator () == "test2::derived"); - assert (++i == e); - } - - t.commit (); - } - - // Views. - // - { - typedef odb::result root_result; - typedef odb::result base_result; - - transaction t (db->begin ()); - - // root - // - { - root_result qr (db->query ()); - root_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && i->rp_id == rp.id && i->r_id == d.id); - assert (++i == e); - } - - // base - // - { - base_result qr (db->query ()); - base_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && - i->bp_id == bp.id && i->b_id == d.id && i->str == d.str); - assert (++i == e); - } - - t.commit (); - } - } - - // Test 3: delayed loading. - // - { - using namespace test3; - - base b1 (21, 21); - base b2 (22, 22); - base b3 (23, 23); - - derived d1 (31, 31, "d"); - derived d2 (32, 32, "dd"); - derived d3 (33, 33, "ddd"); - - b1.rptr = new root (1); - b2.rptr = new base (2, 2); - b3.rptr = new derived (3, 3, "b3"); - - d1.rptr = new root (4); - d2.rptr = new base (5, 5); - d3.rptr = new derived (6, 6, "d3"); - - d2.bptr = new base (7, 7); - d3.bptr = new derived (8, 8, "d3b"); - - { - transaction t (db->begin ()); - db->persist (b1); - db->persist (b2); - db->persist (b3); - - db->persist (d1); - db->persist (d2); - db->persist (d3); - - db->persist (b1.rptr); - db->persist (b2.rptr); - db->persist (b3.rptr); - - db->persist (d1.rptr); - db->persist (d2.rptr); - db->persist (d3.rptr); - - db->persist (d2.bptr); - db->persist (d3.bptr); - - t.commit (); - } - - { - transaction t (db->begin ()); - - { - unique_ptr p1 (db->load (b1.id)); - unique_ptr p2 (db->load (b2.id)); - unique_ptr p3 (db->load (b3.id)); - assert (*p1 == b1); - assert (*p2 == b2); - assert (*p3 == b3); - } - - { - unique_ptr p1 (db->load (d1.id)); - unique_ptr p2 (db->load (d2.id)); - unique_ptr p3 (db->load (d3.id)); - assert (*p1 == d1); - assert (*p2 == d2); - assert (*p3 == d3); - } - - t.commit (); - } - - // Query. - // - { - typedef odb::query derived_query; - typedef odb::result derived_result; - - transaction t (db->begin ()); - - // Test query conditions with columns in pointed-to objects from - // multiple tables. - // - { - derived_result qr ( - db->query ( - derived_query::rptr->id == 6 && - derived_query::bptr->id == 8 && - derived_query::bptr->num == 8)); - - derived_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && *i == d3); - assert (++i == e); - } - - t.commit (); - } - - // Views. - // - { - typedef odb::query base_query; - typedef odb::result base_result; - - typedef odb::query derived_query; - typedef odb::result derived_result; - - typedef odb::query root_query; - typedef odb::result root_result; - - transaction t (db->begin ()); - - // base - // - { - base_result qr ( - db->query ( - base_query::base::num == b2.num && - base_query::base::id == b2.id && - base_query::r::id == b2.rptr->id)); - - base_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && - i->b_id == b2.id && - i->r_id == b2.rptr->id && - i->num == b2.num); - assert (++i == e); - } - - // derived - // - { - derived_result qr ( - db->query ( - derived_query::d::str == d3.str && - derived_query::d::num == d3.num && - derived_query::b::num == d3.bptr->num && - derived_query::d::id == d3.id && - derived_query::b::id == d3.bptr->id && - derived_query::r::id == d3.rptr->id)); - - derived_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && - i->d_id == d3.id && - i->b_id == d3.bptr->id && - i->r_id == d3.rptr->id && - i->d_num == d3.num && - i->b_num == d3.bptr->num && - i->str == d3.str); - assert (++i == e); - } - - // root - // - { - root_result qr ( - db->query ( - root_query::r::id.in (b2.rptr->id, d2.rptr->id))); - - root_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && - i->r_id == d2.rptr->id && - i->d_id == d2.id && - i->str == d2.str); - assert (++i == e); - } - - t.commit (); - } - } - - // Test 4: views. - // - { - using namespace test4; - - base1 b1 (21, 1); - - root2 r2 (11, 0); - base2 b2 (21, 1, "abc"); - - { - transaction t (db->begin ()); - db->persist (b1); - db->persist (r2); - db->persist (b2); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - { - result qr ( - db->query ( - query::base1::num == b1.num)); - - result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && i->str == "abc"); - assert (++i == e); - } - - t.commit (); - } - - { - typedef odb::result result; - - transaction t (db->begin ()); - - { - result qr (db->query ()); - result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && i->min_num == 1); - assert (++i == e); - } - - t.commit (); - } - - { - typedef odb::result result; - - transaction t (db->begin ()); - - { - result qr (db->query ()); - result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && i->str == "abc"); - assert (++i == e); - } - - t.commit (); - } - } - - // Test 5: polymorphism and optimistic concurrency. - // - { - using namespace test5; - - root r (1, 1); - base b (2, 2, "bbb"); - derived d (3, 3, "ddd"); - - r.strs.push_back ("a"); - r.strs.push_back ("aa"); - r.strs.push_back ("aaa"); - - b.nums.push_back (21); - b.nums.push_back (22); - b.nums.push_back (23); - b.strs.push_back ("b"); - b.strs.push_back ("bb"); - b.strs.push_back ("bbb"); - - d.nums.push_back (31); - d.nums.push_back (32); - d.nums.push_back (33); - d.strs.push_back ("d"); - d.strs.push_back ("dd"); - d.strs.push_back ("ddd"); - - { - transaction t (db->begin ()); - db->persist (r); - db->persist (b); - db->persist (d); - t.commit (); - } - - // Update. - // - { - transaction t (db->begin ()); - - // Root. - // - { - unique_ptr p (db->load (r.id)); - - r.num++; - r.strs.push_back ("aaaa"); - db->update (r); - - p->num--; - p->strs.pop_back (); - try - { - db->update (p); - assert (false); - } - catch (const odb::object_changed&) {} - - // Make sure the object is intact. - // - db->reload (p); - assert (r == *p); - } - - // Base. - // - { - unique_ptr p (db->load (b.id)); - - b.num++; - b.str += "b"; - b.strs.push_back ("bbbb"); - b.nums.push_back (24); - db->update (b); - - p->num--; - p->str += "B"; - p->strs.pop_back (); - p->nums.pop_back (); - try - { - db->update (p); - assert (false); - } - catch (const odb::object_changed&) {} - - // Make sure the object is intact. - // - db->reload (p); - assert (b == *p); - } - - // Derived. - // - { - unique_ptr p (db->load (d.id)); // Via root. - - d.num++; - d.str += "d"; - d.strs.push_back ("dddd"); - d.nums.push_back (24); - d.dnum++; - d.dstr += "d"; - db->update (d); - - derived& d1 (static_cast (*p)); - d1.num--; - d1.str += "D"; - d1.strs.pop_back (); - d1.nums.pop_back (); - d1.dnum--; - d1.dstr += "D"; - try - { - db->update (p); - assert (false); - } - catch (const odb::object_changed&) {} - - // Make sure the object is intact. - // - db->reload (p); - assert (d == *p); - } - - t.commit (); - } - - // Reload. - // - { - transaction t (db->begin ()); - - // Make sure reload doesn't modify the object if the versions - // match. - // - derived d1 (d); - d1.num++; - d1.str += "d"; - d1.strs.push_back ("dddd"); - d1.nums.push_back (24); - d1.dnum++; - d1.dstr += "d"; - derived d2 (d1); - - db->reload (d1); - assert (d1 == d2); - - t.commit (); - } - - // Erase. - // - { - transaction t (db->begin ()); - - // Root. - // - { - unique_ptr p (db->load (r.id)); - - r.num++; - r.strs.push_back ("aaaaa"); - db->update (r); - - try - { - db->erase (p); - assert (false); - } - catch (const odb::object_changed&) {} - - db->reload (p); - db->erase (p); - } - - // Base. - // - { - unique_ptr p (db->load (b.id)); - - b.num++; - b.str += "b"; - b.strs.push_back ("bbbb"); - b.nums.push_back (24); - db->update (b); - - try - { - db->erase (p); - assert (false); - } - catch (const odb::object_changed&) {} - - db->reload (p); - db->erase (p); - } - - // Derived. - // - { - unique_ptr p (db->load (d.id)); // Via root. - - d.num++; - d.str += "d"; - d.strs.push_back ("dddd"); - d.nums.push_back (24); - d.dnum++; - d.dstr += "d"; - db->update (d); - - try - { - db->erase (p); - assert (false); - } - catch (const odb::object_changed&) {} - - db->reload (p); - db->erase (p); - } - - // Try to update non-existent object. - // - { - try - { - db->update (d); - assert (false); - } - catch (const odb::object_changed&) {} - } - - // Try to erase non-existent object. - // - { - try - { - db->erase (d); - assert (false); - } - catch (const odb::object_changed&) {} - } - - t.commit (); - } - } - - // Test 6: polymorphism and callbacks. - // - { - using namespace test6; - - base b (1, 1, "bbb"); - - unique_ptr d (new derived (2, 2, "ddd")); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (b); - db->persist (d); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d->id)); - - db->load (b.id, *pb); - db->load (d->id, *pd); - - db->reload (*pb); - db->reload (*pd); - - t.commit (); - } - - // Update. - // - { - b.num++; - d->num++; - - transaction t (db->begin ()); - db->update (b); - db->update (d); - t.commit (); - } - - // Query. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query ("ORDER BY" + query::id)); - for (result::iterator i (r.begin ()); i != r.end (); ++i) - *i; - - t.commit (); - } - - // Erase. - // - { - transaction t (db->begin ()); - db->erase (b); - db->erase (d); - t.commit (); - } - - // Recursive (delayed) loading. - // - { - derived d (3, 3, "dddd"); - d.ptr.reset (new derived (4, 4, "ddddd")); - - { - transaction t (db->begin ()); - db->persist (d); - db->persist (d.ptr); - t.commit (); - } - - { - transaction t (db->begin ()); - - unique_ptr p (db->load (d.id)); - t.commit (); - } - } - } - - // Test 7: polymorphism and object cache (session). - // - { - using namespace test7; - - shared_ptr r (new root (1, 1)); - shared_ptr b (new base (2, 2, "b")); - shared_ptr d (new derived (3, 3, "d")); - - // Persist. - // - { - session s; - - { - transaction t (db->begin ()); - db->persist (r); - db->persist (b); - db->persist (d); - t.commit (); - } - - assert (db->load (r->id) == r); - assert (db->load (b->id) == b); - assert (db->load (d->id) == d); - } - - // Load. - // - { - session s; - - transaction t (db->begin ()); - shared_ptr r1 (db->load (r->id)); - shared_ptr b1 (db->load (b->id)); - shared_ptr d1 (db->load (d->id)); - t.commit (); - - assert (db->load (r->id) == r1); - assert (db->load (b->id) == b1); - assert (db->load (d->id) == d1); - - assert (!db->find (b->id)); - } - - // Query. - // - { - typedef odb::query query; - typedef odb::result result; - - session s; - - transaction t (db->begin ()); - shared_ptr r1 (db->load (r->id)); - shared_ptr b1 (db->load (b->id)); - shared_ptr d1 (db->load (d->id)); - t.commit (); - - { - transaction t (db->begin ()); - - result r (db->query ("ORDER BY" + query::id)); - result::iterator i (r.begin ()), e (r.end ()); - - assert (i != e && i.load () == r1); - assert (++i != e && i.load () == b1); - assert (++i != e && i.load () == d1); - assert (++i == e); - - t.commit (); - } - } - - // Erase. - // - { - session s; - - { - transaction t (db->begin ()); - db->load (r->id); - db->load (b->id); - db->load (d->id); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (r); - db->erase (b); - db->erase (d); - t.commit (); - } - - { - transaction t (db->begin ()); - assert (!db->find (r->id)); - assert (!db->find (b->id)); - assert (!db->find (d->id)); - t.commit (); - } - } - } - - // Test 8: polymorphism and abstract bases. - // - { - using namespace test8; - - base b (1, 1, "b"); - interm i (2, 2, "i", true); - derived1 d1 (3, 3, "d1", true); - derived2 d2 (4, 4, "d2", false); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (b); - db->persist (static_cast (d1)); - db->persist (static_cast (d2)); - - try - { - db->persist (i); - assert (false); - } - catch (const odb::abstract_class&) {} - - try - { - db->persist (static_cast (i)); - assert (false); - } - catch (const odb::no_type_info&) {} - - t.commit (); - } - - // Load. - // - { - base vb; - interm vi; - derived1 vd1; - derived2 vd2; - - transaction t (db->begin ()); - - // load (id) - // - unique_ptr pb (db->load (b.id)); - unique_ptr pd1 (db->load (d1.id)); - unique_ptr pd2 (db->load (d2.id)); - - assert (*pb == b); - assert (*pd1 == d1); - assert (*pd2 == d2); - - // load (id, obj) - // - db->load (b.id, static_cast (vb)); - db->load (d1.id, static_cast (vd1)); - db->load (d2.id, static_cast (vd2)); - - assert (vb == b); - assert (vd1 == d1); - assert (vd2 == d2); - - try - { - db->load (i.id, static_cast (vi)); - assert (false); - } - catch (const odb::no_type_info&) {} - - // reload (obj) - // - vb.num = 0; - vd1.num = 0; - vd2.num = 0; - - db->reload (static_cast (vb)); - db->reload (static_cast (vd1)); - db->reload (static_cast (vd2)); - - assert (vb == b); - assert (vd1 == d1); - assert (vd2 == d2); - - try - { - db->reload (static_cast (vi)); - assert (false); - } - catch (const odb::no_type_info&) {} - - t.commit (); - } - - // Update. - // - { - b.num++; - b.str += 'b'; - d1.num++; - d1.str += "d1"; - d2.num++; - d2.str += "d1"; - - { - transaction t (db->begin ()); - db->update (static_cast (b)); - db->update (d1); - db->update (static_cast (d2)); - - try - { - db->update (i); - assert (false); - } - catch (const odb::abstract_class&) {} - - try - { - db->update (static_cast (i)); - assert (false); - } - catch (const odb::no_type_info&) {} - - t.commit (); - } - - { - transaction t (db->begin ()); - - unique_ptr pb (db->load (b.id)); - unique_ptr pd1 (db->load (d1.id)); - unique_ptr pd2 (db->load (d2.id)); - - t.commit (); - - assert (*pb == b); - assert (*pd1 == d1); - assert (*pd2 == d2); - } - } - - // Erase. - // - { - transaction t (db->begin ()); - db->erase (b); - db->erase (d1.id); - db->erase (static_cast (d2)); - - try - { - db->erase (i); - assert (false); - } - catch (const odb::abstract_class&) {} - - try - { - db->erase (static_cast (i)); - assert (false); - } - catch (const odb::no_type_info&) {} - - t.commit (); - } - } - - // Test 9: polymorphism and readonly classes. - // - { - using namespace test9; - - ro_root ro_r (1, 1); - rw_base rw_b (2, 2, "b"); - ro_derived ro_d (3, 3, "d"); - - rw_root rw_r (1, 1); - ro_base ro_b (2, 2, "b"); - rw_derived rw_d (3, 3, "d"); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (ro_r); - db->persist (rw_b); - db->persist (ro_d); - - db->persist (rw_r); - db->persist (ro_b); - db->persist (rw_d); - t.commit (); - } - - // Update. - // - { - ro_root ro_r1 (ro_r); - rw_base rw_b1 (rw_b); - ro_derived ro_d1 (ro_d); - - ro_base ro_b1 (ro_b); - rw_derived rw_d1 (rw_d); - - ro_r1.num++; - ro_r1.strs.push_back ("b"); - - rw_b1.num++; - rw_b1.strs.push_back ("b"); - rw_b1.str += "b"; - rw_b1.nums.push_back (2); - rw_b.str += "b"; - rw_b.nums.push_back (2); - - ro_d1.num++; - ro_d1.strs.push_back ("d"); - ro_d1.str += "d"; - ro_d1.nums.push_back (3); - ro_d1.dnum++; - ro_d1.dstr += "d"; - - rw_r.num++; - rw_r.strs.push_back ("b"); - - ro_b1.num++; - ro_b1.strs.push_back ("b"); - ro_b1.str += "b"; - ro_b1.nums.push_back (2); - - rw_d1.num++; - rw_d1.strs.push_back ("d"); - rw_d1.str += "d"; - rw_d1.nums.push_back (3); - rw_d1.dnum++; - rw_d1.dstr += "d"; - rw_d.dnum++; - rw_d.dstr += "d"; - - { - // These should be no-ops. - // - db->update (ro_r1); - db->update (static_cast (ro_d1)); - db->update (ro_b1); - - transaction t (db->begin ()); - db->update (static_cast (rw_b1)); - db->update (rw_r); - db->update (static_cast (rw_d1)); - t.commit (); - } - } - - // Load. - // - { - transaction t (db->begin ()); - - unique_ptr p_ro_r (db->load (ro_r.id)); - unique_ptr p_rw_b (db->load (rw_b.id)); - unique_ptr p_ro_d (db->load (ro_d.id)); - - unique_ptr p_rw_r (db->load (rw_r.id)); - unique_ptr p_ro_b (db->load (ro_b.id)); - unique_ptr p_rw_d (db->load (rw_d.id)); - - t.commit (); - - assert (*p_ro_r == ro_r); - assert (*p_rw_b == rw_b); - assert (*p_ro_d == ro_d); - - assert (*p_rw_r == rw_r); - assert (*p_ro_b == ro_b); - assert (*p_rw_d == rw_d); - } - } - - // Test 10: empty polymorphic classes. - // - { - using namespace test10; - - base b (1, 1); - derived d (2, 2); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (b); - db->persist (static_cast (d)); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - t.commit (); - - assert (*pb == b); - assert (*pd == d); - } - - // Update. - // - { - b.num++; - d.num++; - - transaction t (db->begin ()); - db->update (static_cast (b)); - db->update (d); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - t.commit (); - - assert (*pb == b); - assert (*pd == d); - } - } - - // Test 11: reuse and polymorphic inheritance. - // - { - using namespace test11; - - base b (1, 1, "b"); - derived d (2, 2, "d"); - - b.strs.push_back ("b"); - b.nums.push_back (1); - - d.strs.push_back ("d"); - d.nums.push_back (1); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (b); - db->persist (static_cast (d)); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - t.commit (); - - assert (*pb == b); - assert (*pd == d); - } - - // Update. - // - { - b.num++; - b.str += "b"; - b.strs.push_back ("bb"); - b.nums.push_back (2); - - d.num++; - d.str += "d"; - d.strs.push_back ("dd"); - d.nums.push_back (2); - d.dnum++; - d.dstr += "d"; - - transaction t (db->begin ()); - db->update (b); - db->update (d); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - t.commit (); - - assert (*pb == b); - assert (*pd == d); - } - - // Query. - // - { - typedef odb::query base_query; - typedef odb::result base_result; - - typedef odb::query derived_query; - typedef odb::result derived_result; - - transaction t (db->begin ()); - - { - base_result qr (db->query (base_query::num == 2)); - base_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && *i == b); - assert (++i == e); - } - - { - derived_result qr (db->query (derived_query::num == 3)); - derived_result::iterator i (qr.begin ()), e (qr.end ()); - - assert (i != e && *i == d); - assert (++i == e); - } - - t.commit (); - } - } - - // Test 12: polymorphic objects with auto id. - // - { - using namespace test12; - - base b (1); - derived d (2); - - unsigned long id1, id2; - - // Persist. - // - { - transaction t (db->begin ()); - id1 = db->persist (b); - id2 = db->persist (static_cast (d)); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - - unique_ptr pb (db->load (id1)); - unique_ptr pd (db->load (id2)); - - t.commit (); - - assert (*pb == b); - assert (*pd == d); - } - } - - // Test 13: polymorphic derived without any non-container data members - // (which results in an empty SELECT statement). - // - { - using namespace test13; - - base b; - b.nums.push_back (123); - derived d; - d.nums.push_back (123); - d.strs.push_back ("abc"); - - base1 b1; - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (b); - db->persist (d); - db->persist (b1); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - - unique_ptr pbr (db->load (b.id)); - unique_ptr pdr (db->load (d.id)); - unique_ptr pdb (db->load (d.id)); - unique_ptr pb1r (db->load (b1.id)); - t.commit (); - - base& rb (static_cast (*pbr)); - derived& rd1 (static_cast (*pdr)); - derived& rd2 (static_cast (*pdb)); - base1 rb1 (static_cast (*pb1r)); - - assert (rb.id == b.id && rb.nums == b.nums); - assert (rd1.id == d.id && rd1.nums == rd1.nums && - rd1.strs == rd1.strs); - assert (rd2.id == d.id && rd2.nums == rd2.nums && - rd2.strs == rd2.strs); - assert (rb1.id == b1.id); - } - } - - // Test 14: inverse pointer in polymorphic base. - // - { - using namespace test14; - - derived d; - d.num = 123; - - d.o1 = new object1; - d.o2 = new object2; - d.o3.push_back (new object3); - d.o4.push_back (new object4); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (d.o1); - db->persist (d.o2); - db->persist (d.o3[0]); - db->persist (d.o4[0]); - db->persist (d); - t.commit (); - } - - // Load. - // - { - session s; - - transaction t (db->begin ()); - object1* p1 (db->load (d.o1->id)); - object2* p2 (db->load (d.o2->id)); - object3* p3 (db->load (d.o3[0]->id)); - object4* p4 (db->load (d.o4[0]->id)); - t.commit (); - - assert (p1->d->num == d.num); - assert (p2->d[0]->num == d.num); - assert (p3->d[0]->num == d.num); - assert (p4->d->num == d.num); - delete p1->d; - } - - // Query. - // - { - typedef odb::query query; - typedef odb::result result; - - session s; - transaction t (db->begin ()); - - result r (db->query (query::d->num == d.num)); - result::iterator i (r.begin ()), e (r.end ()); - - assert (i != e && i->d->num == d.num); - delete i.load ()->d; - assert (++i == e); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - session s; - transaction t (db->begin ()); - - result r (db->query (query::d->num == d.num)); - result::iterator i (r.begin ()), e (r.end ()); - - assert (i != e && i->d->num == d.num); - delete i.load ()->d; - assert (++i == e); - t.commit (); - } - } - - // Test 15: LOB/long data and polymorphism. - // - { - using namespace test15; - - const char data[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B"; - - derived d; - d.blob.assign (data, data + sizeof (data)); - - // Persist. - // - { - transaction t (db->begin ()); - base* b (&d); - db->persist (b); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - - unique_ptr pb (db->load (d.id)); - t.commit (); - - derived* pd (dynamic_cast (pb.get ())); - assert (pd != 0 && pd->blob == d.blob); - } - - // Query. - // - { - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query ()); - result::iterator i (r.begin ()), e (r.end ()); - - assert (i != e); - - derived* pd (dynamic_cast (&*i)); - assert (pd != 0 && pd->blob == d.blob); - - assert (++i == e); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/inheritance/polymorphism/test1.hxx b/common/inheritance/polymorphism/test1.hxx deleted file mode 100644 index 7f598de..0000000 --- a/common/inheritance/polymorphism/test1.hxx +++ /dev/null @@ -1,115 +0,0 @@ -// file : common/inheritance/polymorphism/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#include -#include -#include - -#include - -// Test basic polymorphism functionality. -// -#pragma db namespace table("t1_") -namespace test1 -{ - #pragma db object polymorphic - struct root - { - virtual ~root () {} - root () {} - root (unsigned long i, unsigned long n): id (i), num (n) {} - - #pragma db id column("object_id") - unsigned long id; - - unsigned long num; - std::vector strs; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (root)) - return false; - - return id == r.id && num == r.num && strs == r.strs; - } - }; - - inline bool - operator== (const root& x, const root& y) {return x.compare (y);} - - #pragma db object - struct base: root - { - base () {} - base (unsigned long i, unsigned long n, const std::string& s) - : root (i, n), str (s) {} - - std::string str; - std::vector nums; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (base)) - return false; - - const base& b (static_cast (r)); - return root::compare (r, false) && str == b.str && nums == b.nums; - } - }; - - #pragma db object - struct derived: base - { - derived () {} - derived (unsigned long i, unsigned long n, const std::string& s) - : base (i, n, s), dnum (n + 1), dstr (s + 'd') {} - - unsigned long dnum; - std::string dstr; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (derived)) - return false; - - const derived& d (static_cast (r)); - return base::compare (r, false) && dnum == d.dnum && dstr == d.dstr; - } - }; - - // Views. - // - #pragma db view object(root) - struct root_view - { - //#pragma db column(root::typeid_) - std::string typeid_; // @@ tmp - - unsigned long num; - }; - - #pragma db view object(base = b) - struct base_view - { - unsigned long id; - unsigned long num; - std::string str; - }; - - #pragma db view object(derived) - struct derived_view - { - unsigned long num; - std::string str; - unsigned long dnum; - std::string dstr; - }; -} - -#endif // TEST1_HXX diff --git a/common/inheritance/polymorphism/test10.hxx b/common/inheritance/polymorphism/test10.hxx deleted file mode 100644 index 63673a1..0000000 --- a/common/inheritance/polymorphism/test10.hxx +++ /dev/null @@ -1,78 +0,0 @@ -// file : common/inheritance/polymorphism/test10.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST10_HXX -#define TEST10_HXX - -#include - -#include - -// Test empty polymorphic classes. -// -#pragma db namespace table("t10_") -namespace test10 -{ - #pragma db object polymorphic - struct root - { - virtual ~root () = 0; // Auto-abstract. - root () {} - root (unsigned long i): id (i) {} - - #pragma db id - unsigned long id; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (root)) - return false; - - return id == r.id; - } - }; - - inline root:: - ~root () {} - - inline bool - operator== (const root& x, const root& y) {return x.compare (y);} - - #pragma db object - struct base: root - { - base () {} - base (unsigned long i, unsigned long n): root (i), num (n) {} - - unsigned long num; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (base)) - return false; - - const base& b (static_cast (r)); - return root::compare (r, false) && num == b.num; - } - }; - - #pragma db object - struct derived: base - { - derived () {} - derived (unsigned long i, unsigned long n): base (i, n) {} - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (derived)) - return false; - - return base::compare (r, false); - } - }; -} - -#endif // TEST10_HXX diff --git a/common/inheritance/polymorphism/test11.hxx b/common/inheritance/polymorphism/test11.hxx deleted file mode 100644 index 2d38a6c..0000000 --- a/common/inheritance/polymorphism/test11.hxx +++ /dev/null @@ -1,78 +0,0 @@ -// file : common/inheritance/polymorphism/test11.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST11_HXX -#define TEST11_HXX - -#include -#include -#include - -#include - -// Test mixing reuse and polymorphic inheritance. -// -#pragma db namespace table("t11_") -namespace test11 -{ - #pragma db object abstract - struct root - { - root () {} - root (unsigned long i, unsigned long n): id (i), num (n) {} - - #pragma db id - unsigned long id; - - unsigned long num; - std::vector strs; - }; - - #pragma db object polymorphic - struct base: root - { - virtual ~base () {} - base () {} - base (unsigned long i, unsigned long n, const std::string& s) - : root (i, n), str (s) {} - - std::string str; - std::vector nums; - - virtual bool - compare (const base& b, bool tc = true) const - { - if (tc && typeid (b) != typeid (base)) - return false; - - return id == b.id && num == b.num && strs == b.strs && - str == b.str && nums == b.nums; - } - }; - - inline bool - operator== (const base& x, const base& y) {return x.compare (y);} - - #pragma db object - struct derived: base - { - derived () {} - derived (unsigned long i, unsigned long n, const std::string& s) - : base (i, n, s), dnum (n + 1), dstr (s + 'd') {} - - unsigned long dnum; - std::string dstr; - - virtual bool - compare (const base& b, bool tc = true) const - { - if (tc && typeid (b) != typeid (derived)) - return false; - - const derived& d (static_cast (b)); - return base::compare (b, false) && dnum == d.dnum && dstr == d.dstr; - } - }; -} - -#endif // TEST11_HXX diff --git a/common/inheritance/polymorphism/test12.hxx b/common/inheritance/polymorphism/test12.hxx deleted file mode 100644 index 85000ac..0000000 --- a/common/inheritance/polymorphism/test12.hxx +++ /dev/null @@ -1,79 +0,0 @@ -// file : common/inheritance/polymorphism/test12.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST12_HXX -#define TEST12_HXX - -#include - -#include - -// Test polymorphic classes with private auto id. -// -#pragma db namespace table("t12_") -namespace test12 -{ - #pragma db object polymorphic - struct root - { - virtual ~root () = 0; // Auto-abstract. - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (root)) - return false; - - return id_ == r.id_; - } - - unsigned long id () const {return id_;} - void id (unsigned long id) {id_ = id;} - private: - #pragma db id auto access(id) - unsigned long id_; - }; - - inline root:: - ~root () {} - - inline bool - operator== (const root& x, const root& y) {return x.compare (y);} - - #pragma db object - struct base: root - { - base () {} - base (unsigned long n): num (n) {} - - unsigned long num; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (base)) - return false; - - const base& b (static_cast (r)); - return root::compare (r, false) && num == b.num; - } - }; - - #pragma db object - struct derived: base - { - derived () {} - derived (unsigned long n): base (n) {} - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (derived)) - return false; - - return base::compare (r, false); - } - }; -} - -#endif // TEST12_HXX diff --git a/common/inheritance/polymorphism/test13.hxx b/common/inheritance/polymorphism/test13.hxx deleted file mode 100644 index 3240a9a..0000000 --- a/common/inheritance/polymorphism/test13.hxx +++ /dev/null @@ -1,46 +0,0 @@ -// file : common/inheritance/polymorphism/test13.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST13_HXX -#define TEST13_HXX - -#include -#include - -#include - -// Test polymorphic derived without any non-container data members (which -// results in an empty SELECT statement). -// -#pragma db namespace table("t13_") -namespace test13 -{ - #pragma db object polymorphic - struct root - { - virtual ~root () {} - - #pragma db id auto - unsigned long id; - }; - - #pragma db object - struct base: root - { - std::vector nums; - }; - - #pragma db object - struct derived: base - { - std::vector strs; - }; - - #pragma db object - struct base1: root - { - // Nothing. - }; -} - -#endif // TEST13_HXX diff --git a/common/inheritance/polymorphism/test14.hxx b/common/inheritance/polymorphism/test14.hxx deleted file mode 100644 index 1050861..0000000 --- a/common/inheritance/polymorphism/test14.hxx +++ /dev/null @@ -1,99 +0,0 @@ -// file : common/inheritance/polymorphism/test14.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST14_HXX -#define TEST14_HXX - -#include - -#include - -// Test inverse pointer in polymorphic base. -// -#pragma db namespace table("t14_") -namespace test14 -{ - struct object1; - struct object2; - struct object3; - struct object4; - - #pragma db object polymorphic session - struct base - { - virtual ~base (); - - #pragma db id auto - unsigned long id; - - object1* o1; - object2* o2; - std::vector o3; - std::vector o4; - }; - - #pragma db object - struct derived: base - { - unsigned long num; - }; - - // one-to-one(i) - // - #pragma db object session - struct object1 - { - #pragma db id auto - unsigned long id; - - #pragma db inverse(o1) - derived* d; - }; - - // one-to-many(i) - // - #pragma db object session - struct object2 - { - #pragma db id auto - unsigned long id; - - #pragma db inverse(o2) - std::vector d; - }; - - // many-to-many(i) - // - #pragma db object session - struct object3 - { - #pragma db id auto - unsigned long id; - - #pragma db inverse(o3) - std::vector d; - }; - - // many-to-one(i) - // - #pragma db object session - struct object4 - { - #pragma db id auto - unsigned long id; - - #pragma db inverse(o4) - derived* d; - }; - - inline base:: - ~base () - { - delete o1; - delete o2; - delete o3[0]; - delete o4[0]; - } -} - -#endif // TEST14_HXX diff --git a/common/inheritance/polymorphism/test15.hxx b/common/inheritance/polymorphism/test15.hxx deleted file mode 100644 index 5799ace..0000000 --- a/common/inheritance/polymorphism/test15.hxx +++ /dev/null @@ -1,44 +0,0 @@ -// file : common/inheritance/polymorphism/test15.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST15_HXX -#define TEST15_HXX - -#include - -#include - -#ifdef ODB_COMPILER -# if defined(ODB_DATABASE_PGSQL) -# define BLOB_TYPE "BYTEA" -# elif defined(ODB_DATABASE_MSSQL) -# define BLOB_TYPE "VARBINARY(max)" -# else -# define BLOB_TYPE "BLOB" -# endif -#endif - - -// Test LOB/long data and polymorphism. -// -#pragma db namespace table("t15_") -namespace test15 -{ - #pragma db object polymorphic - struct base - { - virtual ~base () {} - - #pragma db id auto - unsigned long id; - }; - - #pragma db object - struct derived: base - { - #pragma db type(BLOB_TYPE) - std::vector blob; - }; -} - -#endif // TEST15_HXX diff --git a/common/inheritance/polymorphism/test2.hxx b/common/inheritance/polymorphism/test2.hxx deleted file mode 100644 index 9890e02..0000000 --- a/common/inheritance/polymorphism/test2.hxx +++ /dev/null @@ -1,105 +0,0 @@ -// file : common/inheritance/polymorphism/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#include -#include - -#include -#include - -// Test inverse object pointers in polymorhic bases. -// -#pragma db namespace table("t2_") -namespace test2 -{ - struct root; - - #pragma db object - struct root_pointer - { - root_pointer (root* r = 0): p (r) {} - - #pragma db id auto - unsigned long id; - - root* p; - }; - - #pragma db object polymorphic - struct root - { - virtual ~root () {} - root () {} - root (unsigned long i): id (i) {} - - #pragma db id - unsigned long id; - - #pragma db inverse(p) - odb::lazy_ptr rp; - }; - - struct base; - - #pragma db object - struct base_pointer - { - base_pointer (base* b = 0) {if (b != 0) vp.push_back (b);} - - #pragma db id auto - unsigned long id; - - std::vector vp; - }; - - #pragma db object - struct base: root - { - base () {} - base (unsigned long i, const std::string& s): root (i), str (s) {} - - std::string str; - - #pragma db inverse(vp) - odb::lazy_ptr bp; - }; - - #pragma db object - struct derived: base - { - derived () {} - derived (unsigned long i, const std::string& s, unsigned long n) - : base (i, s), num (n) {} - - unsigned long num; - }; - - // Views. - // - #pragma db view object(root_pointer = rp) object(root) - struct root_view - { - #pragma db column(rp::id) - unsigned long rp_id; - - #pragma db column(root::id) - unsigned long r_id; - }; - - #pragma db view object(base_pointer) object(base = b) - struct base_view - { - #pragma db column(base_pointer::id) - unsigned long bp_id; - - #pragma db column(b::id) - unsigned long b_id; - - std::string str; - }; -} - -#endif // TEST2_HXX diff --git a/common/inheritance/polymorphism/test3.hxx b/common/inheritance/polymorphism/test3.hxx deleted file mode 100644 index fd68f24..0000000 --- a/common/inheritance/polymorphism/test3.hxx +++ /dev/null @@ -1,146 +0,0 @@ -// file : common/inheritance/polymorphism/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#include -#include - -#include - -// Test delayed loading. -// -#pragma db namespace table("t3_") -namespace test3 -{ - #pragma db object polymorphic - struct root - { - virtual ~root () {} - root () {} - root (unsigned long i): id (i) {} - - #pragma db id - unsigned long id; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (root)) - return false; - - return id == r.id; - } - }; - - inline bool - operator== (const root& x, const root& y) {return x.compare (y);} - - #pragma db object - struct base: root - { - virtual ~base () {delete rptr;} - base (): rptr (0) {} - base (unsigned long i, unsigned long n): root (i), num (n), rptr (0) {} - - unsigned long num; - root* rptr; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (base)) - return false; - - const base& b (static_cast (r)); - return - root::compare (r, false) && - num == b.num && - ((rptr == 0 && b.rptr == 0) || rptr->compare (*b.rptr)); - } - }; - - #pragma db object - struct derived: base - { - virtual ~derived () {delete bptr;} - derived (): bptr (0) {} - derived (unsigned long i, unsigned long n, const std::string& s) - : base (i, n), str (s), bptr (0) {} - - std::string str; - base* bptr; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (derived)) - return false; - - const derived& d (static_cast (r)); - return - base::compare (r, false) && - str == d.str && - ((bptr == 0 && d.bptr == 0) || bptr->compare (*d.bptr)); - } - }; - - // Views. - // - #pragma db view object(base) object(root = r) - struct base_view - { - #pragma db column(base::id) - unsigned long b_id; - - #pragma db column(r::id) - unsigned long r_id; - - unsigned long num; - }; - - #pragma db view \ - object(derived = d) \ - object(base = b) \ - object(root = r: d::rptr) - struct derived_view - { - #pragma db column(d::id) - unsigned long d_id; - - #pragma db column(b::id) - unsigned long b_id; - - #pragma db column(r::id) - unsigned long r_id; - - #pragma db column(d::num) - unsigned long d_num; - - #pragma db column(b::num) - unsigned long b_num; - - std::string str; - }; - - // This is an example of a pathological case, where the right-hand-side - // of the join condition comes from one of the bases. As a result, we - // join the base table first, which means we will get both bases and - // derived objects instead of just derived. - // - //#pragma db view object(root = r) object(derived = d) - #pragma db view object(derived = d) object(root = r) - struct root_view - { - #pragma db column(r::id) - unsigned long r_id; - - #pragma db column(d::id) - unsigned long d_id; - - std::string str; - }; -} - -#endif // TEST3_HXX diff --git a/common/inheritance/polymorphism/test4.hxx b/common/inheritance/polymorphism/test4.hxx deleted file mode 100644 index 148c53c..0000000 --- a/common/inheritance/polymorphism/test4.hxx +++ /dev/null @@ -1,84 +0,0 @@ -// file : common/inheritance/polymorphism/test4.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST4_HXX -#define TEST4_HXX - -#include - -#include - -// Test views. -// -#pragma db namespace table("t4_") -namespace test4 -{ - #pragma db object polymorphic - struct root1 - { - virtual ~root1 () {} - root1 () {} - root1 (unsigned long i): id (i) {} - - #pragma db id - unsigned long id; - }; - - #pragma db object - struct base1: root1 - { - base1 () {} - base1 (unsigned long i, unsigned long n): root1 (i), num (n) {} - - unsigned long num; - }; - - #pragma db object polymorphic - struct root2 - { - virtual ~root2 () {} - root2 () {} - root2 (unsigned long i, unsigned long n): id (i), num (n) {} - - #pragma db id - unsigned long id; - - unsigned long num; - }; - - #pragma db object - struct base2: root2 - { - base2 () {} - base2 (unsigned long i, unsigned long n, const std::string& s) - : root2 (i, n), str (s) {} - - std::string str; - }; - - // Test custom join condition. - // - #pragma db view object(base2) object(base1: base2::num == base1::num) - struct view1 - { - std::string str; - }; - - #pragma db view object(base2) - struct view2 - { - #pragma db column("min(" + base2::num + ")") - unsigned long min_num; - }; - - // Test custom join condition that uses object id. It cannot come - // from the base since the base table hasn't been join'ed yet. - // - #pragma db view object(base1) object(base2: base2::id == base1::id) - struct view3 - { - std::string str; - }; -} - -#endif // TEST4_HXX diff --git a/common/inheritance/polymorphism/test5.hxx b/common/inheritance/polymorphism/test5.hxx deleted file mode 100644 index 172e7e8..0000000 --- a/common/inheritance/polymorphism/test5.hxx +++ /dev/null @@ -1,92 +0,0 @@ -// file : common/inheritance/polymorphism/test5.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST5_HXX -#define TEST5_HXX - -#include -#include -#include -#include - -#include - -// Test polymorphism and optimistic concurrency. -// -#pragma db namespace table("t5_") -namespace test5 -{ - #pragma db object polymorphic optimistic pointer(std::unique_ptr) - struct root - { - virtual ~root () {} - root () {} - root (unsigned long i, unsigned long n): id (i), num (n) {} - - #pragma db id - unsigned long id; - - #pragma db version - unsigned long version; - - unsigned long num; - std::vector strs; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (root)) - return false; - - return id == r.id && version == r.version && - num == r.num && strs == r.strs; - } - }; - - inline bool - operator== (const root& x, const root& y) {return x.compare (y);} - - #pragma db object - struct base: root - { - base () {} - base (unsigned long i, unsigned long n, const std::string& s) - : root (i, n), str (s) {} - - std::string str; - std::vector nums; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (base)) - return false; - - const base& b (static_cast (r)); - return root::compare (r, false) && str == b.str && nums == b.nums; - } - }; - - #pragma db object - struct derived: base - { - derived () {} - derived (unsigned long i, unsigned long n, const std::string& s) - : base (i, n, s), dnum (n + 1), dstr (s + 'd') {} - - unsigned long dnum; - std::string dstr; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (derived)) - return false; - - const derived& d (static_cast (r)); - return base::compare (r, false) && dnum == d.dnum && dstr == d.dstr; - } - }; -} - -#endif // TEST5_HXX diff --git a/common/inheritance/polymorphism/test6.hxx b/common/inheritance/polymorphism/test6.hxx deleted file mode 100644 index b0f9a16..0000000 --- a/common/inheritance/polymorphism/test6.hxx +++ /dev/null @@ -1,64 +0,0 @@ -// file : common/inheritance/polymorphism/test6.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST6_HXX -#define TEST6_HXX - -#include -#include - -#include -#include - -// Test polymorphism and callbacks. -// -#pragma db namespace table("t6_") -namespace test6 -{ - #pragma db object polymorphic pointer(std::unique_ptr) - struct root - { - virtual ~root () {} - root (): id (0) {} - root (unsigned long i, unsigned long n): id (i), num (n) {} - - #pragma db id - unsigned long id; - - unsigned long num; - }; - - #pragma db object callback(db_callback) - struct base: root - { - base () {} - base (unsigned long i, unsigned long n, const std::string& s) - : root (i, n), str (s) {} - - std::string str; - - void - db_callback (odb::callback_event, odb::database&); - - void - db_callback (odb::callback_event, odb::database&) const; - }; - - #pragma db object callback(db_callback) - struct derived: base - { - derived () {} - derived (unsigned long i, unsigned long n, const std::string& s) - : base (i, n, s), dnum (n + 1), dstr (s + 'd') {} - - unsigned long dnum; - std::string dstr; - - std::unique_ptr ptr; - - void - db_callback (odb::callback_event, odb::database&) const; - }; -} - -#endif // TEST6_HXX diff --git a/common/inheritance/polymorphism/test7.hxx b/common/inheritance/polymorphism/test7.hxx deleted file mode 100644 index 60da98e..0000000 --- a/common/inheritance/polymorphism/test7.hxx +++ /dev/null @@ -1,54 +0,0 @@ -// file : common/inheritance/polymorphism/test7.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST7_HXX -#define TEST7_HXX - -#include -#include - -#include - -// Test polymorphism and object cache (session). -// -#pragma db namespace table("t7_") -namespace test7 -{ - using std::shared_ptr; - - #pragma db object polymorphic pointer(shared_ptr) session - struct root - { - virtual ~root () {} - root (): id (0) {} - root (unsigned long i, unsigned long n): id (i), num (n) {} - - #pragma db id - unsigned long id; - - unsigned long num; - }; - - #pragma db object - struct base: root - { - base () {} - base (unsigned long i, unsigned long n, const std::string& s) - : root (i, n), str (s) {} - - std::string str; - }; - - #pragma db object - struct derived: base - { - derived () {} - derived (unsigned long i, unsigned long n, const std::string& s) - : base (i, n, s), dnum (n + 1), dstr (s + 'd') {} - - unsigned long dnum; - std::string dstr; - }; -} - -#endif // TEST7_HXX diff --git a/common/inheritance/polymorphism/test8.hxx b/common/inheritance/polymorphism/test8.hxx deleted file mode 100644 index 84b6688..0000000 --- a/common/inheritance/polymorphism/test8.hxx +++ /dev/null @@ -1,129 +0,0 @@ -// file : common/inheritance/polymorphism/test8.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST8_HXX -#define TEST8_HXX - -#include -#include -#include - -#include - -// Test polymorphism and abstract bases. -// -#pragma db namespace table("t8_") -namespace test8 -{ - #pragma db object polymorphic - struct root - { - virtual ~root () = 0; // Auto-abstract. - root () {} - root (unsigned long i, unsigned long n): id (i), num (n) {} - - #pragma db id - unsigned long id; - - unsigned long num; - std::vector strs; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (root)) - return false; - - return id == r.id && num == r.num && strs == r.strs; - } - }; - - inline root:: - ~root () {} - - inline bool - operator== (const root& x, const root& y) {return x.compare (y);} - - #pragma db object - struct base: root - { - base () {} - base (unsigned long i, unsigned long n, const std::string& s) - : root (i, n), str (s) {} - - std::string str; - std::vector nums; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (base)) - return false; - - const base& b (static_cast (r)); - return root::compare (r, false) && str == b.str && nums == b.nums; - } - }; - - #pragma db object abstract - struct interm: base - { - interm () {} - interm (unsigned long i, unsigned long n, const std::string& s, bool b) - : base (i, n, s), bln (b) {} - - bool bln; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (interm)) - return false; - - const interm& i (static_cast (r)); - return base::compare (r, false) && bln == i.bln; - } - }; - - #pragma db object - struct derived1: interm - { - derived1 () {} - derived1 (unsigned long i, unsigned long n, const std::string& s, bool b) - : interm (i, n, s, b), dnum (n + 1) {} - - unsigned long dnum; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (derived1)) - return false; - - const derived1& d (static_cast (r)); - return interm::compare (r, false) && dnum == d.dnum; - } - }; - - #pragma db object - struct derived2: interm - { - derived2 () {} - derived2 (unsigned long i, unsigned long n, const std::string& s, bool b) - : interm (i, n, s, b), dstr (s + 'd') {} - - std::string dstr; - - virtual bool - compare (const root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (derived2)) - return false; - - const derived2& d (static_cast (r)); - return interm::compare (r, false) && dstr == d.dstr; - } - }; -} - -#endif // TEST8_HXX diff --git a/common/inheritance/polymorphism/test9.hxx b/common/inheritance/polymorphism/test9.hxx deleted file mode 100644 index cdc97ae..0000000 --- a/common/inheritance/polymorphism/test9.hxx +++ /dev/null @@ -1,161 +0,0 @@ -// file : common/inheritance/polymorphism/test9.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST9_HXX -#define TEST9_HXX - -#include -#include -#include - -#include - -// Test polymorphism and readonly classes. -// -#pragma db namespace table("t9_") -namespace test9 -{ - // - // ro_root, rw_base, ro_derived - // - #pragma db object polymorphic readonly - struct ro_root - { - virtual ~ro_root () {} - ro_root () {} - ro_root (unsigned long i, unsigned long n): id (i), num (n) {} - - #pragma db id - unsigned long id; - - unsigned long num; - std::vector strs; - - virtual bool - compare (const ro_root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (ro_root)) - return false; - - return id == r.id && num == r.num && strs == r.strs; - } - }; - - inline bool - operator== (const ro_root& x, const ro_root& y) {return x.compare (y);} - - #pragma db object - struct rw_base: ro_root - { - rw_base () {} - rw_base (unsigned long i, unsigned long n, const std::string& s) - : ro_root (i, n), str (s) {} - - std::string str; - std::vector nums; - - virtual bool - compare (const ro_root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (rw_base)) - return false; - - const rw_base& b (static_cast (r)); - return ro_root::compare (r, false) && str == b.str && nums == b.nums; - } - }; - - #pragma db object readonly - struct ro_derived: rw_base - { - ro_derived () {} - ro_derived (unsigned long i, unsigned long n, const std::string& s) - : rw_base (i, n, s), dnum (n + 1), dstr (s + 'd') {} - - unsigned long dnum; - std::string dstr; - - virtual bool - compare (const ro_root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (ro_derived)) - return false; - - const ro_derived& d (static_cast (r)); - return rw_base::compare (r, false) && dnum == d.dnum && dstr == d.dstr; - } - }; - - // - // rw_root, ro_base, rw_derived - // - #pragma db object polymorphic - struct rw_root - { - virtual ~rw_root () {} - rw_root () {} - rw_root (unsigned long i, unsigned long n): id (i), num (n) {} - - #pragma db id - unsigned long id; - - unsigned long num; - std::vector strs; - - virtual bool - compare (const rw_root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (rw_root)) - return false; - - return id == r.id && num == r.num && strs == r.strs; - } - }; - - inline bool - operator== (const rw_root& x, const rw_root& y) {return x.compare (y);} - - #pragma db object readonly - struct ro_base: rw_root - { - ro_base () {} - ro_base (unsigned long i, unsigned long n, const std::string& s) - : rw_root (i, n), str (s) {} - - std::string str; - std::vector nums; - - virtual bool - compare (const rw_root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (ro_base)) - return false; - - const ro_base& b (static_cast (r)); - return rw_root::compare (r, false) && str == b.str && nums == b.nums; - } - }; - - #pragma db object - struct rw_derived: ro_base - { - rw_derived () {} - rw_derived (unsigned long i, unsigned long n, const std::string& s) - : ro_base (i, n, s), dnum (n + 1), dstr (s + 'd') {} - - unsigned long dnum; - std::string dstr; - - virtual bool - compare (const rw_root& r, bool tc = true) const - { - if (tc && typeid (r) != typeid (rw_derived)) - return false; - - const rw_derived& d (static_cast (r)); - return ro_base::compare (r, false) && dnum == d.dnum && dstr == d.dstr; - } - }; -} - -#endif // TEST9_HXX diff --git a/common/inheritance/polymorphism/testscript b/common/inheritance/polymorphism/testscript deleted file mode 100644 index 89e5726..0000000 --- a/common/inheritance/polymorphism/testscript +++ /dev/null @@ -1,80 +0,0 @@ -# file : common/inheritance/polymorphism/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -+cat <=output - base pre_persist 1 const - base post_persist 1 const - derived pre_persist 2 const - derived post_persist 2 const - base pre_load 0 - base post_load 1 - derived pre_load 0 const - derived post_load 2 const - base pre_load 1 - base post_load 1 - derived pre_load 2 const - derived post_load 2 const - base pre_load 1 - base post_load 1 - derived pre_load 2 const - derived post_load 2 const - base pre_update 1 const - base post_update 1 const - derived pre_update 2 const - derived post_update 2 const - base pre_load 0 - base post_load 1 - derived pre_load 0 const - derived post_load 2 const - base pre_erase 1 const - base post_erase 1 const - derived pre_erase 2 const - derived post_erase 2 const - derived pre_persist 3 const - derived post_persist 3 const - derived pre_persist 4 const - derived post_persist 4 const - derived pre_load 0 const - derived pre_load 0 const - derived post_load 4 const - derived post_load 3 const - EOI - -test.redirects += >>>../output - -: mysql -: -if $mysql -{ - .include ../../../mysql-schema.testscript - - for s: $schemas - cat $out_base/"$s"($multi ? '-mysql' : '').sql | $create_schema_cmd - end; - - $* ($multi ? 'mysql' : ) $mysql_options -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql-schema.testscript - - for s: $schemas - $create_schema_cmd -f $out_base/"$s"($multi ? '-pgsql' : '').sql - end; - - $* ($multi ? 'pgsql' : ) $pgsql_options -} diff --git a/common/inheritance/reuse/buildfile b/common/inheritance/reuse/buildfile deleted file mode 100644 index b82439a..0000000 --- a/common/inheritance/reuse/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/inheritance/reuse/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix inhrt_r_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/inheritance/reuse/driver.cxx b/common/inheritance/reuse/driver.cxx deleted file mode 100644 index e6122bb..0000000 --- a/common/inheritance/reuse/driver.cxx +++ /dev/null @@ -1,237 +0,0 @@ -// file : common/inheritance/reuse/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test reuse object inheritance. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - base b; - b.comp_.bools.push_back (true); - b.comp_.obools.push_back (true); - b.comp_.num = 10; - b.comp_.str = "comp bbb"; - b.comp_.nums.push_back (101); - b.comp_.nums.push_back (102); - b.comp_.onums.push_back (101); - b.comp_.onums.push_back (102); - b.num_ = 0; - b.str_ = "bbb"; - b.strs_.push_back ("bbb one"); - b.strs_.push_back ("bbb two"); - b.ostrs_.push_back ("bbb one"); - b.ostrs_.push_back ("bbb two"); - - object1 o1; - o1.comp_.bools.push_back (false); - o1.comp_.obools.push_back (false); - o1.comp_.num = 11; - o1.comp_.str = "comp o1o1o1"; - o1.comp_.nums.push_back (111); - o1.comp_.nums.push_back (112); - o1.comp_.onums.push_back (111); - o1.comp_.onums.push_back (112); - static_cast (o1).num_ = 1; - o1.num1_ = 21; - o1.str_ = "base o1o1o1"; - o1.strs_.push_back ("base o1o1o1 one"); - o1.strs_.push_back ("base o1o1o1 two"); - o1.ostrs_.push_back ("base o1o1o1 one"); - o1.ostrs_.push_back ("base o1o1o1 two"); - - object2 o2; - o2.comp_.bools.push_back (true); - o2.comp_.bools.push_back (false); - o2.comp_.obools.push_back (true); - o2.comp_.obools.push_back (false); - o2.comp_.num = 12; - o2.comp_.str = "comp o2o2o2"; - o2.comp_.nums.push_back (121); - o2.comp_.nums.push_back (122); - o2.comp_.onums.push_back (121); - o2.comp_.onums.push_back (122); - o2.num_ = 2; - static_cast (o2).str_ = "base o2o2o2"; - o2.str_ = "o2o2o2"; - o2.strs_.push_back ("base o2o2o2 one"); - o2.strs_.push_back ("base o2o2o2 two"); - o2.ostrs_.push_back ("base o2o2o2 one"); - o2.ostrs_.push_back ("base o2o2o2 two"); - - object3 o3; - o3.comp_.bools.push_back (false); - o3.comp_.bools.push_back (false); - o3.comp_.obools.push_back (false); - o3.comp_.obools.push_back (false); - o3.comp_.num = 13; - o3.comp_.str = "comp o3o3o3"; - o3.comp_.nums.push_back (131); - o3.comp_.nums.push_back (132); - o3.comp_.onums.push_back (131); - o3.comp_.onums.push_back (132); - o3.num_ = 3; - o3.str_ = "base o3o3o3"; - o3.strs_.push_back ("base o3o3o3 one"); - o3.strs_.push_back ("base o3o3o3 two"); - o3.ostrs_.push_back ("base o3o3o3 one"); - o3.ostrs_.push_back ("base o3o3o3 two"); - - reference r; - r.o1_ = &o1; - - empty_object e; - e.comp_.bools.push_back (true); - e.comp_.bools.push_back (true); - e.comp_.obools.push_back (true); - e.comp_.obools.push_back (true); - e.comp_.num = 14; - e.comp_.str = "comp eee"; - e.comp_.nums.push_back (141); - e.comp_.nums.push_back (142); - e.comp_.onums.push_back (141); - e.comp_.onums.push_back (142); - e.num_ = 4; - e.str_ = "base eee"; - e.strs_.push_back ("base eee one"); - e.strs_.push_back ("base eee two"); - e.ostrs_.push_back ("base eee one"); - e.ostrs_.push_back ("base eee two"); - - // persist - // - { - transaction t (db->begin ()); - db->persist (b); - db->persist (o1); - db->persist (o2); - db->persist (o3); - db->persist (r); - db->persist (e); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - unique_ptr lb (db->load (b.id_)); - unique_ptr lo1 (db->load (o1.id_)); - unique_ptr lo2 (db->load (o2.id_)); - unique_ptr lo3 (db->load (o3.id_)); - unique_ptr le (db->load (e.id_)); - unique_ptr lr (db->load (r.id_)); - t.commit (); - - assert (b == *lb); - assert (o1 == *lo1); - assert (o2 == *lo2); - assert (o3 == *lo3); - assert (lr->o1_->id_ == r.o1_->id_); - assert (e == *le); - - delete lr->o1_; - } - - // update - // - { - transaction t (db->begin ()); - db->update (b); - db->update (o1); - db->update (o2); - db->update (o3); - db->update (r); - db->update (e); - t.commit (); - } - - // query - // - { - typedef odb::query b_query; - typedef odb::query o1_query; - typedef odb::query o2_query; - typedef odb::query r_query; - - typedef odb::result r_result; - - transaction t (db->begin ()); - - assert (!db->query (b_query::comp.num == 10).empty ()); - assert (!db->query (o1_query::num1 == 21).empty ()); - assert (!db->query (o2_query::num == 2).empty ()); - - // Query condition with hidden members. - // - assert ( - !db->query (o2_query::base::str == "base o2o2o2").empty ()); - - // Query condition with referenced composite member in base class. - // - { - r_result r (db->query (r_query::o1->comp.num == 11)); - assert (!r.empty ()); - delete r.begin ()->o1_; - } - - t.commit (); - } - - // views - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query (query::num == o2.num_)); - result::iterator i (r.begin ()); - assert (i != r.end () && - i->num == o2.num_ && i->id == o2.id_ && i->str == o2.str_); - assert (++i == r.end ()); - - t.commit (); - } - - // erase - // - { - transaction t (db->begin ()); - db->erase (b); - db->erase (o1); - db->erase (o2); - db->erase (o3); - db->erase (r); - db->erase (e); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/inheritance/reuse/test.hxx b/common/inheritance/reuse/test.hxx deleted file mode 100644 index 48f474f..0000000 --- a/common/inheritance/reuse/test.hxx +++ /dev/null @@ -1,163 +0,0 @@ -// file : common/inheritance/reuse/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include -#include - -#pragma db value -struct comp_base -{ - std::vector bools; - odb::vector obools; - - bool - operator== (const comp_base& y) const - { - return bools == y.bools && obools == y.obools; - } -}; - -#pragma db value -struct comp: comp_base -{ - unsigned int num; - std::string str; - - std::vector nums; - odb::vector onums; - - bool - operator== (const comp& y) const - { - return - static_cast (*this) == y && - num == y.num && - str == y.str && - nums == y.nums && - onums == y.onums; - } -}; - -#pragma db object abstract -struct abstract_base -{ - comp comp_; - - unsigned int num_; - std::string str_; - - std::vector strs_; - odb::vector ostrs_; - - bool - operator== (const abstract_base& y) const - { - return - comp_ == y.comp_ && - num_ == y.num_ && - str_ == y.str_ && - strs_ == y.strs_ && - ostrs_ == y.ostrs_; - } -}; - -#pragma db object -struct base: abstract_base -{ - #pragma db id auto - unsigned long id_; - - bool - operator== (const base& y) const - { - return id_ == y.id_ && static_cast (*this) == y; - } -}; - -#pragma db object -struct object1: base -{ - unsigned int num1_; - - bool - operator== (const object1& y) const - { - return static_cast (*this) == y && num1_ == y.num1_; - } -}; - -#pragma db object -struct object2: base -{ - #pragma db column("derived_str") - std::string str_; - - bool - operator== (const object2& y) const - { - return static_cast (*this) == y && str_ == y.str_; - } -}; - -// Reference to derived object. -// -#pragma db object -struct reference -{ - #pragma db id auto - unsigned long id_; - - object1* o1_; -}; - -// Multiple inheritance. -// -#pragma db object abstract -struct id_base -{ - #pragma db id auto - unsigned long id_; - - bool - operator== (const id_base& y) const - { - return id_ == y.id_; - } -}; - -#pragma db object -struct object3: abstract_base, id_base -{ - bool - operator== (const object3& y) const - { - return - static_cast (*this) == y && - static_cast (*this) == y; - } -}; - -// Empty derived object. -// -#pragma db object -struct empty_object: base -{ -}; - -// View based on the derived object. -// -#pragma db view object(object2) -struct object2_view -{ - unsigned int num; // from abstract_base - unsigned long id; // from base - std::string str; // from object2, hides one from abstract_base -}; - -#endif // TEST_HXX diff --git a/common/inheritance/reuse/testscript b/common/inheritance/reuse/testscript deleted file mode 100644 index 995b3f5..0000000 --- a/common/inheritance/reuse/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/inheritance/reuse/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/inheritance/transient/buildfile b/common/inheritance/transient/buildfile deleted file mode 100644 index 1961abc..0000000 --- a/common/inheritance/transient/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/inheritance/transient/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix inhrt_t_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/inheritance/transient/driver.cxx b/common/inheritance/transient/driver.cxx deleted file mode 100644 index 1caae6c..0000000 --- a/common/inheritance/transient/driver.cxx +++ /dev/null @@ -1,80 +0,0 @@ -// file : common/inheritance/transient/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test transient inheritance of objects, composite value types, and views. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - object o; - o.num = 1; - o.str = "abc"; - o.strs.push_back ("abc 1"); - o.strs.push_back ("abc 2"); - o.c.num = 11; - o.c.str = "comp abc"; - o.c.nums.push_back (111); - o.c.nums.push_back (112); - - // persist - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id_)); - t.commit (); - - assert (*p == o); - } - - // view - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query (query::id == o.id_)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->num == o.num && i->str == o.str); - assert (++i == r.end ()); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/inheritance/transient/test.hxx b/common/inheritance/transient/test.hxx deleted file mode 100644 index 394ee8f..0000000 --- a/common/inheritance/transient/test.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// file : common/inheritance/transient/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -struct object; - -struct base -{ - int n; - std::vector v; - object* p; -}; - -#pragma db value -struct comp: base -{ - unsigned int num; - std::string str; - std::vector nums; - - bool - operator== (const comp& y) const - { - return num == y.num && str == y.str && nums == y.nums; - } -}; - -#pragma db object -struct object: base -{ - #pragma db id auto - unsigned int id_; - - unsigned int num; - std::string str; - std::vector strs; - comp c; - - bool - operator== (const object& y) const - { - return num == y.num && str == y.str && strs == y.strs && c == y.c; - } -}; - -#pragma db view object(object) -struct view: base -{ - unsigned int num; - std::string str; -}; - -#endif // TEST_HXX diff --git a/common/inheritance/transient/testscript b/common/inheritance/transient/testscript deleted file mode 100644 index bce91de..0000000 --- a/common/inheritance/transient/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/inheritance/transient/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/inverse/buildfile b/common/inverse/buildfile deleted file mode 100644 index 63fa1cb..0000000 --- a/common/inverse/buildfile +++ /dev/null @@ -1,42 +0,0 @@ -# file : common/inverse/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_inverse_ \ - --generate-schema \ - --generate-query \ - --generate-session - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/inverse/driver.cxx b/common/inverse/driver.cxx deleted file mode 100644 index 842438e..0000000 --- a/common/inverse/driver.cxx +++ /dev/null @@ -1,502 +0,0 @@ -// file : common/inverse/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test bidirectional relationships with inverse sides. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test raw pointers. - // - { - using namespace test1; - - obj1_ptr o1_1 (new obj1); - obj1_ptr o1_2 (new obj1); - obj2_ptr o2 (new obj2); - obj3_ptr o3_1 (new obj3); - obj3_ptr o3_2 (new obj3); - obj4_ptr o4_1 (new obj4); - obj4_ptr o4_2 (new obj4); - obj5_ptr o5_1 (new obj5); - obj5_ptr o5_2 (new obj5); - obj5_ptr o5_3 (new obj5); - obj5_ptr o5_4 (new obj5); - - o1_1->id = "obj1 1"; - o1_1->o2 = o2; - o1_1->o3.insert (o3_1); - o1_1->o3.insert (o3_2); - o1_1->o4 = o4_1; - o1_1->o5.insert (o5_1); - o1_1->o5.insert (o5_2); - - o1_2->id = "obj1 2"; - o1_2->o2 = 0; - o1_2->o3.clear (); - o1_2->o4 = o4_2; - o1_2->o5.insert (o5_3); - o1_2->o5.insert (o5_4); - - o2->str = "obj2"; - o2->o1 = o1_1; - - o3_1->str = "obj3 1"; - o3_1->o1 = o1_1; - - o3_2->str = "obj3 2"; - o3_2->o1 = o1_1; - - o4_1->str = "obj4 1"; - o4_1->o1.insert (o1_1); - - o4_2->str = "obj4 2"; - o4_2->o1.insert (o1_2); - - o5_1->str = "obj5 1"; - o5_1->o1.insert (o1_1); - - o5_2->str = "obj5 2"; - o5_2->o1.insert (o1_1); - - o5_3->str = "obj5 3"; - o5_3->o1.insert (o1_2); - - o5_4->str = "obj5 4"; - o5_4->o1.insert (o1_2); - - // persist - // - { - transaction t (db->begin ()); - - // objN come before obj1 to get object id assigned. - // - db->persist (o5_1); - db->persist (o5_2); - db->persist (o5_3); - db->persist (o5_4); - db->persist (o4_1); - db->persist (o4_2); - db->persist (o3_1); - db->persist (o3_2); - db->persist (o2); - db->persist (o1_1); - db->persist (o1_2); - - t.commit (); - } - - // load - // - { - session s; - transaction t (db->begin ()); - obj2_ptr x2 (db->load (o2->id)); - obj3_ptr x3_1 (db->load (o3_1->id)); - obj3_ptr x3_2 (db->load (o3_2->id)); - obj4_ptr x4_1 (db->load (o4_1->id)); - obj4_ptr x4_2 (db->load (o4_2->id)); - obj5_ptr x5_1 (db->load (o5_1->id)); - obj5_ptr x5_2 (db->load (o5_2->id)); - obj5_ptr x5_3 (db->load (o5_3->id)); - obj5_ptr x5_4 (db->load (o5_4->id)); - t.commit (); - - assert (x2->str == o2->str); - assert (x2->o1->id == o1_1->id); - assert (x2->o1->o2 == x2); - - assert (x3_1->str == o3_1->str); - assert (x3_2->str == o3_2->str); - assert (x3_1->o1 == x3_2->o1); - assert (x3_1->o1->id == o1_1->id); - assert (x3_1->o1->o3.find (x3_1) != x3_1->o1->o3.end ()); - assert (x3_1->o1->o3.find (x3_2) != x3_1->o1->o3.end ()); - - assert (x4_1->str == o4_1->str); - assert (x4_2->str == o4_2->str); - assert ((*x4_1->o1.begin ())->id == o1_1->id); - assert ((*x4_2->o1.begin ())->id == o1_2->id); - assert ((*x4_1->o1.begin ())->o4 == x4_1); - assert ((*x4_2->o1.begin ())->o4 == x4_2); - - assert (x5_1->str == o5_1->str); - assert (x5_2->str == o5_2->str); - assert ((*x5_1->o1.begin ())->id == o1_1->id); - assert ((*x5_2->o1.begin ())->id == o1_1->id); - assert ((*x5_3->o1.begin ())->id == o1_2->id); - assert ((*x5_4->o1.begin ())->id == o1_2->id); - assert ((*x5_1->o1.begin ())->o5.find (x5_1) != - (*x5_1->o1.begin ())->o5.end ()); - assert ((*x5_2->o1.begin ())->o5.find (x5_2) != - (*x5_2->o1.begin ())->o5.end ()); - assert ((*x5_3->o1.begin ())->o5.find (x5_3) != - (*x5_3->o1.begin ())->o5.end ()); - assert ((*x5_4->o1.begin ())->o5.find (x5_4) != - (*x5_4->o1.begin ())->o5.end ()); - - delete *x4_1->o1.begin (); - delete *x4_2->o1.begin (); - } - - // query - // - { - // one(i)-to-one - // - typedef odb::query query; - typedef odb::result result; - - session s; - transaction t (db->begin ()); - - result r (db->query (query::o1->id == "obj1 1")); - assert (!r.empty ()); - assert (r.begin ()->id == o2->id); - assert (r.begin ()->o1->id == o1_1->id); - assert (size (r) == 1); - - t.commit (); - } - - { - // one(i)-to-many - // - typedef odb::query query; - typedef odb::result result; - - session s; - transaction t (db->begin ()); - - result r (db->query (query::o1->id == "obj1 1")); - size_t n (0); - - for (result::iterator i (r.begin ()); i != r.end (); ++i) - { - assert (i->id == o3_1->id || i->id == o3_2->id); - assert (i->o1->id == o1_1->id); - n++; - } - - assert (n == 2); - - t.commit (); - } - - delete o1_1; - delete o1_2; - } - - // Test shared_ptr/weak_ptr. - // - { - using namespace test2; - - obj1_ptr o1_1 (new obj1); - obj1_ptr o1_2 (new obj1); - obj2_ptr o2 (new obj2); - obj3_ptr o3_1 (new obj3); - obj3_ptr o3_2 (new obj3); - obj4_ptr o4 (new obj4); - obj5_ptr o5_1 (new obj5); - obj5_ptr o5_2 (new obj5); - - o1_1->id = "obj1 1"; - o1_1->o2 = o2; - o1_1->o3.push_back (o3_1); - o1_1->o3.push_back (o3_2); - o1_1->o4 = o4; - o1_1->o5.push_back (o5_1); - o1_1->o5.push_back (o5_2); - - o1_2->id = "obj1 2"; - o1_2->o2 = obj2_ptr (); - o1_2->o3.clear (); - o1_2->o4 = o4; - o1_2->o5.push_back (o5_1); - - o2->str = "obj2"; - o2->o1 = o1_1; - - o3_1->str = "obj3 1"; - o3_1->o1 = o1_1; - - o3_2->str = "obj3 3"; - o3_2->o1 = o1_1; - - o4->str = "obj4"; - o4->o1.push_back (o1_1); - o4->o1.push_back (o1_2); - - o5_1->str = "obj5 1"; - o5_1->o1.push_back (o1_1); - o5_1->o1.push_back (o1_2); - - o5_2->str = "obj5 2"; - o5_2->o1.push_back (o1_1); - - // persist - // - { - transaction t (db->begin ()); - - // objN come before obj1 to get object id assigned. - // - db->persist (o5_1); - db->persist (o5_2); - db->persist (o4); - db->persist (o3_1); - db->persist (o3_2); - db->persist (o2); - db->persist (o1_1); - db->persist (o1_2); - - t.commit (); - } - - // load - // - { - session s; - transaction t (db->begin ()); - obj2_ptr x2 (db->load (o2->id)); - obj3_ptr x3_1 (db->load (o3_1->id)); - obj3_ptr x3_2 (db->load (o3_2->id)); - obj4_ptr x4 (db->load (o4->id)); - obj5_ptr x5_1 (db->load (o5_1->id)); - obj5_ptr x5_2 (db->load (o5_2->id)); - t.commit (); - - assert (x2->str == o2->str); - assert (x2->o1.lock ()->id == o1_1->id); - assert (x2->o1.lock ()->o2 == x2); - - assert (x3_1->str == o3_1->str); - assert (x3_2->str == o3_2->str); - assert (x3_1->o1.lock () == x3_2->o1.lock ()); - assert (x3_1->o1.lock ()->id == o1_1->id); - assert (x3_1->o1.lock ()->o3[0] == x3_1); - assert (x3_1->o1.lock ()->o3[1] == x3_2); - - { - assert (x4->str == o4->str); - - obj1_ptr t1 (x4->o1[0].lock ()), t2 (x4->o1[1].lock ()); - - assert (t1->id == o1_1->id || t2->id == o1_1->id); - assert (t1->id == o1_2->id || t2->id == o1_2->id); - } - - { - assert (x5_1->str == o5_1->str); - assert (x5_2->str == o5_2->str); - - obj1_ptr t1 (x5_1->o1[0].lock ()), t2 (x5_1->o1[1].lock ()), - t3 (x5_2->o1[0].lock ()); - - assert (t1->id == o1_1->id || t2->id == o1_1->id); - assert (t1->id == o1_2->id || t2->id == o1_2->id); - assert (t3->id == o1_1->id); - } - } - } - - // Test inverse based on points_to. - // - { - using namespace test3; - - { - obj1 o1 (1, 2); - o1.o2 = new obj2; - - { - transaction t (db->begin ()); - - o1.o2->o1 = db->persist (o1); - db->persist (o1.o2); - - t.commit (); - } - - { - transaction t (db->begin ()); - - unique_ptr p (db->load (o1.id)); - assert (p->o2->id == o1.o2->id); - - t.commit (); - } - - { - typedef odb::query query; - - transaction t (db->begin ()); - - unique_ptr p (db->query_one (query::o2->o1.i == o1.id.i && - query::o2->o1.j == o1.id.j)); - assert (p->o2->id == o1.o2->id); - - t.commit (); - } - } - - { - obj3 o3; - o3.o4.push_back (new obj4); - o3.o4.push_back (new obj4); - - { - transaction t (db->begin ()); - - o3.o4[0]->o3 = o3.o4[1]->o3 = db->persist (o3); - db->persist (o3.o4[0]); - db->persist (o3.o4[1]); - - t.commit (); - } - - { - transaction t (db->begin ()); - - unique_ptr p (db->load (o3.id)); - assert (p->o4[0]->id == o3.o4[0]->id); - assert (p->o4[1]->id == o3.o4[1]->id); - - t.commit (); - } - - { - typedef odb::query query; - - transaction t (db->begin ()); - - unique_ptr p (db->query_one (query::id == o3.id)); - assert (p->o4[0]->id == o3.o4[0]->id); - assert (p->o4[1]->id == o3.o4[1]->id); - - t.commit (); - } - } - } - - // Test inverse with nested data members. - // - { - using namespace test4; - - { - obj1 o1; - o1.o2 = new obj2; - - { - transaction t (db->begin ()); - - o1.o2->id.i = db->persist (o1); - o1.o2->id.j = 123; - db->persist (o1.o2); - - t.commit (); - } - - { - transaction t (db->begin ()); - - unique_ptr p (db->load (o1.id)); - assert (p->o2->id.i == o1.o2->id.i && p->o2->id.j == o1.o2->id.j); - - t.commit (); - } - - { - typedef odb::query query; - - transaction t (db->begin ()); - - unique_ptr p (db->query_one ( - query::o2->id.i == o1.o2->id.i && - query::o2->id.j == o1.o2->id.j)); - assert (p->o2->id.i == o1.o2->id.i && p->o2->id.j == o1.o2->id.j); - - t.commit (); - } - } - - { - obj3 o3; - o3.o4.push_back (new obj4); - o3.o4.push_back (new obj4); - - { - transaction t (db->begin ()); - - o3.o4[0]->id.i = o3.o4[1]->id.i = db->persist (o3); - o3.o4[0]->id.j = 123; - o3.o4[1]->id.j = 234; - db->persist (o3.o4[0]); - db->persist (o3.o4[1]); - - t.commit (); - } - - { - transaction t (db->begin ()); - - unique_ptr p (db->load (o3.id)); - assert (p->o4[0]->id.i == o3.o4[0]->id.i && - p->o4[0]->id.j == o3.o4[0]->id.j); - - assert (p->o4[1]->id.i == o3.o4[1]->id.i && - p->o4[1]->id.j == o3.o4[1]->id.j); - - t.commit (); - } - - { - typedef odb::query query; - - transaction t (db->begin ()); - - unique_ptr p (db->query_one (query::id == o3.id)); - - assert (p->o4[0]->id.i == o3.o4[0]->id.i && - p->o4[0]->id.j == o3.o4[0]->id.j); - - assert (p->o4[1]->id.i == o3.o4[1]->id.i && - p->o4[1]->id.j == o3.o4[1]->id.j); - - t.commit (); - } - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/inverse/test.hxx b/common/inverse/test.hxx deleted file mode 100644 index a7b8678..0000000 --- a/common/inverse/test.hxx +++ /dev/null @@ -1,391 +0,0 @@ -// file : common/inverse/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include -#include - -#include - -// Test raw pointers. -// -#pragma db namespace table("t1_") -namespace test1 -{ - struct obj1; - struct obj2; - struct obj3; - struct obj4; - struct obj5; - - typedef obj1* obj1_ptr; - typedef obj2* obj2_ptr; - typedef obj3* obj3_ptr; - typedef obj4* obj4_ptr; - typedef obj5* obj5_ptr; - - typedef std::set obj1_ptr_set; - typedef std::set obj3_ptr_set; - typedef std::set obj5_ptr_set; - - #pragma db object - struct obj1 - { - obj1 (): o2 (0), o4 (0) {} - ~obj1 (); - - #pragma db id - std::string id; - - obj2_ptr o2; - - #pragma db id_column("obj1_id") value_column("obj3_id") - obj3_ptr_set o3; - - obj4_ptr o4; - - obj5_ptr_set o5; - }; - - #pragma db object - struct obj2 - { - #pragma db id auto - int id; - - // one-to-one - // - #pragma db inverse(o2) - obj1_ptr o1; - - std::string str; - }; - - #pragma db object - struct obj3 - { - std::string str; - - // one(i)-to-many - // - #pragma db inverse (o3) - obj1_ptr o1; - - #pragma db id auto - int id; - }; - - #pragma db object - struct obj4 - { - #pragma db id auto - int id; - - std::string str; - - // many(i)-to-one - // - #pragma db inverse (o4) - obj1_ptr_set o1; - }; - - #pragma db object - struct obj5 - { - #pragma db id auto - int id; - - std::string str; - - // many(i)-to-many - // - #pragma db inverse (o5) - obj1_ptr_set o1; - }; - - inline obj1:: - ~obj1 () - { - delete o2; - for (obj3_ptr_set::iterator i (o3.begin ()); i != o3.end (); ++i) - delete *i; - delete o4; - for (obj5_ptr_set::iterator i (o5.begin ()); i != o5.end (); ++i) - delete *i; - } -} - -// Test shared_ptr/weak_ptr. -// -#pragma db namespace table("t2_") -namespace test2 -{ - using std::shared_ptr; - using std::weak_ptr; - - struct obj1; - struct obj2; - struct obj3; - struct obj4; - struct obj5; - - typedef shared_ptr obj1_ptr; - typedef shared_ptr obj2_ptr; - typedef shared_ptr obj3_ptr; - typedef shared_ptr obj4_ptr; - typedef shared_ptr obj5_ptr; - - typedef weak_ptr obj1_wptr; - - typedef std::vector obj1_wptr_vec; - typedef std::vector obj3_ptr_vec; - typedef std::vector obj5_ptr_vec; - - #pragma db object pointer(obj1_ptr) - struct obj1 - { - #pragma db id - std::string id; - - obj2_ptr o2; - - #pragma db id_column("obj1_id") value_column("obj3_id") - obj3_ptr_vec o3; - - obj4_ptr o4; - obj5_ptr_vec o5; - }; - - #pragma db object pointer(obj2_ptr) - struct obj2 - { - #pragma db id auto - int id; - - std::string str; - - // one(i)-to-one - // - #pragma db inverse(o2) - obj1_wptr o1; - }; - - #pragma db object pointer(obj3_ptr) - struct obj3 - { - #pragma db id auto - int id; - - std::string str; - - // one(i)-to-many - // - #pragma db inverse (o3) - obj1_wptr o1; - }; - - #pragma db object pointer(obj4_ptr) - struct obj4 - { - #pragma db id auto - int id; - - std::string str; - - // many(i)-to-one - // - #pragma db inverse (o4) - obj1_wptr_vec o1; - }; - - #pragma db object pointer(obj5_ptr) - struct obj5 - { - #pragma db id auto - int id; - - std::string str; - - // many(i)-to-many - // - #pragma db inverse (o5) - obj1_wptr_vec o1; - }; -} - -// Test inverse based on points_to. -// -#pragma db namespace table("t3_") -namespace test3 -{ - // Inverse pointer. - // - #pragma db value - struct comp - { - int i; - int j; - }; - - inline bool - operator< (comp x, comp y) {return x.i < y.i || (x.i == y.i && x.j < y.j);} - - struct obj2; - - #pragma db object - struct obj1 - { - #pragma db id - comp id; - - #pragma db inverse(o1) - obj2* o2; - - obj1 (int i = 0, int j = 0): o2 (0) {id.i = i; id.j = j;} - ~obj1 (); - }; - - #pragma db object - struct obj2 - { - #pragma db id auto - int id; - - #pragma db points_to(obj1) - comp o1; - -#ifndef ODB_DATABASE_MYSQL - #pragma db member(o1) on_delete(cascade) -#endif - }; - - inline obj1:: - ~obj1 () {delete o2;} - - // Inverse container of pointers. - // - struct obj4; - - #pragma db object - struct obj3 - { - #pragma db id auto - int id; - - #pragma db inverse(o3) - std::vector o4; - - ~obj3 (); - }; - - #pragma db object - struct obj4 - { - #pragma db id auto - int id; - - #pragma db points_to(obj3) - int o3; - }; - - inline obj3:: - ~obj3 () - { - for (std::vector::iterator i (o4.begin ()); i != o4.end (); ++i) - delete *i; - } -}; - -// Test inverse with nested data members. -// -#pragma db namespace table("t4_") -namespace test4 -{ - // Inverse pointer. - // - struct obj1; - struct obj2; - - #pragma db value - struct obj2_id - { - #pragma db points_to(obj1) - int i; - int j; - }; - - inline bool - operator< (obj2_id x, obj2_id y) - {return x.i < y.i || (x.i == y.i && x.j < y.j);} - - #pragma db object - struct obj1 - { - #pragma db id auto - int id; - - #pragma db inverse(id.i) - obj2* o2; - - obj1 (): o2 (0) {} - ~obj1 (); - }; - - #pragma db object - struct obj2 - { - #pragma db id - obj2_id id; - }; - - inline obj1:: - ~obj1 () {delete o2;} - - // Inverse container of pointers. - // - struct obj3; - struct obj4; - - #pragma db value - struct obj4_id - { - #pragma db points_to(obj3) - int i; - int j; - }; - - inline bool - operator< (obj4_id x, obj4_id y) - {return x.i < y.i || (x.i == y.i && x.j < y.j);} - - #pragma db object - struct obj3 - { - #pragma db id auto - int id; - - #pragma db inverse(id.i) - std::vector o4; - - ~obj3 (); - }; - - #pragma db object - struct obj4 - { - #pragma db id - obj4_id id; - }; - - inline obj3:: - ~obj3 () - { - for (std::vector::iterator i (o4.begin ()); i != o4.end (); ++i) - delete *i; - } -}; -#endif // TEST_HXX diff --git a/common/inverse/testscript b/common/inverse/testscript deleted file mode 100644 index c2a4e3e..0000000 --- a/common/inverse/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/inverse/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/lazy-ptr/buildfile b/common/lazy-ptr/buildfile deleted file mode 100644 index d495d2f..0000000 --- a/common/lazy-ptr/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/lazy-ptr/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix lazy_ptr_ \ - --generate-schema \ - --generate-session - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/lazy-ptr/driver.cxx b/common/lazy-ptr/driver.cxx deleted file mode 100644 index 9a3b324..0000000 --- a/common/lazy-ptr/driver.cxx +++ /dev/null @@ -1,360 +0,0 @@ -// file : common/lazy-ptr/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test lazy object pointers. -// - -#include // std::unique_ptr -#include // std::move -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -namespace test2 -{ - cont::cont (unsigned long i) - : id (i) - { - } - - obj_ptr - create (unsigned int id) - { - obj_ptr r (new obj (id)); - return r; - } - - lazy_obj_ptr - create (database& db, unsigned int id) - { - lazy_obj_ptr r (db, id); - return r; - } -} - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Raw. - // - { - using namespace test1; - - // persist - // - obj* o1 (new obj (1)); - - { - transaction t (db->begin ()); - db->persist (o1); - t.commit (); - } - - unique_ptr c1 (new cont (1)); - unique_ptr c2 (new cont (2)); - - lazy_ptr lo1 (*db, 1); - obj* o2 (new obj (2)); - - obj* o3 (new obj (3)); - obj* o4 (new obj (4)); - - c1->o.push_back (lo1); - c1->o.push_back (o2); - c2->o.push_back (o3); - c2->o.push_back (o4); - - // Test pointer comparison. - // - assert (lazy_ptr () == lazy_ptr ()); - assert (lazy_ptr (o1) != lazy_ptr ()); - assert (lo1 != lazy_ptr ()); - assert (lazy_ptr (o1) == lazy_ptr (o1)); - assert (lo1 == lazy_ptr (*db, o1)); - assert (lo1 != lazy_ptr (*db, o2)); - - delete o1; - - { - transaction t (db->begin ()); - - db->persist (o2); - db->persist (o3); - db->persist (o4); - - db->persist (*c1); - db->persist (*c2); - - t.commit (); - } - - // load - // - { - session s; - transaction t (db->begin ()); - unique_ptr c (db->load (1)); - obj* o (db->load (1)); - - // Not loaded. - // - assert (c->o.size () == 2); - assert (!c->o[0].loaded ()); - assert (!c->o[1].loaded ()); - - assert (!o->c.loaded ()); - - // Correct object ids. - // - assert (c->o[0].object_id () == o->id); - assert (o->c.object_id () == c->id); - - // Load. - // - cont* cl (o->c.load ()); - obj* ol (c->o[0].load ()); - - assert (cl == c.get ()); - assert (ol == o); - - // Test unload/reload. - // - o->c.unload (); - assert (!o->c.loaded ()); - o->c.load (); - assert (o->c.loaded ()); - - t.commit (); - } - } - - // std::unique_ptr - // - { - using namespace test2; - - // persist - // - { - obj_ptr o1 (new obj (1)); - transaction t (db->begin ()); - db->persist (*o1); - t.commit (); - } - - cont_ptr c1 (new cont (1)); - cont_ptr c2 (new cont (2)); - - lazy_obj_ptr lo1 = create (*db, 1); - lo1 = create (*db, 1); - - c1->o = std::move (lo1); - c2->o = create (2); - - { - transaction t (db->begin ()); - - db->persist (*c2->o); - - db->persist (*c1); - db->persist (*c2); - - t.commit (); - } - - // load - // - { - session s; - transaction t (db->begin ()); - cont_ptr c (db->load (1)); - obj* o (db->load (1)); - - // Not loaded. - // - assert (!c->o.loaded ()); - assert (!o->c.loaded ()); - - // Correct object ids. - // - assert (c->o.object_id () == o->id); - assert (o->c.object_id () == c->id); - - // Load. - // - cont* cl (o->c.load ()); - const obj_ptr& ol (c->o.load ()); - - assert (cl == c.get ()); - assert (ol.get () == o); - - t.commit (); - } - - // unload/reload - // - { - // No session. - transaction t (db->begin ()); - cont_ptr c (db->load (1)); - - assert (!c->o.loaded ()); - c->o.load (); - assert (c->o.loaded ()); - c->o.unload (); - assert (!c->o.loaded ()); - c->o.load (); - assert (c->o.loaded ()); - - t.commit (); - } - } - - // Shared pointer from C++11 or TR1. - // - { - using namespace test3; - - // persist - // - shared_ptr c1 (new cont (1)); - - { - transaction t (db->begin ()); - db->persist (c1); - t.commit (); - } - - lazy_shared_ptr lc1 (*db, 1); - shared_ptr c2 (new cont (2)); - - shared_ptr o1 (new obj (1)); - shared_ptr o2 (new obj (2)); - - shared_ptr o3 (new obj (3)); - shared_ptr o4 (new obj (4)); - - o1->c = lc1; - o2->c = lc1; - o3->c = c2; - o4->c = c2; - - // Test pointer comparison. - // - assert (lazy_shared_ptr () == lazy_shared_ptr ()); - assert (lazy_shared_ptr (c1) != lazy_shared_ptr ()); - assert (lc1 != lazy_shared_ptr ()); - assert (lazy_shared_ptr (c1) == lazy_shared_ptr (c1)); - assert (lc1 == lazy_shared_ptr (*db, c1)); - assert (lc1 != lazy_shared_ptr (*db, c2)); - - // Test move constructors. - // - { - lazy_shared_ptr tmp (*db, 1); - lazy_shared_ptr l (std::move (tmp)); - assert (lc1 == l); - } - - { - shared_ptr tmp (c1); - lazy_shared_ptr l (*db, std::move (tmp)); - assert (lc1 == l); - } - - { - transaction t (db->begin ()); - - db->persist (o1); - db->persist (o2); - db->persist (o3); - db->persist (o4); - - db->persist (c2); - - t.commit (); - } - - // load - // - { - session s; - transaction t (db->begin ()); - shared_ptr c (db->load (1)); - shared_ptr o (db->load (1)); - - // Not loaded. - // - assert (c->o.size () == 2); - assert (!c->o[0].loaded ()); - assert (!c->o[1].loaded ()); - - assert (!o->c.loaded ()); - - // Correct object ids. - // - assert (c->o[0].object_id () == o->id); - assert (o->c.object_id () == c->id); - - // Load. - // - shared_ptr cl (o->c.load ()); - shared_ptr ol (c->o[0].load ()); - - assert (cl == c); - assert (ol == o); - - t.commit (); - } - - // Test lazy weak locking and reloading. - // - { - // No session. - transaction t (db->begin ()); - shared_ptr c (db->load (1)); - - // Lock. - // - assert (!c->o[1].loaded ()); - lazy_shared_ptr l (c->o[1].lock ()); - assert (!l.loaded ()); - assert (l.object_id () == c->o[1].object_id ()); - - // Reload. - // - assert (!c->o[1].loaded ()); - shared_ptr ol (c->o[1].load ()); - assert (c->o[1].loaded ()); - ol.reset (); - assert (!c->o[1].loaded ()); - ol = c->o[1].load (); - assert (c->o[1].loaded ()); - - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/lazy-ptr/test.hxx b/common/lazy-ptr/test.hxx deleted file mode 100644 index f946029..0000000 --- a/common/lazy-ptr/test.hxx +++ /dev/null @@ -1,147 +0,0 @@ -// file : common/lazy-ptr/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include - -#include -#include - -// Raw pointer. -// -#pragma db namespace table("t1_") -namespace test1 -{ - using odb::lazy_ptr; - class obj; - - #pragma db object - class cont - { - public: - cont () {} - cont (unsigned long i): id (i) {} - ~cont (); - - #pragma db id - unsigned long id; - - typedef std::vector > obj_list; - - #pragma db value_not_null - obj_list o; - }; - - #pragma db object - class obj - { - public: - obj () {} - obj (unsigned long i): id (i) {} - - #pragma db id - unsigned long id; - - #pragma db inverse(o) not_null - lazy_ptr c; // weak - }; - - inline cont:: - ~cont () - { - for (obj_list::iterator i (o.begin ()); i != o.end (); ++i) - if (obj* p = i->get ()) - delete p; - } -} - -// std::auto_ptr/std::unique_ptr -// -#pragma db namespace table("t2_") -namespace test2 -{ - using odb::lazy_ptr; - - class obj; - class cont; - - typedef std::unique_ptr obj_ptr; - typedef std::unique_ptr cont_ptr; - typedef odb::lazy_unique_ptr lazy_obj_ptr; - - #pragma db object - class cont - { - public: - cont () = default; - cont (unsigned long id); - - #pragma db id - unsigned long id; - - #pragma db not_null - lazy_obj_ptr o; - }; - - #pragma db object - class obj - { - public: - obj () = default; - obj (unsigned long i): id (i) {} - - #pragma db id - unsigned long id; - - #pragma db inverse(o) not_null - lazy_ptr c; // weak - }; -} - -// shared_ptr -// -#pragma db namespace table("t3_") -namespace test3 -{ - using std::shared_ptr; - using odb::lazy_shared_ptr; - using odb::lazy_weak_ptr; - - class obj; - - #pragma db object pointer(shared_ptr) - class cont - { - public: - cont () {} - cont (unsigned long i): id (i) {} - - #pragma db id - unsigned long id; - - typedef std::vector > obj_list; - - #pragma db inverse(c) value_not_null - obj_list o; - }; - - #pragma db object pointer(shared_ptr) - class obj - { - public: - obj () {} - obj (unsigned long i): id (i) {} - - #pragma db id - unsigned long id; - - #pragma db not_null - lazy_shared_ptr c; - }; -} - -#endif // TEST_HXX diff --git a/common/lazy-ptr/testscript b/common/lazy-ptr/testscript deleted file mode 100644 index 736fa4c..0000000 --- a/common/lazy-ptr/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/lazy-ptr/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/lifecycle/buildfile b/common/lifecycle/buildfile deleted file mode 100644 index b5b2b00..0000000 --- a/common/lifecycle/buildfile +++ /dev/null @@ -1,40 +0,0 @@ -# file : common/lifecycle/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix lifecycle_ \ - --generate-schema - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/lifecycle/driver.cxx b/common/lifecycle/driver.cxx deleted file mode 100644 index a01d5bd..0000000 --- a/common/lifecycle/driver.cxx +++ /dev/null @@ -1,248 +0,0 @@ -// file : common/lifecycle/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test object state transistions. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Database operation out of transaction. - // - try - { - object o (1); - db->persist (o); - assert (false); - } - catch (const not_in_transaction&) - { - } - - // Transient. - // - try - { - transaction t (db->begin ()); - unique_ptr o (db->load (1)); - assert (false); - t.commit (); - } - catch (const object_not_persistent&) - { - } - - // Persistent. - // - { - object o (1); - o.str_ = "value 1"; - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - try - { - transaction t (db->begin ()); - db->persist (o); - assert (false); - t.commit (); - } - catch (const object_already_persistent&) - { - } - } - - // Find. - // - { - transaction t (db->begin ()); - - unique_ptr o1 (db->find (1)); - assert (o1.get () != 0 && o1->str_ == "value 1"); - - unique_ptr o2 (db->find (2)); - assert (o2.get () == 0); - - t.commit (); - } - - // Find (into existing). - // - { - object o; - - transaction t (db->begin ()); - - assert (db->find (1, o)); - assert (o.str_ == "value 1"); - - assert (!db->find (2, o)); - - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - unique_ptr o (db->load (1)); - assert (o->str_ == "value 1"); - t.commit (); - - try - { - transaction t (db->begin ()); - unique_ptr o (db->load (2)); - assert (false); - t.commit (); - } - catch (const object_not_persistent&) - { - } - } - - // Load (into existing). - // - { - object o; - - transaction t (db->begin ()); - db->load (1, o); - assert (o.str_ == "value 1"); - t.commit (); - - try - { - transaction t (db->begin ()); - db->load (2, o); - assert (false); - t.commit (); - } - catch (const object_not_persistent&) - { - } - } - - // Reload. - // - { - object o; - - transaction t (db->begin ()); - db->load (1, o); - o.str_ = "junk"; - db->reload (o); - assert (o.str_ == "value 1"); - t.commit (); - - try - { - transaction t (db->begin ()); - o.id_ = 2; - db->reload (o); - assert (false); - t.commit (); - } - catch (const object_not_persistent&) - { - } - } - - // Modified. - // - { - transaction t (db->begin ()); - unique_ptr o (db->load (1)); - o->str_ = "value 2"; - db->update (*o); - t.commit (); - - try - { - transaction t (db->begin ()); - o->id_ = 2; - db->update (*o); - assert (false); - t.commit (); - } - catch (const object_not_persistent&) - { - } - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (1)); - assert (o->str_ == "value 2"); - t.commit (); - } - - // Update of unmodified object. - // - { - transaction t (db->begin ()); - unique_ptr o (db->load (1)); - db->update (*o); - t.commit (); - } - - // Transient. - // - { - transaction t (db->begin ()); - unique_ptr o (db->load (1)); - db->erase (*o); - t.commit (); - - try - { - transaction t (db->begin ()); - db->erase (1); - assert (false); - t.commit (); - } - catch (const object_not_persistent&) - { - } - } - - try - { - transaction t (db->begin ()); - unique_ptr o (db->load (1)); - assert (false); - t.commit (); - } - catch (const object_not_persistent&) - { - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/lifecycle/test.hxx b/common/lifecycle/test.hxx deleted file mode 100644 index 8d260d2..0000000 --- a/common/lifecycle/test.hxx +++ /dev/null @@ -1,27 +0,0 @@ -// file : common/lifecycle/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; - std::string str_; -}; - -#endif // TEST_HXX diff --git a/common/lifecycle/testscript b/common/lifecycle/testscript deleted file mode 100644 index 0337bba..0000000 --- a/common/lifecycle/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/lifecycle/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/no-id/buildfile b/common/no-id/buildfile deleted file mode 100644 index 1a64401..0000000 --- a/common/no-id/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/no-id/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix no_id_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/no-id/driver.cxx b/common/no-id/driver.cxx deleted file mode 100644 index eee69a5..0000000 --- a/common/no-id/driver.cxx +++ /dev/null @@ -1,102 +0,0 @@ -// file : common/no-id/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test persistent classes without id. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - object o1 (1, "aaa"); - object o2 (2, "bbb"); - object o3 (3, "ccc"); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o2); // Ok, since there is no id. - db->persist (o3); - t.commit (); - } - - // Compile errors. - // - { - //db->load (1); - //db->find (1); - //db->update (o1); - //db->erase (1); - } - - typedef odb::query query; - typedef odb::result result; - - // Query. - // - { - transaction t (db->begin ()); - - { - result r (db->query ()); - assert (size (r) == 4); - } - - { - result r (db->query (query::str == "aaa")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->num == 1 && i->str == "aaa"); - object o; - i.load (o); - //i.id (); // Compile-time error. - assert (o.num == 1 && o.str == "aaa"); - assert (++i == r.end ()); - } - - { - result r (db->query (query::num < 3)); - assert (size (r) == 3); - } - - t.commit (); - } - - // Erase (query). - // - { - transaction t (db->begin ()); - assert (db->erase_query (query::num == 2) == 2); - assert (db->erase_query () == 2); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/no-id/test.hxx b/common/no-id/test.hxx deleted file mode 100644 index c5b5c65..0000000 --- a/common/no-id/test.hxx +++ /dev/null @@ -1,21 +0,0 @@ -// file : common/no-id/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object no_id -struct object -{ - object () {} - object (unsigned long n, const std::string& s): num (n), str (s) {} - - unsigned long num; - std::string str; -}; - -#endif // TEST_HXX diff --git a/common/no-id/testscript b/common/no-id/testscript deleted file mode 100644 index 5ec57ee..0000000 --- a/common/no-id/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/no-id/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/object/buildfile b/common/object/buildfile deleted file mode 100644 index cb56aee..0000000 --- a/common/object/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/object/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix object_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/object/driver.cxx b/common/object/driver.cxx deleted file mode 100644 index 1c29417..0000000 --- a/common/object/driver.cxx +++ /dev/null @@ -1,84 +0,0 @@ -// file : common/object/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test persistent classes. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test persistent class template instantiation. - // - { - using namespace test1; - - pair_object po; - po.second = "abc"; - - derived d; - d.x = "abc"; - d.n = 123; - - // persist - // - { - transaction t (db->begin ()); - db->persist (po); - db->persist (d); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - unique_ptr po1 (db->load (po.first)); - unique_ptr d1 (db->load (d.id)); - t.commit (); - - assert (po == *po1); - - assert (d.x == d1->x); - assert (d.n == d1->n); - } - - // Test the API confusion. - // - { - transaction t (db->begin ()); - db->update (po); - db->reload (po); - db->erase (po); - - db->query (); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/object/test.hxx b/common/object/test.hxx deleted file mode 100644 index 87bac91..0000000 --- a/common/object/test.hxx +++ /dev/null @@ -1,49 +0,0 @@ -// file : common/object/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include // std::pair - -#include - -// Test persistent class template instantiation. -// -#pragma db namespace table("t1_") -namespace test1 -{ - typedef std::pair pair_object; - #pragma db object(pair_object) - #pragma db member(pair_object::first) id auto - - #pragma db object abstract - struct base_data - { - #pragma db id auto - unsigned long id; - }; - - template - struct base: base_data - { - T x; - }; - - typedef base base_derived; - #pragma db object(base_derived) abstract - - #pragma db object - struct derived: base_derived - { - int n; - }; - - // Test instantiation in order to "see" id, etc. - // - typedef base int_base; - #pragma db object(int_base) -} - -#endif // TEST_HXX diff --git a/common/object/testscript b/common/object/testscript deleted file mode 100644 index 6982409..0000000 --- a/common/object/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/object/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/optimistic/buildfile b/common/optimistic/buildfile deleted file mode 100644 index 06af705..0000000 --- a/common/optimistic/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/optimistic/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_optimistic_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/optimistic/driver.cxx b/common/optimistic/driver.cxx deleted file mode 100644 index 6dfec6e..0000000 --- a/common/optimistic/driver.cxx +++ /dev/null @@ -1,300 +0,0 @@ -// file : common/optimistic/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test optimistic concurrency support. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -unsigned long -version (const unique_ptr& db, unsigned long id) -{ - typedef odb::query query; - typedef odb::result result; - - result r (db->query (query::id == id)); - return r.empty () ? 0 : r.begin ()->ver; -} - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - object o (1); - o.num = 123; - o.str = "abc"; - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Verify initial version in the instance and database. - // - assert (o.ver == 1); - { - transaction t (db->begin ()); - assert (version (db, 1) == 1); - t.commit (); - } - - object c (o); - o.num++; - o.str += 'd'; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - // Verify updated version in the instance and database. - // - assert (o.ver == 2); - { - transaction t (db->begin ()); - assert (version (db, 1) == 2); - t.commit (); - } - - // Verify the data has been updated. - // - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o1->ver == 2 && o1->num == 124 && o1->str == "abcd"); - } - - // Try to update using outdated object. - // - c.num--; - c.str += 'z'; - - { - transaction t (db->begin ()); - - try - { - db->update (c); - assert (false); - } - catch (const object_changed&) {} - - // Verify the data hasn't changed. - // - unique_ptr o1 (db->load (1)); - assert (o1->ver == 2 && o1->num == 124 && o1->str == "abcd"); - - // Reload the object. - // - db->reload (c); - assert (c.ver == 2 && c.num == 124); - - // Check that we don't reload an object that is up-to-date. - // - c.num--; - db->reload (c); - assert (c.ver == 2 && c.num == 123); - - t.commit (); - } - - // Try to delete using an outdated object. - // - { - transaction t (db->begin ()); - - try - { - db->update (o); - db->erase (c); - assert (false); - } - catch (const object_changed&) {} - - t.commit (); - } - - // Try to delete using an up-to-date object. - // - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - - // Try to update deleted object. - // - { - transaction t (db->begin ()); - - try - { - db->update (o); - assert (false); - } - catch (const object_not_persistent&) - { - assert (false); - } - catch (const object_changed&) {} - - t.commit (); - } - - // Optimistic delete of objects with container requires - // extra logic. Test it here. - // - { - container o ("abc"); - o.nums.push_back (1); - o.nums.push_back (2); - o.nums.push_back (3); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - container c (o); - o.nums.pop_back (); - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - // Try to delete using an outdated object. - // - { - transaction t (db->begin ()); - - try - { - db->erase (c); - assert (false); - } - catch (const object_changed&) {} - - // Verify the container data hasn't changed. - // - unique_ptr o1 (db->load ("abc")); - assert (o1->nums.size () == 2 && o1->nums[0] == 1 && o1->nums[1] == 2); - - t.commit (); - } - - // Try to delete using an up-to-date object. - // - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test optimistic class inheritance. This is a shortened version - // of the object test. - // - { - derived o; - o.num = 123; - o.str = "abc"; - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - derived c (o); - o.num++; - o.str += 'd'; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - // Try to update using outdated object. - // - c.num--; - c.str += 'z'; - - { - transaction t (db->begin ()); - - try - { - db->update (c); - assert (false); - } - catch (const object_changed&) {} - - // Reload the object. - // - db->reload (c); - assert (c.ver == 2 && c.num == 124); - - t.commit (); - } - - // Try to delete using an outdated object. - // - { - transaction t (db->begin ()); - - try - { - db->update (o); - db->erase (c); - assert (false); - } - catch (const object_changed&) {} - - t.commit (); - } - - // Try to delete using an up-to-date object. - // - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/optimistic/test.hxx b/common/optimistic/test.hxx deleted file mode 100644 index fcefa3d..0000000 --- a/common/optimistic/test.hxx +++ /dev/null @@ -1,76 +0,0 @@ -// file : common/optimistic/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -#pragma db object optimistic -struct object -{ - object (): ver (123) {} - object (unsigned long id): id_ (id), ver (123) {} - - #pragma db id - unsigned long id_; - - #pragma db version - unsigned long ver; - - unsigned int num; - std::string str; -}; - -#pragma db view object(object) -struct object_version -{ - unsigned long ver; -}; - -// Optimistic class with a container. -// -#pragma db object optimistic -struct container -{ - container (): ver (123) {} - container (const std::string& id): id_ (id), ver (123) {} - - #pragma db id - std::string id_; - - #pragma db version - unsigned long ver; - - std::vector nums; -}; - -// Optimistic class inheritance. -// -#pragma db object abstract optimistic -struct base -{ - base (): ver (123) {} - - #pragma db id auto - unsigned long id_; - - #pragma db version - const unsigned long ver; - - std::string str; - - #pragma db readonly - std::string ro; -}; - -#pragma db object -struct derived: base -{ - unsigned int num; -}; - -#endif // TEST_HXX diff --git a/common/optimistic/testscript b/common/optimistic/testscript deleted file mode 100644 index 9ebafb2..0000000 --- a/common/optimistic/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/optimistic/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/pragma/buildfile b/common/pragma/buildfile deleted file mode 100644 index a2eeaa0..0000000 --- a/common/pragma/buildfile +++ /dev/null @@ -1,39 +0,0 @@ -# file : common/pragma/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix pragma_ - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/pragma/driver.cxx b/common/pragma/driver.cxx deleted file mode 100644 index a9cc6e0..0000000 --- a/common/pragma/driver.cxx +++ /dev/null @@ -1,27 +0,0 @@ -// file : common/pragma/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test #pragma db parsing. -// - -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main () -{ -} diff --git a/common/pragma/test.hxx b/common/pragma/test.hxx deleted file mode 100644 index 6877e73..0000000 --- a/common/pragma/test.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// file : common/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db value(bool) type ("INTEGER") - -struct x {int i;}; -#pragma db value (x) - -namespace N -{ - #pragma db object - struct object1 - { - object1 () {} - - #pragma db id - unsigned long id_; - - #pragma db member type ("INTEGER") - bool b_; - }; - - struct object2 - { - object2 () {} - - unsigned long id_; - }; - - #pragma db object (object2) -} - -PRAGMA_DB (member (N::object2::id_) id auto); - -#endif // TEST_HXX diff --git a/common/pragma/testscript b/common/pragma/testscript deleted file mode 100644 index 089f7a1..0000000 --- a/common/pragma/testscript +++ /dev/null @@ -1,31 +0,0 @@ -# file : common/include/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* &!odb-test.db -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $* -} diff --git a/common/prepared/buildfile b/common/prepared/buildfile deleted file mode 100644 index 4006a4f..0000000 --- a/common/prepared/buildfile +++ /dev/null @@ -1,43 +0,0 @@ -# file : common/prepared/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix prepared_ \ - --generate-schema \ - --generate-query \ - --generate-prepared \ - --omit-unprepared - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/prepared/driver.cxx b/common/prepared/driver.cxx deleted file mode 100644 index 44df651..0000000 --- a/common/prepared/driver.cxx +++ /dev/null @@ -1,444 +0,0 @@ -// file : common/prepared/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test prepared query functionality. -// - -#include // std::unique_ptr -#include // std::move -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -struct params -{ - unsigned short age; - std::string name; -}; - -static void -query_factory (const char* name, connection& c) -{ - typedef odb::query query; - - unique_ptr p (new params); - prepared_query pq ( - c.prepare_query ( - name, - query::age > query::_ref (p->age) && - query::name != query::_ref (p->name))); - c.cache_query (pq, move (p)); -} - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - { - person p1 ("John First", 91); - person p2 ("John Second", 81); - person p3 ("John Third", 71); - person p4 ("John Fourth", 61); - person p5 ("John Fifth", 51); - - transaction t (db->begin ()); - db->persist (p1); - db->persist (p2); - db->persist (p3); - db->persist (p4); - db->persist (p5); - t.commit (); - } - - typedef odb::query query; - typedef odb::prepared_query prep_query; - typedef odb::result result; - - // Uncached query in the same transaction. - // - { - transaction t (db->begin ()); - - unsigned short age (90); - prep_query pq ( - db->prepare_query ( - "person-age-query", - query::age > query::_ref (age))); - - for (unsigned short i (1); i < 6; ++i, age -= 10) - { - result r (pq.execute ()); - assert (size (r) == i); - } - - age = 90; - result r (pq.execute ()); - result::iterator i (r.begin ()); - assert (i != r.end () && i->name_ == "John First" && i->age_ == 91); - assert (++i == r.end ()); - - t.commit (); - } - - // Uncached query in multiple transaction. - // - { - connection_ptr c (db->connection ()); - - unsigned short age (90); - prep_query pq ( - c->prepare_query ( - "person-age-query", - query::age > query::_ref (age))); - - for (unsigned short i (1); i < 6; ++i, age -= 10) - { - transaction t (c->begin ()); - - result r (pq.execute ()); - assert (size (r) == i); - - t.commit (); - } - - transaction t (c->begin ()); - - age = 90; - result r (pq.execute ()); - result::iterator i (r.begin ()); - assert (i != r.end () && i->name_ == "John First" && i->age_ == 91); - assert (++i == r.end ()); - - t.commit (); - } - - // Cached query without parameters. - // - { - for (unsigned short i (1); i < 6; ++i) - { - transaction t (db->begin ()); - - prep_query pq (db->lookup_query ("person-val-age-query")); - - if (!pq) - { - assert (i == 1); - pq = db->prepare_query ( - "person-val-age-query", - query::age > 90); - db->cache_query (pq); - } - else if (i == 2) - { - try - { - db->cache_query (pq); - assert (false); - } - catch (const odb::prepared_already_cached&) - { - } - } - - result r (pq.execute ()); - assert (size (r) == 1); - - t.commit (); - } - } - - // Cached query with parameters. - // - { - for (unsigned short i (1); i < 6; ++i) - { - transaction t (db->begin ()); - - unsigned short* age; - prep_query pq (db->lookup_query ("person-ref-age-query", age)); - - if (!pq) - { - assert (i == 1); - - unique_ptr p (new unsigned short); - age = p.get (); - pq = db->prepare_query ( - "person-ref-age-query", - query::age > query::_ref (*age)); - - db->cache_query (pq, move (p)); - } - else if (i == 2) - { - // Object type mismatch. - // - try - { - db->lookup_query ("person-ref-age-query", age); - assert (false); - } - catch (const odb::prepared_type_mismatch&) - { - } - - // Parameters type mismatch. - // - try - { - int* age; - db->lookup_query ("person-ref-age-query", age); - assert (false); - } - catch (const odb::prepared_type_mismatch&) - { - } - } - - *age = 100 - i * 10; - result r (pq.execute ()); - assert (size (r) == i); - - t.commit (); - } - } - - // Cached query with factory. - // - { - db->query_factory ("person-params-query", &query_factory); - - for (unsigned int i (1); i < 6; ++i) - { - transaction t (db->begin ()); - - params* p; - prep_query pq (db->lookup_query ("person-params-query", p)); - assert (pq); - - p->age = 100 - i * 10; - p->name = "John First"; - result r (pq.execute ()); - assert (size (r) == i - 1); - - t.commit (); - } - - db->query_factory ("person-params-query", - database::query_factory_ptr ()); - } - - // Cached query with wildcard factory. - // - { - db->query_factory ("", &query_factory); - - for (unsigned int i (1); i < 6; ++i) - { - transaction t (db->begin ()); - - params* p; - prep_query pq (db->lookup_query ("person-params-query-1", p)); - assert (pq); - - p->age = 100 - i * 10; - p->name = "John First"; - result r (pq.execute ()); - assert (size (r) == i - 1); - - t.commit (); - } - - db->query_factory ("", database::query_factory_ptr ()); - } - - // Cached query with lambda factory. - // - { - db->query_factory ( - "person-params-query-2", - [] (const char* name, connection& c) - { - typedef odb::query query; - - unique_ptr p (new params); - prepared_query pq ( - c.prepare_query ( - name, - query::age > query::_ref (p->age) && - query::name != query::_ref (p->name))); - c.cache_query (pq, move (p)); - }); - - for (unsigned int i (1); i < 6; ++i) - { - transaction t (db->begin ()); - - params* p; - prep_query pq (db->lookup_query ("person-params-query-2", p)); - assert (pq); - - p->age = 100 - i * 10; - p->name = "John First"; - result r (pq.execute ()); - assert (size (r) == i - 1); - - t.commit (); - } - - db->query_factory ("person-params-query-2", - database::query_factory_ptr ()); - } - - // Cached query with lambda factory using closure. Forces nonoptimized - // representation of std::function. - // - { - const std::string person_name ("John First"); - - db->query_factory ( - "person-params-query-3", - [person_name] (const char* name, connection& c) - { - typedef odb::query query; - - prepared_query pq ( - c.prepare_query ( - name, - query::age > 50 && query::name != person_name)); - c.cache_query (pq); - }); - - { - transaction t (db->begin ()); - - prep_query pq (db->lookup_query ("person-params-query-3")); - assert (pq); - - result r (pq.execute ()); - assert (size (r) == 4); - - t.commit (); - } - - db->query_factory ("person-params-query-3", nullptr); - } - - // View prepared query. - // - { - typedef odb::query query; - typedef odb::prepared_query prep_query; - typedef odb::result result; - - transaction t (db->begin ()); - - unsigned short age (90); - prep_query pq ( - db->prepare_query ( - "person-view-age-query", - query::age > query::_ref (age))); - - for (unsigned short i (1); i < 6; ++i, age -= 10) - { - result r (pq.execute ()); - assert (size (r) == i); - } - - age = 90; - result r (pq.execute ()); - result::iterator i (r.begin ()); - assert (i != r.end () && i->name == "John First" && i->age == 91); - assert (++i == r.end ()); - - t.commit (); - } - - // By-ref parameter image growth. - // - { - transaction t (db->begin ()); - - string name; - prep_query pq ( - db->prepare_query ( - "person-name-query", - query::name != query::_ref (name))); - - { - name = "John First"; - result r (pq.execute ()); - assert (size (r) == 4); - } - - { - name.assign (2048, 'x'); - result r (pq.execute ()); - assert (size (r) == 5); - } - - t.commit (); - } - - // Test execute_one() and execute_value(). - // - { - transaction t (db->begin ()); - - person p ("John Doe", 23); - db->persist (p); - - prep_query pq1 ( - db->prepare_query ("query-1", query::id == p.id_)); - prep_query pq0 ( - db->prepare_query ("query-0", query::id == p.id_ + 1)); - - { - unique_ptr p (pq1.execute_one ()); - assert (p.get () != 0 && p->name_ == "John Doe"); - } - - { - unique_ptr p (pq0.execute_one ()); - assert (p.get () == 0); - } - - { - person p; - assert (pq1.execute_one (p) && p.name_ == "John Doe"); - } - - { - person p ("", 0); - assert (!pq0.execute_one (p) && - p.id_ == 0 && p.name_.empty () && p.age_ == 0); - } - - { - person p (pq1.execute_value ()); - assert (p.name_ == "John Doe"); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/prepared/test.hxx b/common/prepared/test.hxx deleted file mode 100644 index db16e67..0000000 --- a/common/prepared/test.hxx +++ /dev/null @@ -1,32 +0,0 @@ -// file : common/prepared/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object -struct person -{ - person (): id_ (0) {} - person (const std::string& name, unsigned short age) - : id_ (0), name_ (name), age_ (age) {} - - #pragma db id auto - unsigned long id_; - - std::string name_; - unsigned short age_; -}; - -#pragma db view object(person) -struct person_view -{ - std::string name; - unsigned short age; -}; - -#endif // TEST_HXX diff --git a/common/prepared/testscript b/common/prepared/testscript deleted file mode 100644 index 3530c5b..0000000 --- a/common/prepared/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/prepared/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/query/array/buildfile b/common/query/array/buildfile deleted file mode 100644 index 3beb6d0..0000000 --- a/common/query/array/buildfile +++ /dev/null @@ -1,43 +0,0 @@ -# file : common/query/array/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_query_array_ \ - --generate-schema \ - --generate-query \ - --generate-prepared \ - --sql-name-case oracle:upper - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/query/array/driver.cxx b/common/query/array/driver.cxx deleted file mode 100644 index 9327751..0000000 --- a/common/query/array/driver.cxx +++ /dev/null @@ -1,220 +0,0 @@ -// file : common/query/array/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test query support for C arrays. -// - -#include -#include // std::unique_ptr -#include // std::memcpy -#include - -#include -#include - -#include // DATABASE_* -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -#ifndef MULTI_DATABASE -# if defined(DATABASE_MYSQL) -const odb::mysql::database_type_id bt = odb::mysql::id_blob; -# elif defined(DATABASE_SQLITE) -const odb::sqlite::database_type_id bt = odb::sqlite::id_blob; -# elif defined(DATABASE_PGSQL) -const odb::pgsql::database_type_id bt = odb::pgsql::id_bytea; -# elif defined(DATABASE_ORACLE) -const odb::oracle::database_type_id bt = odb::oracle::id_raw; -# elif defined(DATABASE_MSSQL) -const odb::mssql::database_type_id bt = odb::mssql::id_binary; -# else -# error unknown database -# endif -#endif - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - typedef odb::query query; - - const char buf[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6}; - - // - // - { - object o1 (1, "abc", buf); - object o2 (2, "bcd", buf); - object o3 (3, "cde", buf); - - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - } - - { - transaction t (db->begin ()); - - // string - // -#ifndef MULTI_DATABASE - assert (size (db->query (query::s == "abc")) == 1); - assert (size (db->query (query::s == query::_val ("bcd"))) == 1); - assert (size (db->query ("s = " + query::_val ("bcd"))) == 1); - assert (size (db->query ("s = " + query::_ref ("bcd"))) == 1); -#endif - - { - char a[] = "bcd"; - char* ra = a; -#ifndef MULTI_DATABASE - assert (size (db->query (query::s == a)) == 1); - assert (size (db->query (query::s == query::_val (a))) == 1); -#endif - assert (size (db->query (query::s == query::_ref (ra))) == 1); -#ifndef MULTI_DATABASE - assert (size (db->query ("s = " + query::_val (a))) == 1); - assert (size (db->query ("s = " + query::_ref (a))) == 1); -#endif - } - - { - const char a[] = "bcd"; - const char* ra = a; -#ifndef MULTI_DATABASE - assert (size (db->query (query::s == a)) == 1); - assert (size (db->query (query::s == query::_val (a))) == 1); -#endif - assert (size (db->query (query::s == query::_ref (ra))) == 1); -#ifndef MULTI_DATABASE - assert (size (db->query ("s = " + query::_val (a))) == 1); - assert (size (db->query ("s = " + query::_ref (a))) == 1); -#endif - } - - { - const char* p = "cde"; -#ifndef MULTI_DATABASE - assert (size (db->query (query::s == p)) == 1); - assert (size (db->query (query::s == query::_val (p))) == 1); -#endif - assert (size (db->query (query::s == query::_ref (p))) == 1); -#ifndef MULTI_DATABASE - assert (size (db->query ("s = " + query::_val (p))) == 1); - assert (size (db->query ("s = " + query::_ref (p))) == 1); -#endif - } - - { - char a[] = "cde"; - char* p = a; -#ifndef MULTI_DATABASE - assert (size (db->query (query::s == p)) == 1); - assert (size (db->query (query::s == query::_val (p))) == 1); -#endif - assert (size (db->query (query::s == query::_ref (p))) == 1); -#ifndef MULTI_DATABASE - assert (size (db->query ("s = " + query::_val (p))) == 1); - assert (size (db->query ("s = " + query::_ref (p))) == 1); -#endif - } - -#ifndef MULTI_DATABASE - string s ("abc"); - //assert (size (db->query (query::s == s)) == 1); - assert (size (db->query (query::s == s.c_str ())) == 1); - //assert (size (db->query (query::s == query::_val (s))) == 1); - assert (size (db->query (query::s == query::_val (s.c_str ()))) == 1); - - assert (size (db->query ("s = " + query::_val (s))) == 1); - assert (size (db->query ("s = " + query::_ref (s))) == 1); -#endif - - // @@ BUILD2 Ends up with the following warning, but strangely only in the - // multi-database mode: - // - // In file included from odb/odb-tests/common/query/array/test-odb.hxx:31, - // from odb/odb-tests/common/query/array/driver.cxx:20: - // odb/libodb/odb/query-dynamic.hxx: In instantiation of ‘odb::query_base odb::query_column::operator==(const odb::query_column&) const [with T2 = char [17]; T = char [17]]’: - // odb/odb-tests/common/query/array/driver.cxx:144:7: required from here - // odb/libodb/odb/query-dynamic.hxx:895:43: error: comparison between two arrays is deprecated in C++20 [-Werror=array-compare] - // 895 | (void) (sizeof (type_instance () == type_instance ())); - // | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ - // odb/libodb/odb/query-dynamic.hxx:895:43: note: use unary ‘+’ which decays operands to pointers or ‘&‘indirect_ref’ not supported by dump_decl[0] == &‘indirect_ref’ not supported by dump_decl[0]’ to compare the addresses - // - // Looks like compile-time assertion. Doesn't make much sense for - // arrays since compares pointers to objects rather than objects. - // Should we somehow suppress the assertion for arrays or similar? - // - // Note: temporarily ifndef-ed. - // -#ifndef MULTI_DATABASE - assert (size (db->query (query::s == query::s1)) == 3); -#endif - - // std::array - // - array a; - memcpy (a.data (), "abc", 4); // VC++ strcpy deprecation. - -#ifndef MULTI_DATABASE - assert (size (db->query (query::a == a)) == 1); - assert (size (db->query (query::a == query::_val (a))) == 1); -#endif - assert (size (db->query (query::a == query::_ref (a))) == 1); -#ifndef MULTI_DATABASE - assert (size (db->query ("a = " + query::_val (a))) == 1); - assert (size (db->query ("a = " + query::_ref (a))) == 1); -#endif - - // char - // - assert (size (db->query (query::c == 'a')) == 1); - - char c ('b'); - assert (size (db->query (query::c == query::_val (c))) == 1); - assert (size (db->query (query::c == query::_ref (c))) == 1); - -#ifndef MULTI_DATABASE - assert (size (db->query ("c = " + query::_val ('c'))) == 1); - assert (size (db->query ("c = " + query::_ref (c))) == 1); -#endif - - assert (size (db->query (query::c == query::c1)) == 3); - - // buffer - // -#ifndef MULTI_DATABASE - assert (size (db->query (query::b == buf)) == 3); - assert (size (db->query (query::b == query::_val (buf))) == 3); -#endif - - assert (size (db->query (query::b == query::_ref (buf))) == 3); - -#ifndef MULTI_DATABASE - assert (size (db->query ("b = " + query::_val (buf))) == 3); - assert (size (db->query ("b = " + query::_ref (buf))) == 3); -#endif - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/query/array/test.hxx b/common/query/array/test.hxx deleted file mode 100644 index f0d5f3b..0000000 --- a/common/query/array/test.hxx +++ /dev/null @@ -1,70 +0,0 @@ -// file : common/query/array/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include // std::memcpy, std::strlen - -#include - -#pragma db object -struct object -{ - object () {} - object (unsigned long id, const char* s, const char* b) - : id_ (id) - { - std::memcpy (s_, s, std::strlen (s) + 1); // VC++ strncpy deprecation. - std::memcpy (s1_, s, std::strlen (s) + 1); - std::memcpy (a_.data (), s, std::strlen (s) + 1); - c_ = c1_ = *s; - std::memcpy (b_, b, sizeof (b_)); - } - - #pragma db id - unsigned long id_; - - char s_[17]; - char s1_[17]; - -#ifdef ODB_COMPILER -# if defined(ODB_DATABASE_MYSQL) || \ - defined(ODB_DATABASE_PGSQL) || \ - defined(ODB_DATABASE_ORACLE) || \ - defined(ODB_DATABASE_MSSQL) -# pragma db type("VARCHAR(16)") -# elif defined(ODB_DATABASE_SQLITE) -# pragma db type("TEXT") -# elif defined(ODB_DATABASE_COMMON) -# pragma db type("DYMMU") // Necessary to make it a value. -# else -# error unknown database -# endif -#endif - std::array a_; - - char c_; - char c1_; - -#ifdef ODB_COMPILER -# if defined(ODB_DATABASE_MYSQL) -# pragma db type("BINARY(16)") -# elif defined(ODB_DATABASE_SQLITE) -# pragma db type("BLOB") -# elif defined(ODB_DATABASE_PGSQL) -# pragma db type("BYTEA") -# elif defined(ODB_DATABASE_ORACLE) -# pragma db type("RAW(16)") -# elif defined(ODB_DATABASE_MSSQL) -# pragma db type("BINARY(16)") -# elif defined(ODB_DATABASE_COMMON) -# else -# error unknown database -# endif -#endif - char b_[16]; -}; - -#endif // TEST_HXX diff --git a/common/query/array/testscript b/common/query/array/testscript deleted file mode 100644 index 631ae24..0000000 --- a/common/query/array/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/query/array/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/query/basics/buildfile b/common/query/basics/buildfile deleted file mode 100644 index e38e6fe..0000000 --- a/common/query/basics/buildfile +++ /dev/null @@ -1,42 +0,0 @@ -# file : common/query/basics/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_query_basics_ \ - --generate-schema \ - --generate-query \ - --generate-prepared - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/query/basics/driver.cxx b/common/query/basics/driver.cxx deleted file mode 100644 index 73b81d2..0000000 --- a/common/query/basics/driver.cxx +++ /dev/null @@ -1,668 +0,0 @@ -// file : common/query/basics/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test basic query support. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include // DATABASE_XXX -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -void -print (result& r) -{ - for (result::iterator i (r.begin ()); i != r.end (); ++i) - { - unique_ptr o (i.load ()); - cout << *o << endl; - } - cout << endl; -} - -const char* names[] = { "John", "Jane", "Joe" }; -const char** names_end = names + sizeof (names)/sizeof (names[0]); - -const char* key_data[] = { "\x23\x03\x15", "\x13\x13\x54", "\x08\x62\x35" }; - -int -main (int argc, char* argv[]) -{ - buffer - key1 (key_data[0], key_data[0] + 3), - key2 (key_data[1], key_data[1] + 3), - key3 (key_data[2], key_data[2] + 3); - - try - { - unique_ptr db (create_database (argc, argv)); - odb::database_id db_id (db->id ()); - - typedef odb::query query; - typedef odb::result result; - - // - // - { - person p1 (1, "John", "Doe", 30, true, key1); - person p2 (2, "Jane", "Doe", 29, true, key2); - person p3 (3, "Joe", "Dirt", 31, false, key3); - p3.middle_name_.reset (new string ("Squeaky")); - person p4 (4, "Johansen", "Johansen", 32, false); - p4.middle_name_.reset (new string ("J")); - - transaction t (db->begin ()); - db->persist (p1); - db->persist (p2); - db->persist (p3); - db->persist (p4); - t.commit (); - } - - // - // Native queries. - // - - // Compilation tests. - // -#ifndef MULTI_DATABASE - if (false) - { - string name; - unsigned short age; - - db->query ("age = " + query::_ref (age)); - db->query ("age = " + query::_val (age)); - - query age_q (query::_ref (age) + " = age"); - query name_q ("first = " + query::_val (name)); - query q (age_q + "AND" + name_q); - - db->query (q); - db->query (age_q + "OR" + - name_q + "OR" + - "age < " + query::_ref (age)); - - query q1 (query::_val (name)); - q1 += " = first"; - } -#endif - - // Select-all query. - // - cout << "test 001" << endl; - { - transaction t (db->begin ()); - result r (db->query ()); - - for (result::iterator i (r.begin ()); i != r.end (); ++i) - { - person p; - i.load (p); - cout << p << endl; - } - - t.commit (); - } - - // Select-all query with order by. - // - cout << "test 002" << endl; - { - transaction t (db->begin ()); - result r (db->query ("ORDER BY" + query::age)); - - for (result::iterator i (r.begin ()); i != r.end (); ++i) - { - person& p (*i); - - cout << p.first_name_; - - if (i->middle_name_.get () != 0) - cout << ' ' << *i->middle_name_; - - cout << ' ' << i->last_name_ << ' ' << i->age_ << - (i->married_ ? " married" : " single") << endl; - } - cout << endl; - - t.commit (); - } - - // String query. - // - cout << "test 003" << endl; - { - transaction t (db->begin ()); - - result r; - if (db_id != odb::id_oracle) - r = db->query ("age >= 30 AND last = 'Doe'"); - else - r = db->query ("\"age\" >= 30 AND \"last\" = 'Doe'"); - - print (r); - t.commit (); - } - - // Value binding. - // - cout << "test 004" << endl; - { - transaction t (db->begin ()); - - const char* name = "Doe"; - -#if defined(MULTI_DATABASE) - result r ( - db->query ( - query::age >= query::_val (30) && - query::last_name == query::_val (name))); - -#elif defined(DATABASE_ORACLE) - result r ( - db->query ( - "\"age\" >= " + query::_val (30) + "AND" + - "\"last\" = " + query::_val (name))); -#else - result r ( - db->query ( - "age >= " + query::_val (30) + "AND" + - "last = " + query::_val (name))); -#endif - - print (r); - t.commit (); - } - - // Reference binding. - // - cout << "test 005" << endl; - { - transaction t (db->begin ()); - - string name; - unsigned short age; - -#if defined(MULTI_DATABASE) - query q (query::age >= query::_ref (age) && - query::last_name == query::_ref (name)); -#elif defined(DATABASE_ORACLE) - query q ("\"age\" >= " + query::_ref (age) + "AND" + - "\"last\" = " + query::_ref (name)); -#else - query q ("age >= " + query::_ref (age) + "AND" + - "last = " + query::_ref (name)); -#endif - - name = "Doe"; - age = 30; - result r (db->query (q)); - print (r); - - name = "Dirt"; - age = 31; - r = db->query (q); - print (r); - - t.commit (); - } - - // - // Language-embedded queries. - // - - // Compilation tests. - // - if (false) - { - string name; - unsigned short age; - - // Column operators. - // - query q1 (query::married); - db->query (query::married); - db->query (query::married == true); - - //db->query (query::age); - - db->query (query::age == 30); - db->query (query::age == age); - db->query (query::age == query::_val (30)); - db->query (query::age == query::_val (age)); - db->query (query::age == query::_ref (age)); - //db->query (query::age == "123"); - //db->query ("123" == query::age); - //db->query (query::age == query::_val ("123")); - //db->query (query::age == query::_ref (name)); - db->query (query::last_name == "Doe"); - db->query (query::last_name == name); -#ifndef MULTI_DATABASE - db->query (query::last_name == query::_val ("Doe")); -#endif - db->query (query::last_name == query::_val (name)); - db->query (query::last_name == query::_ref (name)); - //db->query (query::last_name == 30); - //db->query (query::last_name == query::_val (30)); - //db->query (query::last_name == query::_ref (age)); - - db->query (query::last_name.is_null ()); - db->query (query::last_name.is_not_null ()); - - db->query (query::first_name == query::last_name); - - db->query (query::first_name.in ("John", "Jane")); - db->query (query::first_name.in_range (names, names_end)); - - db->query (query::first_name.like ("J%")); - db->query (query::first_name.like ("J%!%", "!")); - - // Query operators. - // - db->query (query::age == 30 && query::last_name == "Doe"); - db->query (query::age == 30 || query::last_name == "Doe"); - db->query (!(query::age == 30 || query::last_name == "Doe")); - db->query ((query::last_name == "Doe") + "ORDER BY age"); - } - - // Test is_null/is_not_null. - // - cout << "test 006" << endl; - { - transaction t (db->begin ()); - result r (db->query (query::middle_name.is_null ())); - print (r); - r = db->query (query::middle_name.is_not_null ()); - print (r); - t.commit (); - } - - // Test boolean columns. - // - cout << "test 007" << endl; - { - transaction t (db->begin ()); - result r (db->query (query::married)); - print (r); - r = db->query (!query::married); - print (r); - t.commit (); - } - - // Test implicit by-value, explicit by-value, and by-reference. - // - cout << "test 008" << endl; - { - string name ("Dirt"); - - transaction t (db->begin ()); - result r (db->query (query::last_name == "Doe")); - print (r); - r = db->query (query::last_name == query::_val (name)); - print (r); - query q (query::last_name == query::_ref (name)); - name = "Doe"; - r = db->query (q); - print (r); - t.commit (); - } - - // Test column operators (==, !=, <, >, <=, >=). - // - cout << "test 009" << endl; - { - transaction t (db->begin ()); - - // == - // - result r (db->query (query::last_name == "Doe")); - print (r); - - // != - // - r = db->query (query::last_name != "Doe"); - print (r); - - // < - // - r = db->query (query::age < 31); - print (r); - - // > - // - r = db->query (query::age > 30); - print (r); - - // <= - // - r = db->query (query::age <= 30); - print (r); - - // >= - // - r = db->query (query::age >= 31); - print (r); - - t.commit (); - } - - // Test query operators (&&, ||, (), !, +). - // - cout << "test 010" << endl; - { - transaction t (db->begin ()); - - // && - // - result r (db->query ( - query::last_name == "Doe" && query::age == 29)); - print (r); - - // || - // - r = db->query (query::last_name == "Doe" || query::age == 31); - print (r); - - // () - // - r = db->query ( - (query::last_name != "Doe" || query::age == 29) && query::married); - print (r); - - // != - // - r = db->query (!(query::last_name == "Doe")); - print (r); - - // + - // - r = db->query ((query::last_name == "Doe") + - "ORDER BY" + query::age); - print (r); - - t.commit (); - } - - // Test in/in_range. - // - cout << "test 011" << endl; - { - transaction t (db->begin ()); - - result r (db->query (query::first_name.in ("John", "Jane"))); - print (r); - - r = db->query (query::first_name.in_range (names, names_end)); - print (r); - - // Empty range. - // - r = db->query (query::last_name == "Doe" && - query::first_name.in_range (names, names)); - assert (r.empty ()); - - t.commit (); - } - - // Test column-to-column comparison. - // - cout << "test 012" << endl; - { - transaction t (db->begin ()); - result r (db->query (query::first_name == query::last_name)); - print (r); - t.commit (); - } - - // Test value_traits::value_type != value_traits::query_type. - // - cout << "test 013" << endl; - { - transaction t (db->begin ()); - result r (db->query (query::middle_name == "Squeaky")); - print (r); - t.commit (); - } - - // Test that loading of the same object type during iteration does - // not invalidate the result. - // - cout << "test 014" << endl; - { - transaction t (db->begin ()); - result r (db->query (query::last_name == "Doe")); - - result::iterator i (r.begin ()); - assert (i != r.end ()); - ++i; - assert (i != r.end ()); - - { - unique_ptr joe (db->load (3)); - } - - { - person p (5, "Peter", "Peterson", 70, false, key3); - db->persist (p); - db->erase (p); - } - - // SQL Server does not support re-loading of an object with long data - // from a query result. - // - if (db_id != odb::id_mssql) - assert (i->last_name_ == "Doe"); // Actual load. - - // Overwrite object image again. - // - unique_ptr joe (db->load (3)); - person p; - i.load (p); - assert (p.last_name_ == "Doe"); - - t.commit (); - } - - // Test uncached result. - // - cout << "test 015" << endl; - { - transaction t (db->begin ()); - result r (db->query (query::last_name == "Doe", false)); - print (r); - t.commit (); - } - - // Test BLOB column operations. - // - cout << "test 016" << endl; - { - transaction t (db->begin ()); - - result r; - result::iterator i; - - // == - // - - // Oracle does not support LOB comparisons. - // -#if defined(MULTI_DATABASE) || !defined(DATABASE_ORACLE) - if (db_id != odb::id_oracle) - { - r = db->query (query::public_key == key2); - - i = r.begin (); - assert (i != r.end ()); - - assert (*i->public_key_ == key2); - assert (++i == r.end ()); - } -#endif - - // is_null - // - r = db->query (query::public_key.is_null ()); - - i = r.begin (); - assert (i != r.end ()); - - assert (i->first_name_ == "Johansen" && i->last_name_ == "Johansen"); - assert (++i == r.end ()); - - // is_not_null - // - r = db->query (query::public_key.is_not_null ()); - - i = r.begin (); - assert (i != r.end ()); - - assert (i->first_name_ == "John" && i->last_name_ == "Doe"); - assert (++i != r.end ()); - - assert (i->first_name_ == "Jane" && i->last_name_ == "Doe"); - assert (++i != r.end ()); - - assert (i->first_name_ == "Joe" && i->last_name_ == "Dirt"); - assert (++i == r.end ()); - - t.commit (); - } - - // Test iterator::id(). - // - cout << "test 017" << endl; - { - transaction t (db->begin ()); - result r (db->query (query::last_name == "Dirt")); - - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i.id () == 3); - - t.commit (); - } - - // Test empty result set. - // - cout << "test 018" << endl; - { - { - transaction t (db->begin ()); - result r (db->query (query::last_name == "None")); - assert (r.empty ()); - t.commit (); - } - - { - transaction t (db->begin ()); - result r (db->query (query::last_name == "None")); - assert (r.begin () == r.end ()); - t.commit (); - } - } - - // Test size() validity at the beginning/middle/end of result set. - // - cout << "test 019" << endl; - if (db_id != odb::id_sqlite && - db_id != odb::id_oracle && - db_id != odb::id_mssql) - { - { - transaction t (db->begin ()); - result r (db->query ()); - assert (r.size () == 4); - result::iterator i (r.begin ()); - assert (r.size () == 4); - ++i; - ++i; - ++i; - assert (r.size () == 4); - ++i; - assert (r.size () == 4); - } - - { - transaction t (db->begin ()); - result r (db->query (false)); - result::iterator i (r.begin ()); - ++i; - ++i; - r.cache (); // Cache in the middle. - assert (r.size () == 4); - ++i; - assert (r.size () == 4); - ++i; - assert (r.size () == 4); - } - - { - transaction t (db->begin ()); - result r (db->query (false)); - result::iterator i (r.begin ()); - ++i; - ++i; - ++i; - r.cache (); // Cache at the end. - assert (r.size () == 4); - } - - { - transaction t (db->begin ()); - result r (db->query (query::last_name == "None")); - assert (r.size () == 0); - for (result::iterator i (r.begin ()); i != r.end (); ++i) ; - assert (r.size () == 0); - } - } - - // Test like. - // - cout << "test 020" << endl; - { - transaction t (db->begin ()); - - result r (db->query (query::first_name.like ("Jo%"))); - print (r); - - r = db->query (!query::first_name.like ("Jo%")); - print (r); - - r = db->query (query::first_name.like ("Jo!%", "!")); - print (r); - - // In Oracle one can only escape special characters (% and _). - // - string v; - if (db_id != odb::id_oracle) - v = "!Ja%"; - else - v = "Ja%"; - - r = db->query (query::first_name.like (query::_ref (v), "!")); - print (r); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/query/basics/test.hxx b/common/query/basics/test.hxx deleted file mode 100644 index 239f6d6..0000000 --- a/common/query/basics/test.hxx +++ /dev/null @@ -1,117 +0,0 @@ -// file : common/query/basics/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include -#include - -#include -#include - -#ifdef ODB_COMPILER -# if defined(ODB_DATABASE_PGSQL) -# define BLOB_TYPE "BYTEA" -# elif defined(ODB_DATABASE_MSSQL) -# define BLOB_TYPE "VARBINARY(max)" -# else -# define BLOB_TYPE "BLOB" -# endif -#endif - -typedef std::vector buffer; -typedef odb::nullable nullable_buffer; - -#pragma db object -struct person -{ - person (unsigned long id, - const std::string& fn, - const std::string& ln, - unsigned short age, - bool married, - const nullable_buffer& public_key = nullable_buffer ()) - : id_ (id), - first_name_ (fn), - last_name_ (ln), - age_ (age), - married_ (married), - public_key_ (public_key) - { - } - - person () - { - } - - #pragma db id - unsigned long id_; - - #pragma db column ("first") - std::string first_name_; - - #pragma db column ("middle") null - std::unique_ptr middle_name_; - - #pragma db column ("last") - std::string last_name_; - - unsigned short age_; - bool married_; - - #pragma db column ("key") type(BLOB_TYPE) null - nullable_buffer public_key_; -}; - -inline std::ostream& -operator<< (std::ostream& os, const person& p) -{ - os << p.first_name_; - - if (p.middle_name_.get () != 0) - os << ' ' << *p.middle_name_; - - os << ' ' << p.last_name_ << ' ' << p.age_ << - (p.married_ ? " married" : " single"); - - return os; -} - -// Test member name conflicts (compilation-only test). -// -#pragma db namespace table("t2_") -namespace test2 -{ - #pragma db object - struct object - { - #pragma db id - int id; - }; - - #pragma db value - struct value - { - object* m_object; - }; - - #pragma db value - struct bar - { - value m_value; - }; - - #pragma db object - struct foo - { - #pragma db id - int id; - - bar m_value; - }; -} - -#endif // TEST_HXX diff --git a/common/query/basics/testscript b/common/query/basics/testscript deleted file mode 100644 index 9086b66..0000000 --- a/common/query/basics/testscript +++ /dev/null @@ -1,150 +0,0 @@ -# file : common/query/basics/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -+cat <=output - test 001 - John Doe 30 married - Jane Doe 29 married - Joe Squeaky Dirt 31 single - Johansen J Johansen 32 single - test 002 - Jane Doe 29 married - John Doe 30 married - Joe Squeaky Dirt 31 single - Johansen J Johansen 32 single - - test 003 - John Doe 30 married - - test 004 - John Doe 30 married - - test 005 - John Doe 30 married - - Joe Squeaky Dirt 31 single - - test 006 - John Doe 30 married - Jane Doe 29 married - - Joe Squeaky Dirt 31 single - Johansen J Johansen 32 single - - test 007 - John Doe 30 married - Jane Doe 29 married - - Joe Squeaky Dirt 31 single - Johansen J Johansen 32 single - - test 008 - John Doe 30 married - Jane Doe 29 married - - Joe Squeaky Dirt 31 single - - John Doe 30 married - Jane Doe 29 married - - test 009 - John Doe 30 married - Jane Doe 29 married - - Joe Squeaky Dirt 31 single - Johansen J Johansen 32 single - - John Doe 30 married - Jane Doe 29 married - - Joe Squeaky Dirt 31 single - Johansen J Johansen 32 single - - John Doe 30 married - Jane Doe 29 married - - Joe Squeaky Dirt 31 single - Johansen J Johansen 32 single - - test 010 - Jane Doe 29 married - - John Doe 30 married - Jane Doe 29 married - Joe Squeaky Dirt 31 single - - Jane Doe 29 married - - Joe Squeaky Dirt 31 single - Johansen J Johansen 32 single - - Jane Doe 29 married - John Doe 30 married - - test 011 - John Doe 30 married - Jane Doe 29 married - - John Doe 30 married - Jane Doe 29 married - Joe Squeaky Dirt 31 single - - test 012 - Johansen J Johansen 32 single - - test 013 - Joe Squeaky Dirt 31 single - - test 014 - test 015 - John Doe 30 married - Jane Doe 29 married - - test 016 - test 017 - test 018 - test 019 - test 020 - John Doe 30 married - Joe Squeaky Dirt 31 single - Johansen J Johansen 32 single - - Jane Doe 29 married - - - Jane Doe 29 married - - EOI - -test.redirects += >>>../output - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/query/one/buildfile b/common/query/one/buildfile deleted file mode 100644 index 76a36b0..0000000 --- a/common/query/one/buildfile +++ /dev/null @@ -1,42 +0,0 @@ -# file : common/query/one/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_query_one_ \ - --generate-schema \ - --generate-query \ - --generate-prepared - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/query/one/driver.cxx b/common/query/one/driver.cxx deleted file mode 100644 index 4c3dcdc..0000000 --- a/common/query/one/driver.cxx +++ /dev/null @@ -1,205 +0,0 @@ -// file : common/query/one/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test query one support. -// -// We assume that other tests in common/query/ exercise a variety of -// different kinds of queries. Here we are concerned with what is -// specific to query_one() and query_value(). -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - odb::database_id db_id (db->id ()); - - transaction t (db->begin ()); - - // query_one() - // - { - unique_ptr o (db->query_one ()); - assert (o.get () == 0); - } - - { - object o (4); - assert (!db->query_one (o) && o.id_ == 4 && o.str_.empty ()); - } - - /* - { - object o (db->query_value ()); - assert (false); - } - */ - - object o (1); - o.str_ = "value 1"; - db->persist (o); - - { - unique_ptr o (db->query_one ()); - assert (o.get () != 0 && o->str_ == "value 1"); - } - - { - object o; - assert (db->query_one (o) && o.str_ == "value 1"); - } - - { - object o (db->query_value ()); - assert (o.str_ == "value 1"); - } - - // query_one(const char*) - // - const char* q1_c (db_id == odb::id_oracle ? "\"id\" = 1" : "id = 1"); - const char* q0_c (db_id == odb::id_oracle ? "\"id\" = 2" : "id = 2"); - - { - unique_ptr o (db->query_one (q1_c)); - assert (o.get () != 0 && o->str_ == "value 1"); - } - - { - unique_ptr o (db->query_one (q0_c)); - assert (o.get () == 0); - } - - { - object o; - assert (db->query_one (q1_c, o) && o.str_ == "value 1"); - } - - { - object o (4); - assert (!db->query_one (q0_c, o) && - o.id_ == 4 && o.str_.empty ()); - } - - { - object o (db->query_value (q1_c)); - assert (o.str_ == "value 1"); - } - - // query_one(std::string) - // - string q1_s (q1_c); - string q0_s (q0_c); - - { - unique_ptr o (db->query_one (q1_s)); - assert (o.get () != 0 && o->str_ == "value 1"); - } - - { - unique_ptr o (db->query_one (q0_s)); - assert (o.get () == 0); - } - - { - object o; - assert (db->query_one (q1_s, o) && o.str_ == "value 1"); - } - - { - object o (4); - assert (!db->query_one (q0_s, o) && - o.id_ == 4 && o.str_.empty ()); - } - - { - object o (db->query_value (q1_s)); - assert (o.str_ == "value 1"); - } - - // query_one(odb::query) - // - typedef odb::query query; - - query q1 (query::id == 1); - query q0 (query::id == 2); - - { - unique_ptr o (db->query_one (q1)); - assert (o.get () != 0 && o->str_ == "value 1"); - } - - { - unique_ptr o (db->query_one (q0)); - assert (o.get () == 0); - } - - { - object o; - assert (db->query_one (q1, o) && o.str_ == "value 1"); - } - - { - object o (4); - assert (!db->query_one (q0, o) && o.id_ == 4 && o.str_.empty ()); - } - - { - object o (db->query_value (q1)); - assert (o.str_ == "value 1"); - } - - // Assertion on more than one element. - // - { - object o (2); - o.str_ = "value 2"; - db->persist (o); - } - - /* - { - unique_ptr o (db->query_one ()); - assert (false); - } - */ - - /* - { - object o; - db->query_one (o); - assert (false); - } - */ - - /* - { - object o (db->query_value ()); - assert (false); - } - */ - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/query/one/test.hxx b/common/query/one/test.hxx deleted file mode 100644 index 3008063..0000000 --- a/common/query/one/test.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// file : common/query/one/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; - std::string str_; -}; - -#endif // TEST_HXX diff --git a/common/query/one/testscript b/common/query/one/testscript deleted file mode 100644 index 963a206..0000000 --- a/common/query/one/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/query/one/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/readonly/buildfile b/common/readonly/buildfile deleted file mode 100644 index 2d83cf1..0000000 --- a/common/readonly/buildfile +++ /dev/null @@ -1,40 +0,0 @@ -# file : common/readonly/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix readonly_ \ - --generate-schema - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/readonly/driver.cxx b/common/readonly/driver.cxx deleted file mode 100644 index b207627..0000000 --- a/common/readonly/driver.cxx +++ /dev/null @@ -1,324 +0,0 @@ -// file : common/readonly/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test readonly members/objects. Also test that const members are -// treated as readonly. For other const member tests, see the const- -// member test. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include // DATABASE_* -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Simple. - // - { - simple o (1, 1); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - o.ro++; - const_cast (o.co)++; - o.rw++; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - db->load (1, o); - t.commit (); - } - - assert (o.ro == 1 && o.co == 1 && o.rw == 2); - } - - // Pointer. - // - { - pointer p (1, new pointer (2)); - unique_ptr p1 (new pointer (3)); - - { - transaction t (db->begin ()); - db->persist (p); - db->persist (p.ro); - db->persist (*p1); - t.commit (); - } - - delete p.ro; - p.ro = p1.release (); - const_cast (p.co) = p.ro; - p.rw = p.ro; - - { - transaction t (db->begin ()); - db->update (p); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (1)); - t.commit (); - - assert (p->ro->id == 2 && p->co->id == 2 && p->rw->id == 3); - } - } - - // Composite. - // - { - composite o (1, 1); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - o.ro.v++; - o.ro.ro++; - const_cast (o.ro.co)++; - o.ro.rw++; - - value& co (const_cast (o.co)); - co.v++; - co.ro++; - const_cast (co.co)++; - co.rw++; - - o.rw.v++; - o.rw.ro++; - const_cast (o.rw.co)++; - o.rw.rw++; - - o.v.v++; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - db->load (1, o); - t.commit (); - } - - assert (o.ro.v == 1 && - o.ro.ro == 1 && - o.ro.co == 1 && - o.ro.rw == 1 && - - o.co.v == 1 && - o.co.ro == 1 && - o.co.co == 1 && - o.co.rw == 1 && - - o.rw.v == 1 && - o.rw.ro == 1 && - o.rw.co == 1 && - o.rw.rw == 2 && - - o.v.v == 1); - } - - // Container. - // - { - typedef vector ulongs; - - container o (1); - - o.ro.push_back (1); - o.ro.push_back (2); - - ulongs& co (const_cast (o.co)); - co.push_back (1); - co.push_back (2); - - o.rw.push_back (1); - o.rw.push_back (2); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - o.ro[0]++; - o.ro.pop_back (); - - co[0]++; - co.pop_back (); - - o.rw[0]++; - o.rw.pop_back (); - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - db->load (1, o); - t.commit (); - } - - assert (o.ro.size () == 2 && o.ro[0] == 1 && o.ro[1] == 2 && - o.co.size () == 2 && o.co[0] == 1 && o.co[1] == 2 && - o.rw.size () == 1 && o.rw[0] == 2); - } - - // Readonly object. - // - { -#ifndef MULTI_DATABASE - typedef odb::object_traits_impl so_traits; - typedef odb::object_traits_impl ro_traits; - typedef odb::object_traits_impl rw_traits; - - assert (so_traits::column_count == - so_traits::id_column_count + so_traits::readonly_column_count); - - assert (ro_traits::column_count == - ro_traits::id_column_count + ro_traits::readonly_column_count); - - assert (rw_traits::column_count != - rw_traits::id_column_count + rw_traits::readonly_column_count); -#endif - - simple_object so (1, 1); - ro_object ro_o (1, 1); - rw_object rw_o (1, 1); - - ro_o.cr.push_back (1); - ro_o.cr.push_back (2); - - rw_o.cr.push_back (1); - rw_o.cr.push_back (2); - - { - transaction t (db->begin ()); - db->persist (so); - db->persist (ro_o); - db->persist (rw_o); - t.commit (); - } - - rw_o.sv++; - rw_o.rw_sv++; - - { - transaction t (db->begin ()); - //db->update (so); // Compile error. - //db->update (ro_o); // Compile error. - db->update (rw_o); - t.commit (); - } - - { - transaction t (db->begin ()); - db->load (1, so); - db->load (1, ro_o); - db->load (1, rw_o); - t.commit (); - } - - assert (rw_o.sv == 1 && rw_o.rw_sv == 2); - } - - // Readonly object. - // - { - wrapper o (1, 1); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - *o.pl = 2; - *o.cpl = 2; - o.pcl.reset (new unsigned long (2)); - const_cast (*o.cpcl) = 2; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - db->load (1, o); - t.commit (); - } - - assert (*o.pl == 2 && *o.cpl == 2 && *o.pcl == 2 && *o.cpcl == 1); - } - - // Readonly object with auto id. - // - { - ro_auto o1 (1); - ro_auto o2 (2); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (p1->num == o1.num); - assert (p2->num == o2.num); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/readonly/test.hxx b/common/readonly/test.hxx deleted file mode 100644 index 45797b6..0000000 --- a/common/readonly/test.hxx +++ /dev/null @@ -1,225 +0,0 @@ -// file : common/readonly/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include // std::unique_ptr - -#include - -// Simple readonly object. -// -#pragma db object -struct simple -{ - simple (unsigned long i, unsigned long x) - : id (i), ro (x), co (x), rw (x) - { - } - - simple (): co (0) {} - - #pragma db id - unsigned long id; - - #pragma db readonly - unsigned long ro; - - const unsigned long co; - - unsigned long rw; -}; - -// Readonly pointer. -// -#pragma db object -struct pointer -{ - pointer (unsigned long i, pointer* p = 0): id (i), ro (p), co (p), rw (p) {} - pointer (): ro (0), co (0), rw (0) {} - - ~pointer () - { - delete ro; - - if (co != ro) - delete co; - - if (rw != ro && rw != co) - delete rw; - } - - #pragma db id - unsigned long id; - - #pragma db readonly - pointer* ro; - - pointer* const co; - - pointer* rw; -}; - -// Composite readonly value as well as simple readonly value inside -// a composite. -// -#pragma db value readonly -struct ro_value -{ - ro_value () {} - ro_value (unsigned long x): v (x) {} - - unsigned long v; -}; - -#pragma db value -struct value: ro_value -{ - value (): co (0) {} - value (unsigned long x): ro_value (x), ro (x), co (x), rw (x) {} - - #pragma db readonly - unsigned long ro; - - const unsigned long co; - - unsigned long rw; -}; - -#pragma db object -struct composite -{ - composite (unsigned long i, unsigned long x) - : id (i), ro (x), co (x), rw (x), v (x) - { - } - - composite () {} - - #pragma db id - unsigned long id; - - #pragma db readonly - value ro; - - const value co; - - value rw; - ro_value v; -}; - -// Readonly container. -// -#pragma db object -struct container -{ - container (unsigned long i): id (i) {} - container () {} - - #pragma db id - unsigned long id; - - #pragma db readonly - std::vector ro; - - const std::vector co; - - std::vector rw; -}; - -// Readonly object. -// -#pragma db object readonly -struct simple_object -{ - simple_object (unsigned long i, unsigned long x): id (i), sv (x) {} - simple_object () {} - - #pragma db id - unsigned long id; - - unsigned long sv; -}; - -#pragma db object -struct object -{ - object (unsigned long i, unsigned long x): id (i), sv (x) {} - object () {} - - #pragma db id - unsigned long id; - - unsigned long sv; -}; - -#pragma db object readonly -struct ro_object: object -{ - ro_object (unsigned long i, unsigned long x) - : object (i, x), cv (x) - { - } - - ro_object () {} - - value cv; - std::vector cr; -}; - -#pragma db object -struct rw_object: ro_object -{ - rw_object (unsigned long i, unsigned long x) - : ro_object (i, x), rw_sv (x) - { - } - - rw_object () {} - - unsigned long rw_sv; -}; - -// Readonly wrappers. Here we make sure that only const wrappers with -// const wrapped types are automatically treated as readonly. -// -#pragma db object -struct wrapper -{ - wrapper (unsigned long i, unsigned long x) - : id (i), - pl (new unsigned long (x)), - cpl (new unsigned long (x)), - pcl (new unsigned long (x)), - cpcl (new unsigned long (x)) - { - } - - wrapper () {} - - #pragma db id - unsigned long id; - - std::unique_ptr pl; - const std::unique_ptr cpl; - std::unique_ptr pcl; - const std::unique_ptr cpcl; -}; - -// Readonly object with auto id. -// -#pragma db object readonly -struct ro_auto -{ - ro_auto (unsigned long n): num (n) {} - ro_auto () {} - - #pragma db id auto - unsigned long id; - - unsigned long num; -}; - -#endif // TEST_HXX diff --git a/common/readonly/testscript b/common/readonly/testscript deleted file mode 100644 index c798201..0000000 --- a/common/readonly/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/readonly/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/relationship/basics/buildfile b/common/relationship/basics/buildfile deleted file mode 100644 index d7bbb7e..0000000 --- a/common/relationship/basics/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/relationship/basics/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_rel_basics_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/relationship/basics/driver.cxx b/common/relationship/basics/driver.cxx deleted file mode 100644 index e27c127..0000000 --- a/common/relationship/basics/driver.cxx +++ /dev/null @@ -1,150 +0,0 @@ -// file : common/relationship/basics/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test object relationships. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - aggr a ("aggr"); - a.o1 = new obj1 ("o1", "obj1"); - a.o2.reset (new obj2 ("obj2")); - - a.v2.push_back (obj2_ptr (new obj2 ("v1 obj2 1"))); - a.v2.push_back (0); - a.v2.push_back (obj2_ptr (new obj2 ("v1 obj2 2"))); - - a.o3.reset (new obj3 ("obj3")); - - a.c.num = 123; - a.c.o3.reset (new obj3 ("c")); - - a.cv.push_back (comp (234, obj3_ptr (new obj3 ("cv 0")))); - a.cv.push_back (comp (235, obj3_ptr ())); - a.cv.push_back (comp (236, obj3_ptr (new obj3 ("cv 2")))); - - a.v1.push_back (new obj1 ("v1 0", "v1 0")); - a.v1.push_back (0); - a.v1.push_back (new obj1 ("v1 2", "v1 2")); - - // Set cannot contain NULL pointers. - // - a.s1.insert (new obj1 ("s1 0", "s1 0")); - a.s1.insert (new obj1 ("s1 2", "s1 2")); - - a.m1[0] = new obj1 ("m1 0", "m1 0"); - a.m1[1] = 0; - a.m1[2] = new obj1 ("m1 2", "m1 2"); - - // persist - // - { - transaction t (db->begin ()); - db->persist (a.o1); - db->persist (a.o2); - - for (obj2_vec::iterator i (a.v2.begin ()); i != a.v2.end (); ++i) - if (*i) - db->persist (*i); - - db->persist (a.o3); - - db->persist (a.c.o3); - - for (comp_vec::iterator i (a.cv.begin ()); i != a.cv.end (); ++i) - if (i->o3) - db->persist (i->o3); - - for (obj1_vec::iterator i (a.v1.begin ()); i != a.v1.end (); ++i) - if (*i) - db->persist (*i); - - for (obj1_set::iterator i (a.s1.begin ()); i != a.s1.end (); ++i) - if (*i) - db->persist (*i); - - for (obj1_map::iterator i (a.m1.begin ()); i != a.m1.end (); ++i) - if (i->second) - db->persist (i->second); - - db->persist (a); - t.commit (); - } - - // load & compare - // - { - transaction t (db->begin ()); - unique_ptr a1 (db->load (a.id)); - t.commit (); - - assert (*a1 == a); - } - - // query - // - typedef odb::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - result r (db->query (query::o1->str == "obj1")); - assert (!r.empty ()); - assert (r.begin ()->o1->id == a.o1->id); - assert (size (r) == 1); - - t.commit (); - } - - // Test NULL pointer. - // - delete a.o1; - a.o1 = 0; - a.o2.reset (); - a.o3.reset (); - - { - transaction t (db->begin ()); - db->update (a); - t.commit (); - } - - // load & compare - // - { - transaction t (db->begin ()); - unique_ptr a1 (db->load (a.id)); - t.commit (); - - assert (*a1 == a); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/relationship/basics/test.hxx b/common/relationship/basics/test.hxx deleted file mode 100644 index 8a2742e..0000000 --- a/common/relationship/basics/test.hxx +++ /dev/null @@ -1,260 +0,0 @@ -// file : common/relationship/basics/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include -#include -#include - -#include - -// Raw pointer. -// -#pragma db object pointer(obj1*) -struct obj1 -{ - obj1 () {} - obj1 (const std::string& i, const std::string& s): id (i), str (s) {} - - #pragma db id - std::string id; - std::string str; -}; - -inline bool -operator== (const obj1& x, const obj1& y) -{ - return x.id == y.id && x.str == y.str; -} - -// vector -// -typedef std::vector obj1_vec; - -inline bool -operator== (const obj1_vec& x, const obj1_vec& y) -{ - if (x.size () != y.size ()) - return false; - - for (obj1_vec::size_type i (0); i < x.size (); ++i) - if (!(x[i] ? (y[i] && *x[i] == *y[i]) : !y[i])) - return false; - - return true; -} - -// set -// -struct obj1_cmp -{ - bool - operator() (obj1* x, obj1* y) const - { - return (!x || !y) ? x < y : x->id < y->id; - } -}; - -typedef std::set obj1_set; - -inline bool -operator== (const obj1_set& x, const obj1_set& y) -{ - if (x.size () != y.size ()) - return false; - - for (obj1_set::const_iterator i (x.begin ()); i != x.end (); ++i) - { - obj1_set::const_iterator j (y.find (*i)); - - if (j == y.end ()) - return false; - - obj1* x (*i); - obj1* y (*j); - - if (!(x ? (y && *x == *y) : !y)) - return false; - } - - return true; -} - -// map -// -typedef std::map obj1_map; - -inline bool -operator== (const obj1_map& x, const obj1_map& y) -{ - if (x.size () != y.size ()) - return false; - - for (obj1_map::const_iterator i (x.begin ()); i != x.end (); ++i) - { - obj1_map::const_iterator j (y.find (i->first)); - - if (j == y.end ()) - return false; - - obj1* x (i->second); - obj1* y (j->second); - - if (!(x ? (y && *x == *y) : !y)) - return false; - } - - return true; -} - -// auto_ptr/unique_ptr -// -struct obj2; - -typedef std::unique_ptr obj2_ptr; - -#pragma db object pointer(obj2_ptr) -struct obj2 -{ - obj2 () {} - obj2 (const std::string& s): str (s) {} - - #pragma db id auto - unsigned long id; - - std::string str; -}; - -inline bool -operator== (const obj2& x, const obj2& y) -{ - return x.id == y.id && x.str == y.str; -} - -typedef std::vector obj2_vec; - -inline bool -operator== (const obj2_vec& x, const obj2_vec& y) -{ - if (x.size () != y.size ()) - return false; - - for (obj2_vec::size_type i (0); i < x.size (); ++i) - if (!(x[i] ? (y[i] && *x[i] == *y[i]) : !y[i])) - return false; - - return true; -} - -// shared_ptr -// -struct obj3; - -typedef std::shared_ptr obj3_ptr; - -#pragma db object pointer(obj3_ptr) -struct obj3 -{ - obj3 () {} - obj3 (const std::string& s): str (s) {} - - #pragma db id auto - unsigned long id; - - std::string str; -}; - -inline bool -operator== (const obj3& x, const obj3& y) -{ - return x.id == y.id && x.str == y.str; -} - -// composite -// -#pragma db value -struct comp -{ - comp () {} - comp (int n, obj3_ptr o): num (n), o3 (o) {} - - int num; - obj3_ptr o3; -}; - -inline bool -operator== (const comp& x, const comp& y) -{ - return x.num == y.num && - (x.o3 ? (y.o3 && *x.o3 == *y.o3) : !y.o3); -} - -typedef std::vector comp_vec; - -// -// -#pragma db object -struct aggr -{ - aggr (): o1 (0) {} - aggr (const std::string& s): o1 (0), str (s) {} - - ~aggr () - { - delete o1; - - for (obj1_vec::iterator i (v1.begin ()); i != v1.end (); ++i) - delete *i; - - for (obj1_set::iterator i (s1.begin ()); i != s1.end (); ++i) - delete *i; - - for (obj1_map::iterator i (m1.begin ()); i != m1.end (); ++i) - delete i->second; - } - - #pragma db id auto - unsigned long id; - - obj1* o1; - - obj2_ptr o2; // std::auto_ptr or std::unique_ptr - obj2_vec v2; - - obj3_ptr o3; - comp c; - comp_vec cv; - - obj1_vec v1; - obj1_set s1; - obj1_map m1; - - std::string str; - -private: - aggr (const aggr&); - aggr& operator= (const aggr&); -}; - -inline bool -operator== (const aggr& x, const aggr& y) -{ - return - x.id == y.id && - (x.o1 ? (y.o1 && *x.o1 == *y.o1) : !y.o1) && - (x.o2.get () ? (y.o2.get () && *x.o2 == *y.o2) : !y.o2.get ()) && - x.v2 == y.v2 && - (x.o3.get () ? (y.o3.get () && *x.o3 == *y.o3) : !y.o3.get ()) && - x.c == y.c && - x.cv == y.cv && - x.v1 == y.v1 && - x.s1 == y.s1 && - x.m1 == y.m1 && - x.str == y.str; -} - -#endif // TEST_HXX diff --git a/common/relationship/basics/testscript b/common/relationship/basics/testscript deleted file mode 100644 index b498bfa..0000000 --- a/common/relationship/basics/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/relationship/basics/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/relationship/on-delete/buildfile b/common/relationship/on-delete/buildfile deleted file mode 100644 index 965a2eb..0000000 --- a/common/relationship/on-delete/buildfile +++ /dev/null @@ -1,43 +0,0 @@ -# file : common/relationship/on-delete/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_rel_on_d_ \ - --generate-schema \ - --fkeys-deferrable-mode mysql:not_deferrable \ - --fkeys-deferrable-mode mssql:not_deferrable - - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/relationship/on-delete/driver.cxx b/common/relationship/on-delete/driver.cxx deleted file mode 100644 index eec57cf..0000000 --- a/common/relationship/on-delete/driver.cxx +++ /dev/null @@ -1,82 +0,0 @@ -// file : common/relationship/on-delete/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test ON DELETE functionality. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - object o; - - cascade c; - c.p = &o; - - cascade_cont cc; - cc.p.push_back (&o); - - set_null n; - n.p = &o; - - set_null_cont nc; - nc.p.push_back (&o); - - { - transaction t (db->begin ()); - db->persist (o); - db->persist (c); - db->persist (cc); - db->persist (n); - db->persist (nc); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - - { - transaction t (db->begin ()); - assert (db->find (c.id) == 0); - - unique_ptr pcc (db->load (cc.id)); - assert (pcc->p.empty ()); - - unique_ptr pn (db->load (n.id)); - assert (pn->p == 0); - - unique_ptr pnc (db->load (nc.id)); - assert (pnc->p.size () == 1 && pnc->p[0] == 0); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/relationship/on-delete/test.hxx b/common/relationship/on-delete/test.hxx deleted file mode 100644 index 841acd9..0000000 --- a/common/relationship/on-delete/test.hxx +++ /dev/null @@ -1,58 +0,0 @@ -// file : common/relationship/on-delete/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object -struct object -{ - #pragma db id auto - unsigned long id; -}; - -#pragma db object -struct cascade -{ - #pragma db id auto - unsigned long id; - - #pragma db on_delete(cascade) - object* p; -}; - -#pragma db object -struct cascade_cont -{ - #pragma db id auto - unsigned long id; - - #pragma db on_delete(cascade) - std::vector p; -}; - -#pragma db object -struct set_null -{ - #pragma db id auto - unsigned long id; - - #pragma db on_delete(set_null) - object* p; -}; - -#pragma db object -struct set_null_cont -{ - #pragma db id auto - unsigned long id; - - #pragma db on_delete(set_null) - std::vector p; -}; - -#endif // TEST_HXX diff --git a/common/relationship/on-delete/testscript b/common/relationship/on-delete/testscript deleted file mode 100644 index 8288ebc..0000000 --- a/common/relationship/on-delete/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/relationship/on-delete/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/relationship/query/buildfile b/common/relationship/query/buildfile deleted file mode 100644 index b70edc4..0000000 --- a/common/relationship/query/buildfile +++ /dev/null @@ -1,42 +0,0 @@ -# file : common/relationship/query/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_rel_query_ \ - --generate-schema \ - --generate-query \ - --generate-session - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/relationship/query/driver.cxx b/common/relationship/query/driver.cxx deleted file mode 100644 index 20d5370..0000000 --- a/common/relationship/query/driver.cxx +++ /dev/null @@ -1,168 +0,0 @@ -// file : common/relationship-query/query/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test relationship queries. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // - // - { - shared_ptr ca (new country ("CA", "Canada")); - shared_ptr za (new country ("ZA", "South Africa")); - shared_ptr us (new country ("US", "United States")); - shared_ptr se (new country ("SE", "Sweden")); - - shared_ptr st (new employer ("Simple Tech, Inc", ca)); - shared_ptr ct (new employer ("Complex Tech, Inc", us)); - - // person - // - shared_ptr p1 ( - new person (1, "John", "Doe", 30, ca, true, za)); - - shared_ptr p2 ( - new person (2, "Jane", "Doe", 29, za, false, us)); - p2->husband = p1; - - shared_ptr p3 ( - new person (3, "Joe", "Dirt", 31, us, true, us)); - - shared_ptr p4 ( - new person (4, "Johan", "Johansen", 32, se, false, ca)); - - // employee - // - shared_ptr e1 ( - new employee (1, "John", "Doe", 30, ca, true, za, st)); - - shared_ptr e2 ( - new employee (2, "Jane", "Doe", 29, za, false, us, ct)); - e2->husband = p1; - - shared_ptr e3 ( - new employee (3, "Joe", "Dirt", 31, us, true, us, st)); - - shared_ptr e4 ( - new employee (4, "Johan", "Johansen", 32, se, false, ca, ct)); - - transaction t (db->begin ()); - db->persist (ca); - db->persist (za); - db->persist (us); - db->persist (se); - - db->persist (st); - db->persist (ct); - - db->persist (p1); - db->persist (p2); - db->persist (p3); - db->persist (p4); - - db->persist (e1); - db->persist (e2); - db->persist (e3); - db->persist (e4); - t.commit (); - } - - typedef odb::query p_query; - typedef odb::result p_result; - - typedef odb::query e_query; - typedef odb::result e_result; - - // Make sure we have an independent JOIN for each relationship. - // - { - session s; - transaction t (db->begin ()); - - p_result pr (db->query ( - p_query::residence.location->code == "ZA")); - assert (size (pr) == 1); - - e_result er (db->query ( - e_query::residence.location->code == "ZA")); - assert (size (er) == 1); - - t.commit (); - } - - // Test Self-JOIN. - // - { - session s; - transaction t (db->begin ()); - - p_result pr (db->query (p_query::husband->last_name == "Doe")); - assert (size (pr) == 1); - - e_result er (db->query (e_query::husband->last_name == "Doe")); - assert (size (er) == 1); - - t.commit (); - } - - // Test query conditions from both base and derived. - // - { - session s; - transaction t (db->begin ()); - - e_result r ( - db->query ( - e_query::employed_by->name == "Simple Tech, Inc" && - e_query::nationality->code == "US")); - - assert (size (r) == 1); - - t.commit (); - } - - // Test second-level pointers. - // - { - session s; - transaction t (db->begin ()); - - p_result r ( - db->query ( - p_query::husband->residence.location == "CA")); - - assert (size (r) == 1); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/relationship/query/test.hxx b/common/relationship/query/test.hxx deleted file mode 100644 index c6e2d6d..0000000 --- a/common/relationship/query/test.hxx +++ /dev/null @@ -1,140 +0,0 @@ -// file : common/relationship-query/query/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -using std::shared_ptr; - -struct country; - -#pragma db value -struct residence_info -{ - residence_info (bool p, shared_ptr l) - : permanent (p), location (l) - { - } - - residence_info () - { - } - - bool permanent; - - #pragma db not_null - shared_ptr location; -}; - -#pragma db object pointer(shared_ptr) -struct person -{ - person (unsigned long i, - const std::string& fn, - const std::string& ln, - unsigned short a, - shared_ptr r, - bool p, - shared_ptr n) - : id (i), - first_name (fn), - last_name (ln), - age (a), - residence (p, r), - nationality (n) - { - } - - person () - { - } - - #pragma db id - unsigned long id; - - #pragma db column ("first") - std::string first_name; - - #pragma db column ("last") - std::string last_name; - - unsigned short age; - - residence_info residence; - - #pragma db not_null - shared_ptr nationality; - - shared_ptr husband; // Self-join. -}; - -struct employer; - -#pragma db object pointer(shared_ptr) -struct employee: person -{ - employee (unsigned long i, - const std::string& fn, - const std::string& ln, - unsigned short a, - shared_ptr r, - bool p, - shared_ptr n, - shared_ptr e) - : person (i, fn, ln, a, r, p, n), - employed_by (e) - { - } - - employee () - { - } - - shared_ptr employed_by; -}; - -#pragma db object pointer(shared_ptr) -struct employer -{ - employer (const std::string& n, shared_ptr nat) - : name (n), nationality (nat) - { - } - - employer () - { - } - - #pragma db id - std::string name; - - // The same member name and type as in person (test JOIN alias). - // - #pragma db not_null - shared_ptr nationality; -}; - -#pragma db object pointer(shared_ptr) -struct country -{ - country (const std::string& c, const std::string& n) - : code (c), name (n) - { - } - - country () - { - } - - #pragma db id - std::string code; // ISO 2-letter country code. - - std::string name; -}; - -#endif // TEST_HXX diff --git a/common/relationship/query/testscript b/common/relationship/query/testscript deleted file mode 100644 index d5ad419..0000000 --- a/common/relationship/query/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/relationship/query/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/schema/embedded/basics/buildfile b/common/schema/embedded/basics/buildfile deleted file mode 100644 index 0cfe85e..0000000 --- a/common/schema/embedded/basics/buildfile +++ /dev/null @@ -1,42 +0,0 @@ -# file : common/schema/embedded/basics/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix schema_embd_bscs_ \ - --generate-schema \ - --schema-format embedded \ - --schema-name test - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../../alias{database-client}: include = adhoc diff --git a/common/schema/embedded/basics/driver.cxx b/common/schema/embedded/basics/driver.cxx deleted file mode 100644 index 7ba2bce..0000000 --- a/common/schema/embedded/basics/driver.cxx +++ /dev/null @@ -1,59 +0,0 @@ -// file : common/schema/embedded/basics/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test basic embedded schema functionality. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv, false)); - - // Create the database schema. - // - { - connection_ptr c (db->connection ()); - - // Temporarily disable foreign key constraints for SQLite. - // - if (db->id () == odb::id_sqlite) - c->execute ("PRAGMA foreign_keys=OFF"); - - assert (schema_catalog::exists (*db, "test")); - assert (!schema_catalog::exists (*db, "test1")); - assert (!schema_catalog::exists (*db, "")); - - transaction t (c->begin ()); - schema_catalog::create_schema (*db, "test"); - t.commit (); - - if (db->id () == odb::id_sqlite) - c->execute ("PRAGMA foreign_keys=ON"); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/schema/embedded/basics/test.hxx b/common/schema/embedded/basics/test.hxx deleted file mode 100644 index 43331f9..0000000 --- a/common/schema/embedded/basics/test.hxx +++ /dev/null @@ -1,23 +0,0 @@ -// file : common/schema/embedded/basics/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -#pragma db object -struct object -{ - #pragma db auto id - unsigned long id; - - std::string str; - - std::vector nums; -}; - -#endif // TEST_HXX diff --git a/common/schema/embedded/basics/testscript b/common/schema/embedded/basics/testscript deleted file mode 100644 index 24448c0..0000000 --- a/common/schema/embedded/basics/testscript +++ /dev/null @@ -1,31 +0,0 @@ -# file : common/schema/embedded/basics/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../../mysql.testscript - - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../../pgsql.testscript - - $* -} diff --git a/common/schema/embedded/order/.gitignore b/common/schema/embedded/order/.gitignore deleted file mode 100644 index 5d39d39..0000000 --- a/common/schema/embedded/order/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# ODB-generated files. -# -test1-odb.?xx -test1-odb-*.?xx -test2-odb.?xx -test2-odb-*.?xx diff --git a/common/schema/embedded/order/buildfile b/common/schema/embedded/order/buildfile deleted file mode 100644 index 57ad7dd..0000000 --- a/common/schema/embedded/order/buildfile +++ /dev/null @@ -1,48 +0,0 @@ -# file : common/schema/embedded/order/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -hs = test1 test2 - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -for h: $hs -{ - exe{driver}: {hxx ixx cxx}{$h-odb} - - <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} - - for db: $databases - { - exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi - <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} - } -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix schema_embd_ordr_ \ - --generate-schema \ - --schema-format embedded - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../../alias{database-client}: include = adhoc diff --git a/common/schema/embedded/order/driver.cxx b/common/schema/embedded/order/driver.cxx deleted file mode 100644 index fde5e96..0000000 --- a/common/schema/embedded/order/driver.cxx +++ /dev/null @@ -1,65 +0,0 @@ -// file : common/schema/embedded/order/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test statement execution order in embedded schemas. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test1.hxx" -#include "test2.hxx" - -#include "test1-odb.hxx" -#include "test2-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv, false)); - odb::database_id db_id (db->id ()); - - // Create the database schema. - // - { - connection_ptr c (db->connection ()); - - // Temporarily disable foreign key constraints for MySQL and SQLite. - // For MySQL we can actually create the tables in any order. It is - // dropping them that's the problem (there is no IF EXISTS). - // - if (db_id == odb::id_mysql) - c->execute ("SET FOREIGN_KEY_CHECKS=0"); - else if (db_id == odb::id_sqlite) - c->execute ("PRAGMA foreign_keys=OFF"); - - transaction t (c->begin ()); - schema_catalog::create_schema (*db); - t.commit (); - - if (db_id == odb::id_mysql) - c->execute ("SET FOREIGN_KEY_CHECKS=1"); - else if (db_id == odb::id_sqlite) - c->execute ("PRAGMA foreign_keys=ON"); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/schema/embedded/order/test1.hxx b/common/schema/embedded/order/test1.hxx deleted file mode 100644 index b35074b..0000000 --- a/common/schema/embedded/order/test1.hxx +++ /dev/null @@ -1,23 +0,0 @@ -// file : common/schema/embedded/order/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#include - -#include - -#pragma db object polymorphic -struct base -{ - virtual - ~base () {} - - #pragma db auto id - unsigned long id; - - std::string str; -}; - -#endif // TEST1_HXX diff --git a/common/schema/embedded/order/test2.hxx b/common/schema/embedded/order/test2.hxx deleted file mode 100644 index b4e6d20..0000000 --- a/common/schema/embedded/order/test2.hxx +++ /dev/null @@ -1,17 +0,0 @@ -// file : common/schema/embedded/order/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#include - -#include "test1.hxx" - -#pragma db object -struct derived: base -{ - int num; -}; - -#endif // TEST2_HXX diff --git a/common/schema/embedded/order/testscript b/common/schema/embedded/order/testscript deleted file mode 100644 index 6dfe58c..0000000 --- a/common/schema/embedded/order/testscript +++ /dev/null @@ -1,31 +0,0 @@ -# file : common/schema/embedded/order/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../../mysql.testscript - - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../../pgsql.testscript - - $* -} diff --git a/common/schema/namespace/buildfile b/common/schema/namespace/buildfile deleted file mode 100644 index fa496d7..0000000 --- a/common/schema/namespace/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/schema/namespace/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix schema_ns_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/schema/namespace/driver.cxx b/common/schema/namespace/driver.cxx deleted file mode 100644 index 25515f2..0000000 --- a/common/schema/namespace/driver.cxx +++ /dev/null @@ -1,113 +0,0 @@ -// file : common/schema/namespace/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test database schemas (aka database namespaces). -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test database schema (aka database namespace). - // - using ns::object2; - - object2 o2; - o2.id = "aaa"; - o2.nums.push_back (1); - o2.nums.push_back (2); - o2.nums.push_back (3); - o2.obj1 = new object1; - o2.obj1->str = "aaa"; - - { - transaction t (db->begin ()); - db->persist (o2.obj1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p2 (db->load ("aaa")); - t.commit (); - - assert (o2 == *p2); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - { - result r (db->query (query::id == "aaa")); - assert (size (r) == 1); - } - - { - result r (db->query (query::obj1->str == "aaa")); - assert (size (r) == 1); - } - - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query (query::object2::id == "aaa")); - - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->id2 == "aaa" && i->str == "aaa"); - assert (++i == r.end ()); - - t.commit (); - } - - { - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query ()); - - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->str == "aaa"); - assert (++i == r.end ()); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/schema/namespace/test.hxx b/common/schema/namespace/test.hxx deleted file mode 100644 index 0b1844a..0000000 --- a/common/schema/namespace/test.hxx +++ /dev/null @@ -1,158 +0,0 @@ -// file : common/schema/namespace/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -// Table names. -// -#pragma db object table("TABLE_EXPLICIT") -struct table_explicit -{ - #pragma db id - unsigned long id_; -}; - -#pragma db object -struct table_implicit -{ - #pragma db id - unsigned long id_; -}; - -// Column names. -// -#pragma db object -struct column -{ - #pragma db id - int m1; - - #pragma db column("foo") - int m2; - - int m_m3; - int _m4; - int m5_; - int m_; - int m__; -}; - -// Column types. -// -#pragma db object -struct type -{ - #pragma db id - std::string id; - - // Test default C++ to DB type mapping. - // - bool b; - char c; - signed char sc; - unsigned char uc; - short s; - unsigned short us; - int i; - unsigned int ui; - long l; - unsigned long ul; - long long ll; - unsigned long long ull; - float f; - double d; - std::string str; - - #pragma db type("INTEGER") - bool m1; - - #pragma db transient - char* m2; -}; - -// Test database schema (aka database namespace). -// -#ifdef ODB_COMPILER -#if defined (ODB_DATABASE_MYSQL) -//# define DB_SCHEMA "odb_test" -# define DB_SCHEMA "" -#elif defined (ODB_DATABASE_SQLITE) -# define DB_SCHEMA "main" -#elif defined (ODB_DATABASE_PGSQL) -# define DB_SCHEMA "public" -#elif defined (ODB_DATABASE_ORACLE) -//# define DB_SCHEMA "ODB_TEST" -# define DB_SCHEMA "" -#elif defined(ODB_DATABASE_MSSQL) -# define DB_SCHEMA "dbo" -#elif defined(ODB_DATABASE_COMMON) -# define DB_SCHEMA "dummy" -#else -# error unknown database -#endif -#endif - -namespace ns {typedef int my_int;} // Original. - -#pragma db object table(DB_SCHEMA."object_1") -struct object1 -{ - #pragma db id auto - unsigned long id; - - #pragma db column("str") - std::string str; -}; - -inline bool -operator== (const object1& x, const object1& y) -{ - return x.id == y.id && x.str == y.str; -} - -#pragma db namespace schema(DB_SCHEMA) -namespace ns // Extension. -{ - #pragma db object - struct object2 - { - object2 (): obj1 (0) {} - ~object2 () {delete obj1;} - - #pragma db id - std::string id; - - std::vector nums; - object1* obj1; - }; - - inline bool - operator== (const object2& x, const object2& y) - { - return x.id == y.id && x.nums == y.nums && *x.obj1 == *y.obj1; - } -} - -#pragma db view object(object1) object(ns::object2) -struct object_view -{ - #pragma db column(ns::object2::id) - std::string id2; - - std::string str; -}; - -#pragma db view table(DB_SCHEMA."schema_ns_object_1") -struct table_view -{ - #pragma db column(DB_SCHEMA."schema_ns_object_1"."str") - std::string str; -}; - -#endif // TEST_HXX diff --git a/common/schema/namespace/testscript b/common/schema/namespace/testscript deleted file mode 100644 index 0fabe6e..0000000 --- a/common/schema/namespace/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/schema/namespace/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/section/basics/buildfile b/common/section/basics/buildfile deleted file mode 100644 index 5ccdd6b..0000000 --- a/common/section/basics/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/section/basics/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_section_b_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/section/basics/driver.cxx b/common/section/basics/driver.cxx deleted file mode 100644 index 53783a3..0000000 --- a/common/section/basics/driver.cxx +++ /dev/null @@ -1,1735 +0,0 @@ -// file : common/section/basics/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test object section basics. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -struct failed {}; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test lazy-loaded, always updating section. - // - { - using namespace test1; - - object o (123, "abc"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s.loaded ()); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); - - db->load (*p, p->s); - - assert (p->s.loaded ()); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - - t.commit (); - } - - // Update. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - - // We can also update just the section. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o, o.s); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n != o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - - // Test updating unloaded section. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - o.s.unload (); - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); - t.commit (); - } - - // Test reloading of loaded/unloaded sections. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - o.s.unload (); - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - db->reload (o); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); - db->load (o, o.s); - t.commit (); - } - - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - db->reload (o); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - - typedef odb::query query; - typedef odb::result result; - - // Make sure we can access section members in queries. - // - { - transaction t (db->begin ()); - - result r (db->query (query::ss == o.ss)); - result::iterator i (r.begin ()); - - assert (i != r.end () && !i->s.loaded ()); - - db->load (*i, i->s); - assert (i->n == o.n && - i->sn == o.sn && i->ss == o.ss && i->sv == o.sv); - - assert (++i == r.end ()); - - t.commit (); - } - - // Make sure we can load/update sections without messing up the - // loaded object's image. - // - { - transaction t (db->begin ()); - - result r (db->query (query::ss == o.ss)); - result::iterator i (r.begin ()); - - assert (i != r.end ()); - - object o1; - i.load (o1); - db->load (o1, o1.s); - assert (o1.n == o.n && - o1.sn == o.sn && o1.ss == o.ss && o1.sv == o.sv); - - o.sn++; - o.ss += 'd'; - o.sv[0]++; - db->update (o, o.s); - - object o2; - i.load (o2); - db->load (o2, o2.s); - assert (o2.n == o1.n && - o2.sn == o.sn && o2.ss == o.ss && o2.sv == o.sv); - - assert (++i == r.end ()); - - t.commit (); - } - } - - // Test lazy-loaded, change-updated section. - // - { - using namespace test2; - - object o (123, "abc"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s.loaded ()); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); - - db->load (*p, p->s); - - assert (p->s.loaded ()); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - - t.commit (); - } - - // Update but don't mark as changed. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); - t.commit (); - } - - // Mark as changed. - // - o.s.change (); - - { - transaction t (db->begin ()); - db->update (o); - assert (!o.s.changed ()); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - - // We can also update just the section manually. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - o.s.change (); - - { - transaction t (db->begin ()); - db->update (o, o.s); - assert (!o.s.changed ()); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n != o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - } - - // Test lazy-loaded, manually-updated section. - // - { - using namespace test3; - - object o (123, "abc"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s.loaded ()); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); - - db->load (*p, p->s); - - assert (p->s.loaded ()); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - - t.commit (); - } - - // Update the object only. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); - t.commit (); - } - - // Update both the object and section. - // - o.n++; - - { - transaction t (db->begin ()); - db->update (o); - db->update (o, o.s); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - - // We can also update just the section. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o, o.s); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n != o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - - // Test detection of unloaded section update. - // - try - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->update (*p, p->s); - assert (false); - } - catch (const section_not_loaded&) - { - } - } - - // Test eager-loaded, change-updated section. - // - { - using namespace test4; - - object o (123, "abc"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (p->s.loaded ()); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - - t.commit (); - } - - // Update but don't mark as changed. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); - t.commit (); - } - - // Mark as changed. - // - o.s.change (); - - { - transaction t (db->begin ()); - db->update (o); - assert (!o.s.changed ()); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - } - - // Test eager-loaded, manually-updated section. - // - { - using namespace test5; - - object o (123, "abc"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (p->s.loaded ()); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - - t.commit (); - } - - // Update the object only. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); - t.commit (); - } - - // Update both the object and section. - // - o.n++; - - { - transaction t (db->begin ()); - db->update (o); - db->update (o, o.s); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - - // We can also update just the section. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o, o.s); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - assert (p->n != o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - } - - // Test value-only and container-only section. Also multiple sections - // in an object. - // - { - using namespace test6; - - object o (123, "abc"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s1.loaded ()); - assert (o.s2.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s1.loaded ()); - assert (!p->s2.loaded ()); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); - - db->load (*p, p->s1); - assert (p->s1.loaded ()); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv != o.sv); - - db->load (*p, p->s2); - assert (p->s2.loaded ()); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - - t.commit (); - } - - // Update. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s1); - db->load (*p, p->s2); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - - // We can also update just the section. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o, o.s1); - db->update (o, o.s2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s1); - db->load (*p, p->s2); - assert (p->n != o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - t.commit (); - } - } - - // Test value-only and container-only section. Also multiple sections - // in an object. - // - { - using namespace test7; - - object o (123, "abc", true); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s1.loaded ()); - assert (o.s2.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s1.loaded ()); - assert (!p->s2.loaded ()); - assert (p->sn1 != o.sn1 && p->ss1 != o.ss1 && - p->sn2 != o.sn2 && p->ss2 != o.ss2 && p->sb2 != o.sb2); - - db->load (*p, p->s1); - db->load (*p, p->s2); - assert (p->s1.loaded ()); - assert (p->s2.loaded ()); - assert (p->sn1 == o.sn1 && p->ss1 == o.ss1 && - p->sn2 == o.sn2 && p->ss2 == o.ss2 && p->sb2 == o.sb2); - - - t.commit (); - } - - // Update. - // - o.sn1++; - o.sn2++; - o.ss1 += 'd'; - o.ss2 += 'd'; - o.sb2 = !o.sb2; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s1); - db->load (*p, p->s2); - assert (p->sn1 == o.sn1 && p->ss1 == o.ss1 && - p->sn2 == o.sn2 && p->ss2 == o.ss2 && p->sb2 == o.sb2); - t.commit (); - } - - // Manual update of just the section. - // - o.sn1++; - o.sn2++; - o.ss1 += 'd'; - o.ss2 += 'd'; - o.sb2 = !o.sb2; - - { - transaction t (db->begin ()); - db->update (o, o.s2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s1); - db->load (*p, p->s2); - assert (p->sn1 != o.sn1 && p->ss1 != o.ss1 && - p->sn2 == o.sn2 && p->ss2 == o.ss2 && p->sb2 == o.sb2); - t.commit (); - } - } - - // Test readonly and inverse section members. - // - { - using namespace test8; - - object1 o1 (new object (123, "abc")); - object& o (*o1.p); - o.sp = &o1; - - { - transaction t (db->begin ()); - db->persist (o); - db->persist (o1); - t.commit (); - - assert (o.s.loaded ()); - } - - { - session s; - - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - object* p (p1->p); - - assert (!p->s.loaded ()); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sp == 0); - - db->load (*p, p->s); - - assert (p->s.loaded ()); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sp->id == o.sp->id); - - t.commit (); - } - - // Update. - // - o.n++; - o.sn++; - o.ss += 'd'; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - session s; - - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - object* p (p1->p); - - db->load (*p, p->s); - assert (p->n == o.n && - p->sn != o.sn && p->ss == o.ss && p->sp->id == o.sp->id); - - t.commit (); - } - } - - // Test object without any columns to load or update. - // - { - using namespace test9; - - object o (123, "abc"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s.loaded ()); - assert (o.id == o.id && - p->sn != o.sn && p->ss != o.ss); - - db->load (*p, p->s); - - assert (p->s.loaded ()); - assert (o.id == o.id && - p->sn == o.sn && p->ss == o.ss); - - t.commit (); - } - - // Update object. - // - o.sn++; - o.ss += 'd'; - - { - transaction t (db->begin ()); - db->update (o); // No-op. - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (o.id == o.id && - p->sn != o.sn && p->ss != o.ss); - t.commit (); - } - - // Update section. - // - { - transaction t (db->begin ()); - db->update (o, o.s); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (o.id == o.id && - p->sn == o.sn && p->ss == o.ss); - t.commit (); - } - } - - // Test section without any columns or containers to update. - // - { - using namespace test10; - - object o (123); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s.loaded ()); - assert (p->n == o.n && p->sn != o.sn); - - db->load (*p, p->s); - - assert (p->s.loaded ()); - assert (p->n == o.n && p->sn == o.sn); - - t.commit (); - } - - // Update. - // - o.n++; - o.sn++; - - { - transaction t (db->begin ()); - db->update (o); - //db->update (o, o.s); // Error. - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n == o.n && p->sn != o.sn); - t.commit (); - } - } - - // Test section with composite member. - // - { - using namespace test11; - - object o (123, "abc"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s.loaded ()); - assert (p->n == o.n && - p->sn != o.sn && p->sc.s != o.sc.s && p->sc.v != o.sc.v); - - db->load (*p, p->s); - - assert (p->s.loaded ()); - assert (p->n == o.n && - p->sn == o.sn && p->sc.s == o.sc.s && p->sc.v == o.sc.v); - - t.commit (); - } - - // Update. - // - o.n++; - o.sn++; - o.sc.s += 'd'; - o.sc.v[0]++; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n == o.n && - p->sn == o.sn && p->sc.s == o.sc.s && p->sc.v == o.sc.v); - t.commit (); - } - } - - // Test change state restoration on transaction rollback. - // - { - using namespace test12; - - object o (123, "abc"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - // Update. - // - o.n++; - o.sn++; - o.ss += 'd'; - o.s.change (); - - try - { - transaction t (db->begin ()); - db->update (o); - assert (!o.s.changed ()); - throw failed (); - } - catch (const failed&) - { - assert (o.s.changed ()); - } - - // Retry. Also test the object destruction before transaction - // termination case. - // - { - transaction t (db->begin ()); - { - object c (o); - db->update (c); - assert (!c.s.changed ()); - } - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n == o.n && p->sn == o.sn && p->ss == o.ss); - t.commit (); - } - } - - // Test section accessor/modifier. - // - { - using namespace test13; - - object o (123, "abc"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s ().loaded ()); - } - - // Load. - // - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s ().loaded ()); - assert (p->n == o.n && p->sn != o.sn && p->ss != o.ss); - - db->load (*p, p->rw_s ()); - - assert (p->s ().loaded ()); - assert (p->n == o.n && p->sn == o.sn && p->ss == o.ss); - - t.commit (); - } - - // Update. - // - o.n++; - o.sn++; - o.ss += 'd'; - - { - transaction t (db->begin ()); - db->update (o); - db->update (o, o.s ()); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->rw_s ()); - assert (p->n == o.n && p->sn == o.sn && p->ss == o.ss); - t.commit (); - } - - // Test detection of section copy. - // - try - { - transaction t (db->begin ()); - section c (o.s ()); - db->update (o, c); - assert (false); - } - catch (const section_not_in_object&) - { - } - } - - // Test LOB in section streaming, column re-ordering. - // - { - using namespace test14; - - object o (1, 123, "\x01\x02\x03\x04\x05"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s.loaded ()); - assert (p->n == o.n && p->sn != o.sn && p->sb != o.sb); - - db->load (*p, p->s); - - assert (p->s.loaded ()); - assert (p->n == o.n && p->sn == o.sn && p->sb == o.sb); - - t.commit (); - } - - // Update. - // - o.n++; - o.sn++; - o.sb.push_back ('\x06'); - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n == o.n && p->sn == o.sn && p->sb == o.sb); - t.commit (); - } - - // We can also update just the section. - // - o.n++; - o.sn++; - o.sb.push_back ('\x07'); - - { - transaction t (db->begin ()); - db->update (o, o.s); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->n != o.n && p->sn == o.sn && p->sb == o.sb); - t.commit (); - } - } - - // Test sections and optimistic concurrency. - // - { - using namespace test15; - - object o (123, "abc"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s.loaded ()); - assert (p->n == o.n && - p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); - - db->load (*p, p->s); - - assert (p->s.loaded ()); - assert (p->n == o.n && - p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); - - t.commit (); - } - - // Update object. - // - object o1 (o); - o1.n++; - o1.sn++; - o1.ss += 'd'; - o1.sv[0]++; - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - db->update (o1); - assert (o.v != o1.v); - - try - { - db->load (*p, p->s); - assert (false); - } - catch (const object_changed&) - { - db->reload (*p); - assert (!p->s.loaded ()); - db->load (*p, p->s); - - assert (p->n == o1.n && - p->sn == o1.sn && p->ss == o1.ss && p->sv == o1.sv); - } - - db->reload (o); - assert (o.v == o1.v); - assert (o.n == o1.n && - o.sn == o1.sn && o.ss == o1.ss && o.sv == o1.sv); - t.commit (); - } - - // Update section. - // - o1.sn++; - o1.ss += 'd'; - o1.sv[0]++; - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - db->update (o1, o1.s); - assert (o.v != o1.v); - - // Double-check object version was updated. - // - { - unique_ptr p1 (db->load (o.id)); - assert (o1.v == p1->v); - } - - try - { - db->load (*p, p->s); - assert (false); - } - catch (const object_changed&) - { - db->reload (*p); - assert (!p->s.loaded ()); - db->load (*p, p->s); - - assert (p->n == o1.n && - p->sn == o1.sn && p->ss == o1.ss && p->sv == o1.sv); - } - - db->reload (o); - assert (o.v == o1.v); - assert (o.n == o1.n && - o.sn == o1.sn && o.ss == o1.ss && o.sv == o1.sv); - t.commit (); - } - - // Update changed section. - // - o1.sn++; - o1.ss += 'd'; - o1.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o1, o1.s); - - try - { - db->update (o, o.s); - assert (false); - } - catch (const object_changed&) - { - db->reload (o); - db->update (o, o.s); - } - - t.commit (); - } - } - - // Test container-only sections and optimistic concurrency. - // - { - using namespace test16; - - object o (123); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s.loaded ()); - assert (p->sv != o.sv); - - db->load (*p, p->s); - - assert (p->s.loaded ()); - assert (p->sv == o.sv); - - t.commit (); - } - - // Update object. - // - object o1 (o); - o1.sv[0]++; - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - db->update (o1); - assert (o.v != o1.v); - - try - { - db->load (*p, p->s); - assert (false); - } - catch (const object_changed&) - { - db->reload (*p); - assert (!p->s.loaded ()); - db->load (*p, p->s); - - assert (p->sv == o1.sv); - } - - db->reload (o); - assert (o.v == o1.v); - assert (o.sv == o1.sv); - t.commit (); - } - - // Update section. - // - o1.sv[0]++; - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - db->update (o1, o1.s); - assert (o.v != o1.v); - - // Double-check object version was updated. - // - { - unique_ptr p1 (db->load (o.id)); - assert (o1.v == p1->v); - } - - try - { - db->load (*p, p->s); - assert (false); - } - catch (const object_changed&) - { - db->reload (*p); - assert (!p->s.loaded ()); - db->load (*p, p->s); - - assert (p->sv == o1.sv); - } - - db->reload (o); - assert (o.v == o1.v); - assert (o.sv == o1.sv); - t.commit (); - } - - // Update changed section. - // - o1.sv[0]++; - - { - transaction t (db->begin ()); - db->update (o1, o1.s); - - try - { - db->update (o, o.s); - assert (false); - } - catch (const object_changed&) - { - db->reload (o); - db->update (o, o.s); - } - - t.commit (); - } - } - - // Test reuse-inheritance, sections, and optimistic concurrency. - // - { - using namespace test17; - - object o (123); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s1.loaded ()); - assert (o.s2.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s1.loaded ()); - assert (!p->s2.loaded ()); - assert (p->s1n != o.s1n && p->s2v != o.s2v); - - db->load (*p, p->s1); - db->load (*p, p->s2); - - assert (p->s1.loaded ()); - assert (p->s2.loaded ()); - assert (p->s1n == o.s1n && p->s2v == o.s2v); - - t.commit (); - } - - object o1 (o); - - // Update object. - // - for (unsigned short s (1); s < 3; ++s) - { - o1.s1n++; - o1.s2v[0]++; - - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - db->update (o1); - assert (o.v != o1.v); - - try - { - switch (s) - { - case 1: db->load (*p, p->s1); break; - case 2: db->load (*p, p->s2); break; - default: break; - } - assert (false); - } - catch (const object_changed&) - { - db->reload (*p); - - assert (!p->s1.loaded ()); - assert (!p->s2.loaded ()); - - db->load (*p, p->s1); - db->load (*p, p->s2); - - assert (p->s1n == o1.s1n && p->s2v == o1.s2v); - } - - db->reload (o); - assert (o.v == o1.v); - assert (o.s1n == o1.s1n && o.s2v == o1.s2v); - t.commit (); - } - - // Update section. - // - for (unsigned short s (1); s < 3; ++s) - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - switch (s) - { - case 1: - o1.s1n++; - db->update (o1, o1.s1); - assert (o.v != o1.v); - break; - case 2: - o1.s2v[0]++; - db->update (o1, o1.s2); - assert (o.v != o1.v); - break; - default: break; - } - - try - { - switch (s) - { - case 1: db->load (*p, p->s1); break; - case 2: db->load (*p, p->s2); break; - default: break; - } - assert (false); - } - catch (const object_changed&) - { - db->reload (*p); - - assert (!p->s1.loaded ()); - assert (!p->s2.loaded ()); - - db->load (*p, p->s1); - db->load (*p, p->s2); - - assert (p->s1n == o1.s1n && p->s2v == o1.s2v); - } - - db->reload (o); - assert (o.v == o1.v); - assert (o.s1n == o1.s1n && o.s2v == o1.s2v); - t.commit (); - } - - // Update changed section. - // - for (unsigned short s (1); s < 3; ++s) - { - transaction t (db->begin ()); - - switch (s) - { - case 1: - o1.s1n++; - db->update (o1, o1.s1); - break; - case 2: - o1.s2v[0]++; - db->update (o1, o1.s2); - break; - default: break; - } - - try - { - switch (s) - { - case 1: db->update (o, o.s1); break; - case 2: db->update (o, o.s2); break; - default: break; - } - assert (false); - } - catch (const object_changed&) - { - db->reload (o); - - switch (s) - { - case 1: db->update (o, o.s1); break; - case 2: db->update (o, o.s2); break; - default: break; - } - } - - db->reload (o1); - - t.commit (); - } - } - - // Test change-updated section and change-tracking container. - // - { - using namespace test18; - - object o (123); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - - assert (o.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - assert (!p->s.loaded ()); - assert (p->sn != o.sn && p->sv != o.sv); - - db->load (*p, p->s); - - assert (p->s.loaded ()); - assert (p->sn == o.sn && p->sv == o.sv); - - t.commit (); - } - - // Update but don't mark as changed. - // - o.sn++; - o.sv.modify (0)++; - - { - transaction t (db->begin ()); - db->update (o); // Automatically marked as changed. - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->sn == o.sn && p->sv == o.sv); - t.commit (); - } - - // Test updating just the section manually. - // - o.sn++; - o.sv.modify (0)++; - - { - transaction t (db->begin ()); - db->update (o, o.s); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - db->load (*p, p->s); - assert (p->sn == o.sn && p->sv == o.sv); - t.commit (); - } - } - - // Regression: BLOB in a value type used as a map value that is in a - // section. - // - { - using namespace test19; - - object o; - o.m[1].b.assign (560, 'x'); // Size greater than the default image. - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - // Hold "old" connection to force a new set of statements/image - // buffers. - // - connection_ptr c (db->connection ()); - - transaction t (db->begin ()); - unique_ptr p (db->load (o.id)); - - db->load (*p, p->s); - assert (p->m[1].b == o.m[1].b); - - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/section/basics/test.hxx b/common/section/basics/test.hxx deleted file mode 100644 index 702ef8b..0000000 --- a/common/section/basics/test.hxx +++ /dev/null @@ -1,628 +0,0 @@ -// file : common/section/basics/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include -#include -#include - -#ifdef ODB_COMPILER -# if defined(ODB_DATABASE_PGSQL) -# define BLOB_TYPE "BYTEA" -# elif defined(ODB_DATABASE_MSSQL) -# define BLOB_TYPE "VARBINARY(max)" -# else -# define BLOB_TYPE "BLOB" -# endif -#endif - -// Test lazy-loaded, always-updated section. -// -#pragma db namespace table("t1_") -namespace test1 -{ - #pragma db object - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx") - : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} - - #pragma db id auto - unsigned long id; - - #pragma db load(lazy) - odb::section s; - - #pragma db section(s) - int sn; - - int n; - - #pragma db section(s) - std::string ss; - - #pragma db section(s) - std::vector sv; - }; -} - -// Test lazy-loaded, change-updated section. -// -#pragma db namespace table("t2_") -namespace test2 -{ - #pragma db object - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx") - : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} - - #pragma db id auto - unsigned long id; - - #pragma db load(lazy) update(change) - odb::section s; - - #pragma db section(s) - int sn; - - int n; - - #pragma db section(s) - std::string ss; - - #pragma db section(s) - std::vector sv; - }; -} - -// Test lazy-loaded, manually-updated section. -// -#pragma db namespace table("t3_") -namespace test3 -{ - #pragma db object - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx") - : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} - - #pragma db id auto - unsigned long id; - - #pragma db load(lazy) update(manual) - odb::section s; - - #pragma db section(s) - int sn; - - int n; - - #pragma db section(s) - std::string ss; - - #pragma db section(s) - std::vector sv; - }; -} - -// Test eager-loaded, change-updated section. -// -#pragma db namespace table("t4_") -namespace test4 -{ - #pragma db object - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx") - : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} - - #pragma db id auto - unsigned long id; - - #pragma db section(s) - int sn; - - #pragma db update(change) - odb::section s; - - int n; - - #pragma db section(s) - std::string ss; - - #pragma db section(s) - std::vector sv; - }; -} - -// Test eager-loaded, manually-updated section. -// -#pragma db namespace table("t5_") -namespace test5 -{ - #pragma db object - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx") - : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} - - #pragma db id auto - unsigned long id; - - #pragma db section(s) - int sn; - - #pragma db update(manual) - odb::section s; - - int n; - - #pragma db section(s) - std::string ss; - - #pragma db section(s) - std::vector sv; - }; -} - -// Test value-only and container-only section. Also multiple sections -// in an object. -// -#pragma db namespace table("t6_") -namespace test6 -{ - #pragma db object - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx") - : n (n_), sn (n_), ss (s_) {sv.push_back (n_);} - - #pragma db id auto - unsigned long id; - - int n; - - #pragma db load(lazy) - odb::section s1; - - #pragma db load(lazy) - odb::section s2; - - #pragma db section(s1) - int sn; - - #pragma db section(s1) - std::string ss; - - #pragma db section(s2) - std::vector sv; - }; -} - -// Test sections and reuse inheritance. -// -#pragma db namespace table("t7_") -namespace test7 -{ - #pragma db object abstract - struct base - { - #pragma db id auto - unsigned long id; - - #pragma db load(lazy) - odb::section s1; // Empty section. - - #pragma db load(lazy) - odb::section s2; - - #pragma db section(s2) - int sn2; - }; - - #pragma db object abstract - struct interm: base - { - // Section s1 is still empty. - - #pragma db section(s2) - std::string ss2; - }; - - #pragma db object - struct derived: interm - { - #pragma db section(s1) - int sn1; - }; - - #pragma db object - struct object: derived - { - object (int n = 999, const std::string& s = "xxx", bool b = false) - { - sn1 = sn2 = n; - ss1 = ss2 = s; - sb2 = b; - } - - #pragma db section(s1) - std::string ss1; - - #pragma db section(s2) - bool sb2; - }; -} - -// Test readonly and inverse section members. -// -#pragma db namespace table("t8_") -namespace test8 -{ - struct object1; - - #pragma db object session - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx", object1* p_ = 0) - : n (n_), sn (n_), ss (s_), sp (p_) {} - - #pragma db id auto - unsigned long id; - - int n; - - #pragma db load(lazy) - odb::section s; - - #pragma db section(s) readonly - int sn; - - #pragma db section(s) - std::string ss; - - #pragma db inverse(p) section(s) - object1* sp; - }; - - #pragma db object session - struct object1 - { - object1 (object* p_ = 0): p (p_) {} - ~object1 () {delete p;} - - #pragma db id auto - unsigned long id; - - object* p; - }; -} - -// Test object without any columns to load or update. -// -#pragma db namespace table("t9_") -namespace test9 -{ - #pragma db object - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx"): sn (n_), ss (s_) {} - - #pragma db id auto - unsigned long id; - - #pragma db load(lazy) update(manual) - odb::section s; - - #pragma db section(s) - int sn; - - #pragma db section(s) - std::string ss; - }; -} - -// Test section without any columns or containers to update. -// -#pragma db namespace table("t10_") -namespace test10 -{ - #pragma db object - struct object - { - object (int n_ = 999): n (n_), sn (n_) {} - - #pragma db id auto - unsigned long id; - - int n; - - #pragma db load(lazy) - odb::section s; - - #pragma db section(s) readonly - int sn; - }; -} - -// Test section with composite member. -// -#pragma db namespace table("t11_") -namespace test11 -{ - #pragma db value - struct comp - { - comp (int n_, const std::string& s_): s (s_) {v.push_back (n_);} - - std::string s; - std::vector v; - }; - - #pragma db object - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx") - : n (n_), sn (n_), sc (n_, s_) {} - - #pragma db id auto - unsigned long id; - - int n; - - #pragma db load(lazy) - odb::section s; - - #pragma db section(s) - int sn; - - #pragma db section(s) - comp sc; - }; -} - -// Test change state restoration on transaction rollback. -// -#pragma db namespace table("t12_") -namespace test12 -{ - #pragma db object - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx") - : sn (n_), n (n_), ss (s_) {} - - #pragma db id auto - unsigned long id; - - #pragma db load(lazy) update(change) - odb::section s; - - #pragma db section(s) - int sn; - - int n; - - #pragma db section(s) - std::string ss; - }; -} - -// Test section accessor/modifier. -// -#pragma db namespace table("t13_") -namespace test13 -{ - #pragma db object - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx") - : n (n_), sn (n_), ss (s_) {} - - #pragma db id auto - unsigned long id; - - int n; - - #pragma db section(s_) - int sn; - - #pragma db section(s_) - std::string ss; - - public: - const odb::section& - s () const {return s_;} - - odb::section& - rw_s () {return s_;} - - private: - #pragma db load(lazy) update(manual) - odb::section s_; - }; -} - -// Test LOB in section streaming, column re-ordering. -// -#pragma db namespace table("t14_") -namespace test14 -{ - #pragma db object - struct object - { - object (unsigned long id_ = 0, int n_ = 999, const std::string& s_ = "xxx") - : id (id_), sb (s_.begin (), s_.end ()), sn (n_), n (n_) {} - - #pragma db id - unsigned long id; - - #pragma db load(lazy) - odb::section s; - - #pragma db section(s) type(BLOB_TYPE) - std::vector sb; // Comes before sn. - - #pragma db section(s) - int sn; - - int n; - }; -} - -// Test sections and optimistic concurrency. -// -#pragma db namespace table("t15_") -namespace test15 -{ - #pragma db object optimistic - struct object - { - object (int n_ = 999, const std::string& s_ = "xxx") - : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} - - #pragma db id auto - unsigned long id; - - #pragma db version mssql:type("ROWVERSION") - unsigned long long v; - - #pragma db load(lazy) - odb::section s; - - #pragma db section(s) - int sn; - - int n; - - #pragma db section(s) - std::string ss; - - #pragma db section(s) - std::vector sv; - }; -} - -// Test container-only sections and optimistic concurrency. -// -#pragma db namespace table("t16_") -namespace test16 -{ - #pragma db object optimistic - struct object - { - object (int n = 999) {sv.push_back (n);} - - #pragma db id auto - unsigned long id; - - #pragma db version // mssql:type("ROWVERSION") - unsigned long long v; - - #pragma db load(lazy) - odb::section s; - - #pragma db section(s) - std::vector sv; - }; -} - -// Test reuse-inheritance, sections, and optimistic concurrency. -// -#pragma db namespace table("t17_") -namespace test17 -{ - #pragma db object optimistic sectionable abstract - struct root - { - #pragma db id auto - unsigned long id; - - #pragma db version - unsigned long long v; - }; - - #pragma db object - struct base: root - { - }; - - #pragma db object - struct object: base - { - object (int n = 999): s1n (n) {s2v.push_back (n);} - - #pragma db load(lazy) - odb::section s1; - - #pragma db section(s1) - int s1n; - - #pragma db load(lazy) - odb::section s2; - - #pragma db section(s2) - std::vector s2v; - }; -} - -// Test change-updated section and change-tracking container. -// -#pragma db namespace table("t18_") -namespace test18 -{ - #pragma db object - struct object - { - object (int n = 999): sn (n) {sv.push_back (n);} - - #pragma db id auto - unsigned long id; - - #pragma db load(lazy) update(change) - odb::section s; - - #pragma db section(s) - int sn; - - #pragma db section(s) - odb::vector sv; - }; -} - -// Regression: BLOB in a value type used as a map value that is in a section. -// -#include -#include - -#pragma db namespace table("t19_") -namespace test19 -{ - #pragma db value - struct value - { - #pragma db type(BLOB_TYPE) - std::vector b; - }; - - #pragma db object - struct object - { - #pragma db id auto - unsigned long id; - - #pragma db load(lazy) update(always) - odb::section s; - - #pragma db section(s) - std::map m; - }; -} - -#endif // TEST_HXX diff --git a/common/section/basics/testscript b/common/section/basics/testscript deleted file mode 100644 index c0c6617..0000000 --- a/common/section/basics/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/section/basics/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/section/polymorphism/buildfile b/common/section/polymorphism/buildfile deleted file mode 100644 index b9a7514..0000000 --- a/common/section/polymorphism/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/section/polymorphism/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_section_p_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/section/polymorphism/driver.cxx b/common/section/polymorphism/driver.cxx deleted file mode 100644 index c15d317..0000000 --- a/common/section/polymorphism/driver.cxx +++ /dev/null @@ -1,1807 +0,0 @@ -// file : common/section/polymorphism/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test sections in polymorphic objects. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -struct failed {}; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test basic polymorphic section functionality. - // - { - using namespace test1; - - base b (123, "abc"); - derived d (234, "bcd", true); - - { - transaction t (db->begin ()); - db->persist (b); - db->persist (d); - t.commit (); - - assert (b.rs1.loaded ()); - assert (b.rs2.loaded ()); - assert (b.rs3.loaded ()); - assert (b.rs4.loaded ()); - assert (b.bs1.loaded ()); - - assert (d.rs1.loaded ()); - assert (d.rs2.loaded ()); - assert (d.rs3.loaded ()); - assert (d.rs4.loaded ()); - assert (d.bs1.loaded ()); - assert (d.ds1.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - assert (!pb->rs1.loaded ()); - assert (!pb->rs2.loaded ()); - assert (!pb->rs3.loaded ()); - assert (!pb->rs4.loaded ()); - assert (!pb->bs1.loaded ()); - - assert (!pd->rs1.loaded ()); - assert (!pd->rs2.loaded ()); - assert (!pd->rs3.loaded ()); - assert (!pd->rs4.loaded ()); - assert (!pd->bs1.loaded ()); - assert (!pd->ds1.loaded ()); - - assert (pb->rs1n != b.rs1n && pb->rs1s != b.rs1s && - pb->rs2n != b.rs2n && pb->rs2v != b.rs2v && - pb->rs3v != b.rs3v && - pb->rs4n != b.rs4n && - pb->bs1n != b.bs1n); - - assert (pd->rs1n != d.rs1n && pd->rs1s != d.rs1s && - pd->rs1b != d.rs1b && pd->rs1v != d.rs1v && - pd->rs2n != d.rs2n && pd->rs2v != d.rs2v && - pd->rs3v != d.rs3v && pd->rs3n != d.rs3n && - pd->rs4n != d.rs4n && pd->rs4s != d.rs4s && - pd->bs1n != d.bs1n && pd->bs1s != d.bs1s && - pd->ds1n != d.ds1n); - - db->load (*pb, pb->rs1); - db->load (*pb, pb->rs2); - db->load (*pb, pb->rs3); - db->load (*pb, pb->rs4); - db->load (*pb, pb->bs1); - - root* pr (pd.get ()); - db->load (*pr, pr->rs1); // Via base. - db->load (*pd, pd->rs2); - db->load (*pr, pr->rs3); // Via base. - db->load (*pd, pd->rs4); - db->load (*pd, pd->bs1); - db->load (*pd, pd->ds1); - - try - { - db->load (*pr, pd->bs1); // Object-section association is static. - assert (false); - } - catch (const section_not_in_object&) {} - - assert (pb->rs1.loaded ()); - assert (pb->rs2.loaded ()); - assert (pb->rs3.loaded ()); - assert (pb->rs4.loaded ()); - assert (pb->bs1.loaded ()); - - assert (pd->rs1.loaded ()); - assert (pd->rs2.loaded ()); - assert (pd->rs3.loaded ()); - assert (pd->rs4.loaded ()); - assert (pd->bs1.loaded ()); - assert (pd->ds1.loaded ()); - - assert (pb->rs1n == b.rs1n && pb->rs1s == b.rs1s && - pb->rs2n == b.rs2n && pb->rs2v == b.rs2v && - pb->rs3v == b.rs3v && - pb->rs4n == b.rs4n && - pb->bs1n == b.bs1n); - - assert (pd->rs1n == d.rs1n && pd->rs1s == d.rs1s && - pd->rs1b == d.rs1b && pd->rs1v == d.rs1v && - pd->rs2n == d.rs2n && pd->rs2v == d.rs2v && - pd->rs3v == d.rs3v && pd->rs3n == d.rs3n && - pd->rs4n == d.rs4n && pd->rs4s == d.rs4s && - pd->bs1n == d.bs1n && pd->bs1s == d.bs1s && - pd->ds1n == d.ds1n); - t.commit (); - } - - // Update object. - // - b.rs1n++; - b.rs1s += 'd'; - b.rs1.change (); - b.rs2n++; - b.rs2v[0]++; - b.rs3v[0]++; - b.rs4n++; - b.bs1n++; - - d.rs1n++; - d.rs1s += 'e'; - d.rs1b = !d.rs1b; - d.rs1v[0]++; - d.rs1.change (); - d.rs2n++; - d.rs2v[0]++; - d.rs3v[0]++; - d.rs3n++; - d.rs4n++; - d.rs4s += 'e'; - d.bs1n++; - d.bs1s += 'e'; - d.ds1n++; - - { - transaction t (db->begin ()); - db->update (b); - db->update (d); - t.commit (); - - assert (!b.rs1.changed ()); - assert (!d.rs1.changed ()); - } - - { - transaction t (db->begin ()); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - db->load (*pb, pb->rs1); - db->load (*pb, pb->rs2); - db->load (*pb, pb->rs3); - db->load (*pb, pb->rs4); - db->load (*pb, pb->bs1); - - db->load (*pd, pd->rs1); - db->load (*pd, pd->rs2); - db->load (*pd, pd->rs3); - db->load (*pd, pd->rs4); - db->load (*pd, pd->bs1); - db->load (*pd, pd->ds1); - - assert (pb->rs1n == b.rs1n && pb->rs1s == b.rs1s && - pb->rs2n == b.rs2n && pb->rs2v == b.rs2v && - pb->rs3v == b.rs3v && - pb->rs4n == b.rs4n && - pb->bs1n == b.bs1n); - - assert (pd->rs1n == d.rs1n && pd->rs1s == d.rs1s && - pd->rs1b == d.rs1b && pd->rs1v == d.rs1v && - pd->rs2n == d.rs2n && pd->rs2v == d.rs2v && - pd->rs3v == d.rs3v && pd->rs3n == d.rs3n && - pd->rs4n == d.rs4n && pd->rs4s == d.rs4s && - pd->bs1n == d.bs1n && pd->bs1s == d.bs1s && - pd->ds1n == d.ds1n); - t.commit (); - } - - // Update section. - // - b.rs1n++; - b.rs1s += 'd'; - b.rs2n++; - b.rs2v[0]++; - b.rs3v[0]++; - b.rs4n++; - b.bs1n++; - - d.rs1n++; - d.rs1s += 'e'; - d.rs1b = !d.rs1b; - d.rs1v[0]++; - d.rs2n++; - d.rs2v[0]++; - d.rs3v[0]++; - d.rs3n++; - d.rs4n++; - d.rs4s += 'e'; - d.bs1n++; - d.bs1s += 'e'; - d.ds1n++; - - { - transaction t (db->begin ()); - db->update (b, b.rs1); - db->update (b, b.rs2); - db->update (b, b.rs3); - db->update (b, b.rs4); - db->update (b, b.bs1); - - db->update (d, d.rs1); - db->update (d, d.rs2); - db->update (d, d.rs3); - db->update (d, d.rs4); - db->update (d, d.bs1); - db->update (d, d.ds1); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - db->load (*pb, pb->rs1); - db->load (*pb, pb->rs2); - db->load (*pb, pb->rs3); - db->load (*pb, pb->rs4); - db->load (*pb, pb->bs1); - - db->load (*pd, pd->rs1); - db->load (*pd, pd->rs2); - db->load (*pd, pd->rs3); - db->load (*pd, pd->rs4); - db->load (*pd, pd->bs1); - db->load (*pd, pd->ds1); - - assert (pb->rs1n == b.rs1n && pb->rs1s == b.rs1s && - pb->rs2n == b.rs2n && pb->rs2v == b.rs2v && - pb->rs3v == b.rs3v && - pb->rs4n == b.rs4n && - pb->bs1n == b.bs1n); - - assert (pd->rs1n == d.rs1n && pd->rs1s == d.rs1s && - pd->rs1b == d.rs1b && pd->rs1v == d.rs1v && - pd->rs2n == d.rs2n && pd->rs2v == d.rs2v && - pd->rs3v == d.rs3v && pd->rs3n == d.rs3n && - pd->rs4n == d.rs4n && pd->rs4s == d.rs4s && - pd->bs1n == d.bs1n && pd->bs1s == d.bs1s && - pd->ds1n == d.ds1n); - t.commit (); - } - - // Reload. - // - b.rs1n++; - b.rs1s += 'd'; - b.rs1.change (); - b.rs2n++; - b.rs2v[0]++; - b.rs3v[0]++; - b.rs4n++; - b.bs1n++; - - d.rs1n++; - d.rs1s += 'e'; - d.rs1b = !d.rs1b; - d.rs1v[0]++; - d.rs1.change (); - d.rs2n++; - d.rs2v[0]++; - d.rs3v[0]++; - d.rs3n++; - d.rs4n++; - d.rs4s += 'e'; - d.bs1n++; - d.bs1s += 'e'; - d.ds1n++; - - { - transaction t (db->begin ()); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - db->load (*pb, pb->rs1); - db->load (*pb, pb->rs2); - db->load (*pb, pb->rs3); - db->load (*pb, pb->rs4); - db->load (*pb, pb->bs1); - - db->load (*pd, pd->rs1); - db->load (*pd, pd->rs2); - db->load (*pd, pd->rs3); - db->load (*pd, pd->rs4); - db->load (*pd, pd->bs1); - db->load (*pd, pd->ds1); - - db->update (b); - db->update (d); - - db->reload (*pb); - db->reload (*pd); - - assert (pb->rs1n == b.rs1n && pb->rs1s == b.rs1s && - pb->rs2n == b.rs2n && pb->rs2v == b.rs2v && - pb->rs3v == b.rs3v && - pb->rs4n == b.rs4n && - pb->bs1n == b.bs1n); - - assert (pd->rs1n == d.rs1n && pd->rs1s == d.rs1s && - pd->rs1b == d.rs1b && pd->rs1v == d.rs1v && - pd->rs2n == d.rs2n && pd->rs2v == d.rs2v && - pd->rs3v == d.rs3v && pd->rs3n == d.rs3n && - pd->rs4n == d.rs4n && pd->rs4s == d.rs4s && - pd->bs1n == d.bs1n && pd->bs1s == d.bs1s && - pd->ds1n == d.ds1n); - - t.commit (); - } - } - - // Test empty section and override "gap". - // - { - using namespace test2; - - derived d (234); - - { - transaction t (db->begin ()); - db->persist (d); - t.commit (); - - assert (d.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - assert (!pd->s.loaded ()); - assert (pd->sn != d.sn && pd->sv != d.sv); - - root* pr (pd.get ()); - db->load (*pr, pr->s); // Via root. - - assert (pd->s.loaded ()); - assert (pd->sn == d.sn && pd->sv == d.sv); - t.commit (); - } - - // Update object. - // - d.sn++; - d.sv[0]++; - - { - transaction t (db->begin ()); - root* pr (&d); - db->update (pr); // Via root. - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - base* pb (pd.get ()); - db->load (*pb, pb->s); // Via base. - - assert (pd->sn == d.sn && pd->sv == d.sv); - t.commit (); - } - - // Update section. - // - d.sn++; - d.sv[0]++; - - { - transaction t (db->begin ()); - root* pr (&d); - db->update (*pr, pr->s); // Via root. - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - db->load (*pd, pd->s); - - assert (pd->sn == d.sn && pd->sv == d.sv); - t.commit (); - } - - // Reload. - // - d.sn++; - d.sv[0]++; - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - db->load (*pd, pd->s); - - db->update (d); - - root* pr (pd.get ()); - db->reload (*pr); - - assert (pd->sn == d.sn && pd->sv == d.sv); - t.commit (); - } - } - - // Test value-only/container-only base/override combinations. - // - { - using namespace test3; - - root r (123); - base b (234); - derived d (345, "abc"); - - { - transaction t (db->begin ()); - db->persist (r); - db->persist (b); - db->persist (d); - t.commit (); - - assert (r.s1.loaded ()); - assert (r.s2.loaded ()); - assert (r.s3.loaded ()); - assert (r.s4.loaded ()); - - assert (b.s1.loaded ()); - assert (b.s2.loaded ()); - assert (b.s3.loaded ()); - assert (b.s4.loaded ()); - - assert (d.s1.loaded ()); - assert (d.s2.loaded ()); - assert (d.s3.loaded ()); - assert (d.s4.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr pr (db->load (r.id)); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - assert (!pr->s1.loaded ()); - assert (!pr->s2.loaded ()); - assert (!pr->s3.loaded ()); - assert (!pr->s4.loaded ()); - - assert (!pb->s1.loaded ()); - assert (!pb->s2.loaded ()); - assert (!pb->s3.loaded ()); - assert (!pb->s4.loaded ()); - - assert (!pd->s1.loaded ()); - assert (!pd->s2.loaded ()); - assert (!pd->s3.loaded ()); - assert (!pd->s4.loaded ()); - - assert (pr->s1n != r.s1n && - pr->s2n != r.s2n && - pr->s3v != r.s3v && - pr->s4nv != r.s4nv); - - assert (pb->s1n != b.s1n && - pb->s2n != b.s2n && - pb->s3v != b.s3v && - pb->s4nv != b.s4nv); - - assert (pd->s1n != d.s1n && pd->s1s != d.s1s && - pd->s2n != d.s2n && pd->s2v != d.s2v && - pd->s3v != d.s3v && pd->s3n != d.s3n && - pd->s4nv != d.s4nv && pd->s4sv != d.s4sv); - - db->load (*pr, pr->s1); - db->load (*pr, pr->s2); - db->load (*pr, pr->s3); - db->load (*pr, pr->s4); - - db->load (*pb, pb->s1); - db->load (*pb, pb->s2); - db->load (*pb, pb->s3); - db->load (*pb, pb->s4); - - root* pdr (pd.get ()); - db->load (*pdr, pdr->s1); - db->load (*pdr, pdr->s2); - db->load (*pdr, pdr->s3); - db->load (*pdr, pdr->s4); - - assert (pr->s1.loaded ()); - assert (pr->s2.loaded ()); - assert (pr->s3.loaded ()); - assert (pr->s4.loaded ()); - - assert (pb->s1.loaded ()); - assert (pb->s2.loaded ()); - assert (pb->s3.loaded ()); - assert (pb->s4.loaded ()); - - assert (pd->s1.loaded ()); - assert (pd->s2.loaded ()); - assert (pd->s3.loaded ()); - assert (pd->s4.loaded ()); - - assert (pr->s1n == r.s1n && - pr->s2n == r.s2n && - pr->s3v == r.s3v && - pr->s4nv == r.s4nv); - - assert (pb->s1n == b.s1n && - pb->s2n == b.s2n && - pb->s3v == b.s3v && - pb->s4nv == b.s4nv); - - assert (pd->s1n == d.s1n && pd->s1s == d.s1s && - pd->s2n == d.s2n && pd->s2v == d.s2v && - pd->s3v == d.s3v && pd->s3n == d.s3n && - pd->s4nv == d.s4nv && pd->s4sv == d.s4sv); - t.commit (); - } - - // Update object. - // - r.s1n++; - r.s2n++; - r.s3v[0]++; - r.s4nv[0]++; - - b.s1n++; - b.s2n++; - b.s3v[0]++; - b.s4nv[0]++; - - d.s1n++; - d.s1s += 'd'; - d.s2n++; - d.s2v[0]++; - d.s3v[0]++; - d.s3n++; - d.s4nv[0]++; - d.s4sv[0] += 'd'; - - { - transaction t (db->begin ()); - db->update (r); - db->update (b); - db->update (d); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr pr (db->load (r.id)); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - db->load (*pr, pr->s1); - db->load (*pr, pr->s2); - db->load (*pr, pr->s3); - db->load (*pr, pr->s4); - - db->load (*pb, pb->s1); - db->load (*pb, pb->s2); - db->load (*pb, pb->s3); - db->load (*pb, pb->s4); - - db->load (*pd, pd->s1); - db->load (*pd, pd->s2); - db->load (*pd, pd->s3); - db->load (*pd, pd->s4); - - assert (pr->s1n == r.s1n && - pr->s2n == r.s2n && - pr->s3v == r.s3v && - pr->s4nv == r.s4nv); - - assert (pb->s1n == b.s1n && - pb->s2n == b.s2n && - pb->s3v == b.s3v && - pb->s4nv == b.s4nv); - - assert (pd->s1n == d.s1n && pd->s1s == d.s1s && - pd->s2n == d.s2n && pd->s2v == d.s2v && - pd->s3v == d.s3v && pd->s3n == d.s3n && - pd->s4nv == d.s4nv && pd->s4sv == d.s4sv); - t.commit (); - } - - // Update section. - // - r.s1n++; - r.s2n++; - r.s3v[0]++; - r.s4nv[0]++; - - b.s1n++; - b.s2n++; - b.s3v[0]++; - b.s4nv[0]++; - - d.s1n++; - d.s1s += 'd'; - d.s2n++; - d.s2v[0]++; - d.s3v[0]++; - d.s3n++; - d.s4nv[0]++; - d.s4sv[0] += 'd'; - - { - transaction t (db->begin ()); - db->update (r, r.s1); - db->update (r, r.s2); - db->update (r, r.s3); - db->update (r, r.s4); - - db->update (b, b.s1); - db->update (b, b.s2); - db->update (b, b.s3); - db->update (b, b.s4); - - root& rr (d); - db->update (rr, rr.s1); - db->update (rr, rr.s2); - db->update (rr, rr.s3); - db->update (rr, rr.s4); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr pr (db->load (r.id)); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - db->load (*pr, pr->s1); - db->load (*pr, pr->s2); - db->load (*pr, pr->s3); - db->load (*pr, pr->s4); - - db->load (*pb, pb->s1); - db->load (*pb, pb->s2); - db->load (*pb, pb->s3); - db->load (*pb, pb->s4); - - db->load (*pd, pd->s1); - db->load (*pd, pd->s2); - db->load (*pd, pd->s3); - db->load (*pd, pd->s4); - - assert (pr->s1n == r.s1n && - pr->s2n == r.s2n && - pr->s3v == r.s3v && - pr->s4nv == r.s4nv); - - assert (pb->s1n == b.s1n && - pb->s2n == b.s2n && - pb->s3v == b.s3v && - pb->s4nv == b.s4nv); - - assert (pd->s1n == d.s1n && pd->s1s == d.s1s && - pd->s2n == d.s2n && pd->s2v == d.s2v && - pd->s3v == d.s3v && pd->s3n == d.s3n && - pd->s4nv == d.s4nv && pd->s4sv == d.s4sv); - t.commit (); - } - - // Reload. - // - r.s1n++; - r.s2n++; - r.s3v[0]++; - r.s4nv[0]++; - - b.s1n++; - b.s2n++; - b.s3v[0]++; - b.s4nv[0]++; - - d.s1n++; - d.s1s += 'd'; - d.s2n++; - d.s2v[0]++; - d.s3v[0]++; - d.s3n++; - d.s4nv[0]++; - d.s4sv[0] += 'd'; - - { - transaction t (db->begin ()); - unique_ptr pr (db->load (r.id)); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - db->load (*pr, pr->s1); - db->load (*pr, pr->s2); - db->load (*pr, pr->s3); - db->load (*pr, pr->s4); - - db->load (*pb, pb->s1); - db->load (*pb, pb->s2); - db->load (*pb, pb->s3); - db->load (*pb, pb->s4); - - db->load (*pd, pd->s1); - db->load (*pd, pd->s2); - db->load (*pd, pd->s3); - db->load (*pd, pd->s4); - - db->update (r); - db->update (b); - db->update (d); - - db->reload (*pr); - db->reload (*pb); - db->reload (*pd); - - assert (pr->s1n == r.s1n && - pr->s2n == r.s2n && - pr->s3v == r.s3v && - pr->s4nv == r.s4nv); - - assert (pb->s1n == b.s1n && - pb->s2n == b.s2n && - pb->s3v == b.s3v && - pb->s4nv == b.s4nv); - - assert (pd->s1n == d.s1n && pd->s1s == d.s1s && - pd->s2n == d.s2n && pd->s2v == d.s2v && - pd->s3v == d.s3v && pd->s3n == d.s3n && - pd->s4nv == d.s4nv && pd->s4sv == d.s4sv); - t.commit (); - } - } - - // Test basic polymorphic optimistic section functionality. - // - { - using namespace test4; - - base b (123, "abc"); - derived d (234, "bcd", true); - - { - transaction t (db->begin ()); - db->persist (b); - db->persist (d); - t.commit (); - - assert (b.rs1.loaded ()); - assert (b.rs2.loaded ()); - assert (b.rs3.loaded ()); - assert (b.rs4.loaded ()); - assert (b.bs1.loaded ()); - - assert (d.rs1.loaded ()); - assert (d.rs2.loaded ()); - assert (d.rs3.loaded ()); - assert (d.rs4.loaded ()); - assert (d.bs1.loaded ()); - assert (d.ds1.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - assert (!pb->rs1.loaded ()); - assert (!pb->rs2.loaded ()); - assert (!pb->rs3.loaded ()); - assert (!pb->rs4.loaded ()); - assert (!pb->bs1.loaded ()); - - assert (!pd->rs1.loaded ()); - assert (!pd->rs2.loaded ()); - assert (!pd->rs3.loaded ()); - assert (!pd->rs4.loaded ()); - assert (!pd->bs1.loaded ()); - assert (!pd->ds1.loaded ()); - - assert (pb->rs1n != b.rs1n && pb->rs1s != b.rs1s && - pb->rs2n != b.rs2n && - pb->rs3n != b.rs3n && - pb->rs4n != b.rs4n && pb->rs4s != b.rs4s); - - assert (pd->rs1n != d.rs1n && pd->rs1s != d.rs1s && - pd->rs1b != d.rs1b && pd->rs1v != d.rs1v && - pd->rs2n != d.rs2n && - pd->rs3n != d.rs3n && pd->rs3s != d.rs3s && - pd->rs4n != d.rs4n && pd->rs4s != d.rs4s && - pd->rs4v != d.rs4v && - pd->bs1n != d.bs1n && - pd->ds1v != d.ds1v); - - db->load (*pb, pb->rs1); - db->load (*pb, pb->rs2); - db->load (*pb, pb->rs3); - db->load (*pb, pb->rs4); - db->load (*pb, pb->bs1); // No-op. - - root* pr (pd.get ()); - db->load (*pr, pr->rs1); // Via base. - db->load (*pd, pd->rs2); - db->load (*pd, pd->rs3); - db->load (*pr, pr->rs4); // Via base. - db->load (*pd, pd->bs1); - db->load (*pd, pd->ds1); - - assert (pb->rs1.loaded ()); - assert (pb->rs2.loaded ()); - assert (pb->rs3.loaded ()); - assert (pb->rs4.loaded ()); - assert (pb->bs1.loaded ()); - - assert (pd->rs1.loaded ()); - assert (pd->rs2.loaded ()); - assert (pd->rs3.loaded ()); - assert (pd->rs4.loaded ()); - assert (pd->bs1.loaded ()); - assert (pd->ds1.loaded ()); - - assert (pb->rs1n == b.rs1n && pb->rs1s == b.rs1s && - pb->rs2n == b.rs2n && - pb->rs3n == b.rs3n && - pb->rs4n == b.rs4n && pb->rs4s == b.rs4s); - - assert (pd->rs1n == d.rs1n && pd->rs1s == d.rs1s && - pd->rs1b == d.rs1b && pd->rs1v == d.rs1v && - pd->rs2n == d.rs2n && - pd->rs3n == d.rs3n && pd->rs3s == d.rs3s && - pd->rs4n == d.rs4n && pd->rs4s == d.rs4s && - pd->rs4v == d.rs4v && - pd->bs1n == d.bs1n && - pd->ds1v == d.ds1v); - t.commit (); - } - - base b1 (b); - derived d1 (d); - - // Update object. - // - for (unsigned short s (1); s < 7; ++s) - { - b1.rs1n++; - b1.rs1s += 'd'; - b1.rs1.change (); - b1.rs4s += 'd'; - - d1.rs1n++; - d1.rs1s += 'e'; - d1.rs1b = !d.rs1b; - d1.rs1v[0]++; - d1.rs1.change (); - d1.rs4s += 'e'; - d1.rs4v[0]++; - d1.bs1n++; - d1.ds1v[0]++; - - transaction t (db->begin ()); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - db->update (b1); - db->update (d1); - - assert (!b1.rs1.changed ()); - assert (!d1.rs1.changed ()); - - assert (b.v != b1.v); - assert (d.v != d1.v); - - try - { - bool a (false); - switch (s) - { - case 1: db->load (*pb, pb->rs1); break; - case 2: db->load (*pb, pb->rs2); break; - case 3: db->load (*pb, pb->rs3); break; - case 4: db->load (*pb, pb->rs4); break; - case 5: - case 6: a = true; break; // No-op. - default: break; - } - assert (a); - } - catch (const object_changed&) - { - db->reload (*pb); - - assert (!pb->rs1.loaded ()); - assert (!pb->rs2.loaded ()); - assert (!pb->rs3.loaded ()); - assert (!pb->rs3.loaded ()); - assert (!pb->bs1.loaded ()); - - db->load (*pb, pb->rs1); - db->load (*pb, pb->rs2); - db->load (*pb, pb->rs3); - db->load (*pb, pb->rs4); - db->load (*pb, pb->bs1); // No-op. - - assert (pb->rs1n == b1.rs1n && pb->rs1s == b1.rs1s && - pb->rs2n == b1.rs2n && - pb->rs3n == b1.rs3n && - pb->rs4n == b1.rs4n && pb->rs4s == b1.rs4s); - } - - try - { - switch (s) - { - case 1: db->load (*pd, pd->rs1); break; - case 2: db->load (*pd, pd->rs2); break; - case 3: db->load (*pd, pd->rs3); break; - case 4: db->load (*pd, pd->rs4); break; - case 5: db->load (*pd, pd->bs1); break; - case 6: db->load (*pd, pd->ds1); break; - default: break; - } - assert (false); - } - catch (const object_changed&) - { - db->reload (*pd); - - assert (!pd->rs1.loaded ()); - assert (!pd->rs2.loaded ()); - assert (!pd->rs3.loaded ()); - assert (!pd->rs4.loaded ()); - assert (!pd->bs1.loaded ()); - assert (!pd->ds1.loaded ()); - - db->load (*pd, pd->rs1); - db->load (*pd, pd->rs2); - db->load (*pd, pd->rs3); - db->load (*pd, pd->rs4); - db->load (*pd, pd->bs1); - db->load (*pd, pd->ds1); - - assert (pd->rs1n == d1.rs1n && pd->rs1s == d1.rs1s && - pd->rs1b == d1.rs1b && pd->rs1v == d1.rs1v && - pd->rs2n == d1.rs2n && - pd->rs3n == d1.rs3n && pd->rs3s == d1.rs3s && - pd->rs4n == d1.rs4n && pd->rs4s == d1.rs4s && - pd->rs4v == d1.rs4v && - pd->bs1n == d1.bs1n && - pd->ds1v == d1.ds1v); - } - - db->reload (b); - db->reload (d); - - assert (b.v == b1.v); - assert (d.v == d1.v); - - assert (b.rs1n == b1.rs1n && b.rs1s == b1.rs1s && - b.rs2n == b1.rs2n && - b.rs3n == b1.rs3n && - b.rs4n == b1.rs4n && b.rs4s == b1.rs4s); - - assert (d.rs1n == d1.rs1n && d.rs1s == d1.rs1s && - d.rs1b == d1.rs1b && d.rs1v == d1.rs1v && - d.rs2n == d1.rs2n && - d.rs3n == d1.rs3n && d.rs3s == d1.rs3s && - d.rs4n == d1.rs4n && d.rs4s == d1.rs4s && - d.rs4v == d1.rs4v && - d.bs1n == d1.bs1n && - d.ds1v == d1.ds1v); - - t.commit (); - } - - // Update section. - // - for (unsigned short s (1); s < 7; ++s) - { - transaction t (db->begin ()); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - switch (s) - { - case 1: - b1.rs1n++; - b1.rs1s += 'd'; - - d1.rs1n++; - d1.rs1s += 'e'; - d1.rs1b = !d.rs1b; - d1.rs1v[0]++; - - db->update (b1, b1.rs1); - db->update (d1, d1.rs1); - - assert (b.v != b1.v); - assert (d.v != d1.v); - break; - case 2: - db->update (b1, b1.rs2); // No-op. - db->update (d1, d1.rs2); // No-op. - - assert (b.v == b1.v); - assert (d.v == d1.v); - continue; // Object hasn't changed. - case 3: - db->update (b1, b1.rs3); // No-op. - db->update (d1, d1.rs3); // No-op. - - assert (b.v == b1.v); - assert (d.v == d1.v); - continue; // Object hasn't changed. - case 4: - b1.rs4s += 'd'; - - d1.rs4s += 'e'; - d1.rs4v[0]++; - - db->update (b1, b1.rs4); - db->update (d1, d1.rs4); - - assert (b.v != b1.v); - assert (d.v != d1.v); - break; - case 5: - d1.bs1n++; - - db->update (b1, b1.bs1); // No-op. - db->update (d1, d1.bs1); - - assert (b.v == b1.v); - assert (d.v != d1.v); - break; - case 6: - d1.ds1v[0]++; - - db->update (d1, d1.ds1); - - assert (d.v != d1.v); - break; - default: break; - } - - try - { - bool a (false); - switch (s) - { - case 1: db->load (*pb, pb->rs1); break; - case 4: db->load (*pb, pb->rs4); break; - case 5: - case 6: a = true; break; // No-op. - default: break; - } - assert (a); - } - catch (const object_changed&) - { - db->reload (*pb); - - assert (!pb->rs1.loaded ()); - assert (!pb->rs2.loaded ()); - assert (!pb->rs3.loaded ()); - assert (!pb->rs4.loaded ()); - assert (!pb->bs1.loaded ()); - - db->load (*pb, pb->rs1); - db->load (*pb, pb->rs2); - db->load (*pb, pb->rs3); - db->load (*pb, pb->rs4); - db->load (*pb, pb->bs1); // No-op. - - assert (pb->rs1n == b1.rs1n && pb->rs1s == b1.rs1s && - pb->rs2n == b1.rs2n && - pb->rs3n == b1.rs3n && - pb->rs4n == b1.rs4n && pb->rs4s == b1.rs4s); - } - - try - { - switch (s) - { - case 1: db->load (*pd, pd->rs1); break; - case 4: db->load (*pd, pd->rs4); break; - case 5: db->load (*pd, pd->bs1); break; - case 6: db->load (*pd, pd->ds1); break; - default: break; - } - assert (false); - } - catch (const object_changed&) - { - db->reload (*pd); - - assert (!pd->rs1.loaded ()); - assert (!pd->rs2.loaded ()); - assert (!pd->rs3.loaded ()); - assert (!pd->rs4.loaded ()); - assert (!pd->bs1.loaded ()); - assert (!pd->ds1.loaded ()); - - db->load (*pd, pd->rs1); - db->load (*pd, pd->rs2); - db->load (*pd, pd->rs3); - db->load (*pd, pd->rs4); - db->load (*pd, pd->bs1); - db->load (*pd, pd->ds1); - - assert (pd->rs1n == d1.rs1n && pd->rs1s == d1.rs1s && - pd->rs1b == d1.rs1b && pd->rs1v == d1.rs1v && - pd->rs2n == d1.rs2n && - pd->rs3n == d1.rs3n && pd->rs3s == d1.rs3s && - pd->rs4n == d1.rs4n && pd->rs4s == d1.rs4s && - pd->rs4v == d1.rs4v && - pd->bs1n == d1.bs1n && - pd->ds1v == d1.ds1v); - } - - db->reload (b); - db->reload (d); - - assert (b.v == b1.v); - assert (d.v == d1.v); - - assert (b.rs1n == b1.rs1n && b.rs1s == b1.rs1s && - b.rs2n == b1.rs2n && - b.rs3n == b1.rs3n && - b.rs4n == b1.rs4n && b.rs4s == b1.rs4s); - - assert (d.rs1n == d1.rs1n && d.rs1s == d1.rs1s && - d.rs1b == d1.rs1b && d.rs1v == d1.rs1v && - d.rs2n == d1.rs2n && - d.rs3n == d1.rs3n && d.rs3s == d1.rs3s && - d.rs4n == d1.rs4n && d.rs4s == d1.rs4s && - d.rs4v == d1.rs4v && - d.bs1n == d1.bs1n && - d.ds1v == d1.ds1v); - - t.commit (); - } - - // Update changed section. - // - for (unsigned short s (1); s < 7; ++s) - { - if (s == 2 || s == 3) // Readonly sections. - continue; - - transaction t (db->begin ()); - - switch (s) - { - case 1: - b1.rs1n++; - b1.rs1s += 'd'; - - d1.rs1n++; - d1.rs1s += 'e'; - d1.rs1b = !d.rs1b; - d1.rs1v[0]++; - - db->update (b1, b1.rs1); - db->update (d1, d1.rs1); - break; - case 4: - b1.rs4s += 'd'; - - d1.rs4s += 'e'; - d1.rs4v[0]++; - - db->update (b1, b1.rs4); - db->update (d1, d1.rs4); - break; - case 5: - d1.bs1n++; - - db->update (b1, b1.bs1); // No-op. - db->update (d1, d1.bs1); - break; - case 6: - d1.ds1v[0]++; - - db->update (d1, d1.bs1); - break; - default: break; - } - - try - { - bool a (false); - switch (s) - { - case 1: db->update (b, b.rs1); break; - case 4: db->update (b, b.rs4); break; - case 5: - case 6: a = true; break; // No-op. - default: break; - } - assert (a); - } - catch (const object_changed&) - { - db->reload (b); - - switch (s) - { - case 1: db->update (b, b.rs1); break; - case 4: db->update (b, b.rs4); break; - default: break; - } - } - - try - { - switch (s) - { - case 1: db->update (d, d.rs1); break; - case 4: db->update (d, d.rs4); break; - case 5: db->update (d, d.bs1); break; - case 6: db->update (d, d.ds1); break; - default: break; - } - assert (false); - } - catch (const object_changed&) - { - db->reload (d); - - switch (s) - { - case 1: db->update (d, d.rs1); break; - case 4: db->update (d, d.rs4); break; - case 5: db->update (d, d.bs1); break; - case 6: db->update (d, d.ds1); break; - default: break; - } - } - - db->reload (b1); - db->reload (d1); - - t.commit (); - } - } - - // Test polymorphic optimistic readonly/empty to readwrite section - // override. - // - { - using namespace test5; - - base b; - derived d (123); - - { - transaction t (db->begin ()); - db->persist (b); - db->persist (d); - t.commit (); - - assert (b.s.loaded ()); - assert (d.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - assert (!pb->s.loaded ()); - assert (!pd->s.loaded ()); - assert (pd->sn != d.sn); - - db->load (*pb, pb->s); // No-op. - db->load (*pd, pd->s); - - assert (pb->s.loaded ()); - assert (pd->s.loaded ()); - - assert (pd->sn == d.sn); - - t.commit (); - } - - // Update object. - // - base b1 (b); - derived d1 (d); - d1.sn++; - d1.s.change (); - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - db->update (d1); - - assert (!d1.s.changed ()); - assert (d.v != d1.v); - - try - { - db->load (*pd, pd->s); - assert (false); - } - catch (const object_changed&) - { - db->reload (*pd); - assert (!pd->s.loaded ()); - db->load (*pd, pd->s); - assert (pd->sn == d1.sn); - } - - db->reload (d); - assert (d.v == d1.v); - assert (d.sn == d1.sn); - t.commit (); - } - - // Update section. - // - d1.sn++; - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - db->update (b1, b1.s); // No-op. - db->update (d1, d1.s); - - assert (b.v == b1.v); - assert (d.v != d1.v); - - try - { - db->load (*pd, pd->s); - assert (false); - } - catch (const object_changed&) - { - db->reload (*pd); - assert (!pd->s.loaded ()); - db->load (*pd, pd->s); - - assert (pd->sn == d1.sn); - } - - db->reload (d); - assert (d.v == d1.v); - assert (d.sn == d1.sn); - t.commit (); - } - - // Update changed section. - // - d1.sn++; - - { - transaction t (db->begin ()); - db->update (d1, d1.s); - - try - { - db->update (d, d.s); - assert (false); - } - catch (const object_changed&) - { - db->reload (d); - db->update (d, d.s); - } - - t.commit (); - } - } - - // Test polymorphic optimistic readonly/empty to readwrite section - // override, eager-loaded case. - // - { - using namespace test6; - - derived d (123); - - { - transaction t (db->begin ()); - db->persist (d); - t.commit (); - - assert (d.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - assert (pd->s.loaded ()); - assert (pd->sn == d.sn); - - t.commit (); - } - - // Update object. - // - derived d1 (d); - d1.sn++; - d1.s.change (); - - { - transaction t (db->begin ()); - - db->update (d1); - - assert (!d1.s.changed ()); - assert (d.v != d1.v); - - db->reload (d); - assert (d.v == d1.v); - assert (d.sn == d1.sn); - t.commit (); - } - - // Update section. - // - d1.sn++; - - { - transaction t (db->begin ()); - - db->update (d1, d1.s); - assert (d.v != d1.v); - - db->reload (d); - assert (d.v == d1.v); - assert (d.sn == d1.sn); - t.commit (); - } - - // Update changed section. - // - d1.sn++; - - { - transaction t (db->begin ()); - db->update (d1, d1.s); - - try - { - db->update (d, d.s); - assert (false); - } - catch (const object_changed&) - { - db->reload (d); - db->update (d, d.s); - } - - t.commit (); - } - } - - // Test polymorphic optimistic section added in derived. - // - { - using namespace test7; - - base b; - derived d (123); - - { - transaction t (db->begin ()); - db->persist (b); - db->persist (d); - t.commit (); - - assert (b.s.loaded ()); - assert (d.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr pb (db->load (b.id)); - unique_ptr pd (db->load (d.id)); - - assert (!pb->s.loaded ()); - assert (!pd->s.loaded ()); - assert (pd->sn != d.sn); - - db->load (*pb, pb->s); // No-op. - db->load (*pd, pd->s); - - assert (pb->s.loaded ()); - assert (pd->s.loaded ()); - - assert (pd->sn == d.sn); - - t.commit (); - } - - // Update object. - // - base b1 (b); - derived d1 (d); - d1.sn++; - d1.s.change (); - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - db->update (d1); - - assert (!d1.s.changed ()); - assert (d.v != d1.v); - - try - { - db->load (*pd, pd->s); - assert (false); - } - catch (const object_changed&) - { - db->reload (*pd); - assert (!pd->s.loaded ()); - db->load (*pd, pd->s); - assert (pd->sn == d1.sn); - } - - db->reload (d); - assert (d.v == d1.v); - assert (d.sn == d1.sn); - t.commit (); - } - - // Update section. - // - d1.sn++; - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - db->update (b1, b1.s); // No-op. - db->update (d1, d1.s); - - assert (b.v == b1.v); - assert (d.v != d1.v); - - try - { - db->load (*pd, pd->s); - assert (false); - } - catch (const object_changed&) - { - db->reload (*pd); - assert (!pd->s.loaded ()); - db->load (*pd, pd->s); - - assert (pd->sn == d1.sn); - } - - db->reload (d); - assert (d.v == d1.v); - assert (d.sn == d1.sn); - t.commit (); - } - - // Update changed section. - // - d1.sn++; - - { - transaction t (db->begin ()); - db->update (d1, d1.s); - - try - { - db->update (d, d.s); - assert (false); - } - catch (const object_changed&) - { - db->reload (d); - db->update (d, d.s); - } - - t.commit (); - } - } - - // Test reuse/polymorphic inheritance and optimistic mix. - // - { - using namespace test8; - - derived d (123); - - { - transaction t (db->begin ()); - db->persist (d); - t.commit (); - - assert (d.s.loaded ()); - } - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - assert (!pd->s.loaded ()); - assert (pd->sn != d.sn); - - db->load (*pd, pd->s); - - assert (pd->s.loaded ()); - assert (pd->sn == d.sn); - - t.commit (); - } - - // Update object. - // - derived d1 (d); - d1.sn++; - d1.s.change (); - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - db->update (d1); - - assert (!d1.s.changed ()); - assert (d.v != d1.v); - - try - { - db->load (*pd, pd->s); - assert (false); - } - catch (const object_changed&) - { - db->reload (*pd); - assert (!pd->s.loaded ()); - db->load (*pd, pd->s); - assert (pd->sn == d1.sn); - } - - db->reload (d); - assert (d.v == d1.v); - assert (d.sn == d1.sn); - t.commit (); - } - - // Update section. - // - d1.sn++; - - { - transaction t (db->begin ()); - unique_ptr pd (db->load (d.id)); - - db->update (d1, d1.s); - assert (d.v != d1.v); - - try - { - db->load (*pd, pd->s); - assert (false); - } - catch (const object_changed&) - { - db->reload (*pd); - assert (!pd->s.loaded ()); - db->load (*pd, pd->s); - - assert (pd->sn == d1.sn); - } - - db->reload (d); - assert (d.v == d1.v); - assert (d.sn == d1.sn); - t.commit (); - } - - // Update changed section. - // - d1.sn++; - - { - transaction t (db->begin ()); - db->update (d1, d1.s); - - try - { - db->update (d, d.s); - assert (false); - } - catch (const object_changed&) - { - db->reload (d); - db->update (d, d.s); - } - - t.commit (); - } - } - - // Test reuse/polymorphic inheritance and optimistic mix. - // - { - using namespace test9; - using std::shared_ptr; - - unsigned long long id; - - { - container c (123); - - c.e1.push_back (shared_ptr (new element (11))); - c.e1.push_back (shared_ptr (new element (12))); - - c.e2.push_back (shared_ptr (new element (21))); - c.e2.push_back (shared_ptr (new element (22))); - - transaction t (db->begin ()); - - db->persist (c.e1[0]); - db->persist (c.e1[1]); - db->persist (c.e2[0]); - db->persist (c.e2[1]); - - id = db->persist (c); - - t.commit (); - } - - { - transaction t (db->begin ()); - - shared_ptr c (db->load (id)); - - assert (c->n == 123); - db->load (*c, c->s); - assert (c->e1.size () == 2 && c->e1[0]->n == 11 && c->e1[1]->n == 12); - assert (c->e2.size () == 2 && c->e2[0]->n == 21 && c->e2[1]->n == 22); - - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/section/polymorphism/test.hxx b/common/section/polymorphism/test.hxx deleted file mode 100644 index 6d524bd..0000000 --- a/common/section/polymorphism/test.hxx +++ /dev/null @@ -1,542 +0,0 @@ -// file : common/section/polymorphism/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include - -#include -#include - -// Test basic polymorphic section functionality. -// -#pragma db namespace table("t1_") -namespace test1 -{ - #pragma db object polymorphic abstract - struct root - { - root (int n): rs1n (n), rs2n (n), rs4n (n) {rs2v.push_back (n);} - virtual ~root () {} - - #pragma db id auto - unsigned long id; - - // rs1: override in base and derived - // - #pragma db load(lazy) update(change) - odb::section rs1; - - #pragma db section(rs1) - int rs1n; - - // rs2: no override - // - #pragma db load(lazy) - odb::section rs2; - - #pragma db section(rs2) - int rs2n; - - #pragma db section(rs2) - std::vector rs2v; - - // rs3: empty - // - #pragma db load(lazy) - odb::section rs3; - - // rs4: override "gap" - // - #pragma db load(lazy) - odb::section rs4; - - #pragma db section(rs4) - int rs4n; - }; - - #pragma db object - struct base: root - { - base (int n = 999, const std::string& s = "xxx") - : root (n), rs1s (s), bs1n (n) {rs3v.push_back (n);} - - // rs1 - // - #pragma db section(rs1) - std::string rs1s; - - // rs3 - // - #pragma db section(rs3) - std::vector rs3v; - - // bs1: override in derived - // - #pragma db load(lazy) - odb::section bs1; - - #pragma db section(bs1) - int bs1n; - }; - - #pragma db object - struct derived: base - { - derived (int n = 999, const std::string& s = "xxx", bool b = false) - : base (n, s), rs1b (b), rs3n (n), rs4s (s), bs1s (s), ds1n (n) - {rs1v.push_back (n);} - - // rs1 - // - #pragma db section(rs1) - bool rs1b; - - #pragma db section(rs1) - std::vector rs1v; - - // rs3 - // - #pragma db section(rs3) - int rs3n; - - // rs4 - // - #pragma db section(rs4) - std::string rs4s; - - // bs1 - // - #pragma db section(bs1) - std::string bs1s; - - // ds1: no override - // - #pragma db load(lazy) - odb::section ds1; - - #pragma db section(ds1) - int ds1n; - }; -} - -// Test empty section and override "gap". -// -#pragma db namespace table("t2_") -namespace test2 -{ - #pragma db object polymorphic abstract - struct root - { - virtual ~root () {} - - #pragma db id auto - unsigned long id; - - #pragma db load(lazy) - odb::section s; - }; - - #pragma db object abstract - struct base: root - { - // The "gap". - }; - - #pragma db object - struct derived: base - { - derived (int n = 999): sn (n) {sv.push_back (n);} - - #pragma db section(s) - int sn; - - #pragma db section(s) - std::vector sv; - }; -} - -// Test value-only/container-only base/override combinations. -// -#pragma db namespace table("t3_") -namespace test3 -{ - #pragma db object polymorphic - struct root - { - root (int n = 999) - : s1n (n), s2n (n) {s3v.push_back (n); s4nv.push_back (n);} - virtual ~root () {} - - #pragma db id auto - unsigned long id; - - // value/value - // - #pragma db load(lazy) - odb::section s1; - - #pragma db section(s1) - int s1n; - - // value/container - // - #pragma db load(lazy) - odb::section s2; - - #pragma db section(s2) - int s2n; - - // container/value - // - #pragma db load(lazy) - odb::section s3; - - #pragma db section(s3) - std::vector s3v; - - // container/container - // - #pragma db load(lazy) - odb::section s4; - - #pragma db section(s4) - std::vector s4nv; - }; - - #pragma db object - struct base: root - { - base (int n = 999): root (n) {} - - // The "gap". - }; - - #pragma db object - struct derived: base - { - derived (int n = 999, const std::string& s = "xxx") - : base (n), s1s (s), s3n (n) {s2v.push_back (n); s4sv.push_back (s);} - - #pragma db section(s1) - std::string s1s; - - #pragma db section(s2) - std::vector s2v; - - #pragma db section(s3) - int s3n; - - #pragma db section(s4) - std::vector s4sv; - }; -} - -// Test basic polymorphic optimistic section functionality. -// -#pragma db namespace table("t4_") -namespace test4 -{ - #pragma db object polymorphic optimistic abstract sectionable - struct root - { - root (int n): rs1n (n), rs2n (n), rs3n (n), rs4n (n) {} - virtual ~root () {} - - #pragma db id auto - unsigned long id; - - #pragma db version - unsigned long long v; - - // rs1: readwrite, override - // - #pragma db load(lazy) update(change) - odb::section rs1; - - #pragma db section(rs1) - int rs1n; - - // rs2: readonly, no override - // - #pragma db load(lazy) - odb::section rs2; - - #pragma db section(rs2) - const int rs2n; - - // rs3: readonly, readonly override - // - #pragma db load(lazy) - odb::section rs3; - - #pragma db section(rs3) - const int rs3n; - - // rs4: readonly, readwrite override - // - #pragma db load(lazy) - odb::section rs4; - - #pragma db section(rs4) - const int rs4n; - }; - - #pragma db object - struct base: root - { - base (int n = 999, const std::string& s = "xxx") - : root (n), rs1s (s), rs4s (s) {} - - // rs1 - // - #pragma db section(rs1) - std::string rs1s; - - // rs4 - // - #pragma db section(rs4) - std::string rs4s; - - // bs2: empty, readwrite override - // - #pragma db load(lazy) - odb::section bs1; - }; - - #pragma db object - struct derived: base - { - derived (int n = 999, const std::string& s = "xxx", bool b = false) - : base (n, s), rs1b (b), rs3s (s), bs1n (n) - { - rs1v.push_back (n); - rs4v.push_back (n); - ds1v.push_back (n); - } - - // rs1 - // - #pragma db section(rs1) - bool rs1b; - - #pragma db section(rs1) - std::vector rs1v; - - // rs3 - // - #pragma db section(rs3) - const std::string rs3s; - - // rs4 - // - #pragma db section(rs4) - std::vector rs4v; - - // bs1 - // - #pragma db section(bs1) - int bs1n; - - // ds1: readwrite - // - #pragma db load(lazy) - odb::section ds1; - - #pragma db section(ds1) - std::vector ds1v; - }; -} - -// Test polymorphic optimistic readonly/empty to readwrite section override. -// -#pragma db namespace table("t5_") -namespace test5 -{ - #pragma db object polymorphic optimistic abstract - struct root - { - virtual ~root () {} - - #pragma db id auto - unsigned long id; - - #pragma db version - unsigned long long v; - - #pragma db load(lazy) update(change) - odb::section s; - }; - - #pragma db object - struct base: root - { - // The "gap". - }; - - #pragma db object - struct derived: base - { - derived (int n = 999): sn (n) {} - - #pragma db section(s) - int sn; - }; -} - -// Test polymorphic optimistic readonly/empty to readwrite section override, -// eager-loaded case. -// -#pragma db namespace table("t6_") -namespace test6 -{ - #pragma db object polymorphic optimistic abstract - struct root - { - virtual ~root () {} - - #pragma db id auto - unsigned long id; - - #pragma db version - unsigned long long v; - - #pragma db update(change) - odb::section s; - }; - - #pragma db object abstract - struct base: root - { - // The "gap". - }; - - #pragma db object - struct derived: base - { - derived (int n = 999): sn (n) {} - - #pragma db section(s) - int sn; - }; -} - -// Test polymorphic optimistic section added in derived. -// -#pragma db namespace table("t7_") -namespace test7 -{ - #pragma db object polymorphic optimistic sectionable - struct root - { - virtual ~root () {} - - #pragma db id auto - unsigned long id; - - #pragma db version - unsigned long long v; - }; - - #pragma db object - struct base: root - { - #pragma db load(lazy) update(change) - odb::section s; - }; - - #pragma db object - struct derived: base - { - derived (int n = 999): sn (n) {} - - #pragma db section(s) - int sn; - }; -} - -// Test reuse/polymorphic inheritance and optimistic mix. -// -#pragma db namespace table("t8_") -namespace test8 -{ - #pragma db object optimistic sectionable abstract - struct root - { - #pragma db id auto - unsigned long id; - - #pragma db version - unsigned long long v; - }; - - #pragma db object polymorphic sectionable - struct base: root - { - virtual ~base () {} - }; - - #pragma db object - struct derived: base - { - derived (int n = 999): sn (n) {} - - #pragma db load(lazy) update(change) - odb::section s; - - #pragma db section(s) - int sn; - }; -} - -// Test id overwrite regression. -// -// The key here is the setup: the object that contains the containers in a -// section and the pointers to objects stored in those containers. And these -// objects derive polymorphically from the same base (and thus shared the id -// bindind). -// -#pragma db namespace table("t9_") -namespace test9 -{ - #pragma db object polymorphic pointer(std::shared_ptr) - struct base - { - virtual ~base () {} - - #pragma db id auto - unsigned long id; - }; - - #pragma db object - struct element: base - { - element (int n_ = 0): n (n_) {} - - int n; - }; - - typedef std::vector> elements; - - #pragma db object - struct container: base - { - container (int n_ = 0): n (n_) {} - - int n; - - #pragma db load(lazy) update(always) - odb::section s; - - #pragma db section(s) - elements e1; - - #pragma db section(s) - elements e2; - }; -} - -#endif // TEST_HXX diff --git a/common/section/polymorphism/testscript b/common/section/polymorphism/testscript deleted file mode 100644 index f2cd536..0000000 --- a/common/section/polymorphism/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/section/polymorphism/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/session/cache/buildfile b/common/session/cache/buildfile deleted file mode 100644 index 6d5b0bc..0000000 --- a/common/session/cache/buildfile +++ /dev/null @@ -1,41 +0,0 @@ -# file : common/session/cache/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix session_cache_ \ - --generate-schema \ - --generate-session - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/session/cache/driver.cxx b/common/session/cache/driver.cxx deleted file mode 100644 index 4b4ea12..0000000 --- a/common/session/cache/driver.cxx +++ /dev/null @@ -1,83 +0,0 @@ -// file : common/session/cache/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test session object cache. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test the session_required exception. - // - { - using namespace test1; - - shared_ptr o1a (new obj1 (1)); - shared_ptr o1b (new obj1 (2)); - shared_ptr o2 (new obj2 (1)); - - o1a->o2 = o2; - o1b->o2 = o2; - - o2->o1.push_back (o1a); - o2->o1.push_back (o1b); - - { - transaction t (db->begin ()); - db->persist (o1a); - db->persist (o1b); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - - try - { - shared_ptr o1 (db->load (1)); - assert (false); - } - catch (const session_required&) - { - } - - t.commit (); - } - - { - session s; - transaction t (db->begin ()); - shared_ptr o1 (db->load (1)); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/session/cache/test.hxx b/common/session/cache/test.hxx deleted file mode 100644 index d2b1b2b..0000000 --- a/common/session/cache/test.hxx +++ /dev/null @@ -1,50 +0,0 @@ -// file : common/session/cache/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -// Test the session_required exception. -// -#pragma db namespace table("t1_") -namespace test1 -{ - using std::shared_ptr; - using std::weak_ptr; - - #pragma db namespace(test1) pointer(shared_ptr) - - struct obj2; - - #pragma db object - struct obj1 - { - obj1 () {} - obj1 (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - shared_ptr o2; - }; - - #pragma db object - struct obj2 - { - obj2 () {} - obj2 (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db inverse (o2) - std::vector< weak_ptr > o1; - }; -} - -#endif // TEST_HXX diff --git a/common/session/cache/testscript b/common/session/cache/testscript deleted file mode 100644 index 6d013eb..0000000 --- a/common/session/cache/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/session/cache/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/session/custom/buildfile b/common/session/custom/buildfile deleted file mode 100644 index 1b64de1..0000000 --- a/common/session/custom/buildfile +++ /dev/null @@ -1,43 +0,0 @@ -# file : common/session/custom/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx txx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix session_custom_ \ - --generate-schema \ - --generate-session \ - --session-type ::session \ - --hxx-prologue '#include "session.hxx"' - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/session/custom/driver.cxx b/common/session/custom/driver.cxx deleted file mode 100644 index 3056fd6..0000000 --- a/common/session/custom/driver.cxx +++ /dev/null @@ -1,231 +0,0 @@ -// file : common/session/custom/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test custom session (C++11 only). -// - -#include -#include // std::size_t -#include - -#include -#include -#include -#include -#include // ODB_CXX11_* - -#include - -#include "session.hxx" - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; - -using odb::database; -using odb::transaction; - -struct counting_tracer: odb::tracer -{ - virtual void - execute (odb::connection&, const char*) {count++;} - size_t count; -}; - -static counting_tracer tracer; - -struct failed {}; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Simple Tech Ltd. - // - { - shared_ptr er (new employer ("Simple Tech Ltd", "ST")); - - shared_ptr john (new employee ("John", "Doe", er)); - shared_ptr jane (new employee ("Jane", "Doe", er)); - - transaction t (db->begin ()); - - db->persist (er); - db->persist (john); - db->persist (jane); - - t.commit (); - } - - // Complex Systems Inc. - // - { - shared_ptr er (new employer ("Complex Systems Inc", "CS")); - - shared_ptr john (new employee ("John", "Smith", er)); - shared_ptr jane (new employee ("Jane", "Smith", er)); - - transaction t (db->begin ()); - - db->persist (er); - db->persist (john); - db->persist (jane); - - t.commit (); - } - - { - session s; - shared_ptr st, cs; - shared_ptr ste, cse; - - { - transaction t (db->begin ()); - - st = db->load ("Simple Tech Ltd"); -#ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT - ste = db->load (st->employees ()[0].object_id ()); -#else - ste = db->load (st->employees ()[0].object_id ()); -#endif - - // Test object cache. - // - shared_ptr e (st->employees ()[0].load ()); - assert (ste->employer () == st); - assert (ste == e); - - t.commit (); - } - - { - transaction t (db->begin ()); - - cs = db->load ("Complex Systems Inc"); -#ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT - cse = db->load (cs->employees ()[0].object_id ()); -#else - cse = db->load (cs->employees ()[0].object_id ()); -#endif - cs->employees ()[0].load (); - - t.commit (); - } - - cs->symbol ("CSI"); - - // Swap employees. - // - ste->employer (cs); - cse->employer (st); - st->employees ()[0] = cse; - cs->employees ()[0] = ste; - - { - transaction t (db->begin ()); - tracer.count = 0; - t.tracer (tracer); - s.flush (*db); - assert (tracer.count == 3); - t.commit (); - } - - { - transaction t (db->begin ()); - tracer.count = 0; - t.tracer (tracer); - s.flush (*db); - assert (tracer.count == 0); - t.commit (); - } - - cs->symbol ("COMP"); - st->symbol ("SMPL"); - - { - transaction t (db->begin ()); - tracer.count = 0; - t.tracer (tracer); - s.flush (*db); - assert (tracer.count == 2); - t.commit (); - } - - { - transaction t (db->begin ()); - tracer.count = 0; - t.tracer (tracer); - s.flush (*db); - assert (tracer.count == 0); - t.commit (); - } - - // Explicit update. - // - cs->symbol ("CS"); - st->symbol ("ST"); - - { - transaction t (db->begin ()); - db->update (cs); - tracer.count = 0; - t.tracer (tracer); - s.flush (*db); - assert (tracer.count == 1); - t.commit (); - } - - // Rollback after update. - // - cs->symbol ("CSI"); - - try - { - transaction t (db->begin ()); - tracer.count = 0; - t.tracer (tracer); - s.flush (*db); - assert (tracer.count == 1); - throw failed (); - t.commit (); - } - catch (const failed&) - { - transaction t (db->begin ()); - tracer.count = 0; - t.tracer (tracer); - s.flush (*db); - assert (tracer.count == 1); - t.commit (); - } - } - - // Test session destruction before transaction is commited. - // - { - transaction t (db->begin ()); - { - session s; - shared_ptr st (db->load ("Simple Tech Ltd")); - st->symbol ("STL"); - tracer.count = 0; - t.tracer (tracer); - s.flush (*db); - assert (tracer.count == 1); - } - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/session/custom/session.cxx b/common/session/custom/session.cxx deleted file mode 100644 index 1a08c79..0000000 --- a/common/session/custom/session.cxx +++ /dev/null @@ -1,57 +0,0 @@ -// file : common/session/custom/session.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -#include "session.hxx" - -session* session::current; - -session:: -session () - : tran_ (0) -{ - assert (current == 0); - current = this; -} - -session:: -~session () -{ - // Unregister from transaction. - // - if (tran_ != 0) - tran_->callback_unregister (this); - - assert (current == this); - current = 0; -} - -void session:: -flush (odb::database& db) -{ - bool flushed (false); - - for (type_map::iterator i (map_.begin ()), e (map_.end ()); i != e; ++i) - { - bool r (i->second->flush (db)); - flushed = flushed || r; - } - - // If we flushed anything, then register the post-commit/rollback callback. - // - if (flushed) - { - tran_ = &odb::transaction::current (); - tran_->callback_register ( - &mark, this, odb::transaction::event_all, 0, &tran_); - } -} - -void session:: -mark (unsigned short event, void* key, unsigned long long) -{ - session& s (*static_cast (key)); - for (type_map::iterator i (s.map_.begin ()), e (s.map_.end ()); i != e; ++i) - i->second->mark (event); -} diff --git a/common/session/custom/session.hxx b/common/session/custom/session.hxx deleted file mode 100644 index 2d2f597..0000000 --- a/common/session/custom/session.hxx +++ /dev/null @@ -1,191 +0,0 @@ -// file : common/session/custom/session.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef SESSION_HXX -#define SESSION_HXX - -#include -#include -#include - -#include -#include - -#include // odb::object_traits -#include // odb::details::type_info_comparator - -// This custom session implementation assumes we are working with -// one database at a time. -// -class session -{ -public: - session (); - ~session (); - -private: - session (const session&); - session& operator= (const session&); - - // Session for the current thread. This can be implemented in pretty - // much any way that makes sense to the application. It can be a global - // session as we have here. In multi-threaded applications we could use - // TLS instead. - // -public: - static session* current; - - // Change tracking interface. - // -public: - // Call flush() within a transaction to apply the changes to the - // database. - // - void - flush (odb::database&); - -private: - struct object_map_base - { - virtual - ~object_map_base () {} - - // Return true if we flushed anything. - // - virtual bool - flush (odb::database&) = 0; - - virtual void - mark (unsigned short event) = 0; - }; - - enum object_state - { - tracking, // Tracking any modifications by storing the original copy. - changed, // Known to be changed. - flushed // Flushed but not yet committed/rolled back. - }; - - template - struct object_data - { - typedef typename odb::object_traits::pointer_type pointer_type; - - explicit - object_data (pointer_type o): obj (o), state (tracking) {} - - pointer_type obj; - pointer_type orig; - object_state state; - }; - - template - struct object_map: object_map_base, - std::map::id_type, - object_data > - { - virtual bool - flush (odb::database&); - - virtual void - mark (unsigned short event); - }; - - // Object cache interface. - // -public: - static bool - _has_cache () {return current != 0;} - - template - struct cache_position - { - typedef object_map map; - typedef typename map::iterator iterator; - - cache_position (): map_ (0) {} - cache_position (map& m, const iterator& p): map_ (&m), pos_ (p) {} - - cache_position (const cache_position& p) - : map_ (p.map_) - { - // It might not be ok to use an uninitialized iterator. - // - if (p.map_ != 0) - pos_ = p.pos_; - } - - cache_position& - operator= (const cache_position& p) - { - // It might not be ok to use an uninitialized iterator on the rhs. - // - if (p.map_ != 0) - pos_ = p.pos_; - map_ = p.map_; - return *this; - } - - map* map_; - iterator pos_; - }; - - // Cache management. - // - template - static cache_position - _cache_insert (odb::database&, - const typename odb::object_traits::id_type&, - const typename odb::object_traits::pointer_type&); - - template - static typename odb::object_traits::pointer_type - _cache_find (odb::database&, const typename odb::object_traits::id_type&); - - template - static void - _cache_erase (const cache_position& p) - { - if (p.map_ != 0) - p.map_->erase (p.pos_); - } - - // Notifications. - // - template - static void - _cache_persist (const cache_position& p) - { - _cache_load (p); - } - - template - static void - _cache_load (const cache_position&); - - template - static void - _cache_update (odb::database&, const T&); - - template - static void - _cache_erase (odb::database&, - const typename odb::object_traits::id_type&); - -private: - // Post-commit/rollback callback. - // - static void - mark (unsigned short event, void* key, unsigned long long); - -private: - typedef std::map, - odb::details::type_info_comparator> type_map; - type_map map_; - odb::transaction* tran_; -}; - -#include "session.txx" - -#endif // SESSION_HXX diff --git a/common/session/custom/session.txx b/common/session/custom/session.txx deleted file mode 100644 index 65ab933..0000000 --- a/common/session/custom/session.txx +++ /dev/null @@ -1,159 +0,0 @@ -// file : common/session/custom/session.txx -// license : GNU GPL v2; see accompanying LICENSE file - -#include - -template -typename session::cache_position session:: -_cache_insert (odb::database&, - const typename odb::object_traits::id_type& id, - const typename odb::object_traits::pointer_type& obj) -{ - if (current == 0) - return cache_position (); // No session, return empty position. - - std::shared_ptr& pm (current->map_[&typeid (T)]); - - if (!pm) - pm.reset (new object_map); - - object_map& m (static_cast&> (*pm)); - - typename object_map::value_type vt (id, object_data (obj)); - std::pair::iterator, bool> r (m.insert (vt)); - - // We shall never try to re-insert the same object into the cache. - // - assert (r.second); - - return cache_position (m, r.first); -} - -template -typename odb::object_traits::pointer_type session:: -_cache_find (odb::database&, const typename odb::object_traits::id_type& id) -{ - typedef typename odb::object_traits::pointer_type pointer_type; - - if (current == 0) - return pointer_type (); // No session, return NULL pointer. - - type_map::const_iterator ti (current->map_.find (&typeid (T))); - - if (ti == current->map_.end ()) - return pointer_type (); - - const object_map& m (static_cast&> (*ti->second)); - typename object_map::const_iterator oi (m.find (id)); - - if (oi == m.end ()) - return pointer_type (); - - return oi->second.obj; -} - -template -void session:: -_cache_load (const cache_position& p) -{ - typedef typename odb::object_traits::pointer_type pointer_type; - - if (p.map_ == 0) - return; // Empty position. - - // Make a copy for change tracking. If our object model had a - // polymorphic hierarchy, then we would have had to use a - // virtual function-based mechanism (e.g., clone()) instead of - // the copy constructor since for a polymorphic hierarchy all - // the derived objects are stored as pointers to the root object. - // - p.pos_->second.orig = pointer_type (new T (*p.pos_->second.obj)); -} - -template -void session:: -_cache_update (odb::database&, const T& obj) -{ - typedef odb::object_traits object_traits; - typedef typename object_traits::pointer_type pointer_type; - - if (current == 0) - return; // No session. - - // User explicitly updated the object by calling database::update(). - // Change the state to flushed and reset the original copy (we are - // still tracking changes after the update). - // - type_map::iterator ti (current->map_.find (&typeid (T))); - - if (ti == current->map_.end ()) - return; // This object is not in the session. - - object_map& m (static_cast&> (*ti->second)); - typename object_map::iterator oi (m.find (object_traits::id (obj))); - - if (oi == m.end ()) - return; // This object is not in the session. - - object_data& d (oi->second); - d.orig = pointer_type (new T (*d.obj)); - d.state = flushed; -} - -template -void session:: -_cache_erase (odb::database&, - const typename odb::object_traits::id_type& id) -{ - if (current == 0) - return; // No session. - - type_map::iterator ti (current->map_.find (&typeid (T))); - - if (ti == current->map_.end ()) - return; - - object_map& m (static_cast&> (*ti->second)); - typename object_map::iterator oi (m.find (id)); - - if (oi == m.end ()) - return; - - m.erase (oi); - - if (m.empty ()) - current->map_.erase (ti); -} - -template -bool session::object_map:: -flush (odb::database& db) -{ - bool r (false); - for (typename object_map::iterator i (this->begin ()), e (this->end ()); - i != e; ++i) - { - object_data& d (i->second); - - if (d.state == changed || d.obj->changed (*d.orig)) - db.update (d.obj); // State changed by the update() notification. - - r = r || d.state == flushed; - } - - return r; -} - -template -void session::object_map:: -mark (unsigned short event) -{ - for (typename object_map::iterator i (this->begin ()), e (this->end ()); - i != e; ++i) - { - object_data& d (i->second); - - if (d.state == flushed) - d.state = event == odb::transaction::event_commit ? tracking : changed; - } -} diff --git a/common/session/custom/test.hxx b/common/session/custom/test.hxx deleted file mode 100644 index 3f2703f..0000000 --- a/common/session/custom/test.hxx +++ /dev/null @@ -1,118 +0,0 @@ -// file : common/session/custom/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include - -#include -#include - -class employee; - -#pragma db object pointer(std::shared_ptr) session -class employer -{ -public: - employer (const std::string& name, const std::string& symbol) - : name_ (name), symbol_ (symbol) {} - - const std::string& - name () const {return name_;} - - const std::string& - symbol () const {return symbol_;} - - void - symbol (const std::string& symbol) {symbol_ = symbol;} - - // Employees of this employer. - // - typedef std::vector> employees_type; - - const employees_type& - employees () const {return employees_;} - - employees_type& - employees () {return employees_;} - - // Change tracking. - // -public: - bool - changed (const employer& orig) const - { - // Note that we don't need to track object ids, inverse pointers, nor - // readonly/const data members. - // - return symbol_ != orig.symbol_; - } - -private: - friend class odb::access; - employer () {} - - #pragma db id - std::string name_; - - std::string symbol_; - - #pragma db value_not_null inverse(employer_) - employees_type employees_; -}; - -#pragma db object pointer(std::shared_ptr) session -class employee -{ -public: - typedef ::employer employer_type; - - employee (const std::string& first, - const std::string& last, - std::shared_ptr employer) - : first_ (first), last_ (last), employer_ (employer) {} - - // Name. - // - const std::string& - first () const {return first_;} - - const std::string& - last () const {return last_;} - - // Employer. - // - std::shared_ptr - employer () const {return employer_;} - - void - employer (std::shared_ptr e) {employer_ = e;} - - // Change tracking. - // -public: - bool - changed (const employee& orig) const - { - return first_ != orig.first_ || last_ != orig.last_ || - employer_ != orig.employer_; - } - -private: - friend class odb::access; - employee () {} - - #pragma db id auto - unsigned long id_; - - std::string first_; - std::string last_; - - #pragma db not_null - std::shared_ptr employer_; -}; - -#endif // TEST_HXX diff --git a/common/session/custom/testscript b/common/session/custom/testscript deleted file mode 100644 index 39c281d..0000000 --- a/common/session/custom/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/session/custom/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/statement/processing/buildfile b/common/statement/processing/buildfile deleted file mode 100644 index 97124e8..0000000 --- a/common/statement/processing/buildfile +++ /dev/null @@ -1,8 +0,0 @@ -# file : common/statement/processing/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libs = libodb%lib{odb} - -exe{driver}: {hxx cxx}{*} $libs testscript - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/common/statement/processing/driver.cxx b/common/statement/processing/driver.cxx deleted file mode 100644 index 2d00107..0000000 --- a/common/statement/processing/driver.cxx +++ /dev/null @@ -1,619 +0,0 @@ -// file : common/statement/processing/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test internal statement processing machinery. -// - -#include -#include - -#include - -#undef NDEBUG -#include - -using namespace std; - -static bool -insert (const char* stmt, - const char* expected, - const void* const* bind, - size_t bind_size) -{ - string r; - odb::statement::process_insert ( - r, stmt, bind, bind_size, sizeof (void*), '$'); - return r == expected; -} - -static bool -update (const char* stmt, - const char* expected, - const void* const* bind, - size_t bind_size) -{ - string r; - odb::statement::process_update ( - r, stmt, bind, bind_size, sizeof (void*), '$'); - return r == expected; -} - -static bool -select (const char* stmt, - const char* expected, - const void* const* bind, - size_t bind_size) -{ - string r; - odb::statement::process_select ( - r, stmt, bind, bind_size, sizeof (void*), '[', ']', true); - return r == expected; -} - -int -main (int, char* argv[]) -{ - // - // INSERT - // - - // Fast path. - // - { - void* b[] = {argv, argv}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b])\n" - "VALUES\n" - "(DEFAULT,\n$1)", - "INSERT INTO [foo] ([a], [b]) VALUES (DEFAULT, $1)", - b, 2)); - } - - // Empty via statement. - // - /* LIBODB_DEBUG_STATEMENT_PROCESSING - { - assert (insert ("INSERT INTO [foo]\n" - "DEFAULT VALUES", - "INSERT INTO [foo] DEFAULT VALUES", - 0, 0)); - } - */ - - // Empty via bind. - // - { - void* b[] = {0}; - assert (insert ("INSERT INTO [foo]\n" - "([a])\n" - "VALUES\n" - "($1)", - "INSERT INTO [foo] DEFAULT VALUES", - b, 1)); - } - - // Empty with OUTPUT. - // - { - void* b[] = {0, 0}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b])\n" - "OUTPUT INSERTED.[id]\n" - "VALUES\n" - "($1,\n$2)", - "INSERT INTO [foo] OUTPUT INSERTED.[id] DEFAULT VALUES", - b, 2)); - } - - // Empty with RETURNING. - // - { - void* b[] = {0, 0, 0}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b],\n[c])\n" - "VALUES\n" - "($1,\n$1,\n$2)\n" - "RETURNING [id]", - "INSERT INTO [foo] DEFAULT VALUES RETURNING [id]", - b, 3)); - } - - // Empty via bind, but not values. - // - { - void* b[] = {0}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b])\n" - "VALUES\n" - "(1,\n$1)", - "INSERT INTO [foo] ([a]) VALUES (1)", - b, 1)); - } - - // Empty via bind, but not values. - // - { - void* b[] = {0}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b],\n[c])\n" - "VALUES\n" - "(1,\n$1,\nDEFAULT)", - "INSERT INTO [foo] ([a], [c]) VALUES (1, DEFAULT)", - b, 1)); - } - - // First not present. - // - { - void* b[] = {0, argv, argv}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b],\n[c])\n" - "VALUES\n" - "($1,\n$2,\n$3)", - "INSERT INTO [foo] ([b], [c]) VALUES ($2, $3)", - b, 3)); - } - - // Last not present. - // - { - void* b[] = {argv, argv, 0}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b],\n[c])\n" - "VALUES\n" - "($1,\n$2,\n$3)", - "INSERT INTO [foo] ([a], [b]) VALUES ($1, $2)", - b, 3)); - } - - // Middle not present. - // - { - void* b[] = {argv, 0, argv}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b],\n[c])\n" - "VALUES\n" - "($1,\n$2,\n$3)", - "INSERT INTO [foo] ([a], [c]) VALUES ($1, $3)", - b, 3)); - } - - // Multiple not present. - // - { - void* b[] = {0, argv, 0, argv, 0}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b],\n[c],\n[d],\n[e])\n" - "VALUES\n" - "($1,\n$2,\n$3,\n$4,\n$5)", - "INSERT INTO [foo] ([b], [d]) VALUES ($2, $4)", - b, 5)); - } - - // Not present and OUTPUT. - // - { - void* b[] = {argv, 0, argv}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b],\n[c])\n" - "OUTPUT INSERTED.[id]\n" - "VALUES\n" - "($1,\n$2,\n$3)", - "INSERT INTO [foo] ([a], [c]) OUTPUT INSERTED.[id] " - "VALUES ($1, $3)", - b, 3)); - } - - // Not present and RETURNING. - // - { - void* b[] = {argv, 0, argv}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b],\n[c])\n" - "VALUES\n" - "($1,\n$2,\n$3)\n" - "RETURNING [id]", - "INSERT INTO [foo] ([a], [c]) VALUES ($1, $3) " - "RETURNING [id]", - b, 3)); - } - - // Value expressions. - // - { - void* b[] = {argv, argv, argv}; - assert (insert ("INSERT INTO [foo]\n" - "([a],\n[b],\n[c])\n" - "VALUES\n" - "($1,\nCAST($2, TEXT),\n$3)", - "INSERT INTO [foo] ([a], [b], [c]) " - "VALUES ($1, CAST($2, TEXT), $3)", - b, 3)); - } - - // - // UPDATE - // - - // Fast path. - // - { - void* b[] = {argv, argv}; - assert (update ("UPDATE [foo]\n" - "SET\n" - "ver=ver+1,\n[a]=$1\n" - "WHERE [id]=$2", - "UPDATE [foo] SET ver=ver+1, [a]=$1 WHERE [id]=$2", - b, 2)); - } - - // Empty via bind. - // - { - void* b[] = {0, argv}; - assert (update ("UPDATE [foo]\n" - "SET\n" - "[a]=$1\n" - "WHERE [id]=$2", - "", - b, 2)); - } - - // Empty via bind, but not values. - // - { - void* b[] = {0, argv}; - assert (update ("UPDATE [foo]\n" - "SET\n" - "ver=ver+1,\n[a]=$1\n" - "WHERE [id]=$2", - "UPDATE [foo] SET ver=ver+1 WHERE [id]=$2", - b, 2)); - } - - // First not present. - // - { - void* b[] = {0, argv, argv, argv}; - assert (update ("UPDATE [foo]\n" - "SET\n" - "[a]=$1,\n" - "[b]=$2,\n" - "[c]=$3\n" - "WHERE [id]=$4", - "UPDATE [foo] SET [b]=$2, [c]=$3 WHERE [id]=$4", - b, 4)); - } - - // Last not present. - // - { - void* b[] = {argv, argv, 0, argv}; - assert (update ("UPDATE [foo]\n" - "SET\n" - "[a]=$1,\n" - "[b]=$2,\n" - "[c]=$3\n" - "WHERE [id]=$4", - "UPDATE [foo] SET [a]=$1, [b]=$2 WHERE [id]=$4", - b, 4)); - } - - // Middle not present. - // - { - void* b[] = {argv, 0, argv, argv}; - assert (update ("UPDATE [foo]\n" - "SET\n" - "[a]=$1,\n" - "[b]=$2,\n" - "[c]=$3\n" - "WHERE [id]=$4", - "UPDATE [foo] SET [a]=$1, [c]=$3 WHERE [id]=$4", - b, 4)); - } - - // Multiple not present. - // - { - void* b[] = {0, argv, 0, argv, argv}; - assert (update ("UPDATE [foo]\n" - "SET\n" - "[a]=$1,\n" - "[b]=$2,\n" - "[c]=$3,\n" - "[d]=$4\n" - "WHERE [id]=$5", - "UPDATE [foo] SET [b]=$2, [d]=$4 WHERE [id]=$5", - b, 5)); - } - - // Not present and OUTPUT. - // - { - void* b[] = {argv, 0, argv, argv}; - assert (update ("UPDATE [foo]\n" - "SET\n" - "[a]=$1,\n" - "[b]=$2,\n" - "[c]=$3\n" - "OUTPUT INSERTED.[ver] " - "WHERE [id]=$4", - "UPDATE [foo] SET [a]=$1, [c]=$3 OUTPUT INSERTED.[ver] " - "WHERE [id]=$4", - b, 4)); - } - - // Value expressions. - // - { - void* b[] = {argv, argv, argv, argv}; - assert (update ("UPDATE [foo]\n" - "SET\n" - "[a]=$1,\n" - "[b]=CAST($2, TEXT),\n" - "[c]=$3\n" - "WHERE [id]=$4", - "UPDATE [foo] SET [a]=$1, [b]=CAST($2, TEXT), [c]=$3 " - "WHERE [id]=$4", - b, 4)); - } - - // No OUTPUT/WHERE clause. - // - { - void* b[] = {argv, 0, argv}; - assert (update ("UPDATE [foo]\n" - "SET\n" - "[a]=$1,\n" - "[b]=$2,\n" - "[c]=$3", - "UPDATE [foo] SET [a]=$1, [c]=$3", - b, 4)); - } - - // - // SELECT - // - - // Empty. - // - { - void* b[] = {0, 0, 0}; - assert (select ("SELECT\n" - "[a].[x],\n" - "[t].[y],\n" - "[t].[z]\n" - "FROM [t]\n" - "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" - "WHERE [t].[id]=$1", - "", - b, 3)); - } - - // Fast path. - // - { - void* b[] = {argv, argv}; - assert (select ("SELECT\n" - "[s].[t].[x],\n" - "[a].[y]\n" - "FROM [s].[t]\n" - "LEFT JOIN [t1] AS [a] ON [a].[id]=[s].[t].[id]\n" - "WHERE [s].[t].[id]=$1", - "SELECT [s].[t].[x], [a].[y] FROM [s].[t] " - "LEFT JOIN [t1] AS [a] ON [a].[id]=[s].[t].[id] " - "WHERE [s].[t].[id]=$1", - b, 2)); - } - - // First not present. - // - { - void* b[] = {0, argv, argv}; - assert (select ("SELECT\n" - "[a].[x],\n" - "[t].[y],\n" - "[t].[z]\n" - "FROM [t]\n" - "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" - "WHERE [t].[id]=$1", - "SELECT [t].[y], [t].[z] FROM [t] WHERE [t].[id]=$1", - b, 3)); - } - - // Last not present. - // - { - void* b[] = {argv, argv, 0}; - assert (select ("SELECT\n" - "[t].[x],\n" - "[t].[y],\n" - "[a].[z]\n" - "FROM [t]\n" - "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" - "WHERE [t].[id]=$1", - "SELECT [t].[x], [t].[y] FROM [t] WHERE [t].[id]=$1", - b, 3)); - } - - // Middle not present. - // - { - void* b[] = {argv, 0, argv}; - assert (select ("SELECT\n" - "[t].[x],\n" - "[a].[y],\n" - "[t].[z]\n" - "FROM [t]\n" - "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" - "WHERE [t].[id]=$1", - "SELECT [t].[x], [t].[z] FROM [t] WHERE [t].[id]=$1", - b, 3)); - } - - // Multiple not present. - // - { - void* b[] = {0, argv, 0, argv}; - assert (select ("SELECT\n" - "[a1].[w],\n" - "[t].[x],\n" - "[a2].[y],\n" - "[a3].[z]\n" - "FROM [t]\n" - "LEFT JOIN [t1] AS [a1] ON [a1].[id]=[t].[id]\n" - "LEFT JOIN [t2] AS [a2] ON [a2].[id]=[t].[id]\n" - "LEFT JOIN [t3] AS [a3] ON [a3].[id]=[t].[id]\n" - "WHERE [t].[id]=$1", - "SELECT [t].[x], [a3].[z] FROM [t] " - "LEFT JOIN [t3] AS [a3] ON [a3].[id]=[t].[id] " - "WHERE [t].[id]=$1", - b, 4)); - } - - // Column expression. - // - { - void* b[] = {argv, argv, 0}; - assert (select ("SELECT\n" - "[t].[x],\n" - "CAST([a].[y], TEXT),\n" - "[t].[z]\n" - "FROM [t]\n" - "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" - "WHERE [t].[id]=$1", - "SELECT [t].[x], CAST([a].[y], TEXT) FROM [t] " - "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id] " - "WHERE [t].[id]=$1", - b, 3)); - } - - // No WHERE. - // - { - void* b[] = {argv, 0, argv}; - assert (select ("SELECT\n" - "[t].[x],\n" - "[t].[y],\n" - "[t].[z]\n" - "FROM [t]", - "SELECT [t].[x], [t].[z] FROM [t]", - b, 3)); - } - - // JOIN without WHERE. - // - { - void* b[] = {argv, 0, argv}; - assert (select ("SELECT\n" - "[t].[x],\n" - "[a].[y],\n" - "[t].[z]\n" - "FROM [t]\n" - "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]", - "SELECT [t].[x], [t].[z] FROM [t]", - b, 3)); - } - - // JOIN presence because of WHERE. - // - { - void* b[] = {argv, 0, argv}; - assert (select ("SELECT\n" - "[t].[x],\n" - "[a].[y],\n" - "[t].[z]\n" - "FROM [t]\n" - "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" - "WHERE [t].[id]=$1 AND [a].[id]=$2", - "SELECT [t].[x], [t].[z] FROM [t] " - "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id] " - "WHERE [t].[id]=$1 AND [a].[id]=$2", - b, 3)); - } - - - // JOIN presence because of dependent JOIN. - // - { - void* b[] = {argv, argv, argv}; - assert (select ("SELECT\n" - "[t].[x],\n" - "[a_b].[y],\n" - "[t].[z]\n" - "FROM [t]\n" - "LEFT JOIN [d] AS [a_d] ON [a_d].[id]=[t].[id]\n" - "LEFT JOIN [b] AS [a_b] ON [a_b].[id]=[a_d].[id]\n" - "WHERE [t].[id]=$1", - "SELECT [t].[x], [a_b].[y], [t].[z] FROM [t] " - "LEFT JOIN [d] AS [a_d] ON [a_d].[id]=[t].[id] " - "LEFT JOIN [b] AS [a_b] ON [a_b].[id]=[a_d].[id] " - "WHERE [t].[id]=$1", - b, 3)); - } - - // JOIN without alias and with schema. - // - { - void* b[] = {argv, argv, argv}; - assert (select ("SELECT\n" - "[t].[x],\n" - "[s].[t1].[y],\n" - "[t2].[z]\n" - "FROM [t]\n" - "LEFT JOIN [s].[t1] ON [s].[t1].[id]=[t].[id]\n" - "LEFT JOIN [t2] ON [t2].[id]=[t].[id]\n" - "WHERE [t].[id]=$1", - "SELECT [t].[x], [s].[t1].[y], [t2].[z] FROM [t] " - "LEFT JOIN [s].[t1] ON [s].[t1].[id]=[t].[id] " - "LEFT JOIN [t2] ON [t2].[id]=[t].[id] " - "WHERE [t].[id]=$1", - b, 3)); - } - - // JOIN alias top-level qualifer test. - // - { - void* b[] = {argv, 0}; - assert (select ("SELECT\n" - "[s].[a].[x],\n" - "[a].[y]\n" - "FROM [s].[a]\n" - "LEFT JOIN [t1] AS [a] ON [a].[id]=[s].[a].[id]\n" - "WHERE [s].[a].[id]=$1", - "SELECT [s].[a].[x] FROM [s].[a] WHERE [s].[a].[id]=$1", - b, 2)); - } - - // JOIN alias bottom-level qualifer test (FROM case). - // - { - void* b[] = {argv, 0}; - assert (select ("SELECT\n" - "[a].[t].[x],\n" - "[a].[y]\n" - "FROM [a].[t]\n" - "LEFT JOIN [t1] AS [a] ON [a].[id]=[a].[t].[id]\n" - "WHERE [a].[t].[id]=$1", - "SELECT [a].[t].[x] FROM [a].[t] WHERE [a].[t].[id]=$1", - b, 2)); - } - - // JOIN alias bottom-level qualifer test (LEFT JOIN case). - // - { - void* b[] = {0, argv}; - assert (select ("SELECT\n" - "[a].[y],\n" - "[a].[t2].[x]\n" - "FROM [t]\n" - "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" - "LEFT JOIN [a].[t2] ON [a].[t2].[id]=[t].[id]\n" - "WHERE [t].[id]=$1", - "SELECT [a].[t2].[x] FROM [t] " - "LEFT JOIN [a].[t2] ON [a].[t2].[id]=[t].[id] " - "WHERE [t].[id]=$1", - b, 2)); - } -} diff --git a/common/statement/processing/testscript b/common/statement/processing/testscript deleted file mode 100644 index 2460dc6..0000000 --- a/common/statement/processing/testscript +++ /dev/null @@ -1,6 +0,0 @@ -# file : common/statement/processing/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -: basics -: -$* diff --git a/common/threads/buildfile b/common/threads/buildfile deleted file mode 100644 index 53b98ec..0000000 --- a/common/threads/buildfile +++ /dev/null @@ -1,49 +0,0 @@ -# file : common/threads/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix threads_ \ - --generate-schema \ - --generate-query \ - --generate-prepared - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# While we don't call any pthread_*() functions, this appears to be needed for -# some std::thread implementations (like libstdc++). Note that -# odb::details::thread inlines some std::thread API calls. -# -if ($cxx.target.class != 'windows') - cxx.libs += -pthread - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/threads/driver.cxx b/common/threads/driver.cxx deleted file mode 100644 index 1add011..0000000 --- a/common/threads/driver.cxx +++ /dev/null @@ -1,236 +0,0 @@ -// file : common/threads/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test operations in a multi-threaded environment. -// - -#include -#include // std::unique_ptr -#include // std::size_t -#include - -#include -#include - -#include -#include - -#include // DATABASE_* -#include - -#if defined(DATABASE_SQLITE) -# include -#endif - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; -namespace details = odb::details; - -const unsigned long thread_count = 24; -const unsigned long iteration_count = 30; -const unsigned long sub_iteration_count = 40; - -struct task -{ - task (database& db, unsigned long n) - : db_ (db), n_ (n) - { - } - - void* - execute () - { - try - { - for (unsigned long i (0); i < iteration_count; ++i) - { - unsigned long id ((n_ * iteration_count + i) * 3); - - object o1 (id, "first object"); - object o2 (id + 1, "second object"); - object o3 (id + 2, "third object"); - - // The following transactions may lead to deadlocks. - // - while (true) - { - try - { - transaction t (db_.begin ()); - - db_.persist (o1); - db_.persist (o2); - db_.persist (o3); - t.commit (); - break; - } - catch (const deadlock&) {} - } - - while (true) - { - try - { -#if !defined(DATABASE_SQLITE) - transaction t (db_.begin ()); -#else - // SQLite has a peculiar table locking mode (shared cache) - // which can lead to any of the transactions in this test - // deadlocking even though they shouldn't from the user's - // perspective. One way to work around this problem is to - // start a "write" transaction as such right away. - // - transaction t; - - if (db_.id () != odb::id_sqlite) - t.reset (db_.begin ()); - else - { - t.reset ( - static_cast (db_).begin_immediate ()); - } -#endif - unique_ptr o (db_.load (id)); - assert (o->str_ == "first object"); - o->str_ = "another value"; - db_.update (*o); - t.commit (); - break; - } - catch (const deadlock&) {} - } - - for (unsigned long j (0); j < sub_iteration_count; ++j) - { - typedef odb::query query; - typedef odb::prepared_query prep_query; - typedef odb::result result; - - while (true) - { - try - { - transaction t (db_.begin ()); - - prep_query pq (db_.lookup_query ("object-query")); - - if (!pq) - { - pq = db_.prepare_query ( - "object-query", query::str == "another value"); - db_.cache_query (pq); - } - - result r (pq.execute (false)); - - bool found (false); - for (result::iterator i (r.begin ()); i != r.end (); ++i) - { - if (i->id_ == id) - { - found = true; - break; - } - } - assert (found); - t.commit (); - break; - } - catch (const deadlock&) {} - } - } - - while (true) - { - try - { - transaction t (db_.begin ()); - db_.erase (id); - t.commit (); - break; - } - catch (const deadlock&) {} - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return reinterpret_cast (1); - } - - return 0; - } - - static void* - execute (void* arg) - { - return static_cast (arg)->execute (); - } - - database& db_; - unsigned long n_; -}; - -bool -test (int argc, char* argv[], size_t max_connections) -{ - unique_ptr db (create_database (argc, argv, true, max_connections)); - - vector > threads; - vector > tasks; - - for (unsigned long i (0); i < thread_count; ++i) - { - details::shared_ptr t (new (details::shared) task (*db, i)); - tasks.push_back (t); - - threads.push_back ( - details::shared_ptr ( - new (details::shared) details::thread (&task::execute, t.get ()))); - } - - bool r (true); - - for (unsigned long i (0); i < thread_count; ++i) - if (threads[i]->join () != 0) - r = false; - - { - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query ()); - - for (result::iterator i (r.begin ()); i != r.end (); ++i) - db->erase (i->id_); - - t.commit (); - } - - return r; -} - -int -main (int argc, char* argv[]) -{ - try - { - if (!(test (argc, argv, 0) && - test (argc, argv, thread_count - 1) && - test (argc, argv, thread_count / 2) && - test (argc, argv, thread_count / 4))) - return 1; - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/threads/test.hxx b/common/threads/test.hxx deleted file mode 100644 index 2ed6e67..0000000 --- a/common/threads/test.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// file : common/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object -struct object -{ - object (unsigned long id, const std::string& str) - : id_ (id), str_ (str) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; - - std::string str_; -}; - -#endif // TEST_HXX diff --git a/common/threads/testscript b/common/threads/testscript deleted file mode 100644 index 87e03e0..0000000 --- a/common/threads/testscript +++ /dev/null @@ -1,50 +0,0 @@ -# file : common/threads/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - # Note: this is quite slow: - # - # $ time ./driver --database ~/odb-test.db - # real 3m5.593s - # user 1m1.244s - # sys 0m26.793s - # - # $ time ./driver --database /tmp/odb-test.db - # real 0m13.909s - # user 0m16.724s - # sys 0m4.874s - # - # $ time ./driver --database "file::memory:" - # real 0m12.406s - # user 0m15.694s - # sys 0m4.207s - # - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/transaction/basics/buildfile b/common/transaction/basics/buildfile deleted file mode 100644 index f412235..0000000 --- a/common/transaction/basics/buildfile +++ /dev/null @@ -1,13 +0,0 @@ -# file : common/transaction/basics/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libs = libodb%lib{odb} -import libs += lib{common} - -exe{driver}: {hxx cxx}{*} $libs testscript - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/transaction/basics/driver.cxx b/common/transaction/basics/driver.cxx deleted file mode 100644 index 1833555..0000000 --- a/common/transaction/basics/driver.cxx +++ /dev/null @@ -1,151 +0,0 @@ -// file : common/transaction/basics/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test basic transaction operations. -// - -#include -#include // std::unique_ptr -#include - -#include -#include -#include -#include -#include - -#include -#include - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -struct transaction_tracer: odb::tracer -{ - virtual void - execute (connection&, const char* s) - { - string str (s); - - if (str == "BEGIN") - cout << "begin transaction" << endl; - else if (str == "COMMIT") - cout << "commit transaction" << endl; - else if (str == "ROLLBACK") - cout << "rollback transaction" << endl; - } - - // Override the other version to get rid of a Sun CC warning. - // - virtual void - execute (connection& c, const statement& s) - { - execute (c, s.text ()); - } -}; - -int -main (int argc, char* argv[]) -{ - { - transaction_tracer tracer; - unique_ptr db (create_database (argc, argv, false)); - db->tracer (tracer); - - assert (!transaction::has_current ()); - - // Current and db accessors. - // - cout << "test 001" << endl; - { - transaction t (db->begin ()); - assert (&t.database () == db.get ()); - assert (transaction::has_current ()); - assert (&transaction::current () == &t); - - transaction::reset_current (); - assert (!transaction::has_current ()); - - transaction t2 (db->begin (), false); - assert (!transaction::has_current ()); - - transaction::current (t2); - assert (&transaction::current () == &t2); - } - - // Commit. - // - cout << "test 002" << endl; - { - transaction t (db->begin ()); - t.commit (); - } - - // Rollback. - // - cout << "test 003" << endl; - { - transaction t (db->begin ()); - t.rollback (); - } - - // Auto rollback. - // - cout << "test 004" << endl; - { - transaction t (db->begin ()); - } - - // Nested transaction. - // - cout << "test 005" << endl; - { - transaction t (db->begin ()); - - try - { - transaction n (db->begin ()); - } - catch (const already_in_transaction&) - { - cout << "already_in_transaction" << endl; - } - } - - // Concrete transaction type. - // - cout << "test 006" << endl; - { - assert (sizeof (odb_db::transaction) == sizeof (transaction)); - - odb_db::transaction t (static_cast (*db).begin ()); - odb_db::transaction& r (odb_db::transaction::current ()); - assert (&t == &r); - } - - // Transaction restart. - // - cout << "test 007" << endl; - { - transaction t (db->begin ()); - t.commit (); - t.reset (db->begin ()); - t.commit (); - } - } - - // Test early connection release. - // - { - unique_ptr db (create_database (argc, argv, false, 1)); - transaction t1 (db->begin ()); - t1.commit (); - transaction t2 (db->begin ()); - t2.rollback (); - transaction t3 (db->begin ()); - t3.commit (); - } -} diff --git a/common/transaction/basics/testscript b/common/transaction/basics/testscript deleted file mode 100644 index 94c58b6..0000000 --- a/common/transaction/basics/testscript +++ /dev/null @@ -1,62 +0,0 @@ -# file : common/transaction/basics/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -+cat <=output - test 001 - begin transaction - begin transaction - rollback transaction - rollback transaction - test 002 - begin transaction - commit transaction - test 003 - begin transaction - rollback transaction - test 004 - begin transaction - rollback transaction - test 005 - begin transaction - already_in_transaction - rollback transaction - test 006 - begin transaction - rollback transaction - test 007 - begin transaction - commit transaction - begin transaction - commit transaction - EOI - -test.redirects += >>>../output - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $* -} diff --git a/common/transaction/callback/buildfile b/common/transaction/callback/buildfile deleted file mode 100644 index 78b1b03..0000000 --- a/common/transaction/callback/buildfile +++ /dev/null @@ -1,13 +0,0 @@ -# file : common/transaction/callback/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libs = libodb%lib{odb} -import libs += lib{common} - -exe{driver}: {hxx cxx}{*} $libs testscript - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/transaction/callback/driver.cxx b/common/transaction/callback/driver.cxx deleted file mode 100644 index d0af993..0000000 --- a/common/transaction/callback/driver.cxx +++ /dev/null @@ -1,231 +0,0 @@ -// file : common/transaction/callback/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test transaction callbacks. -// - -#include // std::unique_ptr -#include // std::size_t -#include - -#include -#include - -#include - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -struct callback -{ - callback (unsigned short v): v_ (v), t_ (0) {} - callback (unsigned short v, transaction& t): v_ (v), t_ (0) {register_ (t);} - ~callback () {if (t_ != 0) unregister ();} - - void - register_ (transaction& t) - { - t_ = &t; - t.callback_register (&func, this, transaction::event_all, v_, &t_); - } - - void - unregister () - { - cout << " unregister callback " << v_ << endl; - t_->callback_unregister (this); - t_ = 0; - } - - void - update (unsigned short v) - { - v_ = v; - t_->callback_update (this, transaction::event_all, v_, &t_); - } - -private: - static void - func (unsigned short event, void* key, unsigned long long data) - { - callback& c (*static_cast (key)); - - const char* en; - switch (event) - { - case transaction::event_commit: - en = "commit"; - break; - case transaction::event_rollback: - en = "rollback"; - break; - default: - en = "unknown"; - } - - cout << " callback " << c.v_ << " " << en << endl; - - assert (data == c.v_); - assert (c.t_ == 0); - } - - unsigned short v_; - transaction* t_; -}; - -struct failed {}; - -static void -throw_func (unsigned short, void*, unsigned long long) -{ - throw failed (); -} - -static void -dummy_func (unsigned short, void* key, unsigned long long data) -{ - assert (reinterpret_cast (key) == data); -} - -static void -fill (transaction& t) -{ - // 20 is from odb/transaction.hxx. - // - for (size_t i (0); i < 20; ++i) - t.callback_register (&dummy_func, - reinterpret_cast (i), - transaction::event_all, - i); -} - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv, false)); - - // We want to test both stack and dynamic slots. - // - for (unsigned short i (1); i < 3; ++i) - { - // Test basic logic. - // - cout << "test " << i << "/001" << endl; - - // Commit callback. - // - { - transaction t (db->begin ()); - if (i == 2) fill (t); - callback c1 (1, t); - t.commit (); - } - - // Rollback callback. - // - { - transaction t (db->begin ()); - if (i == 2) fill (t); - callback c1 (1, t); - t.rollback (); - } - - // Rollback via exception callback. - // - { - callback c1 (1); - - try - { - transaction t (db->begin ()); - if (i == 2) fill (t); - c1.register_ (t); - throw failed (); - } - catch (const failed&) - { - } - } - - // Unregister callback at the end. - // - { - transaction t (db->begin ()); - if (i == 2) fill (t); - callback c1 (1, t); - c1.unregister (); - t.callback_unregister (&c1); // Test unregistering non-registered key. - t.commit (); - } - - { - transaction t (db->begin ()); - if (i == 2) fill (t); - callback c1 (1, t); - c1.unregister (); - callback c2 (2, t); - t.commit (); - } - - // Unregister callback in the middle. - // - cout << "test " << i << "/002" << endl; - { - transaction t (db->begin ()); - if (i == 2) fill (t); - callback c1 (1, t); - callback c2 (2, t); - callback c3 (3, t); - c2.unregister (); - t.commit (); - } - - { - transaction t (db->begin ()); - if (i == 2) fill (t); - callback c1 (1, t); - callback c2 (2, t); - callback c3 (3, t); - c2.unregister (); - callback c4 (4, t); // Using the free slot. - t.commit (); - } - - // Test a callback in the middle that throws. - // - cout << "test " << i << "/003" << endl; - try - { - transaction t (db->begin ()); - if (i == 2) fill (t); - callback c1 (1, t); - t.callback_register (&throw_func, 0); - callback c2 (2, t); - t.commit (); - } - catch (const failed&) - { - } - - // Test callback_update(). - // - { - transaction t (db->begin ()); - if (i == 2) fill (t); - callback c (1, t); - c.update (2); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/transaction/callback/testscript b/common/transaction/callback/testscript deleted file mode 100644 index 7229ecd..0000000 --- a/common/transaction/callback/testscript +++ /dev/null @@ -1,72 +0,0 @@ -# file : common/transaction/callback/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -+cat <=output - test 1/001 - callback 1 commit - callback 1 rollback - callback 1 rollback - unregister callback 1 - unregister callback 1 - callback 2 commit - test 1/002 - unregister callback 2 - callback 1 commit - callback 3 commit - unregister callback 2 - callback 1 commit - callback 4 commit - callback 3 commit - test 1/003 - callback 1 commit - callback 2 commit - test 2/001 - callback 1 commit - callback 1 rollback - callback 1 rollback - unregister callback 1 - unregister callback 1 - callback 2 commit - test 2/002 - unregister callback 2 - callback 1 commit - callback 3 commit - unregister callback 2 - callback 1 commit - callback 4 commit - callback 3 commit - test 2/003 - callback 1 commit - callback 2 commit - EOI - -test.redirects += >>>../output - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $* -} diff --git a/common/types/buildfile b/common/types/buildfile deleted file mode 100644 index 95fe5b6..0000000 --- a/common/types/buildfile +++ /dev/null @@ -1,39 +0,0 @@ -# file : common/types/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix types_ - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/types/driver.cxx b/common/types/driver.cxx deleted file mode 100644 index bdc66b8..0000000 --- a/common/types/driver.cxx +++ /dev/null @@ -1,37 +0,0 @@ -// file : common/types/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test C++ type handling (anonymous types, aliasing). -// - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -template -struct same_p -{ - static const bool result = false; -}; - -template -struct same_p -{ - static const bool result = true; -}; - -int -main () -{ - assert ((same_p::id_type, int>::result)); -} diff --git a/common/types/test.hxx b/common/types/test.hxx deleted file mode 100644 index a99b499..0000000 --- a/common/types/test.hxx +++ /dev/null @@ -1,55 +0,0 @@ -// file : common/types/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#ifdef ODB_COMPILER -typedef int int_t; -typedef short num_t; -#else -typedef int num_t; -#endif - -typedef num_t num_type; - -#pragma db object -struct object1 -{ - typedef int int_type; - - #pragma db id - int_type id_; -}; - -#pragma db object -struct object2 -{ - #pragma db id - num_type num_; -}; - -// Template-id with "inner" name (compilation test). -// -template -struct num_wrap -{ -#ifdef ODB_COMPILER - typedef num_wrap this_type; // Name that we should not use. -#endif - - num_wrap () {} - num_wrap (X v): v_ (v) {} - operator X () const {return v_;} - - X v_; -}; - -#pragma db object -struct object3 -{ - #pragma db id type("INTEGER") - num_wrap num_; // Use long long to avoid warnings. -}; - -#endif // TEST_HXX diff --git a/common/types/testscript b/common/types/testscript deleted file mode 100644 index 159972b..0000000 --- a/common/types/testscript +++ /dev/null @@ -1,6 +0,0 @@ -# file : common/types/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -: basic -: -$* diff --git a/common/view/basics/buildfile b/common/view/basics/buildfile deleted file mode 100644 index d9738a4..0000000 --- a/common/view/basics/buildfile +++ /dev/null @@ -1,42 +0,0 @@ -# file : common/view/basics/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_view_b_ \ - --generate-schema \ - --generate-query \ - --generate-prepared - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/view/basics/driver.cxx b/common/view/basics/driver.cxx deleted file mode 100644 index e2f611a..0000000 --- a/common/view/basics/driver.cxx +++ /dev/null @@ -1,846 +0,0 @@ -// file : common/view/basics/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test view basics. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include -#include // DATABASE_XXX - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -template -void -view1_check (odb::result& r) -{ - typedef odb::result result; - - typename result::iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->first == "Jane" && i->last == "Doe" && i->age == 29); - - assert (++i != r.end ()); - V v; - i.load (v); - assert (v.first == "John" && v.last == "Doe" && v.age == 30); - - assert (++i == r.end ()); -} - -template -void -view2_test (const unique_ptr& db) -{ - typedef odb::query query; - typedef odb::result result; - typedef typename result::iterator iterator; - - transaction t (db->begin ()); - - { - result r (db->query ()); - iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->count == 4); - } - - { - result r; - if (db->id () != odb::id_oracle) - r = db->query ("age < 31"); - else - r = db->query ("\"age\" < 31"); - - iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->count == 2); - } - - { - result r (db->query (query::age < 31)); - iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->count == 2); - } - - { - unique_ptr v (db->query_one ()); - assert (v->count == 4); - } - - { - unique_ptr v; - if (db->id () != odb::id_oracle) - v.reset (db->query_one ("age < 31")); - else - v.reset (db->query_one ("\"age\" < 31")); - assert (v->count == 2); - } - - { - unique_ptr v (db->query_one (query::age < 31)); - assert (v->count == 2); - } - - t.commit (); -} - -template -void -view4_test (const unique_ptr& db) -{ - typedef odb::query query; - typedef odb::result result; - typedef typename result::iterator iterator; - - transaction t (db->begin ()); - - { - result r; - if (db->id () != odb::id_oracle) - r = db->query ((query::person::age > 30) + "ORDER BY age"); - else - r = db->query ((query::person::age > 30) + "ORDER BY \"age\""); - - iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->first_name == "Joe" && i->last_name == "Dirt" && - i->name == "United States"); - - assert (++i != r.end ()); - assert (i->first_name == "Johan" && i->last_name == "Johansen" && - i->name == "Sweden"); - - assert (++i == r.end ()); - } - - { - result r (db->query ( - (query::person::age > 30) + - "ORDER BY " + query::person::age)); - - iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->first_name == "Joe" && i->last_name == "Dirt" && - i->name == "United States"); - - assert (++i != r.end ()); - assert (i->first_name == "Johan" && i->last_name == "Johansen" && - i->name == "Sweden"); - - assert (++i == r.end ()); - } - - { - result r (db->query (query::residence::code == "US")); - - iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->first_name == "Joe" && i->last_name == "Dirt" && - i->name == "United States"); - - assert (++i == r.end ()); - } - - t.commit (); -} - -template -void -view6_test (const unique_ptr& db, const odb::query& q) -{ - typedef odb::result result; - typedef typename result::iterator iterator; - - transaction t (db->begin ()); - - { - result r (db->query (q)); - - iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->first_name == "John" && i->last_name == "Doe" && - i->employer == "Simple Tech, Inc"); - - assert (++i != r.end ()); - assert (i->first_name == "Joe" && i->last_name == "Dirt" && - i->employer == "Simple Tech, Inc"); - - assert (++i == r.end ()); - } - - t.commit (); -} - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // - // - { - country ca ("CA", "Canada"); - country za ("ZA", "South Africa"); - country us ("US", "United States"); - country se ("SE", "Sweden"); - - person p1 (1, "John", "Doe", 30, male, measures (60, 160), &ca, &ca); - person p2 (2, "Jane", "Doe", 29, female, measures (70, 170), &za, &us); - person p3 (3, "Joe", "Dirt", 31, male, measures (80, 180), &us, &za); - person p4 (4, "Johan", "Johansen", 32, male, measures (90, 190), &se, - &se); - - p2.husband = &p1; - - employer st ("Simple Tech, Inc"); - employer ct ("Complex Tech, Inc"); - - p2.previous_employer = st.name; - p3.previous_employer = ct.name; - - st.employees.push_back (&p1); - st.employees.push_back (&p3); - st.head_count = 2; - - ct.employees.push_back (&p2); - ct.employees.push_back (&p4); - ct.head_count = 2; - - transaction t (db->begin ()); - db->persist (ca); - db->persist (za); - db->persist (us); - db->persist (se); - - db->persist (p1); - db->persist (p2); - db->persist (p3); - db->persist (p4); - - db->persist (st); - db->persist (ct); - t.commit (); - } - - // view1 - // - { - typedef odb::result result; - - { - transaction t (db->begin ()); - - { - result r (db->query ()); - assert (size (r) == 4); - } - - { - result r; - if (db->id () != odb::id_oracle) - r = db->query ("ORDER BY age"); - else - r = db->query ("ORDER BY \"age\""); - - assert (size (r) == 4); - } - - { - result r; - if (db->id () != odb::id_oracle) - r = db->query ("age < 31 ORDER BY age"); - else - r = db->query ("\"age\" < 31 ORDER BY \"age\""); - - view1_check (r); - } - - t.commit (); - } - } - - // view1a - // - { - typedef odb::result result; - - { - transaction t (db->begin ()); - - result r (db->query ()); - view1_check (r); - - t.commit (); - } - } - - // view1b - // - { - typedef odb::result result; - - { - transaction t (db->begin ()); - - result r (db->query ()); - view1_check (r); - - t.commit (); - } - - // No native parameter support in dynamic multi-database mode. - // -#ifndef MULTI_DATABASE - { - typedef odb::query query; - - transaction t (db->begin ()); - -#ifndef DATABASE_ORACLE - result r (db->query ("first = " + query::_val ("Jane"))); -#else - result r (db->query ("\"first\" = " + query::_val ("Jane"))); -#endif - - result::iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->first == "Jane" && i->last == "Doe"); - assert (++i == r.end ()); - - t.commit (); - } -#endif - } - - // view1c - // - { - typedef odb::result result; - - { - transaction t (db->begin ()); - - result r; - if (db->id () != odb::id_oracle) - r = db->query ("SELECT first, last, age " - "FROM t_view_b_person " - "WHERE age < 31 ORDER BY age"); - else - r = db->query ("SELECT \"first\", \"last\", \"age\" " - "FROM \"t_view_b_person\" " - "WHERE \"age\" < 31 ORDER BY \"age\""); - view1_check (r); - - t.commit (); - } - } - - // view1d - // - { - typedef odb::result result; - - { - transaction t (db->begin ()); - - { - result r; - if (db->id () != odb::id_oracle) - r = db->query ("age < 31 ORDER BY age"); - else - r = db->query ("\"age\" < 31 ORDER BY \"age\""); - - view1_check (r); - } - - t.commit (); - } - } - - // view2 - // - view2_test (db); - view2_test (db); - view2_test (db); - view2_test (db); - - // view3 - // - { - typedef odb::result result; // Test const result. - - { - transaction t (db->begin ()); - - { - result r (db->query ()); - - size_t count (0); - for (result::iterator i (r.begin ()); i != r.end (); ++i) - { - if (i->last_name == "Doe") - assert (i->count == 2); - else if (i->last_name == "Dirt" || - i->last_name == "Johansen") - assert (i->count == 1); - else - assert (false); - - count++; - } - - assert (count == 3); - } - - t.commit (); - } - } - - // view3a - // - { - typedef odb::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - { - result r (db->query (query::last_name == "Doe")); - result::iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->last_name == "Doe" && i->count == 2); - assert (++i == r.end ()); - } - - t.commit (); - } - } - - // view4 - // - view4_test (db); - view4_test (db); - - // view5 - // - { - typedef odb::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - { - result r ( - db->query ( - query::residence::name == query::nationality::name)); - - result::iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->first_name == "John" && i->last_name == "Doe" && - i->rname == "Canada" && i->rname == "Canada"); - - assert (++i != r.end ()); - assert (i->first_name == "Johan" && i->last_name == "Johansen" && - i->rname == "Sweden" && i->rname == "Sweden"); - - assert (++i == r.end ()); - } - - t.commit (); - } - } - - // view6 - // - view6_test ( - db, odb::query::employer::name == "Simple Tech, Inc"); - - view6_test ( - db, odb::query::employer::name == "Simple Tech, Inc"); - - view6_test ( - db, odb::query::employer::name == "Simple Tech, Inc"); - - // No native parameter support in dynamic multi-database mode. - // -#ifndef MULTI_DATABASE - view6_test ( -#ifndef DATABASE_ORACLE - db, "e.name = " + odb::query::_val ("Simple Tech, Inc")); -#else - db, "\"e\".\"name\" = " + odb::query::_val ("Simple Tech, Inc")); -#endif -#endif - - // view7 - // - { - typedef odb::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - { - result r (db->query (query::person::last_name == "Doe")); - - result::iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->first_name == "Jane" && i->last_name == "Doe" && - !i->head_count.null () && *i->head_count == 2); - - assert (++i != r.end ()); - assert (i->first_name == "John" && i->last_name == "Doe" && - i->head_count.null ()); - - assert (++i == r.end ()); - } - - t.commit (); - } - } - - // view8 - // - { - typedef odb::result result; - - { - transaction t (db->begin ()); - - { - result r (db->query ()); - - result::iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->wife_name == "Jane" && i->husb_name == "John"); - assert (++i == r.end ()); - } - - t.commit (); - } - } - - // view9 - // - { - typedef odb::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - { - // Test case-insensitive clause prefix detection. - // - result r (db->query ("where" + (query::gender == female))); - - result::iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->first_name == "Jane" && i->last_name == "Doe" && - i->gender == female); - assert (++i == r.end ()); - } - - t.commit (); - } - } - - // view10 - // - { - typedef odb::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - { - result r (db->query ( - query::measures.weight > 60 && - query::measures.hight < 190)); - - result::iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->last_name == "Doe" && - i->measures.weight == 70 && i->measures.hight == 170); - - assert (++i != r.end ()); - assert (i->last_name == "Dirt" && - i->measures.weight == 80 && i->measures.hight == 180); - - assert (++i == r.end ()); - } - - t.commit (); - } - } - - // view11 - // - { - typedef odb::result result; - - { - transaction t (db->begin ()); - - { - result r (db->query ()); - - result::iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->last_name == "Doe" && i->hight == 170); - - assert (++i != r.end ()); - assert (i->last_name == "Dirt" && i->hight == 180); - - assert (++i == r.end ()); - } - - t.commit (); - } - } - - // view12 - // - { - typedef odb::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - { - result r (db->query (query::last_name == "Dirt")); - - result::iterator i (r.begin ()); - - assert (i != r.end ()); - assert (i->residence == "US"); - assert (++i == r.end ()); - } - - t.commit (); - } - } - - // view13 - // - { - typedef odb::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - { - result r (db->query ( - (query::person::age < 32) + - "ORDER BY" + query::employer::name)); - - assert (size (r) == 2); - } - - t.commit (); - } - } - - // view14 - // - { - transaction t (db->begin ()); - assert (size (db->query ()) == 2); - t.commit (); - } - - // Test join types. - // - { - using namespace test2; - - { - obj1 o11 (1, 1); - obj1 o12 (2, 2); - - obj2 o21 (1, 1); - obj2 o22 (2, 1); - obj2 o23 (3, 3); - - transaction t (db->begin ()); - db->persist (o11); - db->persist (o12); - db->persist (o21); - db->persist (o22); - db->persist (o23); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query ( - "ORDER BY" + query::o1::id1 + "," + query::o2::id2)); - result::iterator i (r.begin ()); - assert ( i != r.end () && i->id1 == 1 && *i->id2 == 1); - assert (++i != r.end () && i->id1 == 1 && *i->id2 == 2); - assert (++i != r.end () && i->id1 == 2 && i->id2.null ()); - assert (++i == r.end ()); - t.commit (); - } - - // @@ BUILD2 Also disable for DATABASE_MYSQL and DATABASE_PGSQL (see - // vright definition for details). - // -#if !defined(DATABASE_MYSQL) && \ - !defined(DATABASE_SQLITE) && \ - !defined(DATABASE_PGSQL) - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query ( - "ORDER BY" + query::o1::id1 + "," + query::o2::id2)); - result::iterator i (r.begin ()); - assert ( i != r.end () && i->id1 == 1 && *i->id2 == 1); - assert (++i != r.end () && i->id1 == 1 && *i->id2 == 2); - assert (++i != r.end () && i->id1 == 2 && i->id2.null ()); - assert (++i == r.end ()); - t.commit (); - } -#endif - - // @@ BUILD2 Also disable for DATABASE_PGSQL (see vfull definition for - // details). - // -#if !defined(DATABASE_MYSQL) && \ - !defined(DATABASE_SQLITE) && \ - !defined(DATABASE_PGSQL) - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query ( - "ORDER BY" + query::o1::id1 + "," + query::o2::id2)); - result::iterator i (r.begin ()); - - // SQL Server orders NULL values first. Got to be different. - // -#ifdef DATABASE_MSSQL - assert ( i != r.end () && i->id1.null () && *i->id2 == 3); - assert (++i != r.end () && *i->id1 == 1 && *i->id2 == 1); - assert (++i != r.end () && *i->id1 == 1 && *i->id2 == 2); - assert (++i != r.end () && *i->id1 == 2 && i->id2.null ()); -#else - assert ( i != r.end () && *i->id1 == 1 && *i->id2 == 1); - assert (++i != r.end () && *i->id1 == 1 && *i->id2 == 2); - assert (++i != r.end () && *i->id1 == 2 && i->id2.null ()); - assert (++i != r.end () && i->id1.null () && *i->id2 == 3); -#endif - assert (++i == r.end ()); - t.commit (); - } -#endif - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query ( - "ORDER BY" + query::o1::id1 + "," + query::o2::id2)); - result::iterator i (r.begin ()); - assert ( i != r.end () && i->id1 == 1 && i->id2 == 1); - assert (++i != r.end () && i->id1 == 1 && i->id2 == 2); - assert (++i == r.end ()); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query ( - "ORDER BY" + query::o1::id1 + "," + query::o2::id2)); - result::iterator i (r.begin ()); - assert ( i != r.end () && i->id1 == 1 && i->id2 == 1); - assert (++i != r.end () && i->id1 == 1 && i->id2 == 2); - assert (++i != r.end () && i->id1 == 1 && i->id2 == 3); - assert (++i != r.end () && i->id1 == 2 && i->id2 == 1); - assert (++i != r.end () && i->id1 == 2 && i->id2 == 2); - assert (++i != r.end () && i->id1 == 2 && i->id2 == 3); - assert (++i == r.end ()); - t.commit (); - } - - // Inner JOIN via relationship/container. - // - { - obj3 o31 (1, 1); - obj3 o32 (2, 2); - - obj4 o41 (1, 1); - obj4 o42 (2, 2); - o42.o3.push_back (&o32); - - transaction t (db->begin ()); - db->persist (o31); - db->persist (o32); - db->persist (o41); - db->persist (o42); - t.commit (); - } - - { - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query ()); - result::iterator i (r.begin ()); - assert ( i != r.end () && i->id4 == 2); - assert (++i == r.end ()); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/view/basics/test.hxx b/common/view/basics/test.hxx deleted file mode 100644 index 130bcd4..0000000 --- a/common/view/basics/test.hxx +++ /dev/null @@ -1,640 +0,0 @@ -// file : common/view/basics/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include // std::size_t - -#include -#include - -struct employer; - -#pragma db object -struct country -{ - country (const std::string& c, const std::string& n) - : code (c), name (n) - { - } - - country () - { - } - - #pragma db id - std::string code; // ISO 2-letter country code. - - std::string name; -}; - -enum gender_type {male, female}; - -#pragma db value -struct measures -{ - measures (unsigned short w, unsigned short h) : weight (w), hight (h) {} - measures () {} - - unsigned short weight; - unsigned short hight; -}; - -#pragma db object -struct person -{ - typedef ::measures measures_type; - - person (unsigned long i, - const std::string& fn, - const std::string& ln, - unsigned short a, - gender_type g, - const measures_type m, - country* r, - country* n) - : id (i), - first_name_ (fn), - last_name_ (ln), - age (a), - gender (g), - measures (m), - residence (r), - nationality (n), - husband (0) - { - } - - person () - { - } - - #pragma db id - unsigned long id; - - #pragma db column("first") - std::string first_name_; - - #pragma db column("last") - std::string last_name_; - - unsigned short age; - - // #pragma db type("INT") - in MySQL test type pragma copying - gender_type gender; - - measures_type measures; - - #pragma db not_null - country* residence; - - #pragma db not_null - country* nationality; - - #pragma db inverse(employees) - employer* employed_by; - - // A non-pointer relationship. - // - odb::nullable previous_employer; - - person* husband; // Self-reference. -}; - -#pragma db object -struct employer -{ - employer (const std::string& n) - : name (n) - { - } - - employer () - { - } - - #pragma db id - std::string name; - unsigned int head_count; - std::vector employees; -}; - -// -// General view with no associated objects. -// - -// Complete suffix query template. -// -#ifndef ODB_DATABASE_ORACLE -# pragma db view query("SELECT first, last, age FROM t_view_b_person") -#else -# pragma db view query("SELECT \"first\", \"last\", \"age\" " \ - "FROM \"t_view_b_person\"") -#endif -struct view1 -{ - std::string first; - std::string last; - unsigned short age; -}; - -// Complete query. -// -#ifndef ODB_DATABASE_ORACLE -# pragma db view query("SELECT first, last, age " \ - "FROM t_view_b_person " \ - "WHERE age < 31 ORDER BY age") -#else -# pragma db view query("SELECT \"first\", \"last\", \"age\" " \ - "FROM \"t_view_b_person\" " \ - "WHERE \"age\" < 31 ORDER BY \"age\"") -#endif -struct view1a -{ - std::string first; - std::string last; - unsigned short age; -}; - -// Complete placeholder query template. -// -#ifndef ODB_DATABASE_ORACLE -# pragma db view query("SELECT first, last, age " \ - "FROM t_view_b_person " \ - "WHERE age < 31 AND (?) ORDER BY age") -#else -# pragma db view query("SELECT \"first\", \"last\", \"age\" " \ - "FROM \"t_view_b_person\" " \ - "WHERE \"age\" < 31 AND (?) ORDER BY \"age\"") -#endif -struct view1b -{ - std::string first; - std::string last; - unsigned short age; -}; - -// Runtime query. -// -#pragma db view //query() -struct view1c -{ - std::string first; - std::string last; - unsigned short age; -}; - -// Assembled SELECT and FROM-lists. -// -#pragma db view table("t_view_b_person") -struct view1d -{ - #pragma db column("first") - std::string first; - - #pragma db column("last") - std::string last; - - #pragma db column("age") - unsigned short age; -}; - -// -// Count view plus associated object. -// - -// Complete suffix query. -// -#ifndef ODB_DATABASE_ORACLE -# pragma db view object(person) \ - query("SELECT count(id) FROM t_view_b_person") -#else -# pragma db view object(person) \ - query("SELECT count(\"id\") FROM \"t_view_b_person\"") -#endif -struct view2 -{ - std::size_t count; -}; - -// Generated query, literal column. -// -#pragma db view object(person) -struct view2a -{ -#ifndef ODB_DATABASE_ORACLE - #pragma db column("count(id)") -#else - #pragma db column("count(\"id\")") -#endif - std::size_t count; -}; - -// Generated query, qualified literal column. -// -#pragma db view object(person) -struct view2b -{ -#ifndef ODB_DATABASE_ORACLE - #pragma db column("count(t_view_b_person.id)") -#else - #pragma db column("count(\"t_view_b_person\".\"id\")") -#endif - std::size_t count; -}; - -// Generated query, expression column. -// -#pragma db view object(person) -struct view2c -{ - #pragma db column("count(" + person::id + ")") - std::size_t count; -}; - -// -// Aggregate view plus associated object with a custom alias. -// - -// Complete suffix query. -// -#ifndef ODB_DATABASE_ORACLE -# pragma db view object(person = test) \ - query("SELECT last, count(last) " \ - "FROM t_view_b_person " \ - "GROUP BY last") -#else -# pragma db view object(person = test) \ - query("SELECT \"last\", count(\"last\") " \ - "FROM \"t_view_b_person\" " \ - "GROUP BY \"last\"") -#endif -struct view3 -{ - std::string last_name; - std::size_t count; -}; - -// Generated query with integrated query condition and placeholder. -// -#pragma db view object(person = test) \ - query((?) + "GROUP BY" + test::last_name_) -struct view3a -{ - // Automatically resolved to test::last_name_. - // - std::string last_name; - - #pragma db column("count(" + test::last_name_ + ")") - std::size_t count; -}; - -// -// JOIN view plus associated objects, some with custom aliases. -// - -// Complete suffix query. -// -#ifndef ODB_DATABASE_ORACLE -# pragma db view object(person) object(country = residence) \ - query("SELECT first, last, residence.name " \ - "FROM t_view_b_person " \ - "LEFT JOIN t_view_b_country AS residence " \ - "ON t_view_b_person.residence = residence.code") -#else -# pragma db view object(person) object(country = residence) \ - query("SELECT \"first\", \"last\", \"residence\".\"name\" " \ - "FROM \"t_view_b_person\" " \ - "LEFT JOIN \"t_view_b_country\" \"residence\" " \ - "ON \"t_view_b_person\".\"residence\" = \"residence\".\"code\"") -#endif -struct view4 -{ - std::string first_name; - std::string last_name; - std::string name; -}; - -// Generated query. -// -#pragma db view object(person) \ - object(country = residence: person::residence) -struct view4a -{ - std::string first_name; - std::string last_name; - std::string name; -}; - -// -// JOIN the same object twice. -// -#pragma db view object(person) \ - object(country = residence: person::residence) \ - object(country = nationality: person::nationality) \ - query((?) + "ORDER BY" + person::age) -struct view5 -{ - std::string first_name; - std::string last_name; - - #pragma db column(residence::name) - std::string rname; - - #pragma db column(nationality::name) - std::string nname; -}; - -// -// JOIN via one(i)-to-many relationship. -// - -// Automatic relationship discovery. -// -#pragma db view object(person) object(employer) -struct view6 -{ - std::string first_name; - std::string last_name; - - #pragma db column(::employer::name) - std::string employer; -}; - -// Manual relationship specification, left side. -// -#pragma db view object(person) object(employer: person::employed_by) -struct view6a -{ - std::string first_name; - std::string last_name; - - #pragma db column(::employer::name) - std::string employer; -}; - -// Manual relationship specification, right side. -// -#pragma db view object(person) object(employer: employer::employees) -struct view6b -{ - std::string first_name; - std::string last_name; - - #pragma db column(::employer::name) - std::string employer; -}; - -// The same using tables. -// -#if defined(ODB_DATABASE_ORACLE) -#pragma db view table("t_view_b_person" = "p") \ - table("t_view_b_employer_employees" = "ee": "\"ee\".\"value\" = \"p\".\"id\"")\ - table("t_view_b_employer" = "e": "\"ee\".\"object_id\" = \"e\".\"name\"") -#elif defined(ODB_DATABASE_MSSQL) -#pragma db view table("t_view_b_person" = "p") \ - table("t_view_b_employer_employees" = "ee": "ee.value = p.id") \ - table("t_view_b_employer" = "e": "[ee].[object_id] = e.name") -#elif defined(ODB_DATABASE_MYSQL) -#pragma db view table("t_view_b_person" = "p") \ - table("t_view_b_employer_employees" = "ee": "ee.value = p.id") \ - table("t_view_b_employer" = "e": "`ee`.`object_id` = e.name") -#else -#pragma db view table("t_view_b_person" = "p") \ - table("t_view_b_employer_employees" = "ee": "ee.value = p.id") \ - table("t_view_b_employer" = "e": "\"ee\".\"object_id\" = e.name") -#endif -struct view6c -{ - #pragma db column("p.first") - std::string first_name; - - #pragma db column("p.last") - std::string last_name; - - #pragma db column("e"."name") - std::string employer; -}; - -// -// JOIN via a custom condition. -// -#pragma db view object(person) \ - object(employer: person::previous_employer == employer::name)\ - query((?) + "ORDER BY" + person::age) -struct view7 -{ - std::string first_name; - std::string last_name; - - odb::nullable head_count; -}; - -// -// Self-JOIN. -// -#pragma db view object(person = wife) object(person = husb) \ - query (wife::husband.is_not_null ()) -struct view8 -{ - #pragma db column(wife::first_name_) - std::string wife_name; - - #pragma db column(husb::first_name_) - std::string husb_name; -}; - -// -// Enum mapping. -// -#pragma db view object(person) -struct view9 -{ - std::string first_name; - std::string last_name; - gender_type gender; -}; - -// -// Composite in view. -// -#pragma db view object(person) query((?) + "ORDER BY" + person::age) -struct view10 -{ - std::string last_name; - ::measures measures; -}; - -// -// Composite in object. -// -#pragma db view object(person) \ - query((person::measures.weight > 60 && person::measures.hight < 190 && (?)) \ - + "ORDER BY" + person::age) -struct view11 -{ - std::string last_name; - - #pragma db column(person::measures.hight) - unsigned short hight; -}; - -// -// Extract object pointer as object id. -// -#pragma db view object(person) -struct view12 -{ - std::string residence; -}; - -// -// Test 'distinct' result modifier. -// -#pragma db view object(employer) object(person) query(distinct) -struct view13 -{ - std::string name; -}; - -// -// Test 'for_update' result modifier. -// -#pragma db view object(employer) query((?), for_update) -struct view14 -{ - std::string name; -}; - -// Test join types. -// -#pragma db namespace table("t2_") -namespace test2 -{ - #pragma db object - struct obj1 - { - obj1 (int id = 0, int n_ = 0): id1 (id), n (n_) {} - - #pragma db id - int id1; - - int n; - }; - - #pragma db object no_id - struct obj2 - { - obj2 (int id = 0, int n_ = 0): id2 (id), n (n_) {} - - #pragma db id - int id2; - - int n; - }; - - #pragma db view object(obj1 = o1) object(obj2 = o2 left: o1::n == o2::n) - struct vleft - { - int id1; - odb::nullable id2; - }; - - // @@ BUILD2 Also disable for ODB_DATABASE_MYSQL and ODB_DATABASE_PGSQL, - // otherwise we end up with the following error: - // - // test-odb-mysql.hxx:3202:20: error: invalid use of incomplete type ‘class odb::access::view_traits’ - // 3202 | public access::view_traits< ::test2::vright > - // | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // -//#if !defined(ODB_DATABASE_SQLITE) && !defined(ODB_DATABASE_COMMON) -#if !defined(ODB_DATABASE_MYSQL) && \ - !defined(ODB_DATABASE_SQLITE) && \ - !defined(ODB_DATABASE_PGSQL) && \ - !defined(ODB_DATABASE_COMMON) - - #pragma db view object(obj2 = o2) object(obj1 = o1 right: o2::n == o1::n) - struct vright - { - int id1; - odb::nullable id2; - }; - -#endif - - // @@ BUILD2 Also disable for ODB_DATABASE_PGSQL, otherwise we end up with the - // following error: - // - // test-odb-pgsql.hxx:3325:20: error: invalid use of incomplete type ‘class odb::access::view_traits’ - // 3325 | public access::view_traits< ::test2::vfull > - // | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // -/* -#if !defined(ODB_DATABASE_MYSQL) && \ - !defined(ODB_DATABASE_SQLITE) && \ - !defined(ODB_DATABASE_COMMON) -*/ -#if !defined(ODB_DATABASE_MYSQL) && \ - !defined(ODB_DATABASE_SQLITE) && \ - !defined(ODB_DATABASE_PGSQL) && \ - !defined(ODB_DATABASE_COMMON) - - #pragma db view object(obj1 = o1) object(obj2 = o2 full: o1::n == o2::n) - struct vfull - { - odb::nullable id1; - odb::nullable id2; - }; - -#endif - - #pragma db view object(obj1 = o1) object(obj2 = o2 inner: o1::n == o2::n) - struct vinner - { - int id1; - int id2; - }; - - #pragma db view object(obj1 = o1) object(obj2 = o2 cross) - struct vcross - { - int id1; - int id2; - }; - - // Inner JOIN via relationship/container. - // - #pragma db object - struct obj3 - { - obj3 (int id = 0, int n_ = 0): id3 (id), n (n_) {} - - #pragma db id - int id3; - - int n; - }; - - #pragma db object no_id - struct obj4 - { - obj4 (int id = 0, int n_ = 0): id4 (id), n (n_) {} - - #pragma db id - int id4; - - int n; - std::vector o3; - }; - - #pragma db view object(obj4) object(obj3 inner) - struct vrel - { - int id4; - }; -} - -#endif // TEST_HXX diff --git a/common/view/basics/testscript b/common/view/basics/testscript deleted file mode 100644 index faa8408..0000000 --- a/common/view/basics/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/view/basics/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/view/olv/.gitignore b/common/view/olv/.gitignore deleted file mode 100644 index 2b95165..0000000 --- a/common/view/olv/.gitignore +++ /dev/null @@ -1,46 +0,0 @@ -# ODB-generated files. -# -test1-odb.?xx -test1-odb-*.?xx -test1.sql -test1-*.sql - -test2-odb.?xx -test2-odb-*.?xx -test2.sql -test2-*.sql - -test3-odb.?xx -test3-odb-*.?xx -test3.sql -test3-*.sql - -test4-odb.?xx -test4-odb-*.?xx -test4.sql -test4-*.sql - -test5-odb.?xx -test5-odb-*.?xx -test5.sql -test5-*.sql - -test6-odb.?xx -test6-odb-*.?xx -test6.sql -test6-*.sql - -test7-odb.?xx -test7-odb-*.?xx -test7.sql -test7-*.sql - -test8-odb.?xx -test8-odb-*.?xx -test8.sql -test8-*.sql - -test9-odb.?xx -test9-odb-*.?xx -test9.sql -test9-*.sql diff --git a/common/view/olv/buildfile b/common/view/olv/buildfile deleted file mode 100644 index 89ecbcf..0000000 --- a/common/view/olv/buildfile +++ /dev/null @@ -1,50 +0,0 @@ -# file : common/view/olv/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -hs = test1 test2 test3 test4 test5 test6 test7 test8 test9 - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -for h: $hs -{ - exe{driver}: {hxx ixx cxx}{$h-odb} - - <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} - - for db: $databases - { - exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi - <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} - } -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix t_view_olv_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../../alias{database-client}: include = adhoc - -testscript@./: schemas = $hs diff --git a/common/view/olv/driver.cxx b/common/view/olv/driver.cxx deleted file mode 100644 index c08015e..0000000 --- a/common/view/olv/driver.cxx +++ /dev/null @@ -1,654 +0,0 @@ -// file : common/view/olv/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test object loading views. -// - -#include // std::unique_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test1.hxx" -#include "test2.hxx" -#include "test3.hxx" -#include "test4.hxx" -#include "test5.hxx" -#include "test6.hxx" -#include "test7.hxx" -#include "test8.hxx" -#include "test9.hxx" - -#include "test1-odb.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" -#include "test4-odb.hxx" -#include "test5-odb.hxx" -#include "test6-odb.hxx" -#include "test7-odb.hxx" -#include "test8-odb.hxx" -#include "test9-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test basic object loading functionality. - // - { - using namespace test1; - - { - object1 o1a (1, 123); - object2 o2 (1, "abc"); - - transaction t (db->begin ()); - db->persist (o1a); - db->persist (o2); - t.commit (); - } - - { - typedef odb::query query; - - transaction t (db->begin ()); - view1 v (db->query_value (query::object1::n == 123)); - assert (v.o2->s == "abc"); - t.commit (); - } - - { - transaction t (db->begin ()); - view2 v (db->query_value ()); - assert (v.o1->n == 123 && v.o2->s == "abc"); - t.commit (); - } - - { - transaction t (db->begin ()); - view3 v (db->query_value ()); - assert (v.o1->n == 123 && v.o2->s == "abc"); - t.commit (); - } - - { - transaction t (db->begin ()); - view4 v (db->query_value ()); - assert (v.s == "abc" && v.o2->s == "abc" && v.id == 1 && - v.o1->n == 123 && v.n == 123); - t.commit (); - } - - { - transaction t (db->begin ()); - view4 v (db->query_value ()); - assert (v.s == "abc" && v.o2->s == "abc" && v.id == 1 && - v.o1->n == 123 && v.n == 123); - t.commit (); - } - - { - typedef odb::query query; - - object1 o1b (123, 1); - - transaction t (db->begin ()); - db->persist (o1b); - view5 v (db->query_value (query::o1b::n == 1)); - assert (v.o1a->n == 123 && v.o2->s == "abc" && v.o1b->n == 1); - t.commit (); - } - } - - // Test loading of object pointers inside objects. - // - { - using namespace test2; - - shared_ptr o1 (new object1 (123)); - shared_ptr o2 (new object2 ("abc", o1)); - - { - - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - view1 v (db->query_value ()); - assert (v.o2->s == "abc" && v.o2->o1->n == 123); - t.commit (); - } - - { - // Check session interaction. - // - transaction t (db->begin ()); - session s; - shared_ptr o2a (db->load (o2->id)); - view1 v (db->query_value ()); - assert (v.o2 == o2a); - t.commit (); - } - - { - transaction t (db->begin ()); - session s; - view2 v (db->query_value ()); - assert (v.o1->n == 123 && v.o2->s == "abc" && v.o2->o1 == v.o1); - t.commit (); - } - - shared_ptr o3 (new object3 (o2)); - - { - transaction t (db->begin ()); - db->persist (o3); - t.commit (); - } - - { - transaction t (db->begin ()); - session s; - view3 v (db->query_value ()); - assert (v.o1->n == 123 && v.o3->o2->s == "abc" && - v.o3->o2->o1 == v.o1); - t.commit (); - } - - shared_ptr o1b (new object1 (234)); - shared_ptr o2b (new object2 ("bcd", o1b)); - shared_ptr o4 (new object4); - o4->o2.push_back (o2); - o4->o2.push_back (o2b); - - { - transaction t (db->begin ()); - db->persist (o1b); - db->persist (o2b); - db->persist (o4); - t.commit (); - } - - { - transaction t (db->begin ()); - view4 v (db->query_value ()); - assert (v.o4->o2[0]->s == "abc" && v.o4->o2[0]->o1->n == 123 && - v.o4->o2[1]->s == "bcd" && v.o4->o2[1]->o1->n == 234); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - session s; - result r (db->query ("ORDER BY" + query::object1::id)); - result::iterator i (r.begin ()); - - assert (i != r.end ()); - { - const view5& v (*i); - - assert (v.o4->o2[0]->s == "abc" && v.o4->o2[0]->o1->n == 123 && - v.o4->o2[1]->s == "bcd" && v.o4->o2[1]->o1->n == 234 && - v.o4->o2[0]->o1 == v.o1); - } - assert (++i != r.end ()); - { - const view5& v (*i); - - assert (v.o4->o2[0]->s == "abc" && v.o4->o2[0]->o1->n == 123 && - v.o4->o2[1]->s == "bcd" && v.o4->o2[1]->o1->n == 234 && - v.o4->o2[1]->o1 == v.o1); - } - assert (++i == r.end ()); - t.commit (); - } - - shared_ptr o5 (new object5 (o1b, o2)); - - { - transaction t (db->begin ()); - db->persist (o5); - t.commit (); - } - - { - transaction t (db->begin ()); - view6 v (db->query_value ()); - assert (v.o1a->n == 123 && v.o1b->n == 234); - t.commit (); - } - } - - // Test JOINs for pointed-to objects, existing and automatically added. - // - { - using namespace test3; - - shared_ptr o1 (new object1 (123)); - shared_ptr o2 (new object2 ("abc")); - - o1->o2 = o2; - o2->o1 = o1; - - { - - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - view1a v (db->query_value ()); - // VC11 - assert (v.o1->n == 123 && v.o1->o2.object_id () == o2->id); - t.commit (); - } - - { - transaction t (db->begin ()); - view1b v (db->query_value ()); - // VC11 - assert (v.o1->n == 123 && v.o1->o2.object_id () == o2->id); - t.commit (); - } - - // Container case. - // - - shared_ptr o3 (new object3 (123)); - shared_ptr o4 (new object4 ("abc")); - - o3->o4 = o4; - o4->o3.push_back (o3); - - { - - transaction t (db->begin ()); - db->persist (o3); - db->persist (o4); - t.commit (); - } - - { - transaction t (db->begin ()); - view2a v (db->query_value ()); - // VC11 - assert (v.o3->n == 123 && v.o3->o4.object_id () == o4->id); - t.commit (); - } - - { - transaction t (db->begin ()); - view2b v (db->query_value ()); - // VC11 - assert (v.o3->n == 123 && v.o3->o4.object_id () == o4->id); - t.commit (); - } - } - - // Test by-value load. - // - { - using namespace test4; - - { - object1 o1 (1, 123); - object2 o2 (1, "abc", &o1); - - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - view1 v (db->query_value ()); - assert (v.o1.n == 123); - t.commit (); - } - - { - transaction t (db->begin ()); - view1a v (db->query_value ()); - assert (!v.o1_null && v.o1.n == 123); - t.commit (); - } - - { - transaction t (db->begin ()); - view1b v (db->query_value ()); - assert (/*v.o1_p == &v.o1 && */ v.o1.n == 123); // Copy ctor. - t.commit (); - } - - { - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query ()); - result::iterator i (r.begin ()); - assert (i != r.end ()); - - object1 o1; - view1c v (o1); - i.load (v); - - assert (v.o1_p == &o1 && o1.n == 123); - - assert (++i == r.end ()); - t.commit (); - } - - { - transaction t (db->begin ()); - session s; - view2 v (db->query_value ()); - - // @@ BUILD2 As of cl 19.29.30136 (VS 2019 16.11.5) v.o2.o1 points to - // the address of o1 member of the object being returned by - // query_value() which v is a copy of, and thus the - // original assertion fails. Note that changing `view2 v` to - // `const view2& v` doesn't help. - // - //assert (v.o1.n == 123 && v.o2.s == "abc" && v.o2.o1 == &v.o1); - assert (v.o1.n == 123 && v.o2.s == "abc"); - t.commit (); - } - - object1 o1b (2, 234); - - { - transaction t (db->begin ()); - db->persist (o1b); - t.commit (); - } - - { - typedef odb::query query; - - transaction t (db->begin ()); - session s; - view2a v (db->query_value (query::object1::id == 2)); - assert (v.o1.n == 234 && v.o2_null); - t.commit (); - } - - shared_ptr o3 (new object3 (1, 123)); - - { - transaction t (db->begin ()); - db->persist (o3); - t.commit (); - } - - { - transaction t (db->begin ()); - { - view3 v (db->query_value ()); - assert (v.o3_p == &v.o3 && v.o3.n == 123); // Load into value. - } - session s; // Load into cache. - shared_ptr o3a (db->load (o3->id)); - { - view3 v (db->query_value ()); - assert (v.o3_p == o3a.get ()); // Load from cache. - } - t.commit (); - } - } - - // Test NULL object pointers. - // - { - using namespace test5; - - shared_ptr o1a (new object1 (123)); - shared_ptr o1b (new object1 (234)); - shared_ptr o2 (new object2 ("abc", o1a)); - - { - transaction t (db->begin ()); - db->persist (o1a); - db->persist (o1b); - db->persist (o2); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - session s; - result r (db->query ("ORDER BY" + query::object1::id)); - result::iterator i (r.begin ()); - - assert (i != r.end ()); - { - const view1& v (*i); - assert (v.o1->n == 123 && v.o2->s == "abc" && v.o2->o1 == v.o1); - } - assert (++i != r.end ()); - { - const view1& v (*i); - assert (v.o1->n == 234 && !v.o2); - } - assert (++i == r.end ()); - t.commit (); - } - - shared_ptr o3a (new object3 (make_pair (1, 1), 123)); - shared_ptr o3b (new object3 (make_pair (2, 2), 234)); - shared_ptr o4 (new object4 ("abc", o3a)); - - { - transaction t (db->begin ()); - db->persist (o3a); - db->persist (o3b); - db->persist (o4); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - session s; - result r (db->query ("ORDER BY" + query::object3::n)); - result::iterator i (r.begin ()); - - assert (i != r.end ()); - { - const view2& v (*i); - assert (v.o3->n == 123 && v.o4->s == "abc" && v.o4->o3 == v.o3); - } - assert (++i != r.end ()); - { - const view2& v (*i); - assert (v.o3->n == 234 && !v.o4); - } - assert (++i == r.end ()); - t.commit (); - } - } - - // Test interaction with sections. - // - { - using namespace test6; - - shared_ptr o1 (new object1 (123)); - shared_ptr o2 (new object2 ("abc", o1)); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - view1 v (db->query_value ()); - - assert (v.o1->n == 123 && v.o2->s == "abc" && - !v.o2->r.loaded () && !v.o2->o1); - - db->load (*v.o2, v.o2->r); - assert (v.o2->r.loaded () && v.o2->o1 && v.o2->o1->n == 123); - - t.commit (); - } - } - - // Test explicit conversion to smart pointer member. - // - { - using namespace test7; - - object1 o1 (123); - object2 o2 ("abc", &o1); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - session s; - view1 v (db->query_value ()); - assert (v.o1->n == 123 && v.o2->s == "abc" && v.o2->o1 == v.o1.get ()); - t.commit (); - } - } - - // Test loading objects without id. - // - { - using namespace test8; - - object1 o1 (123); - object2 o2 ("abc", &o1); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - session s; - view1 v (db->query_value ()); - assert (v.o1->n == 123 && v.o2->s == "abc" && v.o2->o1 == v.o1.get ()); - t.commit (); - } - } - - // Test loading polymorphic objects. - // - { - using namespace test9; - - root r (1); - base b (2, "a"); - derived d (3, "b", true); - - { - transaction t (db->begin ()); - db->persist (r); - db->persist (b); - db->persist (d); - t.commit (); - } - - { - transaction t (db->begin ()); - - // Load via root. - // - { - view1r r (db->query_value (query::n == 1)); - auto& o (*r.o); - assert (r.n == 1 && r.o->n == 1 && typeid (o) == typeid (root)); - } - - { - view1r r (db->query_value (query::n == 2)); - auto& o (*r.o); - assert (r.n == 2 && r.o->n == 2 && typeid (o) == typeid (base)); - base& b (dynamic_cast (*r.o)); - assert (b.s == "a"); - } - - { - view1r r (db->query_value (query::n == 3)); - auto& o (*r.o); - assert (r.n == 3 && r.o->n == 3 && typeid (o) == typeid (derived)); - derived& d (dynamic_cast (o)); - assert (d.s == "b" && d.b); - } - - // Load via base. - // - { - view1b r (db->query_value (query::n == 2)); - assert (r.s == "a" && r.n == 2 && r.o->n == 2 && b.s == "a"); - } - - { - view1b r (db->query_value (query::n == 3)); - auto& o (*r.o); - assert (r.s == "b" && r.n == 3 && r.o->n == 3 && - typeid (o) == typeid (derived)); - derived& d (dynamic_cast (o)); - assert (d.s == "b" && d.b); - } - - // Load via derived. - // - { - view1d r (db->query_value ()); - assert (r.s == "b" && r.n == 3 && - r.o->n == 3 && r.o->s == "b" && r.o->b); - } - - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/view/olv/test1.hxx b/common/view/olv/test1.hxx deleted file mode 100644 index 0de9483..0000000 --- a/common/view/olv/test1.hxx +++ /dev/null @@ -1,116 +0,0 @@ -// file : common/view/olv/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#include -#include // unique_ptr -#include // std::move - -#include - -// Test basic object loading functionality. -// -#pragma db namespace table("t1_") pointer(std::unique_ptr) -namespace test1 -{ - #pragma db object - struct object1 - { - object1 (int id_ = 0, int n_ = 0): id (id_), n (n_) {} - - #pragma db id - int id; - - int n; - }; - - #pragma db object - struct object2 - { - object2 (int id_ = 0, const char* s_ = ""): id (id_), s (s_) {} - - #pragma db id - int id; - - std::string s; - }; - - #pragma db view object(object1) object(object2: object1::id == object2::id) - struct view1 - { - // VC12 workaround (no default move constructor generation). - // - view1 () {} - view1 (view1&& x): o2 (std::move (x.o2)) {} - - std::unique_ptr o2; - }; - - #pragma db view object(object1) object(object2: object1::id == object2::id) - struct view2 - { - // VC12 workaround (no default move constructor generation). - // - view2 () {} - view2 (view2&& x): o2 (std::move (x.o2)), o1 (std::move (x.o1)) {} - - std::unique_ptr o2; - std::unique_ptr o1; - }; - - #pragma db view object(object1 = o1) object(object2 = o2: o1::id == o2::id) - struct view3 - { - // VC12 workaround (no default move constructor generation). - // - view3 () {} - view3 (view3&& x): o1 (std::move (x.o1)), o2 (std::move (x.o2)) {} - - std::unique_ptr o1; - std::unique_ptr o2; - }; - - #pragma db view object(object1 = o1) object(object2 = o2: o1::id == o2::id) - struct view4 - { - // VC12 workaround (no default move constructor generation). - // - view4 () {} - view4 (view4&& x): s (std::move (x.s)), - o2 (std::move (x.o2)), - id (x.id), - o1 (std::move (x.o1)), - n (x.n) {} - - std::string s; - std::unique_ptr o2; - - #pragma db column(o1::id) - int id; - - std::unique_ptr o1; - int n; - }; - - #pragma db view \ - object(object1) \ - object(object2: object1::id == object2::id) \ - object(object1 = o1b: object1::id == o1b::n) - struct view5 - { - // VC12 workaround (no default move constructor generation). - // - view5 () {} - view5 (view5&& x): o1a (std::move (x.o1a)), - o2 (std::move (x.o2)), - o1b (std::move (x.o1b)) {} - - std::unique_ptr o1a; - std::unique_ptr o2; - std::unique_ptr o1b; - }; -} - -#endif // TEST1_HXX diff --git a/common/view/olv/test2.hxx b/common/view/olv/test2.hxx deleted file mode 100644 index a769daa..0000000 --- a/common/view/olv/test2.hxx +++ /dev/null @@ -1,122 +0,0 @@ -// file : common/view/olv/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#include -#include -#include // shared_ptr - -#include - -// Test loading of object pointers inside objects. -// -#pragma db namespace table("t2_") pointer(std::shared_ptr) session -namespace test2 -{ - using std::shared_ptr; - - #pragma db object - struct object1 - { - object1 (int n_ = 0): n (n_) {} - - #pragma db id auto - int id; - - int n; - }; - - #pragma db object - struct object2 - { - object2 () {} - object2 (const char* s_, shared_ptr o1_): s (s_), o1 (o1_) {} - - #pragma db id auto - int id; - - std::string s; - shared_ptr o1; - }; - - #pragma db view object(object1) object(object2) - struct view1 - { - shared_ptr o2; - }; - - #pragma db view object(object1) object(object2) - struct view2 - { - shared_ptr o2; // "Unfortunate" order. - shared_ptr o1; - }; - - #pragma db object - struct object3 - { - object3 () {} - object3 (shared_ptr o2_): o2 (o2_) {} - - #pragma db id auto - int id; - - shared_ptr o2; - }; - - #pragma db view object(object1) object(object2) object(object3) - struct view3 - { - shared_ptr o3; // "Unfortunate" order. - shared_ptr o1; - }; - - #pragma db object - struct object4 - { - #pragma db id auto - int id; - - std::vector> o2; - }; - - #pragma db view object(object4) - struct view4 - { - shared_ptr o4; - }; - - #pragma db view object(object4) object (object2) object(object1) - struct view5 - { - shared_ptr o4; // "Unfortunate" order. - shared_ptr o1; - }; - - #pragma db object - struct object5 - { - object5 () {} - object5 (shared_ptr o1_, shared_ptr o2_) - : o1 (o1_), o2 (o2_) {} - - #pragma db id auto - int id; - - shared_ptr o1; - shared_ptr o2; - }; - - #pragma db view object(object5) object (object2) \ - object(object1 = o1a: object2::o1) \ - object(object1 = o1b: object5::o1) - struct view6 - { - shared_ptr o1a; - shared_ptr o1b; - }; -} - -#endif // TEST2_HXX diff --git a/common/view/olv/test3.hxx b/common/view/olv/test3.hxx deleted file mode 100644 index 8cf4344..0000000 --- a/common/view/olv/test3.hxx +++ /dev/null @@ -1,106 +0,0 @@ -// file : common/view/olv/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#include -#include -#include // shared_ptr - -#include -#include - -// Test JOINs for pointed-to objects, existing and automatically added. -// -#pragma db namespace table("t3_") pointer(std::shared_ptr) session -namespace test3 -{ - using std::shared_ptr; - - struct object2; - - #pragma db object - struct object1 - { - object1 (int n_ = 0): n (n_) {} - - #pragma db id auto - int id; - - int n; - - #pragma db inverse(o1) - odb::lazy_weak_ptr o2; - }; - - #pragma db object - struct object2 - { - object2 (const char* s_ = ""): s (s_) {} - - #pragma db id auto - int id; - - std::string s; - - shared_ptr o1; - }; - - #pragma db view object(object1) object(object2) - struct view1a // Existing JOIN. - { - shared_ptr o1; - }; - - #pragma db view object(object1) - struct view1b // Automatic JOIN. - { - shared_ptr o1; - }; - - // Container case. - // - struct object4; - - #pragma db object - struct object3 - { - object3 (int n_ = 0): n (n_) {} - - #pragma db id auto - int id; - - int n; - - #pragma db inverse(o3) - odb::lazy_weak_ptr o4; - }; - - #pragma db object - struct object4 - { - object4 (const char* s_ = ""): s (s_) {} - - #pragma db id auto - int id; - - std::string s; - - std::vector> o3; - }; - - #pragma db view object(object3) object(object4 = o4) - struct view2a // Existing JOIN. - { - shared_ptr o3; - }; - - #pragma db view object(object3) - struct view2b // Automatic JOIN. - { - shared_ptr o3; - }; -} - -#endif // TEST3_HXX diff --git a/common/view/olv/test4.hxx b/common/view/olv/test4.hxx deleted file mode 100644 index f2af5fd..0000000 --- a/common/view/olv/test4.hxx +++ /dev/null @@ -1,151 +0,0 @@ -// file : common/view/olv/test4.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST4_HXX -#define TEST4_HXX - -#include -#include // shared_ptr - -#include - -// Test by-value load. -// -#pragma db namespace table("t4_") session -namespace test4 -{ - #pragma db object - struct object1 - { - object1 (int id_ = 0, int n_ = 0): id (id_), n (n_) {} - - #pragma db id - int id; - - int n; - }; - - #pragma db object - struct object2 - { - object2 (int id_ = 0, const char* s_ = "", object1* o1_ = 0) - : id (id_), s (s_), o1 (o1_) {} - - #pragma db id - int id; - - std::string s; - object1* o1; // Shallow copy. - }; - - typedef object1* object1_ptr; - typedef object2* object2_ptr; - - #pragma db view object(object1) - struct view1 - { - #pragma db member(o1_) virtual(object1_ptr) get(&this.o1) set() - - #pragma db transient - object1 o1; - }; - - #pragma db view object(object1) transient - struct view1a - { - view1a (): o1_null (true) {} - - #pragma db member(o1_) virtual(object1_ptr) get(&this.o1) \ - set(this.o1_null = !(?)) - - object1 o1; - bool o1_null; - }; - - #pragma db view object(object1) - struct view1b - { - view1b (): o1_p (0) {} - - #pragma db transient - object1 o1; - - #pragma db get(&this.o1) set(o1_p = (?)) - object1* o1_p; - }; - - #pragma db view object(object1) - struct view1c - { - view1c (object1& o1): o1_p (&o1) {} - - object1* o1_p; - }; - - #pragma db view object(object1) object(object2) transient - struct view2 - { - #pragma db member(o2_) virtual(object2_ptr) get(&this.o2) set() - #pragma db member(o1_) virtual(object1_ptr) get(&this.o1) set() - - object1 o1; - object2 o2; - }; - - #pragma db view object(object1) object(object2) transient - struct view2a - { - #pragma db member(o2_) virtual(object2_ptr) get(&this.o2) \ - set(o2_null = !(?)) - #pragma db member(o1_) virtual(object1_ptr) get(&this.o1) set() - - object1 o1; - object2 o2; - bool o2_null; - }; - - // Test loading into raw pointer with non-raw object pointer. - // - using std::shared_ptr; - - #pragma db object pointer(shared_ptr) - struct object3 - { - object3 (int id_ = 0, int n_ = 0): id (id_), n (n_) {} - - #pragma db id - int id; - - int n; - }; - - #pragma db view object(object3) - struct view3 - { - // This view implements the following slightly twisted logic: if the - // object is already in the cache, then set o3_p to that. Otherwise, - // load it into the by-value instance. We can also check whether o3_p - // points to o3 to distinguish between the two outcomes. - // - - // Since we may be getting the pointer as both smart and raw, we - // need to create a bit of support code to use in the modifier - // expression. - // - void set_o3 (object3* p) {o3_p = p;} // &o3 or NULL. - void set_o3 (shared_ptr p) {o3_p = p.get ();} // From cache. - - #pragma db get(&this.o3) set(set_o3(?)) - object3* o3_p; - - #pragma db transient - object3 o3; - - // Return-by-value support (query_value()). - // - view3 (): o3_p (0) {} - view3 (const view3& x): o3_p (x.o3_p == &x.o3 ? &o3 : x.o3_p), o3 (x.o3) {} - }; -} - -#endif // TEST4_HXX diff --git a/common/view/olv/test5.hxx b/common/view/olv/test5.hxx deleted file mode 100644 index e3a671b..0000000 --- a/common/view/olv/test5.hxx +++ /dev/null @@ -1,86 +0,0 @@ -// file : common/view/olv/test5.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST5_HXX -#define TEST5_HXX - -#include -#include // shared_ptr -#include // pair - -#include - -// Test NULL object pointers. -// -#pragma db namespace table("t5_") pointer(std::shared_ptr) session -namespace test5 -{ - using std::shared_ptr; - - #pragma db object - struct object1 - { - object1 (int n_ = 0): n (n_) {} - - #pragma db id auto - int id; - - int n; - }; - - #pragma db object - struct object2 - { - object2 () {} - object2 (const char* s_, shared_ptr o1_): s (s_), o1 (o1_) {} - - #pragma db id auto - int id; - - std::string s; - shared_ptr o1; - }; - - #pragma db view object(object1) object(object2) - struct view1 - { - shared_ptr o1; - shared_ptr o2; - }; - - typedef std::pair comp_id; - #pragma db value(comp_id) - - #pragma db object - struct object3 - { - object3 (comp_id id_ = comp_id (), int n_ = 0): id (id_), n (n_) {} - - #pragma db id - comp_id id; - - int n; - }; - - #pragma db object - struct object4 - { - object4 () {} - object4 (const char* s_, shared_ptr o3_): s (s_), o3 (o3_) {} - - #pragma db id auto - int id; - - std::string s; - shared_ptr o3; - }; - - #pragma db view object(object3) object(object4) - struct view2 - { - shared_ptr o4; - shared_ptr o3; - }; -} - -#endif // TEST5_HXX diff --git a/common/view/olv/test6.hxx b/common/view/olv/test6.hxx deleted file mode 100644 index 5336fa6..0000000 --- a/common/view/olv/test6.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// file : common/view/olv/test6.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST6_HXX -#define TEST6_HXX - -#include -#include // shared_ptr - -#include -#include - -// Test interaction with sections. -// -#pragma db namespace table("t6_") pointer(std::shared_ptr) -namespace test6 -{ - using std::shared_ptr; - - #pragma db object - struct object1 - { - object1 (int n_ = 0): n (n_) {} - - #pragma db id auto - int id; - - int n; - }; - - #pragma db object - struct object2 - { - object2 () {} - object2 (const char* s_, shared_ptr o1_): s (s_), o1 (o1_) {} - - #pragma db id auto - int id; - - std::string s; - - #pragma db load(lazy) - odb::section r; - - #pragma db section(r) - shared_ptr o1; - }; - - #pragma db view object(object1) object(object2) - struct view1 - { - shared_ptr o1; - shared_ptr o2; - }; -} - -#endif // TEST6_HXX diff --git a/common/view/olv/test7.hxx b/common/view/olv/test7.hxx deleted file mode 100644 index dbdc663..0000000 --- a/common/view/olv/test7.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// file : common/view/olv/test7.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST7_HXX -#define TEST7_HXX - -#include -#include // unique_ptr -#include // std::move - -#include - -// Test explicit conversion to smart pointer member. -// -#pragma db namespace table("t7_") pointer(*) session -namespace test7 -{ - using std::unique_ptr; - - #pragma db object - struct object1 - { - object1 (int n_ = 0): n (n_) {} - - #pragma db id auto - int id; - - int n; - }; - - #pragma db object - struct object2 - { - object2 () {} - object2 (const char* s_, object1* o1_): s (s_), o1 (o1_) {} - - #pragma db id auto - int id; - - std::string s; - object1* o1; // Shallow. - }; - - #pragma db view object(object1) object(object2) - struct view1 - { - // VC12 workaround (no default move constructor generation). - // - view1 () {} - view1 (view1&& x): o2 (std::move (x.o2)), o1 (std::move (x.o1)) {} - - unique_ptr o2; - unique_ptr o1; - }; -} - -#endif // TEST7_HXX diff --git a/common/view/olv/test8.hxx b/common/view/olv/test8.hxx deleted file mode 100644 index 607d222..0000000 --- a/common/view/olv/test8.hxx +++ /dev/null @@ -1,54 +0,0 @@ -// file : common/view/olv/test8.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST8_HXX -#define TEST8_HXX - -#include -#include // unique_ptr -#include // std::move - -#include - -// Test loading objects without id. -// -#pragma db namespace table("t8_") pointer(*) session -namespace test8 -{ - using std::unique_ptr; - - #pragma db object - struct object1 - { - object1 (int n_ = 0): n (n_) {} - - #pragma db id auto - int id; - - int n; - }; - - #pragma db object no_id - struct object2 - { - object2 () {} - object2 (const char* s_, object1* o1_): s (s_), o1 (o1_) {} - - std::string s; - object1* o1; // Shallow. - }; - - #pragma db view object(object1) object(object2) - struct view1 - { - // VC12 workaround (no default move constructor generation). - // - view1 () {} - view1 (view1&& x): o2 (std::move (x.o2)), o1 (std::move (x.o1)) {} - - unique_ptr o2; - unique_ptr o1; - }; -} - -#endif // TEST8_HXX diff --git a/common/view/olv/test9.hxx b/common/view/olv/test9.hxx deleted file mode 100644 index b109de3..0000000 --- a/common/view/olv/test9.hxx +++ /dev/null @@ -1,78 +0,0 @@ -// file : common/view/olv/test9.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST9_HXX -#define TEST9_HXX - -#include -#include // shared_ptr - -#include - -// Test loading polymorphic objects. -// -#pragma db namespace table("t9_") session -namespace test9 -{ - using std::shared_ptr; - - #pragma db object polymorphic pointer(shared_ptr) - struct root - { - virtual ~root () {} - root (int n_ = 0): n (n_) {} - - #pragma db id auto - int id; - - int n; - }; - - #pragma db object - struct base: root - { - base (int n_ = 0, const char* s_ = ""): root (n_), s (s_) {} - - std::string s; - }; - - #pragma db object - struct derived: base - { - derived (int n_ = 0, const char* s_ = "", bool b_ = false) - : base (n_, s_), b (b_) {} - - bool b; - }; - - // Load via root. - // - #pragma db view object(root) - struct view1r - { - shared_ptr o; - int n; - }; - - // Load via base. - // - #pragma db view object(base) - struct view1b - { - std::string s; - shared_ptr o; - int n; - }; - - // Load via derived. - // - #pragma db view object(derived) - struct view1d - { - std::string s; - shared_ptr o; - int n; - }; -} - -#endif // TEST9_HXX diff --git a/common/view/olv/testscript b/common/view/olv/testscript deleted file mode 100644 index 160426d..0000000 --- a/common/view/olv/testscript +++ /dev/null @@ -1,39 +0,0 @@ -# file : common/view/olv/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../../mysql-schema.testscript - - for s: $schemas - cat $out_base/"$s"($multi ? '-mysql' : '').sql | $create_schema_cmd - end; - - $* ($multi ? 'mysql' : ) $mysql_options -} - -: sqlite -: -if $sqlite -{ - .include ../../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../../pgsql-schema.testscript - - for s: $schemas - $create_schema_cmd -f $out_base/"$s"($multi ? '-pgsql' : '').sql - end; - - $* ($multi ? 'pgsql' : ) $pgsql_options -} diff --git a/common/virtual/buildfile b/common/virtual/buildfile deleted file mode 100644 index 96d062e..0000000 --- a/common/virtual/buildfile +++ /dev/null @@ -1,42 +0,0 @@ -# file : common/virtual/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix virtual_ \ - --generate-schema \ - --generate-query \ - --generate-session - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/virtual/driver.cxx b/common/virtual/driver.cxx deleted file mode 100644 index f96f543..0000000 --- a/common/virtual/driver.cxx +++ /dev/null @@ -1,154 +0,0 @@ -// file : common/virtual/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test virtual data members. -// - -#include // std::auto_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test basic virtual data member functionality. - // - { - using namespace test1; - - object o; - o.i (123); - o.c1.i = 123; - o.c1.s = "abc"; - o.v1.push_back ("abc"); - o.v1.push_back ("abd"); - o.v1.push_back ("abe"); - o.p1 = new object; - - { - transaction t (db->begin ()); - db->persist (*o.p1); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (o.id1.v)); - t.commit (); - - assert (o == *p); - } - } - - // Test pragma resolution to virtual data member. - // - { - using namespace test2; - - object1 o1 (1); - o1.o2 = new object2 (1); - o1.o2->o1 = &o1; - - { - transaction t (db->begin ()); - db->persist (*o1.o2); - o1.n1 = o1.o2->id; - db->persist (o1); - t.commit (); - } - - { - session s; - transaction t (db->begin ()); - unique_ptr p (db->load (o1.id)); - t.commit (); - - assert (p->o2->id == o1.o2->id); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::object2::id == o1.o2->id)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->i == o1.n1); - assert (++i == r.end ()); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::o2::id == o1.o2->id)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->i == o1.n1); - assert (++i == r.end ()); - t.commit (); - } - - { - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query ()); - result::iterator i (r.begin ()); - assert (i != r.end () && i->i == o1.n1); - assert (++i == r.end ()); - t.commit (); - } - } - - // Use virtual data members to implement multi-member composite object id. - // - { - using namespace test3; - - person o; - o.first_ = "John"; - o.last_ = "Doe"; - - name id; - { - transaction t (db->begin ()); - id = db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p (db->load (id)); - t.commit (); - - assert (o.first_ == p->first_ && o.last_ == p->last_); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/virtual/test.hxx b/common/virtual/test.hxx deleted file mode 100644 index 2654d09..0000000 --- a/common/virtual/test.hxx +++ /dev/null @@ -1,171 +0,0 @@ -// file : common/virtual/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -// Test basic virtual data member functionality. -// -#pragma db namespace table("t1_") -namespace test1 -{ - #pragma db value - struct comp - { - int i; - - #pragma db transient - std::string s; - #pragma db member(s_) virtual(std::string) access(s) - - bool operator== (const comp& v) const - { - return i == v.i && s == v.s; - } - }; - - #pragma db object transient - struct object - { - object (): p1 (0) {} - ~object () {delete p1;} - - struct {unsigned long v;} id1; - - #pragma db id - #pragma db member(id) get(id1.v) virtual(unsigned long) set(id1.v) - #pragma db member(id) auto - - int i () const {return i1;} - void i (int i) {i1 = i;} - int i1; - - comp c1; - #pragma db member(c) virtual(comp) access(c1) - - typedef std::vector strings; - strings v1; - #pragma db member(v) virtual(strings) access(v1) - - typedef object* object_ptr; - object_ptr p1; - #pragma db member(p) virtual(object_ptr) access(p1) - - bool operator== (const object& o) const - { - return id1.v == o.id1.v && - i1 == o.i1 && - c1 == o.c1 && - v1 == o.v1 && - (p1 != 0 ? o.p1 != 0 && *p1 == *o.p1 : o.p1 == 0); - } - }; - - #pragma db member(object::i) virtual(int) -} - -#pragma db member(test1::object::id) column("oid") - -// Test pragma resolution to virtual data member. -// -#pragma db namespace table("t2_") -namespace test2 -{ - struct object1; - struct object2; - - typedef object1* object1_ptr; - typedef object2* object2_ptr; - - #pragma db object - struct object2 - { - object2 (unsigned long i = 0): id (i) {} - - #pragma db id - unsigned long id; - - #pragma db inverse(o) - object1_ptr o1; - }; - - #pragma db object - struct object1 - { - object1 (unsigned long i = 0): id (i), o2 (0) {} - ~object1 () {delete o2;} - - #pragma db id - unsigned long id; - - #pragma db transient - object2_ptr o2; - #pragma db member(o) virtual(object2_ptr) access(o2) - - #pragma db transient - unsigned long n1; - #pragma db member(n) virtual(unsigned long) access(n1) - #pragma db index member(n) - }; - - #pragma db view object(object1) object(object2) - struct view1 - { - #pragma db column(object1::n) - unsigned long i; - }; - - #pragma db view object(object1 = o1) object(object2 = o2: o1::n == o2::id) - struct view2 - { - #pragma db column(o1::n) - unsigned long i; - }; - - #pragma db view object(object1: object1::n != 0) - struct view3 - { - #pragma db column(test2::object1::n) - unsigned long i; - }; -} - -// Use virtual data members to implement multi-member composite object id. -// -#pragma db namespace table("t3_") -namespace test3 -{ - #pragma db value - struct name - { - name () {} - name (const std::string& f, const std::string& l) - : first (f), last(l) {} - - std::string first; - std::string last; - - bool operator< (const name& x) const - { - return first < x.first || (first == x.first && last < x.last); - } - }; - - #pragma db object transient - struct person - { - std::string first_; - std::string last_; - - #pragma db member(name) virtual(name) id \ - get(::test3::name (this.first_, this.last_)) \ - set(this.first_ = (?).first; this.last_ = (?).last) - }; -} - -#endif // TEST_HXX diff --git a/common/virtual/testscript b/common/virtual/testscript deleted file mode 100644 index 769c7f9..0000000 --- a/common/virtual/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/virtual/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/common/wrapper/buildfile b/common/wrapper/buildfile deleted file mode 100644 index 57f43f2..0000000 --- a/common/wrapper/buildfile +++ /dev/null @@ -1,40 +0,0 @@ -# file : common/wrapper/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import libodb = libodb%lib{odb} - -libs = - -for db: $databases - import libs += libodb-$db%lib{odb-$db} - -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -for db: $databases -{ - exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi - <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} -} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix wrapper_ \ - --generate-schema - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/common/wrapper/driver.cxx b/common/wrapper/driver.cxx deleted file mode 100644 index 9c352fc..0000000 --- a/common/wrapper/driver.cxx +++ /dev/null @@ -1,216 +0,0 @@ -// file : common/wrapper/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test wrapper machinery. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_database (argc, argv)); - - // Test 1: simple values. - // - { - using namespace test1; - - unsigned long id1, id2; - { - object1 o1; - object2 o2; - - o1.num.reset (new int (123)); - o1.nstrs.push_back (nullable_string ()); - o1.nstrs.push_back (nullable_string ("123")); - - o2.sstrs.push_back (str_sptr ()); - o2.sstrs.push_back (str_sptr (new string ("123"))); - - transaction t (db->begin ()); - id1 = db->persist (o1); - id2 = db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (id1)); - unique_ptr o2 (db->load (id2)); - t.commit (); - - assert (*o1->num == 123); - assert (o1->str.get () == 0); - assert (o1->nstr.null ()); - assert (o1->nstrs[0].null ()); - assert (o1->nstrs[1].get () == "123"); - - assert (!o2->sstr); - assert (!o2->sstrs[0]); - assert (*o2->sstrs[1] == "123"); - } - } - - // - // Composite values. - // - unsigned long id; - { - comp_object co; - - co.c1.reset (new comp1 ("123", 123)); - co.vc1.push_back (comp1 ("1", 1)); - co.vc1.push_back (comp1 ("2", 2)); - co.vc1.push_back (comp1 ("3", 3)); - - co.c2.reset (new comp2 ("123", 123)); - co.c2->strs.push_back ("1"); - co.c2->strs.push_back ("2"); - co.c2->strs.push_back ("3"); - - { - transaction t (db->begin ()); - id = db->persist (co); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (id)); - t.commit (); - - assert (*o->c1 == *co.c1); - assert (o->vc1 == co.vc1); - assert (*o->c2 == *co.c2); - } - } - - // - // Containers. - // - { - cont_object co; - - co.nums.reset (new vector); - co.nums->push_back (1); - co.nums->push_back (2); - co.nums->push_back (3); - - co.c.num = 123; - co.c.strs.reset (new vector); - co.c.strs->push_back ("1"); - co.c.strs->push_back ("2"); - co.c.strs->push_back ("3"); - - { - transaction t (db->begin ()); - id = db->persist (co); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (id)); - t.commit (); - - assert (*o->nums == *co.nums); - assert (o->c == co.c); - } - } - - // Test 5: composite NULL values. - // - { - using namespace test5; - - object o1, o2; - - o1.v.push_back (nullable ()); - - o2.p.reset (new comp (1, "a")); - o2.n = comp (2, "b"); - o2.v.push_back (comp (3, "c")); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (p1->p.get () == 0); - assert (!p1->n); - assert (!p1->v[0]); - - assert (p2->p.get () != 0 && *p2->p == *o2.p); - assert (p2->n && *p2->n == *o2.n); - assert (p2->v[0] && *p2->v[0] == *o2.v[0]); - } - - // Update. - // - { - o1.p.reset (new comp (1, "a")); - o1.n = comp (2, "b"); - o1.v[0] = comp (3, "c"); - - o2.p.reset (); - o2.n.reset (); - o2.v[0].reset (); - - transaction t (db->begin ()); - db->update (o1); - db->update (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (o1.id)); - unique_ptr p2 (db->load (o2.id)); - t.commit (); - - assert (p1->p.get () != 0 && *p1->p == *o1.p); - assert (p1->n && *p1->n == *o1.n); - assert (p1->v[0] && *p1->v[0] == *o1.v[0]); - - assert (p2->p.get () == 0); - assert (!p2->n); - assert (!p2->v[0]); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/common/wrapper/test.hxx b/common/wrapper/test.hxx deleted file mode 100644 index 3ae4151..0000000 --- a/common/wrapper/test.hxx +++ /dev/null @@ -1,214 +0,0 @@ -// file : common/wrapper/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include // std::unique_ptr -#include - -#include -#include - -using odb::nullable; - -// Test 1: simple values. -// -#pragma db namespace table("t1_") -namespace test1 -{ - typedef nullable nullable_string; - - typedef std::unique_ptr num_uptr; - typedef std::unique_ptr str_uptr; - typedef std::shared_ptr str_sptr; - - #pragma db object table("obj1") - struct object1 - { - #pragma db id auto - unsigned long id_; - - num_uptr num; - - #pragma db null - str_uptr str; - - nullable_string nstr; - std::vector nstrs; - }; - - #pragma db object - struct object2 - { - #pragma db id auto - unsigned long id_; - - #pragma db null - str_sptr sstr; - - #pragma db value_null - std::vector sstrs; - }; -} - -// -// Composite values. -// - -#pragma db value -struct comp1 -{ - comp1 () {} - comp1 (const std::string& s, int n): str (s), num (n) {} - - std::string str; - int num; -}; - -inline bool -operator== (const comp1& x, const comp1& y) -{ - return x.str == y.str && x.num == y.num; -} - - -#pragma db value -struct comp2 -{ - comp2 () {} - comp2 (const std::string& s, int n): str (s), num (n) {} - - std::string str; - int num; - - std::vector strs; -}; - -inline bool -operator== (const comp2& x, const comp2& y) -{ - return x.str == y.str && x.num == y.num && x.strs == y.strs; -} - -struct comp3; - -typedef std::unique_ptr comp1_uptr; -typedef std::unique_ptr comp2_uptr; -typedef std::unique_ptr comp3_uptr; - -#pragma db object -struct comp_object -{ - #pragma db id auto - unsigned long id_; - - comp1_uptr c1; // Wrapped comp value. - std::vector > vc1; // Container of wrapped comp values. - comp2_uptr c2; // Container inside wrapped comp value. -}; - -// This one is just a compilation test to cover more convolute cases. -// -#pragma db value -struct comp3: comp2 -{ - comp1_uptr c1; - std::vector > vc1; -}; - -#pragma db object -struct comp_object2 -{ - #pragma db id auto - unsigned long id_; - - comp3_uptr c3; -}; - -// -// Containers. -// - -typedef std::unique_ptr> nums_uptr; -typedef std::unique_ptr> strs_uptr; - -#pragma db value -struct cont_comp -{ - int num; - strs_uptr strs; -}; - -inline bool -operator== (const cont_comp& x, const cont_comp& y) -{ - return x.num == y.num && *x.strs == *y.strs; -} - -#pragma db object -struct cont_object -{ - #pragma db id auto - unsigned long id_; - - nums_uptr nums; // Wrapped container. - cont_comp c; // Wrapped container in comp value. -}; - -// Test composite NULL values. -// -#pragma db namespace table("t5_") -namespace test5 -{ - #pragma db value - struct base - { - base () {} - base (int n): num (n) {} - - int num = 0; - }; - - inline bool - operator== (const base& x, const base& y) - { - return x.num == y.num; - } - - #pragma db value - struct comp: base - { - comp () {} - comp (int n, const std::string s): base (n), str (s), extra (n + 1) {} - - std::string str; - base extra; - - odb::nullable always_null; - }; - - inline bool - operator== (const comp& x, const comp& y) - { - return static_cast (x) == y && - x.str == y.str && x.extra == y.extra; - } - - #pragma db object - struct object - { - #pragma db id auto - unsigned long id; - - #pragma db null - std::unique_ptr p; - - odb::nullable n; - - std::vector< odb::nullable > v; - }; -} - -#endif // TEST_HXX diff --git a/common/wrapper/testscript b/common/wrapper/testscript deleted file mode 100644 index 6630813..0000000 --- a/common/wrapper/testscript +++ /dev/null @@ -1,33 +0,0 @@ -# file : common/wrapper/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript - -: mysql -: -if $mysql -{ - .include ../../mysql.testscript - - $create_schema; - $* -} - -: sqlite -: -if $sqlite -{ - .include ../../sqlite.testscript - - $* -} - -: pgsql -: -if $pgsql -{ - .include ../../pgsql.testscript - - $create_schema; - $* -} diff --git a/database-options.testscript b/database-options.testscript deleted file mode 100644 index 2c0ee82..0000000 --- a/database-options.testscript +++ /dev/null @@ -1,75 +0,0 @@ -# file : database-options.testscript -# license : GNU GPL v2; see accompanying LICENSE file - -# For the enabled databases create the test driver option lists (*_options) -# for subsequent use in the tests. Also create the database-specific client -# option lists (*_client_options) and command lines (*_client_cmd) which can -# be used as a base for the data manipulation commands. -# -+if $mysql - mysql_options = --user $config.odb_tests.pgsql.user \ - --database $config.odb_tests.pgsql.database - - mysql_client_options = --user $config.odb_tests.pgsql.user \ - --database $config.odb_tests.pgsql.database - - if $defined(config.odb_tests.mysql.passwd) - mysql_options += --password $config.odb_tests.mysql.passwd - mysql_client_options += --password=$config.odb_tests.mysql.passwd - end - - if $defined(config.odb_tests.mysql.host) - mysql_options += --host $config.odb_tests.mysql.host - mysql_client_options += --host $config.odb_tests.mysql.host - end - - if $defined(config.odb_tests.mysql.port) - mysql_options += --port $config.odb_tests.mysql.port - mysql_client_options += --port $config.odb_tests.mysql.port - end - - if $defined(config.odb_tests.mysql.socket) - mysql_options += --socket $config.odb_tests.mysql.socket - mysql_client_options += --socket $config.odb_tests.mysql.socket - end - - mysql_client_cmd = $path($mysql_client) $mysql_client_options -end - -+if $sqlite - sqlite_options = --database odb-test.db - - # Note that we currently don't manipulate the data using the sqlite3 - # utility. Thus, we don't create the sqlite client option list and command - # line. - # -end - -+if $pgsql - pgsql_options = --user $config.odb_tests.pgsql.user \ - --database $config.odb_tests.pgsql.database - - pgsql_client_options = --quiet \ - --set ON_ERROR_STOP=1 \ - --username $config.odb_tests.pgsql.user \ - --dbname $config.odb_tests.pgsql.database - - if $defined(config.odb_tests.pgsql.host) - pgsql_options += --host $config.odb_tests.pgsql.host - pgsql_client_options += --host $config.odb_tests.pgsql.host - end - - if $defined(config.odb_tests.pgsql.port) - pgsql_options += --port $config.odb_tests.pgsql.port - pgsql_client_options += --port $config.odb_tests.pgsql.port - end - - pgsql_client_cmd = $path($pgsql_client) $pgsql_client_options - - export PGOPTIONS=--client-min-messages=warning -end - -# Set the default schema file name, which can be overridden by the subsequent -# tests in their own scopes. -# -schema = test diff --git a/evolution/add-column/driver.cxx b/evolution/add-column/driver.cxx deleted file mode 100644 index d4eb396..0000000 --- a/evolution/add-column/driver.cxx +++ /dev/null @@ -1,125 +0,0 @@ -// file : evolution/add-column/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test adding a new column. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - object o (1); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - - assert (!p->str); - assert (p->num == 999); - - // Migration. - // - p->str = "abc"; - p->num = 123; - db->update (*p); - - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - - assert (p->str && *p->str == "abc"); - assert (p->num == 123); - - t.commit (); - } - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/add-column/model.hxx b/evolution/add-column/model.hxx deleted file mode 100644 index 6ac9160..0000000 --- a/evolution/add-column/model.hxx +++ /dev/null @@ -1,38 +0,0 @@ -// file : evolution/add-column/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#include -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - -#if MODEL_VERSION == 3 - odb::nullable str; - - #pragma db default(999) - unsigned long num; -#endif - }; -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/add-column/test1.hxx b/evolution/add-column/test1.hxx deleted file mode 100644 index b0d7fda..0000000 --- a/evolution/add-column/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/add-column/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/add-column/test2.hxx b/evolution/add-column/test2.hxx deleted file mode 100644 index b62530a..0000000 --- a/evolution/add-column/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/add-column/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/add-column/test3.hxx b/evolution/add-column/test3.hxx deleted file mode 100644 index b24dba1..0000000 --- a/evolution/add-column/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/add-column/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/add-foreign-key/driver.cxx b/evolution/add-foreign-key/driver.cxx deleted file mode 100644 index 177b615..0000000 --- a/evolution/add-foreign-key/driver.cxx +++ /dev/null @@ -1,173 +0,0 @@ -// file : evolution/add-foreign-key/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test adding a foreign key. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include // DATABASE_XXX -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - object o (1); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - break; - } - case 2: - { - using namespace v3; - -#ifdef DATABASE_SQLITE - // In SQLite we can only add foreign keys inline in the column - // definition. - // - db->connection ()->execute ("PRAGMA foreign_keys=OFF"); -#endif - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - // Both pointers are now NULL. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - - assert (p->o1 == 0 && p->o2 == 0); - - // Migration. The foreign key constraint is not yet there. - // - p->o1 = new object1 (1); - p->o2 = new object2 (1); - db->update (*p); - - t.commit (); - } - - // Migration. Add the missing objects. - // - object1 o1 (1); - object2 o2 (1); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->o1->id_ == 1); - assert (p->o2->id_ == 1); - t.commit (); - } - - // Now the foreign key constraint is there. - // - try - { - object o (2); - o.o1 = new object1 (2); - o.o2 = new object2 (2); - - transaction t (db->begin ()); - db->persist (o); - assert (false); - } - catch (const odb::exception& ) {} - - // As well as the NOT NULL. - // -#ifndef DATABASE_SQLITE - try - { - object o (3); - o.o2 = 0; - - transaction t (db->begin ()); - db->persist (o); - assert (false); - } - catch (const odb::exception& ) {} -#endif - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/add-foreign-key/model.hxx b/evolution/add-foreign-key/model.hxx deleted file mode 100644 index f5fe26d..0000000 --- a/evolution/add-foreign-key/model.hxx +++ /dev/null @@ -1,66 +0,0 @@ -// file : evolution/add-foreign-key/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#include - -#include // DATABASE_XXX - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ -#if MODEL_VERSION == 3 - #pragma db object - struct object1 - { - object1 (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - }; - - #pragma db object - struct object2 - { - object2 (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - }; -#endif - - #pragma db object - struct object - { - #pragma db id - unsigned long id_; - -#if MODEL_VERSION == 2 - object (unsigned long id = 0): id_ (id) {} -#else - object1* o1; - - // There is no support for changing a column to NOT NULL in SQLite. - // -#ifndef ODB_DATABASE_SQLITE - #pragma db not_null -#endif - object2* o2; - - object (unsigned long id = 0): id_ (id), o1 (0), o2 (0) {} - ~object () {delete o1; delete o2;} -#endif - }; -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/add-foreign-key/test1.hxx b/evolution/add-foreign-key/test1.hxx deleted file mode 100644 index 05c78c3..0000000 --- a/evolution/add-foreign-key/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/add-foreign-key/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/add-foreign-key/test2.hxx b/evolution/add-foreign-key/test2.hxx deleted file mode 100644 index c57d9a1..0000000 --- a/evolution/add-foreign-key/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/add-foreign-key/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/add-foreign-key/test3.hxx b/evolution/add-foreign-key/test3.hxx deleted file mode 100644 index c844469..0000000 --- a/evolution/add-foreign-key/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/add-foreign-key/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/add-index/driver.cxx b/evolution/add-index/driver.cxx deleted file mode 100644 index 689504e..0000000 --- a/evolution/add-index/driver.cxx +++ /dev/null @@ -1,165 +0,0 @@ -// file : evolution/add-index/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test adding a new index. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - object o0 (0); - o0.num = 123; - - object o1 (1); - o1.num = 234; - - object o2 (2); - o2.num = 234; - - // Duplicates are ok. - // - { - transaction t (db->begin ()); - db->persist (o0); - db->persist (o1); - db->persist (o2); - t.commit (); - } - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - object o3 (3); - o3.num = 234; - - // Duplicates are still ok but we need to remove them before the - // post migration step. - // - { - transaction t (db->begin ()); - db->persist (o3); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query ( - "ORDER BY" + query::num + "," + query::id)); - - unsigned long prev (0); - for (result::iterator i (r.begin ()); i != r.end (); ++i) - { - if (i->num == prev) - db->erase (*i); - - prev = i->num; - } - - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - { - transaction t (db->begin ()); - auto_ptr p0 (db->load (0)); - auto_ptr p1 (db->load (1)); - - assert (p0->num == 123); - assert (p1->num == 234); - - t.commit (); - } - - try - { - object o2 (2); - o2.num = 234; - - transaction t (db->begin ()); - db->persist (o2); - assert (false); - } - catch (const odb::exception& ) {} - - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/add-index/model.hxx b/evolution/add-index/model.hxx deleted file mode 100644 index fec75cc..0000000 --- a/evolution/add-index/model.hxx +++ /dev/null @@ -1,33 +0,0 @@ -// file : evolution/add-index/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - -#if MODEL_VERSION == 3 - #pragma db unique -#endif - unsigned long num; - }; -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/add-index/test1.hxx b/evolution/add-index/test1.hxx deleted file mode 100644 index 1be2b5b..0000000 --- a/evolution/add-index/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/add-index/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/add-index/test2.hxx b/evolution/add-index/test2.hxx deleted file mode 100644 index a0faca9..0000000 --- a/evolution/add-index/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/add-index/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/add-index/test3.hxx b/evolution/add-index/test3.hxx deleted file mode 100644 index aab9c86..0000000 --- a/evolution/add-index/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/add-index/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/add-table/driver.cxx b/evolution/add-table/driver.cxx deleted file mode 100644 index 67b0f0e..0000000 --- a/evolution/add-table/driver.cxx +++ /dev/null @@ -1,140 +0,0 @@ -// file : evolution/add-table/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test adding a new table (object, container). -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include // DATABASE_XXX -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - // SQLite has broken foreign keys when it comes to DDL. - // -#ifdef DATABASE_SQLITE - db->connection ()->execute ("PRAGMA foreign_keys=OFF"); -#endif - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - -#ifdef DATABASE_SQLITE - db->connection ()->execute ("PRAGMA foreign_keys=ON"); -#endif - } - - object o (1); - o.str = "abc"; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - object1 o1; - o1.nums.push_back (1); - o1.nums.push_back (2); - o1.nums.push_back (3); - - { - transaction t (db->begin ()); - o1.o = db->load (1); - db->persist (o1); - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - typedef odb::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - result r (db->query (query::o->str == "abc")); - result::iterator i (r.begin ()), e (r.end ()); - - assert (i != e && - i->o->id_ == 1 && - i->nums[0] == 1 && i->nums[1] == 2 && i->nums[2] == 3); - assert (++i == e); - - t.commit (); - } - - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/add-table/model.hxx b/evolution/add-table/model.hxx deleted file mode 100644 index 208a156..0000000 --- a/evolution/add-table/model.hxx +++ /dev/null @@ -1,48 +0,0 @@ -// file : evolution/add-table/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include -#include - -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - std::string str; - }; - -#if MODEL_VERSION == 3 - #pragma db object - struct object1 - { - object1 (): o (0) {} - ~object1 () {delete o;} - - #pragma db id auto - unsigned long id_; - - object* o; - std::vector nums; - }; -#endif -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/add-table/test1.hxx b/evolution/add-table/test1.hxx deleted file mode 100644 index adc51a1..0000000 --- a/evolution/add-table/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/add-table/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/add-table/test2.hxx b/evolution/add-table/test2.hxx deleted file mode 100644 index ca03cef..0000000 --- a/evolution/add-table/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/add-table/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/add-table/test3.hxx b/evolution/add-table/test3.hxx deleted file mode 100644 index 39406a2..0000000 --- a/evolution/add-table/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/add-table/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/alter-column/driver.cxx b/evolution/alter-column/driver.cxx deleted file mode 100644 index be63f05..0000000 --- a/evolution/alter-column/driver.cxx +++ /dev/null @@ -1,160 +0,0 @@ -// file : evolution/alter-column/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test altering a column. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - - // SQLite doesn't support altering of columns. - // -#ifndef DATABASE_SQLITE - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - object o (1); - o.num = 123; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - // NULL is already in effect; NOT NULL is not yet. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - - assert (!p->str); - assert (p->num && *p->num == 123); - assert (!p->num1); - - // Migration. - // - p->str = "abc"; - p->num.reset (); - p->num1 = 123; - db->update (*p); - - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - - assert (p->str && *p->str == "abc"); - assert (!p->num); - - t.commit (); - } - - // NOT NULL is now in effect. - // - try - { - object o2 (2); - o2.num1 = 234; // str is NULL - - transaction t (db->begin ()); - db->persist (o2); - assert (false); - } - catch (const odb::exception& ) {} - - try - { - object o3 (3); - o3.str = "bcd"; // num1 is NULL - - transaction t (db->begin ()); - db->persist (o3); - assert (false); - } - catch (const odb::exception& ) {} - - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } -#endif // DATABASE_SQLITE - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/alter-column/model.hxx b/evolution/alter-column/model.hxx deleted file mode 100644 index fc6661c..0000000 --- a/evolution/alter-column/model.hxx +++ /dev/null @@ -1,56 +0,0 @@ -// file : evolution/alter-column/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#include -#include - -#include // DATABASE_XXX - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - // SQLite doesn't support altering of columns. - // -#ifndef DATABASE_SQLITE -#if MODEL_VERSION == 2 - odb::nullable str; - - unsigned long num; -#else - // Use nullable to be able to access during migration. - // - #pragma db not_null - odb::nullable str; - - odb::nullable num; - - // Test adding NOT NULL column. It should be added NULL in pre - // and then converted to NOT NULL in post. - // - #pragma db not_null - odb::nullable num1; -#endif -#endif - }; -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/alter-column/test1.hxx b/evolution/alter-column/test1.hxx deleted file mode 100644 index 9353558..0000000 --- a/evolution/alter-column/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/alter-column/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/alter-column/test2.hxx b/evolution/alter-column/test2.hxx deleted file mode 100644 index e2dbed3..0000000 --- a/evolution/alter-column/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/alter-column/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/alter-column/test3.hxx b/evolution/alter-column/test3.hxx deleted file mode 100644 index ac08e2f..0000000 --- a/evolution/alter-column/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/alter-column/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/combined/driver.cxx b/evolution/combined/driver.cxx deleted file mode 100644 index 88453c3..0000000 --- a/evolution/combined/driver.cxx +++ /dev/null @@ -1,157 +0,0 @@ -// file : evolution/combined/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Combined schema evolution test. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - object o ("1"); - o.dui = 1; - o.anui = 1; - o.dnui = 1; - o.dc = 1; - o.dt.push_back (1); - o.aui = 1; - -#ifndef DATABASE_SQLITE - o.dfk = new object1 (1); - o.acn = 1; - o.acnn.reset (); - o.afk = 1; -#endif - - { - transaction t (db->begin ()); -#ifndef DATABASE_SQLITE - db->persist (o.dfk); -#endif - db->persist (o); - t.commit (); - } - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load ("1")); - - assert (p->ac1 == 999); - assert (!p->ac2); - -#ifndef DATABASE_SQLITE - assert (!p->ac3); -#endif - // Migrate. - // - p->at.push_back ("abc"); - -#ifndef DATABASE_SQLITE - p->dfk = 999; - p->ac3 = 1; - p->acn.reset (); - p->acnn = 1; -#endif - db->update (*p); - - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - { - transaction t (db->begin ()); - auto_ptr p (db->load ("1")); - - // Check post-migration. - // - assert (p->at[0] == "abc"); - -#ifndef DATABASE_SQLITE - assert (p->dfk == 999); - assert (*p->ac3 == 1); - assert (!p->acn); - assert (*p->acnn == 1); -#endif - t.commit (); - } - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/combined/model.hxx b/evolution/combined/model.hxx deleted file mode 100644 index e924943..0000000 --- a/evolution/combined/model.hxx +++ /dev/null @@ -1,174 +0,0 @@ -// file : evolution/combined/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include -#include - -#include -#include - -#include // DATABASE_XXX - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ - #pragma db object - struct object1 - { - object1 (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - }; - - #pragma db object - struct object - { - #pragma db id - std::string id_; - - // - // Pre pass 1. - // - - // Drop unique index. - // -#if MODEL_VERSION == 2 - #pragma db unique -#endif - unsigned long dui; - - // Alter table drop foreign key. Not supported by SQLite. - // -#ifndef DATABASE_SQLITE -#if MODEL_VERSION == 2 - object1* dfk; -#else - #pragma db null - unsigned long dfk; -#endif -#endif - - // Add table. - // -#if MODEL_VERSION == 3 - std::vector at; -#endif - - // Add column. - // -#if MODEL_VERSION == 3 - #pragma db default(999) - unsigned long ac1; - - odb::nullable ac2; - - // Initially added as NULL, converted to NOT NULL. Not supported by SQLite. - // -#ifndef DATABASE_SQLITE - #pragma db not_null - odb::nullable ac3; -#endif -#endif - - // Alter column NULL. Not supported by SQLite. - // -#ifndef DATABASE_SQLITE -#if MODEL_VERSION == 2 - unsigned long acn; -#else - odb::nullable acn; -#endif -#endif - - // - // Pre pass 2. - // - - // Add non-unique indexes. - // -#if MODEL_VERSION == 3 - #pragma db index -#endif - unsigned long anui; - - // - // Post pass 1. - // - - // Drop non-unique indexes. - // -#if MODEL_VERSION == 2 - #pragma db index -#endif - unsigned long dnui; - - // - // Post pass 2. - // - - // Drop table. - // -#if MODEL_VERSION == 2 - std::vector dt; -#endif - - // Drop column. Logical drop (set NULL) in SQLite. - // -#if MODEL_VERSION == 2 - unsigned long dc; -#endif - - // Alter column NOT NULL. Not supported by SQLite. - // -#ifndef DATABASE_SQLITE -#if MODEL_VERSION == 3 - #pragma db not_null -#endif - odb::nullable acnn; -#endif - - // Alter table add foreign key. Not supported by SQLite. - // -#ifndef DATABASE_SQLITE -#if MODEL_VERSION == 2 - #pragma db null - unsigned long afk; -#else - object1* afk; -#endif -#endif - - // Add unique index. - // -#if MODEL_VERSION == 3 - #pragma db unique -#endif - unsigned long aui; - - public: -#ifndef DATABASE_SQLITE -#if MODEL_VERSION == 2 - - object (std::string id = ""): id_ (id), dfk (0) {} - ~object () {delete dfk;} -#else - object (std::string id = ""): id_ (id), afk (0) {} - ~object () {delete afk;} -#endif -#else - object (std::string id = ""): id_ (id) {} -#endif - }; -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/combined/test1.hxx b/evolution/combined/test1.hxx deleted file mode 100644 index 1a18aff..0000000 --- a/evolution/combined/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/combined/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/combined/test2.hxx b/evolution/combined/test2.hxx deleted file mode 100644 index 8eb7ac8..0000000 --- a/evolution/combined/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/combined/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/combined/test3.hxx b/evolution/combined/test3.hxx deleted file mode 100644 index 05a052f..0000000 --- a/evolution/combined/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/combined/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/data/driver.cxx b/evolution/data/driver.cxx deleted file mode 100644 index 73cc852..0000000 --- a/evolution/data/driver.cxx +++ /dev/null @@ -1,178 +0,0 @@ -// file : evolution/data/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test data migration support. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include // DATABASE_XXX, HAVE_CXX11 -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -void -migrate1 (database& db) -{ - using namespace v2; - using namespace v3; - - auto_ptr o1 (db.load (1)); - object2 o2 (1); - o2.num = o1->num; - db.persist (o2); -} - -void -migrate2 (database& db) -{ - using namespace v2; - using namespace v3; - - auto_ptr o1 (db.load (2)); - object2 o2 (2); - o2.num = o1->num; - db.persist (o2); -} - -static const data_migration_entry<3, 1> migrate2_entry (&migrate2); - -int -main (int argc, char* argv[]) -{ - schema_catalog::data_migration_function<3, 1> (&migrate1); - -#ifdef HAVE_CXX11 - schema_catalog::data_migration_function<3, 1> ( - [] (database& db) - { - using namespace v2; - using namespace v3; - - auto_ptr o1 (db.load (11)); - object2 o2 (11); - o2.num = o1->num; - db.persist (o2); - }); -#endif - - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - { - transaction t (db->begin ()); - - { - object1 o1 (1); - o1.num = 123; - db->persist (o1); - } - - { - object1 o1 (2); - o1.num = 123; - db->persist (o1); - } - -#ifdef HAVE_CXX11 - { - object1 o1 (11); - o1.num = 123; - db->persist (o1); - } -#endif - t.commit (); - } - break; - } - case 2: - { - { - transaction t (db->begin ()); - - if (embedded) - schema_catalog::migrate (*db); - else - schema_catalog::migrate_data (*db); - - t.commit (); - } - - break; - } - case 3: - { - using namespace v3; - - { - transaction t (db->begin ()); - - { - auto_ptr o2 (db->load (1)); - assert (o2->num == 123); - } - - { - auto_ptr o2 (db->load (2)); - assert (o2->num == 123); - } - -#ifdef HAVE_CXX11 - { - auto_ptr o2 (db->load (11)); - assert (o2->num == 123); - } -#endif - t.commit (); - } - - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/data/model.hxx b/evolution/data/model.hxx deleted file mode 100644 index 680bc55..0000000 --- a/evolution/data/model.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// file : evolution/data/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ -#if MODEL_VERSION == 2 - #pragma db object - struct object1 - { - object1 (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - int num; - }; -#endif - -#if MODEL_VERSION == 3 - #pragma db object - struct object2 - { - object2 (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - int num; - }; -#endif -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/data/test1.hxx b/evolution/data/test1.hxx deleted file mode 100644 index 976ed04..0000000 --- a/evolution/data/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/data/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/data/test2.hxx b/evolution/data/test2.hxx deleted file mode 100644 index bd72940..0000000 --- a/evolution/data/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/data/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/data/test3.hxx b/evolution/data/test3.hxx deleted file mode 100644 index 0f47099..0000000 --- a/evolution/data/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/data/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/drop-column/driver.cxx b/evolution/drop-column/driver.cxx deleted file mode 100644 index 7f0c253..0000000 --- a/evolution/drop-column/driver.cxx +++ /dev/null @@ -1,126 +0,0 @@ -// file : evolution/drop-column/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test dropping a column. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - object o (1); - o.str = "abc"; - o.num = 123; - o.ptr = new object1 (1, 2); - - { - transaction t (db->begin ()); - db->persist (*o.ptr); - db->persist (o); - t.commit (); - } - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - // Things are still there. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - - assert (p->str == "abc"); - assert (p->num == 123); - assert (p->ptr->id.x == 1 && p->ptr->id.y == 2); - - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - // Now they are gone. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "" && p->ptr == 0); - db->erase (value (1, 2)); // SQLite logical delete test. - t.commit (); - } - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/drop-column/model.hxx b/evolution/drop-column/model.hxx deleted file mode 100644 index 09b63b9..0000000 --- a/evolution/drop-column/model.hxx +++ /dev/null @@ -1,59 +0,0 @@ -// file : evolution/drop-column/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#include -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ - #pragma db value - struct value - { - value (int x_ = 0, int y_ = 0): x (x_), y (y_) {} - int x; - int y; - }; - - #pragma db object - struct object1 - { - object1 (int x = 0, int y = 0): id (x, y) {} - - #pragma db id - value id; - }; - - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id), ptr (0) {} - ~object () {delete ptr;} - - #pragma db id - unsigned long id_; - - std::string str; - unsigned long num; - object1* ptr; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) deleted(3) - #pragma db member(object::num) deleted(3) - #pragma db member(object::ptr) deleted(3) -#endif -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/drop-column/test1.hxx b/evolution/drop-column/test1.hxx deleted file mode 100644 index 1efb1fa..0000000 --- a/evolution/drop-column/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/drop-column/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/drop-column/test2.hxx b/evolution/drop-column/test2.hxx deleted file mode 100644 index 2842cd3..0000000 --- a/evolution/drop-column/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/drop-column/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/drop-column/test3.hxx b/evolution/drop-column/test3.hxx deleted file mode 100644 index d1ce616..0000000 --- a/evolution/drop-column/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/drop-column/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/drop-foreign-key/driver.cxx b/evolution/drop-foreign-key/driver.cxx deleted file mode 100644 index f829562..0000000 --- a/evolution/drop-foreign-key/driver.cxx +++ /dev/null @@ -1,145 +0,0 @@ -// file : evolution/drop-foreign-key/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test dropping a foreign key. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - - // SQLite doesn't support dropping of foreign keys. - // -#ifndef DATABASE_SQLITE - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - object o (1); - o.o1 = new object (2); - o.o2 = new object (3); - - { - transaction t (db->begin ()); - db->persist (o.o1); - db->persist (o.o2); - db->persist (o); - t.commit (); - } - - // The foreign key constraint is there. - // - try - { - object o (11); - o.o1 = new object (12); - o.o2 = new object (13); - - transaction t (db->begin ()); - db->persist (o); - assert (false); - } - catch (const odb::exception& ) {} - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - // The data is still there but the constraints are gone. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - - assert (p->o1 == 2); - assert (p->o2 == 3); - - db->erase (p->o1); - db->erase (p->o2); - - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->o1 == 2); - assert (p->o2 == 3); - t.commit (); - } - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } -#endif // DATABASE_SQLITE - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/drop-foreign-key/model.hxx b/evolution/drop-foreign-key/model.hxx deleted file mode 100644 index eed8c46..0000000 --- a/evolution/drop-foreign-key/model.hxx +++ /dev/null @@ -1,50 +0,0 @@ -// file : evolution/drop-foreign-key/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#include - -#include // DATABASE_XXX - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ - #pragma db object - struct object - { - #pragma db id - unsigned long id_; - - // SQLite doesn't support dropping of foreign keys. - // -#ifndef DATABASE_SQLITE -#if MODEL_VERSION == 2 - object* o1; - object* o2; - - object (unsigned long id = 0): id_ (id), o1 (0), o2 (0) {} - ~object () {delete o1; delete o2;} -#else - #pragma db null - unsigned long o1; - - #pragma db null - unsigned long o2; - - object (unsigned long id = 0): id_ (id) {} -#endif -#endif - }; -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/drop-foreign-key/test1.hxx b/evolution/drop-foreign-key/test1.hxx deleted file mode 100644 index 5476796..0000000 --- a/evolution/drop-foreign-key/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/drop-foreign-key/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/drop-foreign-key/test2.hxx b/evolution/drop-foreign-key/test2.hxx deleted file mode 100644 index f091a25..0000000 --- a/evolution/drop-foreign-key/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/drop-foreign-key/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/drop-foreign-key/test3.hxx b/evolution/drop-foreign-key/test3.hxx deleted file mode 100644 index beb8c42..0000000 --- a/evolution/drop-foreign-key/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/drop-foreign-key/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/drop-index/driver.cxx b/evolution/drop-index/driver.cxx deleted file mode 100644 index 5ad1cd4..0000000 --- a/evolution/drop-index/driver.cxx +++ /dev/null @@ -1,154 +0,0 @@ -// file : evolution/drop-index/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test dropping an index. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - object o0 (0); - o0.num = 123; - - object o1 (1); - o1.num = 234; - - object o2 (2); - o2.num = 234; - - { - transaction t (db->begin ()); - db->persist (o0); - db->persist (o1); - t.commit (); - } - - // Duplicates are not ok. - // - try - { - transaction t (db->begin ()); - db->persist (o2); - assert (false); - } - catch (const odb::exception& ) {} - - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - // Duplicates are now ok. - // - object o2 (2); - o2.num = 234; - - { - transaction t (db->begin ()); - db->persist (o2); - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - { - transaction t (db->begin ()); - auto_ptr p0 (db->load (0)); - auto_ptr p1 (db->load (1)); - auto_ptr p2 (db->load (2)); - - assert (p0->num == 123); - assert (p1->num == 234); - assert (p2->num == 234); - - t.commit (); - } - - // Duplicates are still ok. - // - object o3 (3); - o3.num = 234; - - { - transaction t (db->begin ()); - db->persist (o3); - t.commit (); - } - - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/drop-index/model.hxx b/evolution/drop-index/model.hxx deleted file mode 100644 index 5e163ca..0000000 --- a/evolution/drop-index/model.hxx +++ /dev/null @@ -1,33 +0,0 @@ -// file : evolution/drop-index/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - -#if MODEL_VERSION == 2 - #pragma db unique -#endif - unsigned long num; - }; -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/drop-index/test1.hxx b/evolution/drop-index/test1.hxx deleted file mode 100644 index 5a279bb..0000000 --- a/evolution/drop-index/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/drop-index/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/drop-index/test2.hxx b/evolution/drop-index/test2.hxx deleted file mode 100644 index 78b89f2..0000000 --- a/evolution/drop-index/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/drop-index/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/drop-index/test3.hxx b/evolution/drop-index/test3.hxx deleted file mode 100644 index 17b670d..0000000 --- a/evolution/drop-index/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/drop-index/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/drop-table/driver.cxx b/evolution/drop-table/driver.cxx deleted file mode 100644 index 81cec55..0000000 --- a/evolution/drop-table/driver.cxx +++ /dev/null @@ -1,168 +0,0 @@ -// file : evolution/drop-table/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test dropping a table (object, container). -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - { - using namespace v2; - - object1 o1; - o1.o = new object (1); - o1.o->str = "abc"; - o1.nums.push_back (1); - o1.nums.push_back (2); - o1.nums.push_back (3); - - { - transaction t (db->begin ()); - db->persist (o1.o); - db->persist (o1); - t.commit (); - } - } - - // Polymorphism test. - // - { - // We have to use v3 here because the discriminator includes - // the namespace. - // - using namespace v3; - - base b (123, "abc"); - derived d1 (234, "bcd"); - derived d2 (345, "cde"); - - { - transaction t (db->begin ()); - db->persist (b); - db->persist (d1); - db->persist (d2); - t.commit (); - } - } - - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - // Both object and object1 are still there so we can migrate the data. - // - typedef odb::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - result r (db->query (query::o->str == "abc")); - result::iterator i (r.begin ()), e (r.end ()); - - assert (i != e && - i->o->id_ == 1 && - i->nums[0] == 1 && i->nums[1] == 2 && i->nums[2] == 3); - assert (++i == e); - - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - - break; - } - case 3: - { - using namespace v3; - - // Only object is still there. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "abc"); - t.commit (); - } - - // Polymorphism test. - // - { - transaction t (db->begin ()); - assert (size (db->query ()) == 1); - assert (size (db->query ()) == 1); - t.commit (); - } - - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/drop-table/model.hxx b/evolution/drop-table/model.hxx deleted file mode 100644 index 2c02d09..0000000 --- a/evolution/drop-table/model.hxx +++ /dev/null @@ -1,94 +0,0 @@ -// file : evolution/drop-table/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include -#include - -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - std::string str; - }; - - #pragma db object - struct object1 - { - object1 (): o (0) {} - ~object1 () {delete o;} - - #pragma db id auto - unsigned long id_; - - object* o; - std::vector nums; - }; - -#if MODEL_VERSION == 3 - #pragma db object(object1) deleted(3) -#endif - - // Make sure we also clean up base tables when dropping a - // table corresponding to the polymorphic derived object. - // - #pragma db value - struct value - { - value (unsigned long n = 0, const std::string& s = ""): num (n), str (s) {} - - unsigned long num; - std::string str; - }; - - #pragma db object polymorphic - struct root - { - root (unsigned long n = 0, const std::string& s = ""): id (n, s) {} - virtual ~root () {} - - #pragma db id - value id; - }; - - #pragma db object - struct base: root - { - base (unsigned long n = 0, const std::string& s = "") - : root (n, s), num (n) {} - - unsigned long num; - }; - - #pragma db object - struct derived: base - { - derived (unsigned long n = 0, const std::string& s = "") - : base (n, s), str (s) {} - - std::string str; - }; - -#if MODEL_VERSION == 3 - #pragma db object(derived) deleted(3) -#endif -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/drop-table/test1.hxx b/evolution/drop-table/test1.hxx deleted file mode 100644 index a9ec64c..0000000 --- a/evolution/drop-table/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/drop-table/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/drop-table/test2.hxx b/evolution/drop-table/test2.hxx deleted file mode 100644 index c9ec149..0000000 --- a/evolution/drop-table/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/drop-table/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/drop-table/test3.hxx b/evolution/drop-table/test3.hxx deleted file mode 100644 index 8d3f17b..0000000 --- a/evolution/drop-table/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/drop-table/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/embedded/driver.cxx b/evolution/embedded/driver.cxx deleted file mode 100644 index 1816a5c..0000000 --- a/evolution/embedded/driver.cxx +++ /dev/null @@ -1,181 +0,0 @@ -// file : evolution/embedded/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test embedded schema migration. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include // DATABASE_XXX -#include - -#ifdef DATABASE_PGSQL -# include -#endif - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - t.commit (); - } - - // PostgreSQL cannot continue a transaction after a query failed. We - // have a workaround but only for 9.4+. - // -#ifdef DATABASE_PGSQL - { - odb::connection_ptr c (db->connection ()); - int v (static_cast (*c).server_version ()); - if (v < 90400) - assert (db->schema_version () == 0); - } -#endif - - { - transaction t (db->begin ()); - assert (db->schema_version () == 0); - - schema_catalog::create_schema (*db, "", false); - - assert (db->schema_version () == 1 && !db->schema_migration ()); - - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - assert (db->schema_version () == 2 && !db->schema_migration ()); - - { - transaction t (db->begin ()); - object1 o1 (1); - o1.num = 123; - db->persist (o1); - t.commit (); - } - break; - } - case 2: - { - using namespace v2; - using namespace v3; - - // Check version information correctness. - // - assert (schema_catalog::base_version (*db) == 1); - assert (schema_catalog::current_version (*db) == 3); - assert (schema_catalog::next_version (*db, 0) == 3); - assert (schema_catalog::next_version (*db, 1) == 2); - assert (schema_catalog::next_version (*db) == 3); - assert (schema_catalog::next_version (*db, 3) == 4); - - { - assert (db->schema_version () == 2 && !db->schema_migration ()); - - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - assert (db->schema_version () == 3 && db->schema_migration ()); - - { - transaction t (db->begin ()); - auto_ptr o1 (db->load (1)); - object2 o2 (1); - o2.num = o1->num; - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - - assert (db->schema_version () == 3 && !db->schema_migration ()); - } - break; - } - case 3: - { - using namespace v3; - - // In transaction. - // - { - transaction t (db->begin ()); - assert (db->schema_version () == 3 && !db->schema_migration ()); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr o2 (db->load (1)); - assert (o2->num == 123); - t.commit (); - } - - // Test the case where there is still no version table. - // - db->schema_version_migration (0, false); - - { - transaction t (db->begin ()); - -#ifdef DATABASE_ORACLE - db->execute ("DROP TABLE \"schema_version\""); -#else - db->execute ("DROP TABLE schema_version"); -#endif - t.commit (); - } - - assert (db->schema_version () == 0); - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/embedded/model.hxx b/evolution/embedded/model.hxx deleted file mode 100644 index f3aa7a4..0000000 --- a/evolution/embedded/model.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// file : evolution/embedded/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ -#if MODEL_VERSION == 2 - #pragma db object - struct object1 - { - object1 (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - int num; - }; -#endif - -#if MODEL_VERSION == 3 - #pragma db object - struct object2 - { - object2 (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - int num; - }; -#endif -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/embedded/test1.hxx b/evolution/embedded/test1.hxx deleted file mode 100644 index 32903a1..0000000 --- a/evolution/embedded/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/embedded/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/embedded/test2.hxx b/evolution/embedded/test2.hxx deleted file mode 100644 index fce8760..0000000 --- a/evolution/embedded/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/embedded/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/embedded/test3.hxx b/evolution/embedded/test3.hxx deleted file mode 100644 index d49ecc5..0000000 --- a/evolution/embedded/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/embedded/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/soft-add/driver.cxx b/evolution/soft-add/driver.cxx deleted file mode 100644 index c70edcb..0000000 --- a/evolution/soft-add/driver.cxx +++ /dev/null @@ -1,2219 +0,0 @@ -// file : evolution/soft-add/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test soft-add functionality. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include // DATABASE_XXX -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v3; // NOTE: not v2. - - if (embedded) - { - // SQLite has broken foreign keys when it comes to DDL. - // -#ifdef DATABASE_SQLITE - db->connection ()->execute ("PRAGMA foreign_keys=OFF"); -#endif - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - -#ifdef DATABASE_SQLITE - db->connection ()->execute ("PRAGMA foreign_keys=ON"); -#endif - } - - // Test basic soft-added member logic. - // - { - using namespace test2; - - // None of the database operations should yet include the - // added members. - // - { - object o (1); - o.str = "abc"; - o.num = 123; - o.vec.push_back (123); - o.ptr = new object1 (1); - o.ptr->ptrs.push_back (&o); - - transaction t (db->begin ()); - db->persist (o); - db->persist (*o.ptr); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "" && p->num == 123 && - p->vec.empty () && p->ptr == 0); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && - i->str == "" && i->num == 123 && - i->vec.empty () && i->ptr == 0); - - try - { - db->query (query::str.is_null ()); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - o.ptr = new object1 (2); - o.ptr->ptrs.push_back (&o); - - { - transaction t (db->begin ()); - db->persist (o); - db->persist (*o.ptr); - auto_ptr p (db->load (2)); - assert (p->str == "" && p->num == 234 && - p->vec.empty () && p->ptr == 0); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; - delete o.ptr; - o.ptr = 0; - - { - transaction t (db->begin ()); - db->erase (2); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->str == "" && p->num == 235 && - p->vec.empty () && p->ptr == 0); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test empty statement handling (INSERT, UPDATE). - // - { - using namespace test3; - - // None of the database operations should yet include the - // added members. - // - object o; - o.str = "bcd"; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (o.id)); - assert (p->str == ""); - t.commit (); - } - - o.str += 'e'; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (o.id)); - assert (p->str == ""); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test empty statement handling (SELECT in polymorphic loader). - // - { - using namespace test4; - - // None of the database operations should yet include the - // added members. - // - object o (1); - o.str = "abc"; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (1)); - assert (static_cast (*p).str == ""); - db->erase (o); - t.commit (); - } - } - - // Test container with soft-added value member. - // - { - using namespace test5; - - // None of the database operations should yet include the - // added members. - // - { - object o (1); - o.vec.push_back (value ("abc", 123)); - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->vec[0].str == "" && p->vec[0].num == 123); - t.commit (); - } - - object o (2); - o.vec.push_back (value ("bcd", 234)); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->vec[0].str == "" && p->vec[0].num == 234); - t.commit (); - } - - o.vec.modify (0).str += 'e'; - o.vec.modify (0).num++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->vec[0].str == "" && p->vec[0].num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test view with soft-added member. - // - { - using namespace test6; - - // None of the database operations should yet include the - // added members. - // - { - object o (1); - o.str = "abc"; - o.num = 123; - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "" && i->num == 123); - - try - { - db->query (query::str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - } - - // Test soft-added section member. - // - { - using namespace test7; - - // None of the database operations should yet include the - // added members. - // - { - object o (1); - o.str = "abc"; - o.num = 123; - o.vec.push_back (123); - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - - try - { - db->load (*p, p->s); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; - o.s.change (); - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test soft-added members of a section. - // - { - using namespace test8; - - // None of the database operations should yet include the - // added members. - // - { - object o (1); - o.str = "abc"; - o.num = 123; - o.vec.push_back (123); - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->str == "" && p->num == 123 && p->vec.empty ()); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - assert (i->str == "" && i->num == 123 && i->vec.empty ()); - - try - { - db->query (query::str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "" && p->num == 234 && p->vec.empty ()); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; // No longer automatically marked as changed. - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "" && p->num == 234 && p->vec.empty ()); - t.commit (); - } - - o.s.change (); - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "" && p->num == 235 && p->vec.empty ()); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test basic soft-added member logic in polymorphic classes. - // - { - using namespace test9; - - // None of the database operations should yet include the - // added members. - // - { - object o (1); - o.bstr = "ab"; - o.dstr = "abc"; - o.num = 123; - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (static_cast (db->load (1))); - assert (p->bstr == "" && p->dstr == "" && p->num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::id == 1)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - object& o (static_cast (*i)); - assert (o.bstr == "" && o.dstr == "" && o.num == 123); - - try - { - db->query (query::bstr == "ab"); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && - i->bstr == "" && i->dstr == "" && i->num); - - try - { - db->query (query::dstr == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - auto_ptr p (db->load (2)); - assert (p->bstr == "" && p->dstr == "" && p->num == 234); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - auto_ptr p (db->load (2)); - assert (p->bstr == "" && p->dstr == "" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test soft-added section member in polymorphic classes. - // - { - using namespace test10; - - // None of the database operations should yet include the - // added members. - // - { - object o (1); - o.bstr = "ab"; - o.dstr = "abc"; - o.num = 123; - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - - try - { - db->load (*p, p->s); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - o.s.change (); - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test soft-added members of a section in polymorphic classes. - // - { - using namespace test11; - - // None of the database operations should yet include the - // added members. - // - { - object o (1); - o.bstr = "ab"; - o.dstr = "abc"; - o.num = 123; - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - object& o (static_cast (*p)); - assert (o.bstr == "" && o.dstr == "" && o.num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::id == 1)); - result::iterator i (r.begin ()); - db->load (*i, i->s); - assert (i != r.end ()); - object& o (static_cast (*i)); - assert (o.bstr == "" && o.dstr == "" && o.num == 123); - - try - { - db->query (query::bstr == "ab"); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - db->load (*i, i->s); - assert (i != r.end () && - i->bstr == "" && i->dstr == "" && i->num); - - try - { - db->query (query::dstr == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "" && p->dstr == "" && p->num == 234); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - o.s.change (); - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "" && p->dstr == "" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - - // Test empty statement detection in sections. - // - base b (3); - b.bstr = "bc"; - - { - transaction t (db->begin ()); - db->persist (b); - auto_ptr p (db->load (3)); - db->load (*p, p->s); - assert (p->bstr == ""); - t.commit (); - } - - b.bstr += 'd'; - b.s.change (); - - { - transaction t (db->begin ()); - db->update (b); - auto_ptr p (db->load (3)); - db->load (*p, p->s); - assert (p->bstr == ""); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (b); - t.commit (); - } - } - - // Test soft-added member and optimistic concurrency. - // - { - using namespace test12; - - // None of the database operations should yet include the - // added members. - // - { - object o (1); - o.str = "abc"; - o.num = 123; - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "" && p->num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "" && i->num == 123); - - try - { - db->query (query::str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->str == "" && p->num == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - - { - transaction t (db->begin ()); - unsigned long long v (o.v_); - db->update (o); - assert (o.v_ != v); - auto_ptr p (db->load (2)); - assert (p->str == "" && p->num == 235 && p->v_ == o.v_); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test soft-added member in an object without id. - // - { - using namespace test13; - - typedef odb::query query; - typedef odb::result result; - - // None of the database operations should yet include the - // added members. - // - { - object o; - o.str = "abc"; - o.num = 123; - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "" && i->num == 123); - - try - { - db->query (query::str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - - object o; - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - - result r (db->query (query::num == 234)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "" && i->num == 234); - - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase_query (query::num == 234); - t.commit (); - } - } - - // Test soft-added member in an object with auto id. - // - { - using namespace test14; - - // None of the database operations should yet include the - // added members. - // - unsigned long id; - { - object o; - o.str = "abc"; - o.num = 123; - - transaction t (db->begin ()); - db->persist (o); - id = o.id; - t.commit (); - } - { - transaction t (db->begin ()); - auto_ptr p (db->load (id)); - assert (p->str == "" && p->num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "" && i->num == 123); - - try - { - db->query (query::str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} - - t.commit (); - } - - object o; - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (o.id)); - assert (p->str == "" && p->num == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (o.id)); - assert (p->str == "" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o.id); - t.commit (); - } - } - - // Test soft-added container member in a non-versioned object. - // - { - using namespace test21; - - // None of the database operations should yet include the - // added members. - // - { - object o (1); - o.num = 123; - o.vec.push_back (123); - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->num == 123 && p->vec.empty ()); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->num == 123 && i->vec.empty ()); - t.commit (); - } - - object o (2); - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->num == 234 && p->vec.empty ()); - t.commit (); - } - - o.num++; - o.vec.modify (0)++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->num == 235 && p->vec.empty ()); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test soft-added container member in a non-versioned section. - // - { - using namespace test22; - - // None of the database operations should yet include the - // added members. - // - { - object o (1); - o.num = 123; - o.vec.push_back (123); - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->num == 123 && p->vec.empty ()); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - assert (i->num == 123 && i->vec.empty ()); - t.commit (); - } - - object o (2); - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->num == 234 && p->vec.empty ()); - t.commit (); - } - - o.num++; - o.vec.modify (0)++; // No longer automatically marks as changed. - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->num == 234 && p->vec.empty ()); - t.commit (); - } - - o.s.change (); - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->num == 235 && p->vec.empty ()); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - // Test basic soft-added member logic. - // - { - using namespace test2; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - p->str = "abc"; - p->vec.push_back (123); - delete p->ptr; - p->ptr = new object1 (1); - db->update (*p); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "abc" && p->num == 123 && - p->vec[0] == 123 && p->ptr->id_ == 1); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str.is_not_null () && - query::ptr->id == 1)); - result::iterator i (r.begin ()); - assert (i != r.end () && - i->str == "abc" && i->num == 123 && - i->vec[0] == 123 && i->ptr->id_ == 1); - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - o.ptr = new object1 (2); - o.ptr->ptrs.push_back (&o); - - { - transaction t (db->begin ()); - db->persist (o); - db->persist (*o.ptr); - auto_ptr p (db->load (2)); - assert (p->str == "bcd" && p->num == 234 && - p->vec[0] == 234 && p->ptr->id_ == 2); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; - delete o.ptr; - o.ptr = 0; - - { - transaction t (db->begin ()); - db->erase (2); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->str == "bcde" && p->num == 235 && - p->vec[0] == 235 && p->ptr == 0); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test container with soft-added value member. - // - { - using namespace test5; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - p->vec.modify (0).str = "abc"; - db->update (*p); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->vec[0].str == "abc" && p->vec[0].num == 123); - t.commit (); - } - - object o (2); - o.vec.push_back (value ("bcd", 234)); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->vec[0].str == "bcd" && p->vec[0].num == 234); - t.commit (); - } - - o.vec.modify (0).str += 'e'; - o.vec.modify (0).num++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->vec[0].str == "bcde" && p->vec[0].num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test view with soft-added member. - // - { - using namespace test6; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - p->str = "abc"; - db->update (*p); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "abc" && i->num == 123); - t.commit (); - } - } - - // Test soft-added section member. - // - { - using namespace test7; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - p->str = "abc"; - p->vec.push_back (123); - db->update (*p, p->s); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - assert (i->str == "abc" && i->num == 123 && i->vec[0] == 123); - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "bcd" && p->num == 234 && p->vec[0] == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; // Automatically marks section as updated. - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "bcde" && p->num == 235 && p->vec[0] == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test soft-added members of a section. - // - { - using namespace test8; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - p->str = "abc"; - p->vec.push_back (123); - db->update (*p, p->s); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - assert (i->str == "abc" && i->num == 123 && i->vec[0] == 123); - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "bcd" && p->num == 234 && p->vec[0] == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; // Automatically marks section as updated. - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "bcde" && p->num == 235 && p->vec[0] == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test basic soft-added member logic in polymorphic classes. - // - { - using namespace test9; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - p->bstr = "ab"; - p->dstr = "abc"; - db->update (*p); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (static_cast (db->load (1))); - assert (p->bstr == "ab" && p->dstr == "abc" && p->num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::bstr == "ab")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - object& o (static_cast (*i)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - auto_ptr p (db->load (2)); - assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - auto_ptr p (db->load (2)); - assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (static_cast (o)); - t.commit (); - } - } - - // Test soft-added section member in polymorphic classes. - // - { - using namespace test10; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - p->bstr = "ab"; - p->dstr = "abc"; - db->update (*p, p->s); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - object& o (static_cast (*p)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::bstr == "ab")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - object& o (static_cast (*i)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - o.s.change (); - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (static_cast (o)); - t.commit (); - } - } - - // Test soft-added members of a section in polymorphic classes. - // - { - using namespace test11; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - p->bstr = "ab"; - p->dstr = "abc"; - db->update (*p, p->s); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - object& o (static_cast (*p)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::bstr == "ab")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - object& o (static_cast (*i)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - o.s.change (); - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (static_cast (o)); - t.commit (); - } - } - - // Test soft-added member and optimistic concurrency. - // - { - using namespace test12; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - p->str = "abc"; - db->update (*p); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "abc" && p->num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "abc" && i->num == 123); - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->str == "bcd" && p->num == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - - { - transaction t (db->begin ()); - unsigned long long v (o.v_); - db->update (o); - assert (o.v_ != v); - auto_ptr p (db->load (2)); - assert (p->str == "bcde" && p->num == 235 && p->v_ == o.v_); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test soft-added member in an object without id. - // - { - using namespace test13; - - typedef odb::query query; - typedef odb::result result; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "abc" && i->num == 123); - t.commit (); - } - - object o; - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - - result r (db->query (query::str == "bcd")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "bcd" && i->num == 234); - - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase_query (query::str == "bcd"); - t.commit (); - } - } - - // Test soft-added member in an object with auto id. - // - { - using namespace test14; - - typedef odb::query query; - typedef odb::result result; - - // All the database operations should now include the added - // members. - // - unsigned long id; - { - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - i->str = "abc"; - db->update (*i); - id = i->id; - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (id)); - assert (p->str == "abc" && p->num == 123); - t.commit (); - } - - { - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "abc" && i->num == 123); - t.commit (); - } - - object o; - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (o.id)); - assert (p->str == "bcd" && p->num == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (o.id)); - assert (p->str == "bcde" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test soft-added container member in a non-versioned object. - // - { - using namespace test21; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - p->vec.push_back (123); - db->update (*p); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->num == 123 && p->vec[0] == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->num == 123 && i->vec[0] == 123); - t.commit (); - } - - object o (2); - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->num == 234 && p->vec[0] == 234); - t.commit (); - } - - o.num++; - o.vec.modify (0)++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->num == 235 && p->vec[0] == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test soft-added container member in a non-versioned section. - // - { - using namespace test22; - - // All the database operations should now include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - p->vec.push_back (123); - db->update (*p, p->s); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->num == 123 && p->vec[0] == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - assert (i->num == 123 && i->vec[0] == 123); - t.commit (); - } - - object o (2); - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->num == 234 && p->vec[0] == 234); - t.commit (); - } - - o.num++; - o.vec.modify (0)++; // Automatically marks section as changed. - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->num == 235 && p->vec[0] == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - // Test basic soft-added member logic. - // - { - using namespace test2; - - // All the database operations should still include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "abc" && p->num == 123 && - p->vec[0] == 123 && p->ptr->id_ == 1); - t.commit (); - } - } - - // Test container with soft-added value member. - // - { - using namespace test5; - - // All the database operations should still include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->vec[0].str == "abc" && p->vec[0].num == 123); - t.commit (); - } - } - - // Test view with soft-added member. - // - { - using namespace test6; - - // All the database operations should still include the added - // members. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "abc" && i->num == 123); - t.commit (); - } - } - - // Test soft-added section member. - // - { - using namespace test7; - - // All the database operations should still include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); - t.commit (); - } - } - - // Test soft-added members of a section. - // - { - using namespace test8; - - // All the database operations should still include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); - t.commit (); - } - } - - // Test basic soft-added member logic in polymorphic classes. - // - { - using namespace test9; - - // All the database operations should still include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (static_cast (db->load (1))); - assert (p->bstr == "ab" && p->dstr == "abc" && p->num == 123); - t.commit (); - } - } - - // Test soft-added section member in polymorphic classes. - // - { - using namespace test10; - - // All the database operations should still include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - object& o (static_cast (*p)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - } - - // Test soft-added members of a section in polymorphic classes. - // - { - using namespace test11; - - // All the database operations should still include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - object& o (static_cast (*p)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - } - - // Test soft-added member and optimistic concurrency. - // - { - using namespace test12; - - // All the database operations should still include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "abc" && p->num == 123); - t.commit (); - } - } - - // Test soft-added member in an object without id. - // - { - using namespace test13; - - typedef odb::query query; - typedef odb::result result; - - // All the database operations should still include the added - // members. - // - { - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "abc" && i->num == 123); - t.commit (); - } - } - - // Test soft-added member in an object with auto id. - // - { - using namespace test14; - - // All the database operations should still include the added - // members. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "abc" && i->num == 123); - t.commit (); - } - } - - // Test soft-added container member in a non-versioned object. - // - { - using namespace test21; - - // All the database operations should still include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->num == 123 && p->vec[0] == 123); - t.commit (); - } - } - - // Test soft-added container member in a non-versioned section. - // - { - using namespace test22; - - // All the database operations should still include the added - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->num == 123 && p->vec[0] == 123); - t.commit (); - } - } - - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/soft-add/model.hxx b/evolution/soft-add/model.hxx deleted file mode 100644 index 39d63c4..0000000 --- a/evolution/soft-add/model.hxx +++ /dev/null @@ -1,504 +0,0 @@ -// file : evolution/soft-add/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#include -#include -#include -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ - // The test numbers are made to correspond to the soft-delete ones. - // - - // Test basic soft-added member logic. - // - #pragma db namespace table("t2_") - namespace test2 - { - struct object; - - #pragma db object - struct object1 - { - object1 (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - odb::vector > ptrs; - }; - - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id), ptr (0) {} - ~object () {delete ptr;} - - #pragma db id - unsigned long id_; - - std::string str; - unsigned long num; - odb::vector vec; - - #pragma db inverse(ptrs) - object1* ptr; - }; - -#if MODEL_VERSION == 3 - // Make it a LOB for Oracle and long data for SQL Server. - // - #pragma db member(object::str) added(3) \ - oracle:type("CLOB") \ - mssql:type("VARCHAR(max)") - #pragma db member(object::vec) added(3) - #pragma db member(object::ptr) added(3) -#else - #pragma db member(object::str) transient - #pragma db member(object::vec) transient - #pragma db member(object::ptr) transient -#endif - } - - // Test empty statement handling (INSERT, UPDATE). - // - #pragma db namespace table("t3_") - namespace test3 - { - #pragma db object - struct object - { - #pragma db id auto - unsigned long id; - - std::string str; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) added(3) -#else - #pragma db member(object::str) transient -#endif - } - - // Test empty statement handling (SELECT in polymorphic loader). - // - #pragma db namespace table("t4_") - namespace test4 - { - #pragma db object polymorphic - struct base - { - virtual - ~base () {} - base (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - }; - - #pragma db object - struct object: base - { - object (unsigned long id = 0): base (id) {} - - std::string str; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) added(3) -#else - #pragma db member(object::str) transient -#endif - } - - // Test container with soft-added value member. - // - #pragma db namespace table("t5_") - namespace test5 - { - #pragma db value - struct value - { - value () {} - value (const std::string& s, unsigned long n): str (s), num (n) {} - - std::string str; - unsigned long num; - }; - - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - odb::vector vec; - }; - -#if MODEL_VERSION == 3 - #pragma db member(value::str) added(3) -#else - #pragma db member(value::str) transient -#endif - } - - // Test view with soft-added member. - // - #pragma db namespace table("t6_") - namespace test6 - { - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - std::string str; - unsigned long num; - }; - - #pragma db view object(object) - struct view - { - std::string str; - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) added(3) - #pragma db member(view::str) added(3) -#else - #pragma db member(object::str) transient - #pragma db member(view::str) transient -#endif - } - - // Test soft-added section member. - // - #pragma db namespace table("t7_") - namespace test7 - { - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - -#if MODEL_VERSION == 3 - #pragma db load(lazy) update(change) added(3) - odb::section s; -#endif - - #pragma db section(s) - std::string str; - - unsigned long num; - - #pragma db section(s) - odb::vector vec; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) section(s) - #pragma db member(object::vec) section(s) -#else - #pragma db member(object::str) transient - #pragma db member(object::vec) transient -#endif - } - - // Test soft-added members of a section. - // - #pragma db namespace table("t8_") - namespace test8 - { - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db load(lazy) update(change) - odb::section s; - - std::string str; - - #pragma db section(s) - unsigned long num; - - odb::vector vec; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) added(3) section(s) - #pragma db member(object::vec) added(3) section(s) -#else - #pragma db member(object::str) transient - #pragma db member(object::vec) transient -#endif - } - - // Test basic soft-added member logic in polymorphic classes. - // - #pragma db namespace table("t9_") - namespace test9 - { - #pragma db object polymorphic - struct base - { - virtual - ~base () {} - base (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - std::string bstr; - }; - - #pragma db object - struct object: base - { - object (unsigned long id = 0): base (id) {} - - std::string dstr; - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(base::bstr) added(3) - #pragma db member(object::dstr) added(3) -#else - #pragma db member(base::bstr) transient - #pragma db member(object::dstr) transient -#endif - } - - // Test soft-added section member in polymorphic classes. - // - #pragma db namespace table("t10_") - namespace test10 - { - #pragma db object polymorphic - struct base - { - virtual - ~base () {} - base (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - -#if MODEL_VERSION == 3 - #pragma db load(lazy) update(change) added(3) - odb::section s; -#endif - - std::string bstr; - }; - - #pragma db object - struct object: base - { - object (unsigned long id = 0): base (id) {} - - std::string dstr; - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(base::bstr) section(s) - #pragma db member(object::dstr) section(s) -#else - #pragma db member(base::bstr) transient - #pragma db member(object::dstr) transient -#endif - } - - // Test soft-added members of a section in polymorphic classes. - // - #pragma db namespace table("t11_") - namespace test11 - { - #pragma db object polymorphic - struct base - { - virtual - ~base () {} - base (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db load(lazy) update(change) - odb::section s; - - std::string bstr; - }; - - #pragma db object - struct object: base - { - object (unsigned long id = 0): base (id) {} - - std::string dstr; - - #pragma db section(s) - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(base::bstr) added(3) section(s) - #pragma db member(object::dstr) added(3) section(s) -#else - #pragma db member(base::bstr) transient - #pragma db member(object::dstr) transient -#endif - } - - // Test soft-added member and optimistic concurrency. - // - #pragma db namespace table("t12_") - namespace test12 - { - #pragma db object optimistic - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db version mssql:type("ROWVERSION") - unsigned long long v_; - - std::string str; - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) added(3) -#else - #pragma db member(object::str) transient -#endif - } - - // Test soft-added member in an object without id. - // - #pragma db namespace table("t13_") - namespace test13 - { - #pragma db object no_id - struct object - { - std::string str; - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) added(3) default("abc") \ - mysql:type("VARCHAR(255)") -#else - #pragma db member(object::str) transient -#endif - } - - // Test soft-added member in an object with auto id. - // - #pragma db namespace table("t14_") - namespace test14 - { - #pragma db object - struct object - { - std::string str; - unsigned long num; - - #pragma db id auto - unsigned long id; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) added(3) -#else - #pragma db member(object::str) transient -#endif - } - - // Test soft-added container member in a non-versioned object. - // - #pragma db namespace table("t21_") - namespace test21 - { - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - unsigned long num; - odb::vector vec; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::vec) added(3) -#else - #pragma db member(object::vec) transient -#endif - } - - // Test soft-added container member in a non-versioned section. - // - #pragma db namespace table("t22_") - namespace test22 - { - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db load(lazy) update(change) - odb::section s; - - #pragma db section(s) - unsigned long num; - - odb::vector vec; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::vec) added(3) section(s) -#else - #pragma db member(object::vec) transient -#endif - } -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/soft-add/test1.hxx b/evolution/soft-add/test1.hxx deleted file mode 100644 index 461d663..0000000 --- a/evolution/soft-add/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/soft-add/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/soft-add/test2.hxx b/evolution/soft-add/test2.hxx deleted file mode 100644 index 746da4b..0000000 --- a/evolution/soft-add/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/soft-add/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/soft-add/test3.hxx b/evolution/soft-add/test3.hxx deleted file mode 100644 index f2990d0..0000000 --- a/evolution/soft-add/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/soft-add/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/soft-delete/driver.cxx b/evolution/soft-delete/driver.cxx deleted file mode 100644 index e41a70c..0000000 --- a/evolution/soft-delete/driver.cxx +++ /dev/null @@ -1,2202 +0,0 @@ -// file : evolution/soft-delete/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test soft-delete functionality. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include // DATABASE_XXX -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - // SQLite has broken foreign keys when it comes to DDL. - // -#ifdef DATABASE_SQLITE - db->connection ()->execute ("PRAGMA foreign_keys=OFF"); -#endif - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - -#ifdef DATABASE_SQLITE - db->connection ()->execute ("PRAGMA foreign_keys=ON"); -#endif - } - - // Test soft-deleted objects. - // - { - using namespace test1; - - object o (1); - o.num = 123; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test basic soft-deleted member logic. - // - { - using namespace test2; - - object o (1); - o.str = "abc"; - o.num = 123; - o.vec.push_back (123); - o.ptr = new object1 (1); - o.ptr->ptrs.push_back (&o); - - { - transaction t (db->begin ()); - db->persist (o); - db->persist (*o.ptr); - t.commit (); - } - } - - // Test container with soft-deleted value member. - // - { - using namespace test5; - - object o (1); - o.vec.push_back (value ("abc", 123)); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test view with soft-deleted member. - // - { - using namespace test6; - - object o (1); - o.str = "abc"; - o.num = 123; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test soft-deleted section member. - // - { - using namespace test7; - - object o (1); - o.str = "abc"; - o.num = 123; - o.vec.push_back (123); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test soft-deleted members of a section. - // - { - using namespace test8; - - object o (1); - o.str = "abc"; - o.num = 123; - o.vec.push_back (123); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test basic soft-deleted member logic in polymorphic classes. - // - { - // We have to use v3 here because the discriminator includes - // the namespace. - // - using namespace v3::test9; - - object o (1); - o.bstr = "ab"; - o.dstr = "abc"; - o.num = 123; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test soft-deleted section member in polymorphic classes. - // - { - // We have to use v3 here because the discriminator includes - // the namespace. - // - using namespace v3::test10; - - object o (1); - o.bstr = "ab"; - o.dstr = "abc"; - o.num = 123; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test soft-deleted members of a section in polymorphic classes. - // - { - // We have to use v3 here because the discriminator includes - // the namespace. - // - using namespace v3::test11; - - object o (1); - o.bstr = "ab"; - o.dstr = "abc"; - o.num = 123; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test soft-deleted member and optimistic concurrency. - // - { - using namespace test12; - - object o (1); - o.str = "abc"; - o.num = 123; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test soft-deleted member in an object without id. - // - { - using namespace test13; - - object o; - o.str = "abc"; - o.num = 123; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test soft-deleted member in an object with auto id. - // - { - using namespace test14; - - object o; - o.str = "abc"; - o.num = 123; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test summarily deleted composite values. - // - { - using namespace test15; - - object o (1); - o.v.reset (new value); - o.v->str = "abc"; - o.v->vec.push_back (123); - o.num = 123; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test soft-deleted container member in a non-versioned object. - // - { - using namespace test21; - - object o (1); - o.num = 123; - o.vec.push_back (123); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - // Test soft-deleted container member in a non-versioned section. - // - { - using namespace test22; - - object o (1); - o.num = 123; - o.vec.push_back (123); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - } - - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - // Test soft-deleted objects. - // - { - using namespace test1; - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->num == 123); - t.commit (); - } - } - - // Test basic soft-deleted member logic. - // - { - using namespace test2; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "abc" && p->num == 123 && - p->vec[0] == 123 && p->ptr->id_ == 1); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc" && - query::ptr->id == 1)); - result::iterator i (r.begin ()); - assert (i != r.end () && - i->str == "abc" && i->num == 123 && - i->vec[0] == 123 && i->ptr->id_ == 1); - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - o.ptr = new object1 (2); - o.ptr->ptrs.push_back (&o); - - { - transaction t (db->begin ()); - db->persist (o); - db->persist (*o.ptr); - auto_ptr p (db->load (2)); - assert (p->str == "bcd" && p->num == 234 && - p->vec[0] == 234 && p->ptr->id_ == 2); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; - delete o.ptr; - o.ptr = 0; - - { - transaction t (db->begin ()); - db->erase (2); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->str == "bcde" && p->num == 235 && - p->vec[0] == 235 && p->ptr == 0); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test container with soft-deleted value member. - // - { - using namespace test5; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->vec[0].str == "abc" && p->vec[0].num == 123); - t.commit (); - } - - object o (2); - o.vec.push_back (value ("bcd", 234)); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->vec[0].str == "bcd" && p->vec[0].num == 234); - t.commit (); - } - - o.vec.modify (0).str += 'e'; - o.vec.modify (0).num++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->vec[0].str == "bcde" && p->vec[0].num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test view with soft-deleted member. - // - { - using namespace test6; - - // All the database operations should still include the deleted - // members. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "abc" && i->num == 123); - t.commit (); - } - } - - // Test soft-deleted section member. - // - { - using namespace test7; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - assert (i->str == "abc" && i->num == 123 && i->vec[0] == 123); - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "bcd" && p->num == 234 && p->vec[0] == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; // Automatically marks section as updated. - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "bcde" && p->num == 235 && p->vec[0] == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test soft-deleted members of a section. - // - { - using namespace test8; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - assert (i->str == "abc" && i->num == 123 && i->vec[0] == 123); - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "bcd" && p->num == 234 && p->vec[0] == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; // Automatically marks section as updated. - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "bcde" && p->num == 235 && p->vec[0] == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test basic soft-deleted member logic in polymorphic classes. - // - { - using namespace test9; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (static_cast (db->load (1))); - assert (p->bstr == "ab" && p->dstr == "abc" && p->num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::bstr == "ab")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - object& o (static_cast (*i)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - auto_ptr p (db->load (2)); - assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - auto_ptr p (db->load (2)); - assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (static_cast (o)); - t.commit (); - } - } - - // Test soft-deleted section member in polymorphic classes. - // - { - using namespace test10; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - object& o (static_cast (*p)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::bstr == "ab")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - object& o (static_cast (*i)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - o.s.change (); - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (static_cast (o)); - t.commit (); - } - } - - // Test soft-deleted members of a section in polymorphic classes. - // - { - using namespace test11; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - object& o (static_cast (*p)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::bstr == "ab")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - object& o (static_cast (*i)); - assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - o.s.change (); - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (static_cast (o)); - t.commit (); - } - } - - // Test soft-deleted member and optimistic concurrency. - // - { - using namespace test12; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "abc" && p->num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "abc" && i->num == 123); - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->str == "bcd" && p->num == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - - { - transaction t (db->begin ()); - unsigned long long v (o.v_); - db->update (o); - assert (o.v_ != v); - auto_ptr p (db->load (2)); - assert (p->str == "bcde" && p->num == 235 && p->v_ == o.v_); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test soft-deleted member in an object without id. - // - { - using namespace test13; - - typedef odb::query query; - typedef odb::result result; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "abc" && i->num == 123); - t.commit (); - } - - object o; - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - - result r (db->query (query::str == "bcd")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "bcd" && i->num == 234); - - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase_query (query::str == "bcd"); - t.commit (); - } - } - - // Test soft-deleted member in an object with auto id. - // - { - using namespace test14; - - // All the database operations should still include the deleted - // members. - // - unsigned long id; - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "abc" && i->num == 123); - id = i->id; - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (id)); - assert (p->str == "abc" && p->num == 123); - t.commit (); - } - - object o; - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (o.id)); - assert (p->str == "bcd" && p->num == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (o.id)); - assert (p->str == "bcde" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test summarily deleted composite values. - // - { - using namespace test15; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->v->str == "abc" && p->num == 123 && - p->v->vec[0] == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::v.str == "abc")); - result::iterator i (r.begin ()); - assert (i != r.end () && - i->v->str == "abc" && i->num == 123 && - i->v->vec[0] == 123); - t.commit (); - } - - object o (2); - o.v.reset (new value); - o.v->str = "bcd"; - o.num = 234; - o.v->vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->v->str == "bcd" && p->num == 234 && - p->v->vec[0] == 234); - t.commit (); - } - - o.v->str += 'e'; - o.num++; - o.v->vec.modify (0)++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->v->str == "bcde" && p->num == 235 && - p->v->vec[0] == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test soft-deleted container member in a non-versioned object. - // - { - using namespace test21; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->num == 123 && p->vec[0] == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->num == 123 && i->vec[0] == 123); - t.commit (); - } - - object o (2); - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->num == 234 && p->vec[0] == 234); - t.commit (); - } - - o.num++; - o.vec.modify (0)++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->num == 235 && p->vec[0] == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - // Test soft-deleted container member in a non-versioned section. - // - { - using namespace test22; - - // All the database operations should still include the deleted - // members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->num == 123 && p->vec[0] == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - assert (i->num == 123 && i->vec[0] == 123); - t.commit (); - } - - object o (2); - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->num == 234 && p->vec[0] == 234); - t.commit (); - } - - o.num++; - o.vec.modify (0)++; // Automatically marks section as changed. - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->num == 235 && p->vec[0] == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - // Test soft-deleted objects. - // - { - using namespace test1; - - try - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); // No such table. - assert (false); - } - catch (const odb::exception&) {} - } - - // Test basic soft-deleted member logic. - // - { - using namespace test2; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "" && p->num == 123 && - p->vec.empty () && p->ptr == 0); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && - i->str == "" && i->num == 123 && - i->vec.empty () && i->ptr == 0); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->query (query::str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#else - assert (size (db->query (query::str.is_null ())) == 1); -#endif - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - o.ptr = new object1 (2); - o.ptr->ptrs.push_back (&o); - - { - transaction t (db->begin ()); - db->persist (o); - db->persist (*o.ptr); - auto_ptr p (db->load (2)); - assert (p->str == "" && p->num == 234 && - p->vec.empty () && p->ptr == 0); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; - delete o.ptr; - o.ptr = 0; - - { - transaction t (db->begin ()); - db->erase (2); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->str == "" && p->num == 235 && - p->vec.empty () && p->ptr == 0); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test empty statement handling (INSERT, UPDATE). - // - { - using namespace test3; - - // Now none of the database operations should include the - // deleted member. - // - object o; - o.str = "bcd"; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (o.id)); - assert (p->str == ""); - t.commit (); - } - - o.str += 'e'; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (o.id)); - assert (p->str == ""); - t.commit (); - } - } - - // Test empty statement handling (SELECT in polymorphic loader). - // - { - using namespace test4; - - // Now none of the database operations should include the - // deleted member. - // - object o (1); - o.str = "abc"; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (1)); - assert (static_cast (*p).str == ""); - t.commit (); - } - } - - // Test container with soft-deleted value member. - // - { - using namespace test5; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->vec[0].str == "" && p->vec[0].num == 123); - t.commit (); - } - - object o (2); - o.vec.push_back (value ("bcd", 234)); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->vec[0].str == "" && p->vec[0].num == 234); - t.commit (); - } - - o.vec.modify (0).str += 'e'; - o.vec.modify (0).num++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->vec[0].str == "" && p->vec[0].num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test view with soft-deleted member. - // - { - using namespace test6; - - // Now none of the database operations should include the - // deleted members. - // - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "" && i->num == 123); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->query (query::str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#else - assert (size (db->query (query::str.is_null ())) == 1); -#endif - t.commit (); - } - } - - // Test soft-deleted section member. - // - { - using namespace test7; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->load (*p, p->s); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#endif - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; - o.s.change (); - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test soft-deleted members of a section. - // - { - using namespace test8; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->str == "" && p->num == 123 && p->vec.empty ()); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - assert (i->str == "" && i->num == 123 && i->vec.empty ()); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->query (query::str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#else - assert (size (db->query (query::str.is_null ())) == 1); -#endif - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "" && p->num == 234 && p->vec.empty ()); - t.commit (); - } - - o.str += 'e'; - o.num++; - o.vec.modify (0)++; // No longer automatically marked as changed. - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "" && p->num == 234 && p->vec.empty ()); - t.commit (); - } - - o.s.change (); - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->str == "" && p->num == 235 && p->vec.empty ()); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test basic soft-deleted member logic in polymorphic classes. - // - { - using namespace test9; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - auto_ptr p (static_cast (db->load (1))); - assert (p->bstr == "" && p->dstr == "" && p->num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::id == 1)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - object& o (static_cast (*i)); - assert (o.bstr == "" && o.dstr == "" && o.num == 123); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->query (query::bstr == "ab"); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#else - assert (size (db->query (query::bstr.is_null ())) == 1); -#endif - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && - i->bstr == "" && i->dstr == "" && i->num); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->query (query::dstr == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#else - assert (size (db->query (query::dstr.is_null ())) == 1); -#endif - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - auto_ptr p (db->load (2)); - assert (p->bstr == "" && p->dstr == "" && p->num == 234); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - auto_ptr p (db->load (2)); - assert (p->bstr == "" && p->dstr == "" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test soft-deleted section member in polymorphic classes. - // - { - using namespace test10; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->load (*p, p->s); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#endif - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - o.s.change (); - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test soft-deleted members of a section in polymorphic classes. - // - { - using namespace test11; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - object& o (static_cast (*p)); - assert (o.bstr == "" && o.dstr == "" && o.num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::id == 1)); - result::iterator i (r.begin ()); - db->load (*i, i->s); - assert (i != r.end ()); - object& o (static_cast (*i)); - assert (o.bstr == "" && o.dstr == "" && o.num == 123); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->query (query::bstr == "ab"); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#else - assert (size (db->query (query::bstr.is_null ())) == 1); -#endif - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - db->load (*i, i->s); - assert (i != r.end () && - i->bstr == "" && i->dstr == "" && i->num); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->query (query::dstr == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#else - assert (size (db->query (query::dstr.is_null ())) == 1); -#endif - t.commit (); - } - - object o (2); - o.bstr = "bc"; - o.dstr = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "" && p->dstr == "" && p->num == 234); - t.commit (); - } - - o.bstr += 'd'; - o.dstr += 'e'; - o.num++; - o.s.change (); - - { - transaction t (db->begin ()); - db->update (static_cast (o)); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->bstr == "" && p->dstr == "" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - - // Test empty statement detection in sections. - // - base b (3); - b.bstr = "bc"; - - { - transaction t (db->begin ()); - db->persist (b); - auto_ptr p (db->load (3)); - db->load (*p, p->s); - assert (p->bstr == ""); - t.commit (); - } - - b.bstr += 'd'; - b.s.change (); - - { - transaction t (db->begin ()); - db->update (b); - auto_ptr p (db->load (3)); - db->load (*p, p->s); - assert (p->bstr == ""); - t.commit (); - } - } - - // Test soft-deleted member and optimistic concurrency. - // - { - using namespace test12; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->str == "" && p->num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "" && i->num == 123); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->query (query::str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#else - assert (size (db->query (query::str.is_null ())) == 1); -#endif - t.commit (); - } - - object o (2); - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->str == "" && p->num == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - - { - transaction t (db->begin ()); - unsigned long long v (o.v_); - db->update (o); - assert (o.v_ != v); - auto_ptr p (db->load (2)); - assert (p->str == "" && p->num == 235 && p->v_ == o.v_); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test soft-deleted member in an object without id. - // - { - using namespace test13; - - typedef odb::query query; - typedef odb::result result; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "" && i->num == 123); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->query (query::str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#else - assert (size (db->query (query::str.is_null ())) == 1); -#endif - t.commit (); - } - - object o; - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - - result r (db->query (query::num == 234)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "" && i->num == 234); - - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase_query (query::num == 234); - t.commit (); - } - } - - // Test soft-deleted member in an object with auto id. - // - { - using namespace test14; - - // Now none of the database operations should include the - // deleted members. - // - unsigned long id; - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->str == "" && i->num == 123); - id = i->id; - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->query (query::str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#else - assert (size (db->query (query::str.is_null ())) == 1); -#endif - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (id)); - assert (p->str == "" && p->num == 123); - t.commit (); - } - - object o; - o.str = "bcd"; - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (o.id)); - assert (p->str == "" && p->num == 234); - t.commit (); - } - - o.str += 'e'; - o.num++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (o.id)); - assert (p->str == "" && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (o.id); - t.commit (); - } - } - - // Test summarily deleted composite values. - // - { - using namespace test15; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->v.get () == 0 && p->num == 123); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->v.get () == 0 && i->num == 123); - - // Logical delete in SQLite. - // -#ifndef DATABASE_SQLITE - try - { - db->query (query::v.str == "abc"); // No such column. - assert (false); - } - catch (const odb::exception&) {} -#else - assert (size (db->query (query::v.str.is_null ())) == 1); -#endif - t.commit (); - } - - object o (2); - o.num = 234; - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->v.get () == 0 && p->num == 234); - t.commit (); - } - - o.num++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->v.get () == 0 && p->num == 235); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test soft-deleted container member in a non-versioned object. - // - { - using namespace test21; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - assert (p->num == 123 && p->vec.empty ()); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->num == 123 && i->vec.empty ()); - t.commit (); - } - - object o (2); - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - assert (p->num == 234 && p->vec.empty ()); - t.commit (); - } - - o.num++; - o.vec.modify (0)++; - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - assert (p->num == 235 && p->vec.empty ()); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - // Test soft-deleted container member in a non-versioned section. - // - { - using namespace test22; - - // Now none of the database operations should include the - // deleted members. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - db->load (*p, p->s); - assert (p->num == 123 && p->vec.empty ()); - t.commit (); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::num == 123)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - db->load (*i, i->s); - assert (i->num == 123 && i->vec.empty ()); - t.commit (); - } - - object o (2); - o.num = 234; - o.vec.push_back (234); - - { - transaction t (db->begin ()); - db->persist (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->num == 234 && p->vec.empty ()); - t.commit (); - } - - o.num++; - o.vec.modify (0)++; // No longer automatically marks as changed. - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->num == 234 && p->vec.empty ()); - t.commit (); - } - - o.s.change (); - - { - transaction t (db->begin ()); - db->update (o); - auto_ptr p (db->load (2)); - db->load (*p, p->s); - assert (p->num == 235 && p->vec.empty ()); - t.commit (); - } - - { - transaction t (db->begin ()); - db->erase (2); - t.commit (); - } - } - - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/soft-delete/model.hxx b/evolution/soft-delete/model.hxx deleted file mode 100644 index 65083dd..0000000 --- a/evolution/soft-delete/model.hxx +++ /dev/null @@ -1,518 +0,0 @@ -// file : evolution/soft-delete/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include // HAVE_CXX11 - -#include -#include // std::auto_ptr/unique_ptr - -#include -#include -#include -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ - // Test soft-deleted objects. - // - #pragma db namespace table("t1_") - namespace test1 - { - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db object(object) deleted(3) -#endif - } - - // Test basic soft-deleted member logic. - // - #pragma db namespace table("t2_") - namespace test2 - { - struct object; - - #pragma db object - struct object1 - { - object1 (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - odb::vector > ptrs; - }; - - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id), ptr (0) {} - ~object () {delete ptr;} - - #pragma db id - unsigned long id_; - - std::string str; - unsigned long num; - odb::vector vec; - - #pragma db inverse(ptrs) - object1* ptr; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) deleted(3) - #pragma db member(object::vec) deleted(3) - #pragma db member(object::ptr) deleted(3) -#endif - } - - // Test empty statement handling (INSERT, UPDATE). - // - #pragma db namespace table("t3_") - namespace test3 - { - #pragma db object - struct object - { - #pragma db id auto - unsigned long id; - - std::string str; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) deleted(3) -#endif - } - - // Test empty statement handling (SELECT in polymorphic loader). - // - #pragma db namespace table("t4_") - namespace test4 - { - #pragma db object polymorphic - struct base - { - virtual - ~base () {} - base (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - }; - - #pragma db object - struct object: base - { - object (unsigned long id = 0): base (id) {} - - std::string str; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) deleted(3) -#endif - } - - // Test container with soft-deleted value member. - // - #pragma db namespace table("t5_") - namespace test5 - { - #pragma db value - struct value - { - value () {} - value (const std::string& s, unsigned long n): str (s), num (n) {} - - std::string str; - unsigned long num; - }; - - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - odb::vector vec; - }; - -#if MODEL_VERSION == 3 - #pragma db member(value::str) deleted(3) -#endif - } - - // Test view with soft-deleted member. - // - #pragma db namespace table("t6_") - namespace test6 - { - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - std::string str; - unsigned long num; - }; - - #pragma db view object(object) - struct view - { - std::string str; - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) deleted(3) - #pragma db member(view::str) deleted(3) -#endif - } - - // Test soft-deleted section member. - // - #pragma db namespace table("t7_") - namespace test7 - { - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db load(lazy) update(change) - odb::section s; - - #pragma db section(s) - std::string str; - - unsigned long num; - - #pragma db section(s) - odb::vector vec; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::s) deleted(3) -#endif - } - - // Test soft-deleted members of a section. - // - #pragma db namespace table("t8_") - namespace test8 - { - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db load(lazy) update(change) - odb::section s; - - #pragma db section(s) - std::string str; - - #pragma db section(s) - unsigned long num; - - #pragma db section(s) - odb::vector vec; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) deleted(3) - #pragma db member(object::vec) deleted(3) -#endif - } - - // Test basic soft-deleted member logic in polymorphic classes. - // - #pragma db namespace table("t9_") - namespace test9 - { - #pragma db object polymorphic - struct base - { - virtual - ~base () {} - base (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - std::string bstr; - }; - - #pragma db object - struct object: base - { - object (unsigned long id = 0): base (id) {} - - std::string dstr; - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(base::bstr) deleted(3) - #pragma db member(object::dstr) deleted(3) -#endif - } - - // Test soft-deleted section member in polymorphic classes. - // - #pragma db namespace table("t10_") - namespace test10 - { - #pragma db object polymorphic - struct base - { - virtual - ~base () {} - base (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db load(lazy) update(change) - odb::section s; - - #pragma db section(s) - std::string bstr; - }; - - #pragma db object - struct object: base - { - object (unsigned long id = 0): base (id) {} - - #pragma db section(s) - std::string dstr; - - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(base::s) deleted(3) -#endif - } - - // Test soft-deleted members of a section in polymorphic classes. - // - #pragma db namespace table("t11_") - namespace test11 - { - #pragma db object polymorphic - struct base - { - virtual - ~base () {} - base (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db load(lazy) update(change) - odb::section s; - - #pragma db section(s) - std::string bstr; - }; - - #pragma db object - struct object: base - { - object (unsigned long id = 0): base (id) {} - - #pragma db section(s) - std::string dstr; - - #pragma db section(s) - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(base::bstr) deleted(3) - #pragma db member(object::dstr) deleted(3) -#endif - } - - // Test soft-deleted member and optimistic concurrency. - // - #pragma db namespace table("t12_") - namespace test12 - { - #pragma db object optimistic - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db version mssql:type("ROWVERSION") - unsigned long long v_; - - std::string str; - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) deleted(3) -#endif - } - - // Test soft-deleted member in an object without id. - // - #pragma db namespace table("t13_") - namespace test13 - { - #pragma db object no_id - struct object - { - std::string str; - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) deleted(3) -#endif - } - - // Test soft-deleted member in an object with auto id. - // - #pragma db namespace table("t14_") - namespace test14 - { - #pragma db object - struct object - { - std::string str; - unsigned long num; - - #pragma db id auto - unsigned long id; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::str) deleted(3) -#endif - } - - // Test summarily deleted composite values. - // - #pragma db namespace table("t15_") - namespace test15 - { - #pragma db value - struct value - { - std::string str; - odb::vector vec; - }; - - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - -#ifdef HAVE_CXX11 - std::unique_ptr v; -#else - std::auto_ptr v; -#endif - unsigned long num; - }; - -#if MODEL_VERSION == 3 - #pragma db member(value::str) deleted(3) - #pragma db member(value::vec) deleted(3) -#endif - } - - // Test soft-deleted container member in a non-versioned object. - // - #pragma db namespace table("t21_") - namespace test21 - { - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - unsigned long num; - odb::vector vec; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::vec) deleted(3) -#endif - } - - // Test soft-deleted container member in a non-versioned section. - // - #pragma db namespace table("t22_") - namespace test22 - { - #pragma db object - struct object - { - object (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db load(lazy) update(change) - odb::section s; - - #pragma db section(s) - unsigned long num; - - #pragma db section(s) - odb::vector vec; - }; - -#if MODEL_VERSION == 3 - #pragma db member(object::vec) deleted(3) -#endif - } -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/soft-delete/test1.hxx b/evolution/soft-delete/test1.hxx deleted file mode 100644 index d4df90f..0000000 --- a/evolution/soft-delete/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/soft-delete/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/soft-delete/test2.hxx b/evolution/soft-delete/test2.hxx deleted file mode 100644 index 3b2b5b4..0000000 --- a/evolution/soft-delete/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/soft-delete/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/soft-delete/test3.hxx b/evolution/soft-delete/test3.hxx deleted file mode 100644 index 5a90ab2..0000000 --- a/evolution/soft-delete/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/soft-delete/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/template/driver.cxx b/evolution/template/driver.cxx deleted file mode 100644 index b278acd..0000000 --- a/evolution/template/driver.cxx +++ /dev/null @@ -1,124 +0,0 @@ -// file : evolution/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - schema_catalog::create_schema (*db, "", false); - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - { - transaction t (db->begin ()); - dummy d (1); - db->persist (d); - t.commit (); - } - break; - } - case 2: - { - using namespace v3; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - } - break; - } - case 3: - { - using namespace v3; - - object o; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (o.id_)); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - t.commit (); - } - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/template/model.hxx b/evolution/template/model.hxx deleted file mode 100644 index 182c81f..0000000 --- a/evolution/template/model.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// file : evolution/template/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ -#if MODEL_VERSION == 3 - #pragma db object - struct object - { - #pragma db id auto - unsigned long id_; - }; -#endif - - // The presence of this object makes sure that there are no empty - // changesets and we get the complete set of migration files. - // - #pragma db object - struct dummy - { - dummy (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - }; -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/template/template-vc10.vcxproj b/evolution/template/template-vc10.vcxproj deleted file mode 100644 index c0ebe18..0000000 --- a/evolution/template/template-vc10.vcxproj +++ /dev/null @@ -1,196 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test1.hxx, -odb test1.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options1) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test1.hxx, -test1-odb.hxx;test1-odb.ixx;test1-odb.cxx;test1.sql;model.xml, -model.hxx) -__custom_build_entry__( -test2.hxx, -odb test2.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options2) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test2.hxx, -test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml, -test1-odb.hxx;model.hxx) -__custom_build_entry__( -test3.hxx, -odb test3.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options3) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test3.hxx, -test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql, -test2-odb.hxx;model.hxx) - - -__header_entry__(test1-odb.hxx) -__header_entry__(test1-odb.ixx) -__header_entry__(test2-odb.hxx) -__header_entry__(test2-odb.ixx) -__header_entry__(test3-odb.hxx) -__header_entry__(test3-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test1-odb.cxx) -__source_entry__(test2-odb.cxx) -__source_entry__(test3-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/evolution/template/template-vc10.vcxproj.filters b/evolution/template/template-vc10.vcxproj.filters deleted file mode 100644 index d6ac66e..0000000 --- a/evolution/template/template-vc10.vcxproj.filters +++ /dev/null @@ -1,32 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test1.hxx) -__header_filter_entry__(test1-odb.hxx) -__header_filter_entry__(test1-odb.ixx) -__header_filter_entry__(test2.hxx) -__header_filter_entry__(test2-odb.hxx) -__header_filter_entry__(test2-odb.ixx) -__header_filter_entry__(test3.hxx) -__header_filter_entry__(test3-odb.hxx) -__header_filter_entry__(test3-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test1-odb.cxx) -__source_filter_entry__(test2-odb.cxx) -__source_filter_entry__(test3-odb.cxx) -__source_filter_entries__(extra_sources) - - diff --git a/evolution/template/template-vc11.vcxproj b/evolution/template/template-vc11.vcxproj deleted file mode 100644 index f51fd0c..0000000 --- a/evolution/template/template-vc11.vcxproj +++ /dev/null @@ -1,200 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test1.hxx, -odb test1.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options1) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test1.hxx, -test1-odb.hxx;test1-odb.ixx;test1-odb.cxx;test1.sql;model.xml, -model.hxx) -__custom_build_entry__( -test2.hxx, -odb test2.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options2) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test2.hxx, -test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml, -test1-odb.hxx;model.hxx) -__custom_build_entry__( -test3.hxx, -odb test3.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options3) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test3.hxx, -test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql, -test2-odb.hxx;model.hxx) - - -__header_entry__(test1-odb.hxx) -__header_entry__(test1-odb.ixx) -__header_entry__(test2-odb.hxx) -__header_entry__(test2-odb.ixx) -__header_entry__(test3-odb.hxx) -__header_entry__(test3-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test1-odb.cxx) -__source_entry__(test2-odb.cxx) -__source_entry__(test3-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/evolution/template/template-vc11.vcxproj.filters b/evolution/template/template-vc11.vcxproj.filters deleted file mode 100644 index d6ac66e..0000000 --- a/evolution/template/template-vc11.vcxproj.filters +++ /dev/null @@ -1,32 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test1.hxx) -__header_filter_entry__(test1-odb.hxx) -__header_filter_entry__(test1-odb.ixx) -__header_filter_entry__(test2.hxx) -__header_filter_entry__(test2-odb.hxx) -__header_filter_entry__(test2-odb.ixx) -__header_filter_entry__(test3.hxx) -__header_filter_entry__(test3-odb.hxx) -__header_filter_entry__(test3-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test1-odb.cxx) -__source_filter_entry__(test2-odb.cxx) -__source_filter_entry__(test3-odb.cxx) -__source_filter_entries__(extra_sources) - - diff --git a/evolution/template/template-vc12.vcxproj b/evolution/template/template-vc12.vcxproj deleted file mode 100644 index 9562323..0000000 --- a/evolution/template/template-vc12.vcxproj +++ /dev/null @@ -1,204 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test1.hxx, -odb test1.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options1) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test1.hxx, -test1-odb.hxx;test1-odb.ixx;test1-odb.cxx;test1.sql;model.xml, -model.hxx) -__custom_build_entry__( -test2.hxx, -odb test2.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options2) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test2.hxx, -test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml, -test1-odb.hxx;model.hxx) -__custom_build_entry__( -test3.hxx, -odb test3.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options3) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test3.hxx, -test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql, -test2-odb.hxx;model.hxx) - - -__header_entry__(test1-odb.hxx) -__header_entry__(test1-odb.ixx) -__header_entry__(test2-odb.hxx) -__header_entry__(test2-odb.ixx) -__header_entry__(test3-odb.hxx) -__header_entry__(test3-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test1-odb.cxx) -__source_entry__(test2-odb.cxx) -__source_entry__(test3-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/evolution/template/template-vc12.vcxproj.filters b/evolution/template/template-vc12.vcxproj.filters deleted file mode 100644 index d6ac66e..0000000 --- a/evolution/template/template-vc12.vcxproj.filters +++ /dev/null @@ -1,32 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test1.hxx) -__header_filter_entry__(test1-odb.hxx) -__header_filter_entry__(test1-odb.ixx) -__header_filter_entry__(test2.hxx) -__header_filter_entry__(test2-odb.hxx) -__header_filter_entry__(test2-odb.ixx) -__header_filter_entry__(test3.hxx) -__header_filter_entry__(test3-odb.hxx) -__header_filter_entry__(test3-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test1-odb.cxx) -__source_filter_entry__(test2-odb.cxx) -__source_filter_entry__(test3-odb.cxx) -__source_filter_entries__(extra_sources) - - diff --git a/evolution/template/template-vc8.vcproj b/evolution/template/template-vc8.vcproj deleted file mode 100644 index d6c5f15..0000000 --- a/evolution/template/template-vc8.vcproj +++ /dev/null @@ -1,372 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__source_entry__(test1-odb.cxx) -__source_entry__(test2-odb.cxx) -__source_entry__(test3-odb.cxx) -__source_entries__(extra_sources) - - -__file_entry_custom_build__( -test1.hxx, -odb test1.hxx, -odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options1) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test1.hxx, -test1-odb.hxx;test1-odb.ixx;test1-odb.cxx;test1.sql;model.xml, -model.hxx) -__file_entry__(test1-odb.hxx) -__file_entry__(test1-odb.ixx) -__file_entry_custom_build__( -test2.hxx, -odb test2.hxx, -odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options2) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test2.hxx, -test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml, -test1-odb.hxx;model.hxx) -__file_entry__(test2-odb.hxx) -__file_entry__(test2-odb.ixx) -__file_entry_custom_build__( -test3.hxx, -odb test3.hxx, -odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options3) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test3.hxx, -test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql, -test2-odb.hxx;model.hxx) -__file_entry__(test3-odb.hxx) -__file_entry__(test3-odb.ixx) -__file_entries__(extra_headers) - - - - - diff --git a/evolution/template/template-vc9.vcproj b/evolution/template/template-vc9.vcproj deleted file mode 100644 index 9177928..0000000 --- a/evolution/template/template-vc9.vcproj +++ /dev/null @@ -1,379 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__source_entry__(test1-odb.cxx) -__source_entry__(test2-odb.cxx) -__source_entry__(test3-odb.cxx) -__source_entries__(extra_sources) - - -__file_entry_custom_build__( -test1.hxx, -odb test1.hxx, -odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options1) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test1.hxx, -test1-odb.hxx;test1-odb.ixx;test1-odb.cxx;test1.sql;model.xml, -model.hxx) -__file_entry__(test1-odb.hxx) -__file_entry__(test1-odb.ixx) -__file_entry_custom_build__( -test2.hxx, -odb test2.hxx, -odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options2) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test2.hxx, -test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml, -test1-odb.hxx;model.hxx) -__file_entry__(test2-odb.hxx) -__file_entry__(test2-odb.ixx) -__file_entry_custom_build__( -test3.hxx, -odb test3.hxx, -odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options3) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test3.hxx, -test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql, -test2-odb.hxx;model.hxx) -__file_entry__(test3-odb.hxx) -__file_entry__(test3-odb.ixx) -__file_entries__(extra_headers) - - - - - diff --git a/evolution/template/test1.hxx b/evolution/template/test1.hxx deleted file mode 100644 index 238b686..0000000 --- a/evolution/template/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/template/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/template/test2.hxx b/evolution/template/test2.hxx deleted file mode 100644 index ec982f5..0000000 --- a/evolution/template/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/template/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/template/test3.hxx b/evolution/template/test3.hxx deleted file mode 100644 index 50f3882..0000000 --- a/evolution/template/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/template/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/evolution/version/driver.cxx b/evolution/version/driver.cxx deleted file mode 100644 index 236c9b4..0000000 --- a/evolution/version/driver.cxx +++ /dev/null @@ -1,156 +0,0 @@ -// file : evolution/version/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test schema version access via the database instance. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include // DATABASE_XXX -#include - -#include "test2.hxx" -#include "test3.hxx" -#include "test2-odb.hxx" -#include "test3-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv, false)); - bool embedded (schema_catalog::exists (*db)); - - // 1 - base version - // 2 - migration - // 3 - current version - // - unsigned short pass (*argv[argc - 1] - '0'); - - switch (pass) - { - case 1: - { - using namespace v2; - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::drop_schema (*db); - - assert (db->schema_version () == 0); - - schema_catalog::create_schema (*db, "", false); - - assert (db->schema_version () == 1 && !db->schema_migration ()); - - schema_catalog::migrate_schema (*db, 2); - t.commit (); - } - - assert (db->schema_version () == 2 && !db->schema_migration ()); - - { - transaction t (db->begin ()); - object1 o1 (1); - o1.num = 123; - db->persist (o1); - t.commit (); - } - break; - } - case 2: - { - using namespace v2; - using namespace v3; - - if (embedded) - { - assert (db->schema_version () == 2 && !db->schema_migration ()); - - transaction t (db->begin ()); - schema_catalog::migrate_schema_pre (*db, 3); - t.commit (); - } - - assert (db->schema_version () == 3 && db->schema_migration ()); - - { - transaction t (db->begin ()); - auto_ptr o1 (db->load (1)); - object2 o2 (1); - o2.num = o1->num; - db->persist (o2); - t.commit (); - } - - if (embedded) - { - transaction t (db->begin ()); - schema_catalog::migrate_schema_post (*db, 3); - t.commit (); - - assert (db->schema_version () == 3 && !db->schema_migration ()); - } - break; - } - case 3: - { - using namespace v3; - - // In transaction. - // - { - transaction t (db->begin ()); - assert (db->schema_version () == 3 && !db->schema_migration ()); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr o2 (db->load (1)); - assert (o2->num == 123); - t.commit (); - } - - // Test the case where there is still no version table. - // - db->schema_version_migration (0, false); - - { - transaction t (db->begin ()); - -#ifdef DATABASE_ORACLE - db->execute ("DROP TABLE \"schema_version\""); -#else - db->execute ("DROP TABLE schema_version"); -#endif - t.commit (); - } - - assert (db->schema_version () == 0); - break; - } - default: - { - cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; - return 1; - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/evolution/version/model.hxx b/evolution/version/model.hxx deleted file mode 100644 index cdda00e..0000000 --- a/evolution/version/model.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// file : evolution/version/model.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef MODEL_VERSION -# error model.hxx included directly -#endif - -#include - -#pragma db model version(1, MODEL_VERSION) - -#define MODEL_NAMESPACE_IMPL(V) v##V -#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) - -namespace MODEL_NAMESPACE(MODEL_VERSION) -{ -#if MODEL_VERSION == 2 - #pragma db object - struct object1 - { - object1 (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - int num; - }; -#endif - -#if MODEL_VERSION == 3 - #pragma db object - struct object2 - { - object2 (unsigned long id = 0): id_ (id) {} - - #pragma db id - unsigned long id_; - - int num; - }; -#endif -} - -#undef MODEL_NAMESPACE -#undef MODEL_NAMESPACE_IMPL diff --git a/evolution/version/test1.hxx b/evolution/version/test1.hxx deleted file mode 100644 index a50e54c..0000000 --- a/evolution/version/test1.hxx +++ /dev/null @@ -1,9 +0,0 @@ -// file : evolution/version/test1.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST1_HXX -#define TEST1_HXX - -#pragma db model version(1, 1) - -#endif // TEST1_HXX diff --git a/evolution/version/test2.hxx b/evolution/version/test2.hxx deleted file mode 100644 index f7fc1b7..0000000 --- a/evolution/version/test2.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/version/test2.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST2_HXX -#define TEST2_HXX - -#define MODEL_VERSION 2 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST2_HXX diff --git a/evolution/version/test3.hxx b/evolution/version/test3.hxx deleted file mode 100644 index 364ee31..0000000 --- a/evolution/version/test3.hxx +++ /dev/null @@ -1,11 +0,0 @@ -// file : evolution/version/test3.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST3_HXX -#define TEST3_HXX - -#define MODEL_VERSION 3 -#include "model.hxx" -#undef MODEL_VERSION - -#endif // TEST3_HXX diff --git a/libcommon/.gitignore b/libcommon/.gitignore deleted file mode 100644 index a994ddc..0000000 --- a/libcommon/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Generated config header. -# -config.hxx diff --git a/libcommon/buffer.hxx b/libcommon/buffer.hxx deleted file mode 100644 index 41b7e46..0000000 --- a/libcommon/buffer.hxx +++ /dev/null @@ -1,104 +0,0 @@ -// file : libcommon/buffer.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBCOMMON_BUFFER_HXX -#define LIBCOMMON_BUFFER_HXX - -#include -#include // std::size_t -#include // std::{memcmp,memcpy} - -struct basic_buffer_base -{ - ~basic_buffer_base () - { - operator delete (data_); - } - - basic_buffer_base () - : data_ (0), size_ (0) - { - } - - basic_buffer_base (const void* data, std::size_t size) - : data_ (0), size_ (size) - { - data_ = operator new (size_); - std::memcpy (data_, data, size_); - } - - basic_buffer_base (const basic_buffer_base& y) - : data_ (0), size_ (0) - { - assign (y.data_, y.size_); - } - - basic_buffer_base& - operator= (const basic_buffer_base& y) - { - if (this != &y) - assign (y.data_, y.size_); - - return *this; - } - - void - assign (const void* data, std::size_t size) - { - if (size_ < size) - { - void *p (operator new (size)); - operator delete (data_); - data_ = p; - } - - std::memcpy (data_, data, size); - size_ = size; - } - - std::size_t - size () const - { - return size_; - } - - bool - operator== (const basic_buffer_base& y) const - { - return size_ == y.size_ && std::memcmp (data_, y.data_, size_) == 0; - } - -protected: - void* data_; - std::size_t size_; -}; - -template -struct basic_buffer: basic_buffer_base -{ - basic_buffer () - { - } - - basic_buffer (const T* data, std::size_t size) - : basic_buffer_base (data, size) - { - } - - T* - data () - { - return static_cast (data_); - } - - const T* - data () const - { - return static_cast (data_); - } -}; - -typedef basic_buffer buffer; -typedef basic_buffer ubuffer; - -#endif // LIBCOMMON_BUFFER_HXX diff --git a/libcommon/buildfile b/libcommon/buildfile deleted file mode 100644 index eb61455..0000000 --- a/libcommon/buildfile +++ /dev/null @@ -1,50 +0,0 @@ -# file : libcommon/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -import intf_libs = libodb%lib{odb} - -for db: $databases - import intf_libs += libodb-$db%lib{odb-$db} - -lib{common}: {hxx ixx txx cxx}{** -config} hxx{config} $intf_libs - -# Generated config file. -# -using autoconf - -hxx{config}: in{config} -{ - DATABASE_MYSQL = $mysql - DATABASE_SQLITE = $sqlite - DATABASE_PGSQL = $pgsql - DATABASE_ORACLE = $oracle - DATABASE_MSSQL = $mssql - MULTI_DATABASE = $multi -} - -# Build options. -# -cxx.poptions =+ "-I$out_root" "-I$src_root" - -{hbmia obja}{*}: cxx.poptions += -DLIBCOMMON_STATIC_BUILD -{hbmis objs}{*}: cxx.poptions += -DLIBCOMMON_SHARED_BUILD - -# Export options. -# -lib{common}: -{ - cxx.export.poptions = "-I$out_root" "-I$src_root" - cxx.export.libs = $intf_libs -} - -liba{common}: cxx.export.poptions += -DLIBCOMMON_STATIC -libs{common}: cxx.export.poptions += -DLIBCOMMON_SHARED - -# For pre-releases use the complete version to make sure they cannot -# be used in place of another pre-release or the final version. See -# the version module for details on the version.* variable values. -# -if $version.pre_release - lib{common}: bin.lib.version = "-$version.project_id" -else - lib{common}: bin.lib.version = "-$version.major.$version.minor" diff --git a/libcommon/common.cxx b/libcommon/common.cxx deleted file mode 100644 index b3e4cfd..0000000 --- a/libcommon/common.cxx +++ /dev/null @@ -1,355 +0,0 @@ -// file : libcommon/common.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::exit -#include // std::move -#include - -#include - -#include -#include - -using namespace std; -using namespace odb::core; - - -// MySQL. -// -#if defined(DATABASE_MYSQL) - -#include -#include - -static unique_ptr -create_mysql_database (int& argc, char* argv[], bool, size_t max_connections) -{ - namespace mysql = odb::mysql; - - unique_ptr f; - - if (max_connections != 0) - f.reset (new mysql::connection_pool_factory (max_connections)); - - return unique_ptr ( - new mysql::database (argc, argv, false, "", 0, move (f))); -} -#endif // MySQL - - -// SQLite. -// -#if defined(DATABASE_SQLITE) - -#include -#include -#include -#include -#include - -static unique_ptr -create_sqlite_database (int& argc, - char* argv[], - bool schema, - size_t max_connections) -{ - namespace sqlite = odb::sqlite; - - unique_ptr f; - - if (max_connections != 0) - f.reset (new sqlite::connection_pool_factory (max_connections)); - - unique_ptr db ( - new sqlite::database ( - argc, argv, false, - SQLITE_OPEN_READWRITE - | SQLITE_OPEN_CREATE -#ifdef SQLITE_OPEN_URI - | SQLITE_OPEN_URI -#endif - , - true, - "", - move (f))); - - // Create the database schema. Due to bugs in SQLite foreign key - // support for DDL statements, we need to temporarily disable - // foreign keys. - // - if (schema) - { - connection_ptr c (db->connection ()); - - c->execute ("PRAGMA foreign_keys=OFF"); - - transaction t (c->begin ()); - schema_catalog::create_schema (*db); - t.commit (); - - c->execute ("PRAGMA foreign_keys=ON"); - } - - return db; -} -#endif // SQLite - - -// PostgreSQL. -// -#if defined(DATABASE_PGSQL) - -#include -#include - -static unique_ptr -create_pgsql_database (int& argc, char* argv[], bool, size_t max_connections) -{ - namespace pgsql = odb::pgsql; - - unique_ptr f; - - if (max_connections != 0) - f.reset (new pgsql::connection_pool_factory (max_connections)); - - return unique_ptr ( - new pgsql::database (argc, argv, false, "", move (f))); -} -#endif // PostgreSQL - - -// Oracle. -// -#if defined(DATABASE_ORACLE) - -#include -#include - -static unique_ptr -create_oracle_database (int& argc, char* argv[], bool, size_t max_connections) -{ - namespace oracle = odb::oracle; - - unique_ptr f; - - if (max_connections != 0) - f.reset (new oracle::connection_pool_factory (max_connections)); - - // Set client database character set and client national character set - // to UTF-8. - // - return unique_ptr ( - new oracle::database (argc, argv, false, 873, 873, 0, move (f))); -} -#endif // Oracle - -// SQL Server. -// -#if defined(DATABASE_MSSQL) - -#include -#include - -static unique_ptr -create_mssql_database (int& argc, char* argv[], bool, size_t max_connections) -{ - namespace mssql = odb::mssql; - - unique_ptr f; - - if (max_connections != 0) - f.reset (new mssql::connection_pool_factory (max_connections)); - - return unique_ptr ( - new mssql::database (argc, argv, false, "", - mssql::isolation_read_committed, 0, move (f))); -} -#endif // SQL Server - -// -// -unique_ptr -create_database (int argc, - char* argv[], - bool schema, - size_t max_connections, -#if defined(MULTI_DATABASE) - odb::database_id db -#else - odb::database_id -#endif -) -{ - char** argp = argv + 1; // Position of the next argument. Assignment for VC8. - int argn (argc - 1); // Number of arguments left. - -#if defined(MULTI_DATABASE) - // Figure out which database we are creating. We may be given the - // database name as a program argument or as an id. - // - if (db == odb::id_common && argn != 0) - { - string s (*argp); - - if (s == "mysql") - db = odb::id_mysql; - else if (s == "sqlite") - db = odb::id_sqlite; - else if (s == "pgsql") - db = odb::id_pgsql; - else if (s == "oracle") - db = odb::id_oracle; - else if (s == "mssql") - db = odb::id_mssql; - - if (db != odb::id_common) - { - argp++; - argn--; - } - } - - if (db == odb::id_common) - { - cerr << "Usage: " << argv[0] << " [options]" << endl; - exit (1); - } -#endif - - if (argn != 0 && *argp == string ("--help")) - { -#if defined(MULTI_DATABASE) - cout << "Usage: " << argv[0] << " [options]" << endl; -#else - cout << "Usage: " << argv[0] << " [options]" << endl; -#endif - - cout << "Options:" << endl; - -#if defined(MULTI_DATABASE) - switch (db) - { - case odb::id_mysql: -#if defined(DATABASE_MYSQL) - odb::mysql::database::print_usage (cout); -#else - assert (false); -#endif - break; - case odb::id_sqlite: -#if defined(DATABASE_SQLITE) - odb::sqlite::database::print_usage (cout); -#else - assert (false); -#endif - break; - case odb::id_pgsql: -#if defined(DATABASE_PGSQL) - odb::pgsql::database::print_usage (cout); -#else - assert (false); -#endif - break; - case odb::id_oracle: -#if defined(DATABASE_ORACLE) - odb::oracle::database::print_usage (cout); -#else - assert (false); -#endif - break; - case odb::id_mssql: -#if defined(DATABASE_MSSQL) - odb::mssql::database::print_usage (cout); -#else - assert (false); -#endif - break; - case odb::id_common: - assert (false); - } -#elif defined(DATABASE_MYSQL) - odb::mysql::database::print_usage (cout); -#elif defined(DATABASE_SQLITE) - odb::sqlite::database::print_usage (cout); -#elif defined(DATABASE_PGSQL) - odb::pgsql::database::print_usage (cout); -#elif defined(DATABASE_ORACLE) - odb::oracle::database::print_usage (cout); -#elif defined(DATABASE_MSSQL) - odb::mssql::database::print_usage (cout); -#else -# error unknown database -#endif - - exit (0); - } - -#if defined(MULTI_DATABASE) - switch (db) - { - case odb::id_mysql: -#if defined(DATABASE_MYSQL) - return create_mysql_database (argc, argv, schema, max_connections); -#else - assert (false); - break; -#endif - case odb::id_sqlite: -#if defined(DATABASE_SQLITE) - return create_sqlite_database (argc, argv, schema, max_connections); -#else - assert (false); - break; -#endif - case odb::id_pgsql: -#if defined(DATABASE_PGSQL) - return create_pgsql_database (argc, argv, schema, max_connections); -#else - assert (false); - break; -#endif - case odb::id_oracle: -#if defined(DATABASE_ORACLE) - return create_oracle_database (argc, argv, schema, max_connections); -#else - assert (false); - break; -#endif - case odb::id_mssql: -#if defined(DATABASE_MSSQL) - return create_mssql_database (argc, argv, schema, max_connections); -#else - assert (false); - break; -#endif - case odb::id_common: - assert (false); - } - return unique_ptr (); -#elif defined(DATABASE_MYSQL) - return create_mysql_database (argc, argv, schema, max_connections); -#elif defined(DATABASE_SQLITE) - return create_sqlite_database (argc, argv, schema, max_connections); -#elif defined(DATABASE_PGSQL) - return create_pgsql_database (argc, argv, schema, max_connections); -#elif defined(DATABASE_ORACLE) - return create_oracle_database (argc, argv, schema, max_connections); -#elif defined(DATABASE_MSSQL) - return create_mssql_database (argc, argv, schema, max_connections); -#else -# error unknown database -#endif -} - -bool -size_available () -{ -#if defined(MULTI_DATABASE) || \ - defined(DATABASE_SQLITE) || \ - defined(DATABASE_ORACLE) || \ - defined(DATABASE_MSSQL) - return false; -#else - return true; -#endif -} diff --git a/libcommon/common.hxx b/libcommon/common.hxx deleted file mode 100644 index 9ab978d..0000000 --- a/libcommon/common.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// file : libcommon/common.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBCOMMON_COMMON_HXX -#define LIBCOMMON_COMMON_HXX - -#include // std::unique_ptr -#include // std::size_t - -#include -#include - -#include - -LIBCOMMON_SYMEXPORT std::unique_ptr -create_database (int argc, - char* argv[], - bool create_schema = true, - std::size_t max_connections = 0, - odb::database_id db = odb::id_common); - -template -std::unique_ptr -create_specific_database (int argc, - char* argv[], - bool create_schema = true, - std::size_t max_connections = 0) -{ - std::unique_ptr r ( - create_database (argc, argv, - create_schema, - max_connections, - T::database_id)); - - return std::unique_ptr (&dynamic_cast (*r.release ())); -} - -// This function returns an accurate result only if the result iterator -// hasn't been advanced and after the call the result is no longer valid. -// -template -std::size_t -size (odb::result); - -#include - -#endif // LIBCOMMON_COMMON_HXX diff --git a/libcommon/common.txx b/libcommon/common.txx deleted file mode 100644 index caa7481..0000000 --- a/libcommon/common.txx +++ /dev/null @@ -1,24 +0,0 @@ -// file : libcommon/common.txx -// license : GNU GPL v2; see accompanying LICENSE file - -// We have to use this helper function instead of just checking which -// database is used because the DATABASE_* macro may not be defined -// in a project that includes this header. -// -LIBCOMMON_SYMEXPORT bool -size_available (); - -template -std::size_t -size (odb::result r) -{ - if (size_available ()) - return r.size (); - else - { - std::size_t n (0); - for (typename odb::result::iterator i (r.begin ()); i != r.end (); ++i) - n++; - return n; - } -} diff --git a/libcommon/concrete.hxx b/libcommon/concrete.hxx deleted file mode 100644 index e0f64a5..0000000 --- a/libcommon/concrete.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// file : libcommon/concrete.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBCOMMON_CONCRETE_HXX -#define LIBCOMMON_CONCRETE_HXX - -#include - -// Namespace alias for the concrete database namespace. -// -#if defined(MULTI_DATABASE) - -// Fallback to common interface. -// -#include -#include - -namespace odb_db = odb; - -#elif defined(DATABASE_MYSQL) - -#include -#include - -namespace odb_db = odb::mysql; - -#elif defined(DATABASE_SQLITE) - -#include -#include - -namespace odb_db = odb::sqlite; - -#elif defined(DATABASE_PGSQL) - -#include -#include - -namespace odb_db = odb::pgsql; - -#elif defined(DATABASE_ORACLE) - -#include -#include - -namespace odb_db = odb::oracle; - -#elif defined(DATABASE_MSSQL) - -#include -#include - -namespace odb_db = odb::mssql; - -#endif - -#endif // LIBCOMMON_CONCRETE_HXX diff --git a/libcommon/config.hxx.in b/libcommon/config.hxx.in deleted file mode 100644 index ff90e61..0000000 --- a/libcommon/config.hxx.in +++ /dev/null @@ -1,14 +0,0 @@ -// file : libcommon/config.hxx.in -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBCOMMON_CONFIG_HXX -#define LIBCOMMON_CONFIG_HXX - -#undef DATABASE_MYSQL -#undef DATABASE_SQLITE -#undef DATABASE_PGSQL -#undef DATABASE_ORACLE -#undef DATABASE_MSSQL -#undef MULTI_DATABASE - -#endif // LIBCOMMON_CONFIG_HXX diff --git a/libcommon/export.hxx b/libcommon/export.hxx deleted file mode 100644 index 0de4565..0000000 --- a/libcommon/export.hxx +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -// Normally we don't export class templates (but do complete specializations), -// inline functions, and classes with only inline member functions. Exporting -// classes that inherit from non-exported/imported bases (e.g., std::string) -// will end up badly. The only known workarounds are to not inherit or to not -// export. Also, MinGW GCC doesn't like seeing non-exported functions being -// used before their inline definition. The workaround is to reorder code. In -// the end it's all trial and error. - -#if defined(LIBCOMMON_STATIC) // Using static. -# define LIBCOMMON_SYMEXPORT -#elif defined(LIBCOMMON_STATIC_BUILD) // Building static. -# define LIBCOMMON_SYMEXPORT -#elif defined(LIBCOMMON_SHARED) // Using shared. -# ifdef _WIN32 -# define LIBCOMMON_SYMEXPORT __declspec(dllimport) -# else -# define LIBCOMMON_SYMEXPORT -# endif -#elif defined(LIBCOMMON_SHARED_BUILD) // Building shared. -# ifdef _WIN32 -# define LIBCOMMON_SYMEXPORT __declspec(dllexport) -# else -# define LIBCOMMON_SYMEXPORT -# endif -#else -// If none of the above macros are defined, then we assume we are being used -// by some third-party build system that cannot/doesn't signal the library -// type. Note that this fallback works for both static and shared libraries -// provided the library only exports functions (in other words, no global -// exported data) and for the shared case the result will be sub-optimal -// compared to having dllimport. If, however, your library does export data, -// then you will probably want to replace the fallback with the (commented -// out) error since it won't work for the shared case. -// -# define LIBCOMMON_SYMEXPORT // Using static or shared. -//# error define LIBCOMMON_STATIC or LIBCOMMON_SHARED preprocessor macro to signal libcommon library type being linked -#endif diff --git a/manifest b/manifest deleted file mode 100644 index 858baa7..0000000 --- a/manifest +++ /dev/null @@ -1,48 +0,0 @@ -: 1 -name: odb-tests -version: 2.5.0-b.26.z -project: odb -type: tests -language: c++ -summary: ODB compiler tests -license: GPL-2.0-only -description-file: README.md -url: https://www.codesynthesis.com/products/odb/ -doc-url: https://www.codesynthesis.com/products/odb/doc/manual.xhtml -src-url: https://git.codesynthesis.com/cgit/odb/odb/ -email: odb-users@codesynthesis.com ; Mailing list - -# @@ BUILD2 The odb dependency can only be built with GCC. However, shouldn't -# we test that the odb-generated mappings can be compiled by other -# compilers and properly run afterwards? -# -builds: default -builds: -( +windows -gcc ) ; Requires MinGW GCC. -builds: &gcc ; Requires GCC with plugin support enabled. -builds: &gcc-5+ ; Requires GCC 5 or later. -builds: -static ; Implementation uses plugins and requires -fPIC. - -depends: * build2 >= 0.16.0 -depends: * bpkg >= 0.16.0 - -depends: * odb [2.5.0-b.26.1 2.5.0-b.27) - -depends: libodb [2.5.0-b.26.1 2.5.0-b.27) -depends: libodb-mysql [2.5.0-b.26.1 2.5.0-b.27) ? ($mysql) -depends: libodb-sqlite [2.5.0-b.26.1 2.5.0-b.27) ? ($sqlite) -depends: libodb-pgsql [2.5.0-b.26.1 2.5.0-b.27) ? ($pgsql) -depends: libodb-oracle [2.5.0-b.26.1 2.5.0-b.27) ? ($oracle) -depends: libodb-mssql [2.5.0-b.26.1 2.5.0-b.27) ? ($mssql) - -# Reflect whether libodb-pgsql is likely to support bulk operations. This is -# normally the case on POSIX platforms if libodb-pgsql is linked against libpq -# of the version 14 or above. -# -depends: libpq >= 14.0.0 ? ($pgsql) config.odb_tests.pgsql.bulk_default=true | \ - libpq >= 7.4.0 ? ($pgsql) config.odb_tests.pgsql.bulk_default=false - -# @@ TODO/LATER: use an alternative to automatically detect whether we are -# using MySQL or MariaDB? But maybe we don't need to know? - -depends: mysql >= 5.0.3 ? ($mysql) -depends: psql >= 7.4.0 ? ($pgsql) diff --git a/mssql/custom/custom.sql b/mssql/custom/custom.sql deleted file mode 100644 index 44ef512..0000000 --- a/mssql/custom/custom.sql +++ /dev/null @@ -1,42 +0,0 @@ -/* This file contains helper functions. - */ - -IF OBJECT_ID('dbo.variant_to_string', 'FN') IS NOT NULL - DROP FUNCTION dbo.variant_to_string; -GO - -IF OBJECT_ID('dbo.string_to_variant', 'FN') IS NOT NULL - DROP FUNCTION dbo.string_to_variant; -GO - -CREATE FUNCTION dbo.variant_to_string (@val SQL_VARIANT) RETURNS VARCHAR(max) -AS -BEGIN - RETURN CAST(SQL_VARIANT_PROPERTY(@val, 'BaseType') AS SYSNAME) + ' ' + - CAST(@val AS VARCHAR(max)) -END; -GO - -CREATE FUNCTION dbo.string_to_variant (@val VARCHAR(max)) RETURNS SQL_VARIANT -AS -BEGIN - DECLARE @ret SQL_VARIANT - - DECLARE @pos BIGINT - DECLARE @vtype SYSNAME - DECLARE @vtext VARCHAR(max) - - SET @pos = CHARINDEX(' ', @val) - SET @vtype = SUBSTRING(@val, 1, @pos - 1) - SET @vtext = SUBSTRING(@val, @pos + 1, LEN(@val)) - - IF @vtype = 'tinyint' SET @ret = CAST(@vtext AS TINYINT) - ELSE IF @vtype = 'smallint' SET @ret = CAST(@vtext AS SMALLINT) - ELSE IF @vtype = 'int' SET @ret = CAST(@vtext AS INT) - ELSE IF @vtype = 'bigint' SET @ret = CAST(@vtext AS BIGINT) - ELSE IF @vtype = 'char' SET @ret = CAST(@vtext AS CHAR(8000)) - ELSE IF @vtype = 'varchar' SET @ret = CAST(@vtext AS VARCHAR(8000)) - - RETURN @ret -END; -GO diff --git a/mssql/custom/driver.cxx b/mssql/custom/driver.cxx deleted file mode 100644 index bde7eb6..0000000 --- a/mssql/custom/driver.cxx +++ /dev/null @@ -1,135 +0,0 @@ -// file : mssql/custom/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test custom database type mapping in SQL Server. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -namespace mssql = odb::mssql; -using namespace mssql; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_specific_database (argc, argv)); - - object o (1); - - o.v = variant (123); - o.vv.push_back (variant (string (1024, 'a'))); - o.vv.push_back (variant (123)); - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - o.p = point (1.1111, 2222222222.2); - o.pv.push_back (point (1.1234, 2.2345)); - o.pv.push_back (point (3.3456, 4.4567)); - o.pv.push_back (point (0.0000001, 0.000000001)); // Scientific notation. -#endif - - o.xml = "AAABBBCCC"; - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - - // Query. - // - typedef mssql::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - // Variant comparison. - // - { - result r (db->query (query::v == o.v)); - assert (!r.empty ()); - } - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - // Point comparison. - // - { - result r (db->query (query::p == o.p)); - assert (!r.empty ()); - } - - // Point comparison using native query. - // - { - result r (db->query ( - query::p + ".STEquals(" + query::_val (o.p) + ") = 1")); - assert (!r.empty ()); - } - - // Access to individual members. - // - { - result r (db->query (query::p.x == o.p.x)); - assert (!r.empty ()); - } -#endif - - t.commit (); - } - - // Update. - // -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - o.p.x++; - o.p.y--; - o.pv[1].x--; - o.pv[1].y++; -#endif - - o.xml = "BBBCCCDDD"; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/mssql/custom/query.hxx b/mssql/custom/query.hxx deleted file mode 100644 index fc63378..0000000 --- a/mssql/custom/query.hxx +++ /dev/null @@ -1,183 +0,0 @@ -// file : mssql/custom/query.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef QUERY_HXX -#define QUERY_HXX - -#include - -#include - -#include "test.hxx" // point - -namespace odb -{ - namespace mssql - { -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - template <> - struct query_column - { - private: - const char* table_; - const char* column_; - const char* conversion_; - - unsigned short prec_; - unsigned short scale_; - - std::string x_column_; - std::string y_column_; - - // Sub-columns for individual members. - // - public: - query_column x, y; - - // is_null, is_not_null - // - public: - query_base - is_null () const - { - query_base q (table_, column_); - q += "IS NULL"; - return q; - } - - query_base - is_not_null () const - { - query_base q (table_, column_); - q += "IS NOT NULL"; - return q; - } - - // = - // - public: - query_base - equal (const point& v) const - { - return equal (val_bind (v)); - } - - query_base - equal (val_bind v) const - { - query_base q (table_, column_); - q += ".STEquals("; - q.append (v, conversion_); - q += ") = 1"; - return q; - } - - query_base - equal (ref_bind r) const - { - query_base q (table_, column_); - q += ".STEquals("; - q.append (r, conversion_); - q += ") = 1"; - return q; - } - - friend query_base - operator== (const query_column& c, const point& v) - { - return c.equal (v); - } - - friend query_base - operator== (const point& v, const query_column& c) - { - return c.equal (v); - } - - friend query_base - operator== (const query_column& c, val_bind v) - { - return c.equal (v); - } - - friend query_base - operator== (val_bind v, const query_column& c) - { - return c.equal (v); - } - - friend query_base - operator== (const query_column& c, ref_bind r) - { - return c.equal (r); - } - - friend query_base - operator== (ref_bind r, const query_column& c) - { - return c.equal (r); - } - - // Column comparison. - // - public: - query_base - operator== (const query_column& c) const - { - query_base q (table_, column_); - q += ".STEquals("; - q.append (c.table (), c.column ()); - q += ") = 1"; - return q; - } - - public: - query_column (const char* table, - const char* column, - const char* conv, - unsigned short prec = 0, - unsigned short scale = 0xFFFF) - : table_ (table), column_ (column), conversion_ (conv), - prec_ (prec), scale_ (scale), - x_column_ (std::string (column) + ".STX"), - y_column_ (std::string (column) + ".STY"), - x (table, x_column_.c_str (), 0), - y (table, y_column_.c_str (), 0) - { - } - - const char* - table () const - { - return table_; - } - - const char* - column () const - { - return column_; - } - - const char* - conversion () const - { - return conversion_; - } - - unsigned short - prec () const - { - return prec_; - } - - unsigned short - scale () const - { - return scale_; - } - }; -#endif // SQL Server > 2005 - } -} - -#endif // QUERY_HXX diff --git a/mssql/custom/test.hxx b/mssql/custom/test.hxx deleted file mode 100644 index 4b8a5d7..0000000 --- a/mssql/custom/test.hxx +++ /dev/null @@ -1,121 +0,0 @@ -// file : mssql/types/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -// Map SQL Server SQL_VARIANT type to our variant C++ class that is capable -// of storing either an integer or a string (QVariant and boost::variant -// would be natural alternatives to our own type). The SQL Server functions -// that are used in the 'to' and 'from' expressions below are defined in -// the custom.sql file. The other half of this mapping is in traits.hxx -// (value_traits). -// -#pragma db map type("SQL_VARIANT") \ - as("VARCHAR(max)") \ - to("dbo.string_to_variant((?))") \ - from("dbo.variant_to_string((?))") - -#pragma db value type("SQL_VARIANT") -struct variant -{ - variant (unsigned long v = 0): val_type (type_int), int_val (v) {} - variant (const std::string& v): val_type (type_str), str_val (v) {} - - enum {type_int, type_str} val_type; - unsigned long int_val; - std::string str_val; -}; - -inline bool -operator== (const variant& a, const variant& b) -{ - if (a.val_type != b.val_type) - return false; - - switch (a.val_type) - { - case variant::type_int: - return a.int_val == b.int_val; - case variant::type_str: - return a.str_val == b.str_val; - } - - return false; -} - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 -// Map GEOMETRY SQL Server type to the point C++ struct. The other half -// of this mapping is in traits.hxx (value_traits). -// Note that GEOMETRY is not available in SQL Server 2005. -// -#pragma db map type("GEOMETRY") \ - as("VARCHAR(256)") \ - to("GEOMETRY::STGeomFromText((?), 0)") \ - from("(?).STAsText()") - -#pragma db value type("GEOMETRY") -struct point -{ - point () {} - point (double x_, double y_): x (x_), y (y_) {} - - double x; - double y; -}; - -inline bool -operator== (const point& a, const point& b) -{ - return a.x == b.x && a.y == b.y; -} -#endif // SQL Server > 2005 - -// Map XML SQL Server type to std::string (or any other type that provides -// the value_traits specialization). Note also that -// another alternative would be to interface with the XML data type using -// VARBINARY or NVARCHAR. Here we use implicit string to/from XML conversion, -// however, CAST/CONVERT can be used instead for greater control over -// whitespace handling, etc. -// -#pragma db map type("XML *(\\(.+\\))?") as("VARCHAR(max)") - -#pragma db object -struct object -{ - object () {} - object (unsigned long id_) : id (id_) {} - - #pragma db id - unsigned long id; - - variant v; - std::vector vv; - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - point p; - std::vector pv; -#endif - - #pragma db type("XML") - std::string xml; - - bool - operator== (const object& y) const - { - return id == y.id - && vv == y.vv -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - && p == y.p - && pv == y.pv -#endif - && xml == y.xml; - } -}; - -#endif // TEST_HXX diff --git a/mssql/custom/traits.cxx b/mssql/custom/traits.cxx deleted file mode 100644 index 3f14ae7..0000000 --- a/mssql/custom/traits.cxx +++ /dev/null @@ -1,128 +0,0 @@ -// file : mssql/types/traits.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -#include "traits.hxx" - -using namespace std; - -namespace odb -{ - namespace mssql - { - void value_traits:: - param_callback (const void* context, - size_t*, - const void** buffer, - size_t* size, - chunk_type* chunk, - void* tmp_buf, - size_t tmp_capacity) - { - const variant& v (*static_cast (context)); - string str; - - switch (v.val_type) - { - case variant::type_int: - { - ostringstream os; - os << v.int_val; - - str = "bigint "; - str += os.str (); - break; - } - case variant::type_str: - { - str = "varchar "; - str += v.str_val; - break; - } - } - - // Here we assume that the temoprary buffer is large enough to fit - // the whole string in one go. If that were not the case, then we - // would have had to chunk it. - // - assert (tmp_capacity >= str.size ()); - memcpy (tmp_buf, str.c_str (), str.size ()); - - *buffer = tmp_buf; - *size = str.size (); - *chunk = chunk_one; - } - - void value_traits:: - result_callback (void* context, - size_t*, - void** buffer, - size_t* size, - chunk_type chunk, - size_t, - void* tmp_buf, - size_t tmp_capacity) - { - variant& v (*static_cast (context)); - - switch (chunk) - { - case chunk_null: - case chunk_one: - { - assert (false); // The value cannot be NULL or empty. - break; - } - case chunk_first: - { - // Use the variant's string value as a temporary buffer. If this - // were not possible, we could have allocated one as part of - // context. - // - v.str_val.clear (); - - *buffer = tmp_buf; - *size = tmp_capacity; - break; - } - case chunk_next: - { - v.str_val.append (static_cast (tmp_buf), *size); - - *buffer = tmp_buf; - *size = tmp_capacity; - break; - } - case chunk_last: - { - v.str_val.append (static_cast (tmp_buf), *size); - - // Figure out what we've got. - // - string::size_type p (v.str_val.find (' ')); - assert (p != string::npos); // Must have type followed by value. - string type (v.str_val, 0, p); - string text (v.str_val, p + 1, string::npos); - - if (type == "tinyint" || - type == "smallint" || - type == "int" || - type == "bigint") - { - istringstream is (text); - is >> v.int_val; - v.val_type = variant::type_int; - } - else if (type == "char" || type == "varchar") - { - v.str_val = text; - v.val_type = variant::type_str; - } - else - assert (false); // Unknown type. - - break; - } - } - } - } -} diff --git a/mssql/custom/traits.hxx b/mssql/custom/traits.hxx deleted file mode 100644 index 2bd99cb..0000000 --- a/mssql/custom/traits.hxx +++ /dev/null @@ -1,148 +0,0 @@ -// file : mssql/types/traits.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TRAITS_HXX -#define TRAITS_HXX - -#include // std::numeric_limits -#include -#include // std::memcpy -#include - -#include - -#include "test.hxx" // variant, point - -namespace odb -{ - namespace mssql - { - template <> - class value_traits - { - public: - typedef variant value_type; - typedef variant query_type; - typedef long_callback image_type; - - static void - set_value (variant& v, - result_callback_type& cb, - void*& context) - { - cb = &result_callback; - context = &v; - } - - static void - set_image (param_callback_type& cb, - const void*& context, - bool& is_null, - const variant& v) - { - is_null = false; - cb = ¶m_callback; - context = &v; - } - - static void - param_callback (const void* context, - std::size_t* position, - const void** buffer, - std::size_t* size, - chunk_type* chunk, - void* tmp_buffer, - std::size_t tmp_capacity); - - static void - result_callback (void* context, - std::size_t* position, - void** buffer, - std::size_t* size, - chunk_type chunk, - std::size_t size_left, - void* tmp_buffer, - std::size_t tmp_capacity); - }; - - template <> - struct type_traits - { - static const database_type_id db_type_id = id_long_string; - - struct conversion - { - static const char* to () {return "dbo.string_to_variant((?))";} - }; - }; - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - template <> - class value_traits - { - public: - typedef point value_type; - typedef point query_type; - - typedef char* image_type; - - static void - set_value (point& v, - const char* b, - std::size_t n, - bool is_null) - { - if (is_null) - v = point (); - else - { - // Point format is "POINT (x y)". - // - std::istringstream is (std::string (b + 7, n - 7)); - - is >> v.x; - is >> v.y; - } - } - - static void - set_image (char* b, - std::size_t c, - std::size_t& n, - bool& is_null, - const point& v) - { - is_null = false; - std::ostringstream os; - - // The formula for the number of decimla digits required is given in: - // - // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf - // - os.precision (std::numeric_limits::digits10); - // os.precision (2 + std::numeric_limits::digits * 301/1000); - - os << "POINT (" << v.x << ' ' << v.y << ')'; - - const std::string& s (os.str ()); - n = s.size (); - assert (n <= c); - std::memcpy (b, s.c_str (), n); - } - }; - - template <> - struct type_traits - { - static const database_type_id db_type_id = id_string; - - struct conversion - { - static const char* to () {return "GEOMETRY::STGeomFromText((?), 0)";} - }; - }; -#endif // SQL Server > 2005 - } -} - -#endif // TRAITS_HXX diff --git a/mssql/database/driver.cxx b/mssql/database/driver.cxx deleted file mode 100644 index 08ad34f..0000000 --- a/mssql/database/driver.cxx +++ /dev/null @@ -1,105 +0,0 @@ -// file : mssql/database/driver.cxx -// license : GNU GPL; see accompanying LICENSE file - -// Test that database constructors are unambiguous (compilation only). -// - -#include -#include - -#include - -namespace mssql = odb::mssql; -using namespace mssql; - -static const char* isolation_map[] = {"1", "2", "3", "5", "4"}; - -static bool -check_isolation (connection& c, transaction_isolation i) -{ - std::string s ("SELECT 1 FROM sys.dm_exec_sessions WHERE session_id = @@SPID" - " AND transaction_isolation_level = "); - s += isolation_map[i]; - return c.execute (s) == 1; -} - -int -main (int argc, char* argv[]) -{ - // This code should not execute. - // - if (argc == 0) - { - { - database d1 ("bob", "secret", "db1", "server1"); - database d2 ("bob", "secret", "db1", "server1", "driver1"); - database d3 ("bob", "secret", "db1", "server1", "driver1", "extra"); - database d4 ("bob", "secret", "db1", "server1", "driver1", "extra", - isolation_read_uncommitted); - } - - { - database d1 ("bob", "secret", "db1", protocol_auto); - database d2 ("bob", "secret", "db1", protocol_auto, "server1"); - database d3 ("bob", "secret", "db1", protocol_auto, "server1", "inst1"); - database d4 ("bob", "secret", "db1", protocol_auto, "server1", "inst1", - "driver1"); - database d5 ("bob", "secret", "db1", protocol_auto, "server1", "inst1", - "driver1", "extra"); - database d6 ("bob", "secret", "db1", protocol_auto, "server1", "inst1", - "driver1", "extra", isolation_read_uncommitted); - } - - { - database d1 ("bob", "secret", "db1", "server1", 0); - database d2 ("bob", "secret", "db1", "server1", 999, "driver1"); - database d3 ("bob", "secret", "db1", "server1", 999, "driver1", "extra"); - database d4 ("bob", "secret", "db1", "server1", 999, "driver1", "extra", - isolation_read_uncommitted); - } - - { - database d1 ("conn1"); - database d2 ("conn1", isolation_read_uncommitted); - } - - { - database d1 (argc, argv); - database d2 (argc, argv, false); - database d3 (argc, argv, true, "extra"); - database d4 (argc, argv, false, "extra", isolation_read_uncommitted); - } - } - - // Test transaction isolation levels. - // - { - database d (argc, argv, false, "", isolation_read_uncommitted); - connection_ptr c (d.connection ()); - assert (check_isolation (*c, isolation_read_uncommitted)); - } - - { - database d (argc, argv, false, ""); - connection_ptr c (d.connection ()); - assert (check_isolation (*c, isolation_read_committed)); - } - - { - database d (argc, argv, false, "", isolation_repeatable_read); - connection_ptr c (d.connection ()); - assert (check_isolation (*c, isolation_repeatable_read)); - } - - { - database d (argc, argv, false, "", isolation_snapshot); - connection_ptr c (d.connection ()); - assert (check_isolation (*c, isolation_snapshot)); - } - - { - database d (argc, argv, false, "", isolation_serializable); - connection_ptr c (d.connection ()); - assert (check_isolation (*c, isolation_serializable)); - } -} diff --git a/mssql/native/driver.cxx b/mssql/native/driver.cxx deleted file mode 100644 index f4b4fd7..0000000 --- a/mssql/native/driver.cxx +++ /dev/null @@ -1,73 +0,0 @@ -// file : mssql/native/driver.cxx -// license : GNU GPL; see accompanying LICENSE file - -// Test native SQL execution. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -using namespace std; -namespace mssql = odb::mssql; -using namespace mssql; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_specific_database (argc, argv)); - - // Create the database schema. - // - { - transaction t (db->begin ()); - - db->execute ("IF OBJECT_ID('mssql_native_test', 'U') IS NOT NULL\n" - " DROP TABLE mssql_native_test"); - - db->execute ("CREATE TABLE mssql_native_test (n int)"); - - t.commit (); - } - - // Insert a few rows. - // - { - transaction t (db->begin ()); - - assert ( - db->execute ("INSERT INTO mssql_native_test (n) VALUES (1)") == 1); - - assert ( - db->execute ("INSERT INTO mssql_native_test (n) VALUES (2)") == 1); - - t.commit (); - } - - // Select a few rows. - // - { - transaction t (db->begin ()); - - assert ( - db->execute ("SELECT n FROM mssql_native_test WHERE n < 3") == 2); - - assert ( - db->execute ("SELECT n FROM mssql_native_test WHERE n > 3") == 0); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/mssql/query/driver.cxx b/mssql/query/driver.cxx deleted file mode 100644 index 5600c81..0000000 --- a/mssql/query/driver.cxx +++ /dev/null @@ -1,188 +0,0 @@ -// file : mssql/query/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test SQL Server-specific query support aspects. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -namespace mssql = odb::mssql; -using namespace mssql; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_specific_database (argc, argv)); - - { - object o1; - object o2; - object o3; - - o1.num = 1; - o1.str = "aaa"; - o1.nstr = L"aaa"; - o1.lstr.assign (1024, 'a'); - o1.lnstr.assign (1024, L'a'); - o1.smoney = 11000; - o1.money = 1.1; - - o2.num = 2; - o2.str = "bbb"; - o2.nstr = L"bbb"; - o2.lstr.assign (1024, 'b'); - o2.lnstr.assign (1024, L'b'); - o2.smoney = 22000; - o2.money = 2.2; - - o3.num = 3; - o3.str = "ccc"; - o3.nstr = L"ccc"; - o3.lstr.assign (1024, 'c'); - o3.lnstr.assign (1024, L'c'); - o3.smoney = 33000; - o3.money = 3.3; - - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - } - - typedef mssql::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - // Money and small money. - // - { - result r (db->query (query::smoney < 22000)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->smoney == 11000); - assert (++i == r.end ()); - } - - { - result r (db->query ("smoney < " + query::_val (2.1F))); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->smoney == 11000); - assert (++i == r.end ()); - } - - { - result r (db->query (query::money < 2.2)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->money == 1.1); - assert (++i == r.end ()); - } - - { - result r (db->query ("money < " + query::_val (2.2))); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->money == 1.1); - assert (++i == r.end ()); - } - - // Short/long string. - // - { - result r (db->query (query::str < "bbb")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->str == "aaa"); - assert (++i == r.end ()); - } - - { - result r (db->query ("str < " + query::_val ("bbb", 3))); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->str == "aaa"); - assert (++i == r.end ()); - } - - { - result r (db->query (query::nstr < L"bbb")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->nstr == L"aaa"); - assert (++i == r.end ()); - } - - { - result r (db->query (query::lstr < string (1024, 'b'))); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->lstr == string (1024, 'a')); - assert (++i == r.end ()); - } - - { - string v (1024, 'b'); - result r (db->query (query::lstr < query::_ref (v))); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->lstr == string (1024, 'a')); - assert (++i == r.end ()); - } - - { - result r (db->query (query::lnstr < wstring (1024, L'b'))); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->lnstr == wstring (1024, L'a')); - assert (++i == r.end ()); - } - - // Test image copying with long data. - // - { - result r (db->query (query::str < "ccc")); - result::iterator i (r.begin ()); - - assert (i != r.end ()); - ++i; - assert (i != r.end ()); - - { - result r (db->query (query::str < "bbb")); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (i->str == "aaa"); - assert (++i == r.end ()); - } - - assert (i->str == "bbb"); // Load from copy. - assert (++i == r.end ()); - } - - t.commit (); - } - - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/mssql/query/test.hxx b/mssql/query/test.hxx deleted file mode 100644 index 85c644e..0000000 --- a/mssql/query/test.hxx +++ /dev/null @@ -1,38 +0,0 @@ -// file : mssql/query/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object -struct object -{ - #pragma db id auto - unsigned long id_; - - unsigned int num; - - #pragma db type ("SMALLMONEY") - int smoney; - - #pragma db type ("MONEY") - double money; - - #pragma db type ("VARCHAR(256)") - std::string str; - - #pragma db type ("NVARCHAR(128)") - std::wstring nstr; - - #pragma db type ("VARCHAR(max)") - std::string lstr; - - #pragma db type ("NVARCHAR(max)") - std::wstring lnstr; -}; - -#endif // TEST_HXX diff --git a/mssql/stored-proc/driver.cxx b/mssql/stored-proc/driver.cxx deleted file mode 100644 index 2389798..0000000 --- a/mssql/stored-proc/driver.cxx +++ /dev/null @@ -1,231 +0,0 @@ -// file : mssql/stored-proc/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test SQL Server stored procedure support. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -namespace mssql = odb::mssql; -using namespace mssql; - -void -create_procedure (database& db, const string& name, const string& body) -{ - transaction t (db.begin ()); - - string s (db.query_value ().name); - - db.execute ( - "IF EXISTS (" - " SELECT * FROM sysobjects" - " WHERE name = '" + name + "' AND user_name(uid) = '" + s +"')" - " DROP PROCEDURE [" + s + "].[" + name + "]"); - - db.execute ("CREATE PROCEDURE [" + s + "].[" + name + "] " + body); - - t.commit (); -} - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_specific_database (argc, argv)); - - object o1 (1, "a"); - object o2 (2, "b"); - object o3 (3, "c"); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - } - - { - create_procedure ( - *db, "select_all_objects", - "AS" - " SELECT num, str FROM mssql_stored_proc_object ORDER BY id;"); - - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query ()); - - for (result::iterator i (r.begin ()); i != r.end (); ++i) - cout << i->num << " " << i->str << endl; - cout << endl; - - t.commit (); - } - - { - create_procedure ( - *db, "select_objects", - "(@id INT, @n VARCHAR(512))" - "AS" - " SELECT str FROM mssql_stored_proc_object " - " WHERE [id] = @id OR [num] = @n ORDER BY id;"); - - typedef mssql::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - result r (db->query ( - query::_val (o1.id) + "," + query::_val (o2.num))); - - for (result::iterator i (r.begin ()); i != r.end (); ++i) - cout << i->str << endl; - cout << endl; - - t.commit (); - } - - { - create_procedure ( - *db, "objects_min_max", - "(@min INT = NULL OUTPUT, @max INT = NULL OUTPUT)" - "AS" - " SELECT @min = MIN(num), @max = MAX(num)" - " FROM mssql_stored_proc_object;"); - - create_procedure ( - *db, "objects_min_max_odb", - "AS" - " DECLARE @min INT, @max INT;" - " EXEC objects_min_max @min OUTPUT, @max OUTPUT;" - " SELECT @min, @max;"); - - transaction t (db->begin ()); - - objects_min_max omm (db->query_value ()); - cout << omm.num_min << " " << omm.num_max << endl - << endl; - - t.commit (); - } - - { - create_procedure ( - *db, "insert_object_id", - "(@n INT, @s VARCHAR(512))" - "AS" - " INSERT INTO mssql_stored_proc_object([num], [str])" - " VALUES(@n, @s);"); - - { - typedef mssql::query query; - - transaction t (db->begin ()); - - db->query_one ( - query::_val (4) + "," + query::_val ("d")); - - auto_ptr o (db->load (4)); - cout << o->num << " " << o->str << endl - << endl; - - t.commit (); - } - - { - typedef mssql::query query; - - transaction t (db->begin ()); - - db->query_one ( - "EXEC insert_object_id" + query::_val (5) + "," + query::_val ("e")); - - auto_ptr o (db->load (5)); - cout << o->num << " " << o->str << endl - << endl; - - t.commit (); - } - } - - { - create_procedure ( - *db, "insert_object_id", - "(@n INT, @s VARCHAR(512), @id INT = NULL OUTPUT)" - "AS" - " INSERT INTO mssql_stored_proc_object([num], [str])" - " VALUES(@n, @s);" - " SET @id = SCOPE_IDENTITY();" - " RETURN 123;"); - - typedef mssql::query query; - - { - create_procedure ( - *db, "insert_object_id_odb", - "(@n INT, @s VARCHAR(512))" - "AS" - " DECLARE @id INT;" - " DECLARE @ret INT;" - " EXEC @ret = insert_object_id @n, @s, @id OUTPUT;" - " SELECT @ret, @id;"); - - transaction t (db->begin ()); - - insert_object_id io ( - db->query_value ( - query::_val (6) + "," + query::_val ("f"))); - - cout << io.ret << " " << io.id << endl - << endl; - - t.commit (); - } - - // An alternative implementation that produces a different - // result set configuration at the ODBC level. - // - { - create_procedure ( - *db, "insert_object_id_odb", - "(@n INT, @s VARCHAR(512))" - "AS" - " DECLARE @id INT;" - " DECLARE @ret INT;" - " DECLARE @tbl TABLE(dummy INT);" - " INSERT INTO @tbl EXEC @ret = insert_object_id @n, @s, @id OUTPUT;" - " SELECT @ret, @id;"); - - transaction t (db->begin ()); - - insert_object_id io ( - db->query_value ( - query::_val (7) + "," + query::_val ("g"))); - - cout << io.ret << " " << io.id << endl - << endl; - - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/mssql/stored-proc/test.hxx b/mssql/stored-proc/test.hxx deleted file mode 100644 index 5958ea3..0000000 --- a/mssql/stored-proc/test.hxx +++ /dev/null @@ -1,63 +0,0 @@ -// file : mssql/stored-proc/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db view query("SELECT SCHEMA_NAME()") -struct default_schema -{ - std::string name; -}; - -#pragma db object -struct object -{ - object () {} - object (unsigned int n, std::string s): num (n), str (s) {} - - #pragma db id auto - unsigned long id; - - unsigned int num; - std::string str; -}; - -#pragma db view -struct no_result {}; - -#pragma db view query("EXEC select_all_objects") -struct select_all_objects -{ - unsigned int num; - std::string str; -}; - -#pragma db view query("EXEC select_objects (?)") -struct select_objects -{ - std::string str; -}; - -#pragma db view query("EXEC objects_min_max_odb") -struct objects_min_max -{ - unsigned int num_min; - unsigned int num_max; -}; - -#pragma db view query("EXEC insert_object_id (?)") -struct insert_object {}; - -#pragma db view query("EXEC insert_object_id_odb (?)") -struct insert_object_id -{ - unsigned int ret; - unsigned long id; -}; - -#endif // TEST_HXX diff --git a/mssql/template/driver.cxx b/mssql/template/driver.cxx deleted file mode 100644 index ded03f1..0000000 --- a/mssql/template/driver.cxx +++ /dev/null @@ -1,40 +0,0 @@ -// file : mssql/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -namespace mssql = odb::mssql; -using namespace mssql; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_specific_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/mssql/template/template-vc10.vcxproj b/mssql/template/template-vc10.vcxproj deleted file mode 100644 index 5875d9b..0000000 --- a/mssql/template/template-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/mssql/template/template-vc10.vcxproj.filters b/mssql/template/template-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/mssql/template/template-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/mssql/template/template-vc11.vcxproj b/mssql/template/template-vc11.vcxproj deleted file mode 100644 index 0bee18f..0000000 --- a/mssql/template/template-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/mssql/template/template-vc11.vcxproj.filters b/mssql/template/template-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/mssql/template/template-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/mssql/template/template-vc12.vcxproj b/mssql/template/template-vc12.vcxproj deleted file mode 100644 index 35ffb0f..0000000 --- a/mssql/template/template-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib64\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/mssql/template/template-vc12.vcxproj.filters b/mssql/template/template-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/mssql/template/template-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/mssql/template/template-vc8.vcproj b/mssql/template/template-vc8.vcproj deleted file mode 100644 index cfd697f..0000000 --- a/mssql/template/template-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/mssql/template/template-vc9.vcproj b/mssql/template/template-vc9.vcproj deleted file mode 100644 index 72a95d9..0000000 --- a/mssql/template/template-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/mssql/template/test.hxx b/mssql/template/test.hxx deleted file mode 100644 index 0bc1f95..0000000 --- a/mssql/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : mssql/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/mssql/types/driver.cxx b/mssql/types/driver.cxx deleted file mode 100644 index d900a95..0000000 --- a/mssql/types/driver.cxx +++ /dev/null @@ -1,381 +0,0 @@ -// file : mssql/types/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test SQL Server type conversion. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -namespace mssql = odb::mssql; -using namespace mssql; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_specific_database (argc, argv)); - - { - object o (1); - - o.bit_ = 1; - o.utint_ = 222; - o.stint_ = -123; - o.usint_ = 65000; - o.ssint_ = -12345; - o.uint_ = 4294967290U; - o.sint_ = -1234567890; - o.ubint_ = 18446744073709551610ULL; - o.sbint_ = -1234567890123456789LL; - - o.fsm_ = -214748.3648F; - o.dsm_ = 214748.3647; - o.ism_ = -2147483647 -1; - - o.dm1_ = -922337203685477.5808; - o.dm2_ = 922337203685476.3520; // 922337203685477.5807 - o.im_ = 9223372036854775807LL; - - o.f4_ = 123.123F; - o.f8_ = 123.1234567; - - o.schar_ = "short data char "; - o.svchar_ = "short data varchar"; - - o.lchar_.assign (1025, 'a'); - o.lvchar_ = "long data varchar"; // Test the short string optimization. - o.mvchar_.assign (70000, 'm'); - o.text_.assign (70000, 't'); - - o.snchar_ = L"short data nchar\x1FFF\xD7FF "; - o.snvchar_ = L"short data nvarchar \x1FFF\xD7FF"; - - o.lnchar_.assign (513, L'\x1234'); - o.lnvchar_ = L""; // Test empty string. - o.mnvchar_.assign (70000, L'\x2345'); - o.ntext_.assign (70000, L'\x4356'); - - const char sdata[] = "abc""\x00\x01""def"; - memcpy (o.sbin_, sdata, sizeof (sdata)); - o.svbin_.assign (sdata, sdata + sizeof (sdata)); - - string ldata (256 * 1024, '\x01'); - memset (o.lbin_, 2, sizeof (o.lbin_)); - o.lvbin_.assign (50, '\x03'); - o.mvbin_.assign (ldata.begin (), ldata.end ()); - o.image_.assign (ldata.begin (), ldata.end ()); - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - o.date_ = date_time (2011, 12, 20, 0, 0, 0, 0, 0, 0); - o.time7_ = date_time (0, 0, 0, 13, 34, 39, 123456789, 0, 0); - o.time4_ = date_time (0, 0, 0, 13, 34, 39, 123456700, 0, 0); -#endif - o.sdt_ = date_time (2011, 12, 20, 15, 44, 29, 123456700, 0, 0); - o.dt_ = date_time (2011, 12, 20, 15, 44, 29, 123456700, 0, 0); -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - o.dt2_ = date_time (2011, 12, 20, 15, 44, 29, 123456700, 0, 0); - o.dto7_ = date_time (2011, 12, 20, 15, 44, 29, 123456700, 2, 0); - o.dto0_ = date_time (2011, 12, 20, 15, 44, 29, 123456700, 2, 0); -#endif - -#ifdef _WIN32 - // 6F846D41-C89A-4E4D-B22F-56443CFA543F - o.guid_.Data1 = 0x6F846D41; - o.guid_.Data2 = 0xC89A; - o.guid_.Data3 = 0x4E4D; - memcpy (&o.guid_.Data4, "\xB2\x2F\x56\x44\x3C\xFA\x54\x3F", 8); -#endif - memcpy (o.uuid_, "\x6F\x84\x6D\x41\xC8\x9A\x4E\x4D\xB2\x2F" - "\x56\x44\x3C\xFA\x54\x3F", 16); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - o.time7_ = date_time (0, 0, 0, 13, 34, 39, 123456700, 0, 0); - o.time4_ = date_time (0, 0, 0, 13, 34, 39, 123400000, 0, 0); -#endif - o.sdt_ = date_time (2011, 12, 20, 15, 44, 0, 0, 0, 0); - o.dt_ = date_time (2011, 12, 20, 15, 44, 29, 123000000, 0, 0); -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - o.dto0_ = date_time (2011, 12, 20, 15, 44, 29, 0, 2, 0); -#endif - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - - typedef mssql::query query; - typedef odb::result result; - - // Test UUID in queries. - // - { - char uuid[16]; - memcpy (uuid, o.uuid_, 16); - - transaction t (db->begin ()); - - { - result r (db->query (query::uuid == uuid)); - assert (size (r) == 1); - } - - { - result r (db->query (query::uuid == query::_val (uuid))); - assert (size (r) == 1); - } - - { - result r (db->query (query::uuid == query::_ref (uuid))); - assert (size (r) == 1); - } - - { - const char* d (uuid); - result r (db->query (query::uuid == d)); - assert (size (r) == 1); - } - - t.commit (); - } - - // Test short/long data in queries. - // - { - transaction t (db->begin ()); - - { - result r (db->query (query::svchar == o.svchar_)); - assert (size (r) == 1); - } - - { - result r (db->query (query::snvchar == o.snvchar_)); - assert (size (r) == 1); - } - - { - result r (db->query (query::mvchar == o.mvchar_)); - assert (size (r) == 1); - } - - { - result r (db->query (query::mnvchar == o.mnvchar_)); - assert (size (r) == 1); - } - - t.commit (); - } - } - - // Test long NULL data. - // - { - long_null o1 (1); - long_null o2 (2); - o2.str_.reset (new string); - o2.str_->assign (70000, 'x'); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr p1 (db->load (1)); - auto_ptr p2 (db->load (2)); - t.commit (); - - assert (o1 == *p1); - assert (o2 == *p2); - } - } - - // Test long data in containers. - // - { - long_cont o (1); - o.v.push_back (long_comp ("aaa", 123)); - o.v.push_back (long_comp (string (500, 'b'), 234)); - o.v.push_back (long_comp (string (70000, 'c'), 345)); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (1)); - t.commit (); - - assert (o == *p); - } - } - - // Test char/wchar_t arrays. - // - { - char_array o1 (1, "", L""); - char_array o2 (2, "1234567890", L"12345678\x1FFF\xD7FF"); - char_array o3 (3, "1234567890123456", L"12345678901234\x1FFF\xD7FF"); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - } - - // SQL Server returns padded values for CHAR(N)/NCHAR(N). - // - memcpy (o1.s2, " ", 16); - o1.s3[0] = o1.c1 = ' '; - memcpy (o2.s2, "1234567890 ", 16); - - memset (o1.ls2, ' ', 1025); - memset (o2.ls2 + 10, ' ', 1025 - 10); - - memcpy (o1.ws2, L" ", 16 * sizeof (wchar_t)); - o1.ws3[0] = o1.wc1 = L' '; - memcpy (o2.ws2, L"12345678\x1FFF\xD7FF ", 16 * sizeof (wchar_t)); - - for (size_t i (0); i < 257; ++i) - o1.lws2[i] = L' '; - - for (size_t i (10); i < 257; ++i) - o2.lws2[i] = L' '; - - { - transaction t (db->begin ()); - auto_ptr p1 (db->load (1)); - auto_ptr p2 (db->load (2)); - auto_ptr p3 (db->load (3)); - t.commit (); - - assert (o1 == *p1); - assert (o2 == *p2); - assert (o3 == *p3); - } - } - - // Test optimistic concurrency using ROWVERSION. - // - { - rowversion o (123); - o.str = "abc"; - - { - transaction t (db->begin ()); - db->persist (o); - assert (o.ver != 0); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (o.id_)); - assert (p->ver == o.ver); - p->str += 'd'; - db->update (*p); - assert (p->ver > o.ver); - - // Double-check object version was updated. - // - { - auto_ptr p1 (db->load (o.id_)); - assert (p->ver == p1->ver); - } - - o.str += 'D'; - try - { - db->update (o); - assert (false); - } - catch (const odb::object_changed&) {} - db->reload (o); - assert (o.ver == p->ver); - o.str += 'D'; - db->update (o); - t.commit (); - } - } - - { - rowversion_auto o; - o.str = "abc"; - - { - transaction t (db->begin ()); - db->persist (o); - assert (o.ver != 0); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (o.id_)); - assert (p->ver == o.ver); - p->str += 'd'; - db->update (*p); - assert (p->ver > o.ver); - o.str += 'D'; - try - { - db->update (o); - assert (false); - } - catch (const odb::object_changed&) {} - db->reload (o); - assert (o.ver == p->ver); - o.str += 'D'; - db->update (o); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/mssql/types/test.hxx b/mssql/types/test.hxx deleted file mode 100644 index 5d651a8..0000000 --- a/mssql/types/test.hxx +++ /dev/null @@ -1,517 +0,0 @@ -// file : mssql/types/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#ifdef _WIN32 -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include // GUID -#elif defined(HOST_WIN32) -typedef struct _GUID -{ - unsigned int Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -} GUID; -#endif - -#include // HAVE_CXX11 - -#include -#include -#include // std::auto_ptr -#include // std::memcmp, std::memcpy, std::str[n]cmp, std::strlen -#include // std::wcslen, std::wcs[n]cmp - -#include - -struct date_time -{ - date_time () - { - } - - date_time (short y, - unsigned short m, - unsigned short d, - unsigned short h, - unsigned short min, - unsigned short sec, - unsigned int f, - short tzh, - short tzm) - : year (y), - month (m), - day (d), - hour (h), - minute (min), - second (sec), - fraction (f), - timezone_hour (tzh), - timezone_minute (tzm) - { - } - - bool - operator== (const date_time& y) const - { - return - year == y.year && - month == y.month && - day == y.day && - hour == y.hour && - minute == y.minute && - second == y.second && - fraction == y.fraction && - timezone_hour == y.timezone_hour && - timezone_minute == y.timezone_minute; - } - - short year; - unsigned short month; - unsigned short day; - unsigned short hour; - unsigned short minute; - unsigned short second; - unsigned int fraction; - short timezone_hour; - short timezone_minute; -}; - -#pragma db object -struct object -{ - object () {} - object (unsigned int id): id_ (id) {} - - #pragma db id - unsigned int id_; - - // Integer types. - // - #pragma db type ("BIT") - unsigned char bit_; - - #pragma db type ("TINYINT") - unsigned char utint_; - - #pragma db type ("TINYINT") - unsigned char stint_; - - #pragma db type ("SMALLINT") - unsigned short usint_; - - #pragma db type ("SMALLINT") - short ssint_; - - #pragma db type ("INT") - unsigned int uint_; - - #pragma db type ("INTEGER") - int sint_; - - #pragma db type ("BIGINT") - unsigned long long ubint_; - - #pragma db type ("BIGINT") - long long sbint_; - - // Floating/fixed point types. - // - #pragma db type ("SMALLMONEY") - float fsm_; - - #pragma db type ("SMALLMONEY") - double dsm_; - - #pragma db type ("SMALLMONEY") - int ism_; - - #pragma db type ("MONEY") - double dm1_; - - #pragma db type ("MONEY") - double dm2_; - - #pragma db type ("MONEY") - long long im_; - - #pragma db type ("REAL") - float f4_; - - #pragma db type ("FLOAT") - double f8_; - - // Strings. - // - #pragma db type ("CHAR(20)") - std::string schar_; - - #pragma db type ("VARCHAR(128)") - std::string svchar_; - - #pragma db type ("CHAR(1025)") - std::string lchar_; - - #pragma db type ("CHARACTER VARYING(8000)") - std::string lvchar_; - - #pragma db type ("VARCHAR(max)") - std::string mvchar_; - - #pragma db type ("TEXT") - std::string text_; - - // National strings. - // - #pragma db type ("NCHAR(20)") - std::wstring snchar_; - - #pragma db type ("NVARCHAR(128)") - std::wstring snvchar_; - - #pragma db type ("NCHAR(513)") - std::wstring lnchar_; - - #pragma db type ("NATIONAL CHARACTER VARYING(4000)") - std::wstring lnvchar_; - - #pragma db type ("NVARCHAR(max)") - std::wstring mnvchar_; - - #pragma db type ("NTEXT") - std::wstring ntext_; - - // Binary. - // - #pragma db type ("BINARY(9)") - unsigned char sbin_[9]; - - #pragma db type ("VARBINARY(256)") - std::vector svbin_; - - #pragma db type ("BINARY(1025)") - char lbin_[1025]; - - #pragma db type ("BINARY VARYING(8000)") - std::vector lvbin_; - - #pragma db type ("VARBINARY(max)") - std::vector mvbin_; - - #pragma db type ("IMAGE") - std::vector image_; - - // Date-time. SQL Server 2005 (9.0) only has DATETIME and SMALLDATETIME. - // -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - #pragma db type ("DATE") - date_time date_; - - #pragma db type ("TIME") - date_time time7_; - - #pragma db type ("TIME(4)") - date_time time4_; -#endif - - #pragma db type ("SMALLDATETIME") - date_time sdt_; - - #pragma db type ("DATETIME") - date_time dt_; - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - #pragma db type ("DATETIME2") - date_time dt2_; - - #pragma db type ("DATETIMEOFFSET") - date_time dto7_; - - #pragma db type ("DATETIMEOFFSET(0)") - date_time dto0_; -#endif - - // Other types. - // -#if defined(_WIN32) || defined(HOST_WIN32) - //#pragma db type ("UNIQUEIDENTIFIER") - GUID guid_; -#endif - - #pragma db type ("UNIQUEIDENTIFIER") - char uuid_[16]; - - bool - operator== (const object& y) const - { - return - id_ == y.id_ && - bit_ == y.bit_ && - utint_ == y.utint_ && - stint_ == y.stint_ && - usint_ == y.usint_ && - ssint_ == y.ssint_ && - uint_ == y.uint_ && - sint_ == y.sint_ && - ubint_ == y.ubint_ && - sbint_ == y.sbint_ && - fsm_ == y.fsm_ && - dsm_ == y.dsm_ && - ism_ == y.ism_ && - dm1_ == y.dm1_ && - dm2_ == y.dm2_ && - im_ == y.im_ && - f4_ == y.f4_ && - f8_ == y.f8_ && - - schar_ == y.schar_ && - svchar_ == y.svchar_ && - lchar_ == y.lchar_ && - lvchar_ == y.lvchar_ && - mvchar_ == y.mvchar_ && - text_ == y.text_ && - - snchar_ == y.snchar_ && - snvchar_ == y.snvchar_ && - lnchar_ == y.lnchar_ && - lnvchar_ == y.lnvchar_ && - mnvchar_ == y.mnvchar_ && - ntext_ == y.ntext_ && - - std::memcmp (sbin_, y.sbin_, sizeof (sbin_)) == 0 && - svbin_ == y.svbin_ && - std::memcmp (lbin_, y.lbin_, sizeof (lbin_)) == 0 && - lvbin_ == y.lvbin_ && - mvbin_ == y.mvbin_ && - image_ == y.image_ - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - && date_ == y.date_ - && time7_ == y.time7_ - && time4_ == y.time4_ -#endif - && sdt_ == y.sdt_ - && dt_ == y.dt_ -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - && dt2_ == y.dt2_ - && dto7_ == y.dto7_ - && dto0_ == y.dto0_ -#endif - -#ifdef _WIN32 - && std::memcmp (&guid_, &y.guid_, sizeof (guid_)) == 0 -#endif - && std::memcmp (uuid_, y.uuid_, sizeof (uuid_)) == 0; - } -}; - -// Test long NULL data. -// -#pragma db object -struct long_null -{ - long_null () {} - long_null (unsigned int id): id_ (id) {} - - #pragma db id - unsigned int id_; - - #pragma db type ("VARCHAR(max)") null -#ifdef HAVE_CXX11 - std::unique_ptr str_; -#else - std::auto_ptr str_; -#endif - - bool - operator== (const long_null& y) const - { - return - id_ == y.id_ && - ((str_.get () == 0 && y.str_.get () == 0) || *str_ == *y.str_); - } -}; - -// Test long data in containers, in particular column re-arrangement. -// -#pragma db value -struct long_comp -{ - long_comp () {} - long_comp (std::string s, unsigned int n): str (s), num (n) {} - - #pragma db type ("VARCHAR(max)") - std::string str; - - unsigned int num; - - bool - operator== (const long_comp& y) const - { - return str == y.str && num == y.num; - } -}; - -#pragma db object -struct long_cont -{ - long_cont () {} - long_cont (unsigned int id): id_ (id) {} - - #pragma db id - unsigned int id_; - - std::vector v; - - bool - operator== (const long_cont& y) const - { - return id_ == y.id_ && v == y.v; - } -}; - -// Test char/wchar_t arrays. -// -#pragma db object -struct char_array -{ - char_array () {} - char_array (unsigned long id, const char* s, const wchar_t* ws) - : id_ (id) - { - std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation. - std::memcpy (s2, s, std::strlen (s) + 1); - s3[0] = c1 = *s; - - std::memcpy (ws1, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t)); - std::memcpy (ws2, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t)); - ws3[0] = wc1 = *ws; - - if (std::strlen (s) == sizeof (s2)) - { - std::memset (ls1, '1', 1025); - ls1[1025] = '\0'; - std::memset (ls2, '2', 1025); - - for (std::size_t i (0); i < 257; ++i) - { - lws1[i] = L'1'; - lws2[i] = L'2'; - } - lws1[257] = L'\0'; - } - else - { - std::memcpy (ls1, s, std::strlen (s) + 1); // VC++ strcpy deprecation. - std::memcpy (ls2, s, std::strlen (s) + 1); - - std::memcpy (lws1, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t)); - std::memcpy (lws2, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t)); - } - } - - #pragma db id - unsigned long id_; - - // - // - char s1[17]; - - #pragma db type("CHAR(16)") - char s2[16]; - - char s3[1]; - char c1; - - // Long data. - // - char ls1[1026]; - - #pragma db type("CHAR(1025)") - char ls2[1025]; - - // - // - wchar_t ws1[17]; - - #pragma db type("NCHAR(16)") - wchar_t ws2[16]; - - wchar_t ws3[1]; - wchar_t wc1; - - // Long data. - // - wchar_t lws1[258]; - - #pragma db type("NCHAR(257)") - wchar_t lws2[257]; - - bool - operator== (const char_array& y) const - { - return id_ == y.id_ && - - std::strcmp (s1, y.s1) == 0 && - std::strncmp (s2, y.s2, sizeof (s2)) == 0 && - s3[0] == y.s3[0] && - c1 == y.c1 && - - std::strcmp (ls1, y.ls1) == 0 && - std::strncmp (ls2, y.ls2, sizeof (ls2)) == 0 && - - std::wcscmp (ws1, y.ws1) == 0 && - std::wcsncmp (ws2, y.ws2, sizeof (ws2) / sizeof (wchar_t)) == 0 && - ws3[0] == y.ws3[0] && - wc1 == y.wc1 && - - std::wcscmp (lws1, y.lws1) == 0 && - std::wcsncmp (lws2, y.lws2, sizeof (lws2) / sizeof (wchar_t)) == 0; - } -}; - -// Test optimistic concurrency using ROWVERSION, both with auto and -// manually-assigned ids. -// -#pragma db object optimistic -struct rowversion -{ - rowversion (unsigned int id = 0): id_ (id), ver (0) {} - - #pragma db id - unsigned int id_; - - #pragma db version type("ROWVERSION") -#ifdef _WIN32 - unsigned __int64 ver; -#else - unsigned long long ver; -#endif - - std::string str; -}; - -#pragma db object optimistic -struct rowversion_auto -{ - rowversion_auto (): ver (0) {} - - #pragma db id auto - unsigned int id_; - - #pragma db version type("ROWVERSION") -#ifdef _WIN32 - unsigned __int64 ver; -#else - unsigned long long ver; -#endif - - std::string str; -}; - -#endif // TEST_HXX diff --git a/mssql/types/traits.hxx b/mssql/types/traits.hxx deleted file mode 100644 index 5881f50..0000000 --- a/mssql/types/traits.hxx +++ /dev/null @@ -1,223 +0,0 @@ -// file : mssql/types/traits.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TRAITS_HXX -#define TRAITS_HXX - -#include // date, time, datetime, datetimeoffset -#include - -#include "test.hxx" // date_time - -namespace odb -{ - namespace mssql - { - template <> - class value_traits - { - public: - typedef date_time value_type; - typedef date_time query_type; - typedef date image_type; - - static void - set_value (date_time& v, const date& i, bool is_null) - { - if (!is_null) - { - v.year = i.year; - v.month = i.month; - v.day = i.day; - v.hour = 0; - v.minute = 0; - v.second = 0; - v.fraction = 0; - v.timezone_hour = 0; - v.timezone_minute = 0; - } - } - - static void - set_image (date& i, bool& is_null, const date_time& v) - { - is_null = false; - i.year = v.year; - i.month = v.month; - i.day = v.day; - } - }; - - template <> - class value_traits - { - public: - typedef date_time value_type; - typedef date_time query_type; - typedef time image_type; - - static void - set_value (date_time& v, const time& i, bool is_null) - { - if (!is_null) - { - v.year = 0; - v.month = 0; - v.day = 0; - v.hour = i.hour; - v.minute = i.minute; - v.second = i.second; - v.fraction = i.fraction; - v.timezone_hour = 0; - v.timezone_minute = 0; - } - } - - static void - set_image (time& i, unsigned short s, bool& is_null, const date_time& v) - { - const unsigned int divider[8] = - { - 1000000000, - 100000000, - 10000000, - 1000000, - 100000, - 10000, - 1000, - 100 - }; - - is_null = false; - i.hour = v.hour; - i.minute = v.minute; - i.second = v.second; - i.fraction = v.fraction - v.fraction % divider[s]; - } - }; - - template <> - class value_traits - { - public: - typedef date_time value_type; - typedef date_time query_type; - typedef datetime image_type; - - static void - set_value (date_time& v, const datetime& i, bool is_null) - { - if (!is_null) - { - v.year = i.year; - v.month = i.month; - v.day = i.day; - v.hour = i.hour; - v.minute = i.minute; - v.second = i.second; - v.fraction = i.fraction; - v.timezone_hour = 0; - v.timezone_minute = 0; - } - } - - static void - set_image (datetime& i, - unsigned short s, - bool& is_null, - const date_time& v) - { - const unsigned int divider[8] = - { - 1000000000, - 100000000, - 10000000, - 1000000, - 100000, - 10000, - 1000, - 100 - }; - - is_null = false; - i.year = v.year; - i.month = v.month; - i.day = v.day; - i.hour = v.hour; - i.minute = v.minute; - - // Scale value 8 indicates we are dealing with SMALLDATETIME - // which has the minutes precision. - // - if (s != 8) - { - i.second = v.second; - i.fraction = v.fraction - v.fraction % divider[s]; - } - else - { - i.second = 0; - i.fraction = 0; - } - } - }; - - template <> - class value_traits - { - public: - typedef date_time value_type; - typedef date_time query_type; - typedef datetimeoffset image_type; - - static void - set_value (date_time& v, const datetimeoffset& i, bool is_null) - { - if (!is_null) - { - v.year = i.year; - v.month = i.month; - v.day = i.day; - v.hour = i.hour; - v.minute = i.minute; - v.second = i.second; - v.fraction = i.fraction; - v.timezone_hour = i.timezone_hour; - v.timezone_minute = i.timezone_minute; - } - } - - static void - set_image (datetimeoffset& i, - unsigned short s, - bool& is_null, - const date_time& v) - { - const unsigned int divider[8] = - { - 1000000000, - 100000000, - 10000000, - 1000000, - 100000, - 10000, - 1000, - 100 - }; - - is_null = false; - i.year = v.year; - i.month = v.month; - i.day = v.day; - i.hour = v.hour; - i.minute = v.minute; - i.second = v.second; - i.fraction = v.fraction - v.fraction % divider[s]; - i.timezone_hour = v.timezone_hour; - i.timezone_minute = v.timezone_minute; - } - }; - } -} - -#endif // TRAITS_HXX diff --git a/mysql-schema.testscript b/mysql-schema.testscript deleted file mode 100644 index dfa7852..0000000 --- a/mysql-schema.testscript +++ /dev/null @@ -1,9 +0,0 @@ -# file : mysql-schema.testscript -# license : GNU GPL v2; see accompanying LICENSE file - -# Create the MySQL database schema creation canned command base. -# -create_schema_cmd = [cmdline] \ - $mysql_client_cmd 2>&1 | \ - sed -e "'"'s/^mysql: \[Warning\] Using a password on the command .*//'"'" | \ - sed -n -e "'"'s/(.+)/\1/p'"'" >&2 diff --git a/mysql.testscript b/mysql.testscript deleted file mode 100644 index e218ece..0000000 --- a/mysql.testscript +++ /dev/null @@ -1,12 +0,0 @@ -# file : mysql.testscript -# license : GNU GPL v2; see accompanying LICENSE file - -# Create the MySQL database schema creation canned command and setup the test -# driver command line for the subsequent tests. -# -.include mysql-schema.testscript - -schema_file = [path] $out_base/"$schema"($multi ? '-mysql' : '').sql -create_schema = [cmdline] cat "'""$schema_file""'" | $create_schema_cmd - -test.arguments += ($multi ? 'mysql' : ) $mysql_options diff --git a/mysql/custom/buildfile b/mysql/custom/buildfile deleted file mode 100644 index 4934e7c..0000000 --- a/mysql/custom/buildfile +++ /dev/null @@ -1,37 +0,0 @@ -# file : mysql/custom/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($mysql && !$multi || $build.meta_operation == 'dist') \ -"mysql should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-mysql%lib{odb-mysql} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix mysql_custom_ \ - --generate-schema \ - --default-database common \ - --generate-query \ - --hxx-prologue '#include "traits.hxx"' \ - --hxx-prologue '#include "query.hxx"' - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{mysql-client}: include = adhoc diff --git a/mysql/custom/driver.cxx b/mysql/custom/driver.cxx deleted file mode 100644 index 526dbdc..0000000 --- a/mysql/custom/driver.cxx +++ /dev/null @@ -1,117 +0,0 @@ -// file : mysql/custom/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test custom database type mapping in MySQL. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace mysql = odb::mysql; -using namespace mysql; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_specific_database (argc, argv)); - - object o (1); - o.p = point (1.1111, 2222222222.2); - o.pv.push_back (point (1.1234, 2.2345)); - o.pv.push_back (point (3.3456, 4.4567)); - // VC just cannot roundtrip this. -#ifndef _MSC_VER - o.pv.push_back (point (0.0000001, 0.000000001)); // Scientific notation. -#endif - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - - // Query. - // - typedef mysql::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - // Point comparison. - // - { - result r (db->query (query::p == o.p)); - assert (!r.empty ()); - } - - // Point comparison using native query. - // - { - result r (db->query (query::p + "=" + query::_val (o.p))); - assert (!r.empty ()); - } - - // Access to individual members. - // - { - result r (db->query (query::p.x == o.p.x)); - assert (!r.empty ()); - } - - t.commit (); - } - - // Update. - // - o.p.x++; - o.p.y--; - o.pv[1].x--; - o.pv[1].y++; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/mysql/custom/query.hxx b/mysql/custom/query.hxx deleted file mode 100644 index 2fa8f73..0000000 --- a/mysql/custom/query.hxx +++ /dev/null @@ -1,160 +0,0 @@ -// file : mysql/custom/query.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef QUERY_HXX -#define QUERY_HXX - -#include - -#include - -#include "test.hxx" // point - -namespace odb -{ - namespace mysql - { - template <> - struct query_column - { - private: - const char* table_; - const char* column_; - const char* conversion_; - - std::string x_table_; - std::string y_table_; - std::string s_column_; - - // Sub-columns for individual members. - // - public: - query_column x, y; - - // is_null, is_not_null - // - public: - query_base - is_null () const - { - query_base q (table_, column_); - q += "IS NULL"; - return q; - } - - query_base - is_not_null () const - { - query_base q (table_, column_); - q += "IS NOT NULL"; - return q; - } - - // = - // - public: - query_base - equal (const point& v) const - { - return equal (val_bind (v)); - } - - query_base - equal (val_bind v) const - { - query_base q (table_, column_); - q += "="; - q.append (v, conversion_); - return q; - } - - query_base - equal (ref_bind r) const - { - query_base q (table_, column_); - q += "="; - q.append (r, conversion_); - return q; - } - - friend query_base - operator== (const query_column& c, const point& v) - { - return c.equal (v); - } - - friend query_base - operator== (const point& v, const query_column& c) - { - return c.equal (v); - } - - friend query_base - operator== (const query_column& c, val_bind v) - { - return c.equal (v); - } - - friend query_base - operator== (val_bind v, const query_column& c) - { - return c.equal (v); - } - - friend query_base - operator== (const query_column& c, ref_bind r) - { - return c.equal (r); - } - - friend query_base - operator== (ref_bind r, const query_column& c) - { - return c.equal (r); - } - - // Column comparison. - // - public: - query_base - operator== (const query_column& c) const - { - query_base q (table_, column_); - q += "="; - q.append (c.table (), c.column ()); - return q; - } - - public: - query_column (const char* table, const char* column, const char* conv) - : table_ (table), column_ (column), conversion_ (conv), - x_table_ ("ST_X(" + std::string (table)), // @@ Not very clean. - y_table_ ("ST_Y(" + std::string (table)), - s_column_ (std::string (column) + ")"), // X & Y column suffix. - x (x_table_.c_str (), s_column_.c_str (), 0), - y (y_table_.c_str (), s_column_.c_str (), 0) - { - } - - const char* - table () const - { - return table_; - } - - const char* - column () const - { - return column_; - } - - const char* - conversion () const - { - return conversion_; - } - }; - } -} - -#endif // QUERY_HXX diff --git a/mysql/custom/test.hxx b/mysql/custom/test.hxx deleted file mode 100644 index 82cc59d..0000000 --- a/mysql/custom/test.hxx +++ /dev/null @@ -1,54 +0,0 @@ -// file : mysql/custom/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -// Map GEOMETRY MySQL type to the point C++ struct. The other half -// of this mapping is in traits.hxx (value_traits). -// -#pragma db map type("GEOMETRY") \ - as("VARCHAR(256)") \ - to("ST_GeomFromText((?))") \ - from("ST_AsText((?))") - -#pragma db value type("GEOMETRY") -struct point -{ - point () {} - point (double x_, double y_): x (x_), y (y_) {} - - double x; - double y; -}; - -inline bool -operator== (const point& a, const point& b) -{ - return a.x == b.x && a.y == b.y; -} - -#pragma db object -struct object -{ - object () {} - object (unsigned long id_) : id (id_) {} - - #pragma db id - unsigned long id; - - point p; - std::vector pv; - - bool - operator== (const object& y) const - { - return id == y.id && p == y.p && pv == y.pv; - } -}; - -#endif // TEST_HXX diff --git a/mysql/custom/testscript b/mysql/custom/testscript deleted file mode 100644 index 9bc8839..0000000 --- a/mysql/custom/testscript +++ /dev/null @@ -1,11 +0,0 @@ -# file : mysql/custom/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../mysql.testscript - -+$create_schema - -: basics -: -$* diff --git a/mysql/custom/traits.hxx b/mysql/custom/traits.hxx deleted file mode 100644 index 5386d86..0000000 --- a/mysql/custom/traits.hxx +++ /dev/null @@ -1,88 +0,0 @@ -// file : mysql/types/traits.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TRAITS_HXX -#define TRAITS_HXX - -#include // std::numeric_limits -#include -#include // std::memcpy - -#include - -#include "test.hxx" // point - -namespace odb -{ - namespace mysql - { - template <> - class value_traits - { - public: - typedef point value_type; - typedef point query_type; - - typedef char* image_type; - - static void - set_value (point& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (is_null) - v = point (); - else - { - // Point format is "POINT(x y)". - // - std::istringstream is (std::string (b.data () + 6, n - 6)); - - is >> v.x; - is >> v.y; - } - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const point& v) - { - is_null = false; - std::ostringstream os; - - // The formula for the number of decimla digits required is given in: - // - // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf - // - os.precision (std::numeric_limits::digits10); - // os.precision (2 + std::numeric_limits::digits * 301/1000); - - os << "POINT(" << v.x << ' ' << v.y << ')'; - - const std::string& s (os.str ()); - n = s.size (); - - if (n > b.capacity ()) - b.capacity (n); - - std::memcpy (b.data (), s.c_str (), n); - } - }; - - template <> - struct type_traits - { - static const database_type_id db_type_id = id_string; - - struct conversion - { - static const char* to () {return "ST_GeomFromText((?))";} - }; - }; - } -} - -#endif // TRAITS_HXX diff --git a/mysql/database/buildfile b/mysql/database/buildfile deleted file mode 100644 index 304034e..0000000 --- a/mysql/database/buildfile +++ /dev/null @@ -1,11 +0,0 @@ -# file : mysql/database/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($mysql && !$multi || $build.meta_operation == 'dist') \ -"mysql should be configured via config.odb_tests.database variable as a single database" - -import libs = libodb-mysql%lib{odb-mysql} - -exe{driver}: {hxx cxx}{*} $libs testscript - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/mysql/database/driver.cxx b/mysql/database/driver.cxx deleted file mode 100644 index 525ee87..0000000 --- a/mysql/database/driver.cxx +++ /dev/null @@ -1,72 +0,0 @@ -// file : mysql/database/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test that database constructors are unambiguous (compilation only). -// - -#include - -#include - -#undef NDEBUG -#include - -using std::string; -namespace mysql = odb::mysql; -using namespace mysql; - -int -main (int argc, char* argv[]) -{ - // This code should not execute. - // - if (argc != 0) - return 0; - - { - database d1 (0, 0, 0); - database d2 ("bob", "secret", "db1"); - database d3 ("bob", "secret", "db1", "server1"); - database d4 ("bob", "secret", "db1", "server1", 999); - database d5 ("bob", "secret", "db1", "server1", 999, "sock1"); - database d6 ("bob", "secret", "db1", "server1", 999, "sock1", "charset1"); - } - - std::string u ("bob"), p ("secret"), db ("bd1"), h ("server1"), - s ("sock1"), cs ("charset1"); - - { - database d1 (u, p, db); - database d2 (u, p, db, h); - database d3 (u, p, db, h, 999); - database d4 (u, p, db, h, 999, &s); - database d5 (u, p, db, h, 999, &s, cs); - } - - { - database d1 (u, 0, db); - database d2 (u, &p, db); - database d3 (u, &p, db, h); - database d4 (u, &p, db, h, 999); - database d5 (u, &p, db, h, 999, &s); - database d6 (u, &p, db, h, 999, &s, cs); - } - - { - database d1 (u, p, db, h, 999, "socket1"); - database d2 (u, p, db, h, 999, s); - database d3 (u, p, db, h, 999, s, cs); - } - - { - database d1 (u, 0, db, h, 999, s); - database d2 (u, &p, db, h, 999, "socket1"); - database d3 (u, &p, db, h, 999, s, cs); - } - - { - database d1 (argc, argv); - database d2 (argc, argv, false); - database d3 (argc, argv, true, "charset1"); - } -} diff --git a/mysql/database/testscript b/mysql/database/testscript deleted file mode 100644 index c2ff256..0000000 --- a/mysql/database/testscript +++ /dev/null @@ -1,6 +0,0 @@ -# file : mysql/database/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -: basics -: -$* diff --git a/mysql/index/buildfile b/mysql/index/buildfile deleted file mode 100644 index 9cadce3..0000000 --- a/mysql/index/buildfile +++ /dev/null @@ -1,34 +0,0 @@ -# file : mysql/index/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($mysql && !$multi || $build.meta_operation == 'dist') \ -"mysql should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-mysql%lib{odb-mysql} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix mysql_index_ \ - --generate-schema \ - --default-database common - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{mysql-client}: include = adhoc diff --git a/mysql/index/driver.cxx b/mysql/index/driver.cxx deleted file mode 100644 index 4d0b7ad..0000000 --- a/mysql/index/driver.cxx +++ /dev/null @@ -1,44 +0,0 @@ -// file : mysql/index/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test MySQL index creation. See also the common test. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace mysql = odb::mysql; -using namespace mysql; - -int -main (int argc, char* argv[]) -{ - try - { - // This is just a schema creation test. - // - unique_ptr db (create_specific_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/mysql/index/test.hxx b/mysql/index/test.hxx deleted file mode 100644 index b4f6ae8..0000000 --- a/mysql/index/test.hxx +++ /dev/null @@ -1,20 +0,0 @@ -// file : mysql/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object -struct object -{ - #pragma db id auto - unsigned long id_; - - std::string s; - #pragma db index method("BTREE") member(s, "(200) DESC") -}; - -#endif // TEST_HXX diff --git a/mysql/index/testscript b/mysql/index/testscript deleted file mode 100644 index 26dfc4f..0000000 --- a/mysql/index/testscript +++ /dev/null @@ -1,11 +0,0 @@ -# file : mysql/index/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../mysql.testscript - -+$create_schema - -: basics -: -$* diff --git a/mysql/native/buildfile b/mysql/native/buildfile deleted file mode 100644 index 57c3c30..0000000 --- a/mysql/native/buildfile +++ /dev/null @@ -1,16 +0,0 @@ -# file : mysql/native/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($mysql && !$multi || $build.meta_operation == 'dist') \ -"mysql should be configured via config.odb_tests.database variable as a single database" - -import libs = libodb-mysql%lib{odb-mysql} -import libs += lib{common} - -exe{driver}: {hxx cxx}{*} $libs testscript - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{mysql-client}: include = adhoc diff --git a/mysql/native/driver.cxx b/mysql/native/driver.cxx deleted file mode 100644 index 9b34fd2..0000000 --- a/mysql/native/driver.cxx +++ /dev/null @@ -1,75 +0,0 @@ -// file : mysql/native/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test native SQL execution. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#undef NDEBUG -#include - -using namespace std; -namespace mysql = odb::mysql; -using namespace mysql; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_specific_database (argc, argv)); - - // Create the database schema. - // - { - transaction t (db->begin ()); - - db->execute ("DROP TABLE IF EXISTS mysql_native_test"); - - db->execute ("CREATE TABLE mysql_native_test (n INT PRIMARY KEY) " - "ENGINE=InnoDB"); - - t.commit (); - } - - // Insert a few rows. - // - { - transaction t (db->begin ()); - - assert ( - db->execute ("INSERT INTO mysql_native_test (n) VALUES (1)") == 1); - - assert ( - db->execute ("INSERT INTO mysql_native_test (n) VALUES (2)") == 1); - - t.commit (); - } - - // Select a few rows. - // - { - transaction t (db->begin ()); - - assert ( - db->execute ("SELECT n FROM mysql_native_test WHERE n < 3") == 2); - - assert ( - db->execute ("SELECT n FROM mysql_native_test WHERE n > 3") == 0); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/mysql/native/testscript b/mysql/native/testscript deleted file mode 100644 index 21327ff..0000000 --- a/mysql/native/testscript +++ /dev/null @@ -1,9 +0,0 @@ -# file : mysql/native/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../mysql.testscript - -: basics -: -$* diff --git a/mysql/truncation/buildfile b/mysql/truncation/buildfile deleted file mode 100644 index fbd936b..0000000 --- a/mysql/truncation/buildfile +++ /dev/null @@ -1,35 +0,0 @@ -# file : mysql/truncation/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($mysql && !$multi || $build.meta_operation == 'dist') \ -"mysql should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-mysql%lib{odb-mysql} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix mysql_truncation_ \ - --generate-schema \ - --default-database common \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{mysql-client}: include = adhoc diff --git a/mysql/truncation/driver.cxx b/mysql/truncation/driver.cxx deleted file mode 100644 index 21084f5..0000000 --- a/mysql/truncation/driver.cxx +++ /dev/null @@ -1,192 +0,0 @@ -// file : mysql/truncation/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test insufficient buffer/truncation handling. -// - -#include // std::unique_ptr -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace mysql = odb::mysql; -using namespace mysql; - -int -main (int argc, char* argv[]) -{ - // The default pre-allocated buffer is 256 bytes long. - // - string long_str (300, 'c'); // This will get the buffer to 512 - string longer_str (1025, 'b'); - - try - { - // Test basic operations. - // - { - unique_ptr db (create_specific_database (argc, argv)); - - // Run persist/load so that the initial bindings are established - // (version == 0). - // - { - object1 o (1); - o.str_ = "test string"; - - transaction t (db->begin ()); - db->persist (o); - db->load (1, o); - t.commit (); - } - - { - object2 o (2); - o.str_ = "test string"; - - transaction t (db->begin ()); - db->persist (o); - db->load (2, o); - t.commit (); - } - - // Store/load the long string which should trigger buffer growth. - // - { - object1 o (3); - o.str_ = long_str; - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (3)); - assert (o->str_ == long_str); - t.commit (); - } - - // Store/load longer string. - // - { - object1 o (3); - o.str_ = longer_str; - - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (3)); - assert (o->str_ == longer_str); - t.commit (); - } - } - - // Test query. - // - { - typedef mysql::query query; - typedef odb::result result; - - unique_ptr db (create_specific_database (argc, argv)); - - // Run persist/query so that the initial bindings are established - // (version == 0). - // - { - object1 o (20); - o.str_ = "test string"; - - transaction t (db->begin ()); - db->persist (o); - o.id_++; - db->persist (o); - o.id_++; - db->persist (o); - - result r (db->query (query::id == 20)); - assert (r.begin ()->id_ == 20); - t.commit (); - } - - // Test buffer growth with cached result. - // - { - object1 o; - - transaction t (db->begin ()); - - result r (db->query (query::id >= 20)); - result::iterator i (r.begin ()); - - o.id_ = i->id_; - o.str_ = long_str; - - // This forces buffer growth in the middle of result iteration. - // - db->update (o); - - ++i; - assert (i->str_ == "test string"); - - o.id_ = i->id_; - o.str_ = longer_str; - db->update (o); - - ++i; - assert (i->str_ == "test string"); - - t.commit (); - } - } - - // Test containers. - // - { - unique_ptr db (create_specific_database (argc, argv)); - - // Use different connections to persist and load the object. - // - connection_ptr c1 (db->connection ()); - connection_ptr c2 (db->connection ()); - - container o (1); - o.vec_.push_back (string (513, 'x')); - - { - transaction t (c1->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (c2->begin ()); - unique_ptr p (db->load (1)); - t.commit (); - - assert (p->vec_ == o.vec_); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/mysql/truncation/test.hxx b/mysql/truncation/test.hxx deleted file mode 100644 index 1883b0e..0000000 --- a/mysql/truncation/test.hxx +++ /dev/null @@ -1,48 +0,0 @@ -// file : mysql/truncation/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -#pragma db object table ("test") -struct object1 -{ - object1 () {} - object1 (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - std::string str_; -}; - -#pragma db object table ("test") -struct object2 -{ - object2 () {} - object2 (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - std::string str_; -}; - -#pragma db object -struct container -{ - container () {} - container (unsigned long id) : id_ (id) {} - - #pragma db id - unsigned long id_; - - std::vector vec_; -}; - -#endif // TEST_HXX diff --git a/mysql/truncation/testscript b/mysql/truncation/testscript deleted file mode 100644 index b9b6792..0000000 --- a/mysql/truncation/testscript +++ /dev/null @@ -1,11 +0,0 @@ -# file : mysql/truncation/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../mysql.testscript - -+$create_schema - -: basics -: -$* diff --git a/mysql/types/buildfile b/mysql/types/buildfile deleted file mode 100644 index 112a81f..0000000 --- a/mysql/types/buildfile +++ /dev/null @@ -1,36 +0,0 @@ -# file : mysql/types/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($mysql && !$multi || $build.meta_operation == 'dist') \ -"mysql should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-mysql%lib{odb-mysql} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix mysql_types_ \ - --generate-schema \ - --default-database common \ - --generate-query \ - --hxx-prologue '#include "traits.hxx"' - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{mysql-client}: include = adhoc diff --git a/mysql/types/driver.cxx b/mysql/types/driver.cxx deleted file mode 100644 index 2354b04..0000000 --- a/mysql/types/driver.cxx +++ /dev/null @@ -1,168 +0,0 @@ -// file : mysql/types/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test MySQL type conversion. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace mysql = odb::mysql; -using namespace mysql; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_specific_database (argc, argv)); - - mysql_version v; - { - transaction t (db->begin ()); - db->query ().begin ().load (v); - t.commit (); - } - - //cerr << "MySQL " << v.major << '.' << v.minor << '.' << v.release - // << " protocol " << v.protocol << endl; - - object o (1); - - o.bool_ = true; - o.schar_ = -123; - o.uchar_ = 123; - o.short_ = -12345; - o.ushort_ = 12345; - o.mint_ = -123456; - o.umint_ = 123456; - o.int_ = -123456; - o.uint_ = 123456; - o.long_long_ = -123456; - o.ulong_long_ = 123456; - - o.float_ = 1.123F; - o.float8_ = 1.123; - o.double_ = 1.123; - o.decimal_ = "123.456"; - - o.date_ = date_time (false, 2010, 8, 29, 0, 0, 0); - o.time_ = date_time (true, 0, 0, 0, 12, 26, 59); - o.date_time_ = date_time (false, 2010, 8, 29, 12, 26, 59); - o.timestamp_ = date_time (false, 2010, 8, 29, 12, 26, 59); - o.year_ = 2010; - - // If we are running against MySQL 5.6.4 or later, add fractional - // seconds and also alter the table to allow sub-second precision. - // - if (v.major > 5 || - (v.major == 5 && (v.minor > 6 || - (v.minor == 6 && v.release >= 4)))) - { - o.time_.microseconds = 123456; - o.date_time_.microseconds = 234567; - o.timestamp_.microseconds = 345678; - - transaction t (db->begin ()); - db->execute ("ALTER TABLE `mysql_types_object`" \ - " MODIFY COLUMN `time` TIME(6)," \ - " MODIFY COLUMN `date_time` DATETIME(6)," \ - " MODIFY COLUMN `timestamp` TIMESTAMP(6)"); - t.commit (); - } - - string short_str (128, 's'); - string medium_str (250, 'm'); - string long_str (2040, 'l'); - - const char* sb (short_str.c_str ()), *se (sb + short_str.size ()); - const char* mb (medium_str.c_str ()), *me (mb + medium_str.size ()); - const char* lb (long_str.c_str ()), *le (lb + long_str.size ()); - - o.char_ = short_str; - o.binary_.assign (sb, se); - o.varchar_ = medium_str; - o.varbinary_.assign (mb, me); - o.tinytext_ = short_str; - o.tinyblob_.assign (sb, se); - o.text_ = long_str; - o.blob_.assign (lb, le); - o.mediumtext_ = long_str; - o.mediumblob_.assign (lb, le); - o.longtext_ = long_str; - o.longblob_.assign (lb, le); - - o.bit_.a = 1; - o.bit_.b = 0; - o.bit_.c = 0; - o.bit_.d = 1; - - o.enum_def_ = green; - o.enum_cst_ = blue; - o.enum_str_ = "green"; - o.set_.insert ("green"); - o.set_.insert ("red"); - o.set_.insert ("blue"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // - // - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - - // Test char array. - // - { - char_array o1 (1, ""); - char_array o2 (2, "1234567890"); - char_array o3 (3, "1234567890123456"); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (1)); - unique_ptr p2 (db->load (2)); - unique_ptr p3 (db->load (3)); - t.commit (); - - assert (o1 == *p1); - assert (o2 == *p2); - assert (o3 == *p3); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/mysql/types/test.hxx b/mysql/types/test.hxx deleted file mode 100644 index 82f7496..0000000 --- a/mysql/types/test.hxx +++ /dev/null @@ -1,328 +0,0 @@ -// file : mysql/types/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include -#include // std::unique_ptr -#include // std::memcpy, std::str[n]cmp, std::strlen - -#include - -typedef std::vector buffer; - -struct date_time -{ - date_time () - { - } - - date_time (bool n, - unsigned int y, - unsigned int m, - unsigned int d, - unsigned int h, - unsigned int min, - unsigned int sec, - unsigned int msec = 0) - : negative (n), - year (y), - month (m), - day (d), - hour (h), - minute (min), - second (sec), - microseconds (msec) - { - } - - bool - operator== (const date_time& y) const - { - return - negative == y.negative && - year == y.year && - month == y.month && - day == y.day && - hour == y.hour && - minute == y.minute && - second == y.second && - microseconds == y.microseconds; - } - - bool negative; - unsigned int year; - unsigned int month; - unsigned int day; - unsigned int hour; - unsigned int minute; - unsigned int second; - unsigned int microseconds; -}; - -struct bitfield -{ - unsigned int a: 1; - unsigned int b: 1; - unsigned int c: 1; - unsigned int d: 1; -}; - -inline bool -operator== (bitfield x, bitfield y) -{ - return - x.a == y.a && - x.b == y.b && - x.c == y.c && - x.d == y.d; -} - -#pragma db value(bitfield) type ("BIT(4)") - -typedef std::set set; -typedef std::unique_ptr string_ptr; - -enum color {red, green, blue}; - -#pragma db object -struct object -{ - object () {} - object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - // Integral types. - // - #pragma db type ("BOOL") - bool bool_; - - #pragma db type ("TINYINT") - signed char schar_; - - #pragma db type ("TINYINT UNSIGNED") - unsigned char uchar_; - - #pragma db type ("SMALLINT") - short short_; - - #pragma db type ("SMALLINT UNSIGNED") - unsigned short ushort_; - - #pragma db type ("MEDIUMINT") - int mint_; - - #pragma db type ("MEDIUMINT UNSIGNED") - unsigned int umint_; - - #pragma db type ("INT") - int int_; - - #pragma db type ("INT UNSIGNED") - unsigned int uint_; - - #pragma db type ("BIGINT") - long long long_long_; - - #pragma db type ("BIGINT UNSIGNED") - unsigned long long ulong_long_; - - // Float types. - // - #pragma db type ("FLOAT") - float float_; - - #pragma db type ("FLOAT(32)") - double float8_; - - #pragma db type ("DOUBLE") - double double_; - - #pragma db type ("DECIMAL(6,3)") - std::string decimal_; - - // Data-time types. - // - #pragma db type ("DATE") - date_time date_; - - #pragma db type ("TIME") - date_time time_; - - #pragma db type ("DATETIME") - date_time date_time_; - - #pragma db type ("TIMESTAMP") - date_time timestamp_; - - #pragma db type ("YEAR") - short year_; - - // String and binary types. - // - #pragma db type ("CHAR(128)") - std::string char_; - - #pragma db type ("BINARY(128)") - buffer binary_; - - #pragma db type ("VARCHAR(256)") - std::string varchar_; - - #pragma db type ("VARBINARY(256)") - buffer varbinary_; - - #pragma db type ("TINYTEXT") - std::string tinytext_; - - #pragma db type ("TINYBLOB") - buffer tinyblob_; - - #pragma db type ("TEXT") - std::string text_; - - #pragma db type ("BLOB") - buffer blob_; - - #pragma db type ("MEDIUMTEXT") - std::string mediumtext_; - - #pragma db type ("MEDIUMBLOB") - buffer mediumblob_; - - #pragma db type ("LONGTEXT") - std::string longtext_; - - #pragma db type ("LONGBLOB") - buffer longblob_; - - // Other types. - // - // #pragma db type ("BIT(4)") - assigned by #pragma db value - bitfield bit_; - - // Test ENUM representations (integer and string). - // - color enum_def_; - - // Map to a custom MySQL ENUM type. - // - #pragma db type ("ENUM('R', 'G', 'B')") - color enum_cst_; - - #pragma db type ("ENUM('red', 'green', 'blue')") - std::string enum_str_; - - #pragma db type ("SET('red', 'green', 'blue')") - set set_; - - // Test NULL value. - // - #pragma db type ("TEXT") null - string_ptr null_; - - bool - operator== (const object& y) const - { - return - id_ == y.id_ && - bool_ == y.bool_ && - schar_ == y.schar_ && - uchar_ == y.uchar_ && - short_ == y.short_ && - ushort_ == y.ushort_ && - mint_ == y.mint_ && - umint_ == y.umint_ && - int_ == y.int_ && - uint_ == y.uint_ && - long_long_ == y.long_long_ && - ulong_long_ == y.ulong_long_ && - float_ == y.float_ && - float8_ == y.float8_ && - double_ == y.double_ && - decimal_ == y.decimal_ && - date_ == y.date_ && - time_ == y.time_ && - date_time_ == y.date_time_ && - timestamp_ == y.timestamp_ && - year_ == y.year_ && - char_ == y.char_ && - binary_ == y.binary_ && - varchar_ == y.varchar_ && - varbinary_ == y.varbinary_ && - tinytext_ == y.tinytext_ && - tinyblob_ == y.tinyblob_ && - text_ == y.text_ && - blob_ == y.blob_ && - mediumtext_ == y.mediumtext_ && - mediumblob_ == y.mediumblob_ && - longtext_ == y.longtext_ && - longblob_ == y.longblob_ && - bit_ == y.bit_ && - enum_def_ == y.enum_def_ && - enum_cst_ == y.enum_cst_ && - enum_str_ == y.enum_str_ && - set_ == y.set_ && - ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_); - } -}; - -// Test char array. -// -#pragma db object -struct char_array -{ - char_array () {} - char_array (unsigned long id, const char* s) - : id_ (id) - { - std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation. - std::memcpy (s2, s, std::strlen (s) + 1); - s3[0] = c1 = *s; - } - - #pragma db id - unsigned long id_; - - char s1[17]; - - #pragma db type("CHAR(16)") - char s2[16]; - - char s3[1]; - char c1; - - bool - operator== (const char_array& y) const - { - return id_ == y.id_ && - std::strcmp (s1, y.s1) == 0 && - std::strncmp (s2, y.s2, sizeof (s2)) == 0 && - s3[0] == y.s3[0] && - c1 == y.c1; - } -}; - -// MySQL server version view. -// -#pragma db view query( \ - "SELECT " \ - "CAST(SUBSTRING_INDEX(@@version, '.', 1) AS UNSIGNED)," \ - "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '.', 2), '.', -1) AS UNSIGNED)," \ - "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '-', 1), '.', -1) AS UNSIGNED)," \ - "@@protocol_version") -struct mysql_version -{ - unsigned int major; - unsigned int minor; - unsigned int release; - - unsigned int protocol; -}; - -#endif // TEST_HXX diff --git a/mysql/types/testscript b/mysql/types/testscript deleted file mode 100644 index 2962d1c..0000000 --- a/mysql/types/testscript +++ /dev/null @@ -1,11 +0,0 @@ -# file : mysql/types/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../mysql.testscript - -+$create_schema - -: basics -: -$* diff --git a/mysql/types/traits.hxx b/mysql/types/traits.hxx deleted file mode 100644 index d4ce200..0000000 --- a/mysql/types/traits.hxx +++ /dev/null @@ -1,198 +0,0 @@ -// file : mysql/types/traits.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TRAITS_HXX -#define TRAITS_HXX - -#include // std::memcpy, std::memset - -#include - -#include "test.hxx" // date_time, string_ptr - -namespace odb -{ - namespace mysql - { - template - class value_traits - { - public: - typedef date_time value_type; - typedef date_time query_type; - typedef MYSQL_TIME image_type; - - static void - set_value (date_time& v, const MYSQL_TIME& i, bool is_null) - { - if (!is_null) - { - v.negative = i.neg; - v.year = i.year; - v.month = i.month; - v.day = i.day; - v.hour = i.hour; - v.minute = i.minute; - v.second = i.second; - v.microseconds = static_cast (i.second_part); - } - else - v = date_time (); - } - - static void - set_image (MYSQL_TIME& i, bool& is_null, const date_time& v) - { - is_null = false; - i.neg = v.negative; - i.year = v.year; - i.month = v.month; - i.day = v.day; - i.hour = v.hour; - i.minute = v.minute; - i.second = v.second; - i.second_part = v.microseconds; - } - }; - - template <> - class value_traits - { - public: - typedef bitfield value_type; - typedef bitfield query_type; - typedef unsigned char* image_type; - - static void - set_value (bitfield& v, - const unsigned char* s, - std::size_t, - bool is_null) - { - if (!is_null) - { - v.a = *s & 1; - v.b = (*s >> 1) & 1; - v.c = (*s >> 2) & 1; - v.d = (*s >> 3) & 1; - } - else - v.a = v.b = v.c = v.d = 0; - } - - static void - set_image (unsigned char* s, - std::size_t, - std::size_t& n, - bool& is_null, - bitfield v) - { - is_null = false; - n = 1; - *s = v.a | (v.b << 1) | (v.c << 2) | (v.d << 3); - } - }; - - template <> - class value_traits - { - public: - typedef set value_type; - typedef set query_type; - typedef details::buffer image_type; - - static void - set_value (set& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - v.clear (); - - if (!is_null) - { - const char* s (b.data ()); - const char* e (s + n); - - while (s < e) - { - const char* p (s); - - while (p < e && *p != ',') - ++p; - - v.insert (std::string (s, p - s)); - s = p; - - if (p != e) - ++s; - } - } - } - - static void - set_image (details::buffer& buf, - std::size_t& n, - bool& is_null, - const set& v) - { - is_null = false; - n = 0; - - for (set::const_iterator b (v.begin ()), i (b); i != v.end (); ++i) - { - std::size_t m (i->size () + (i != b ? 1 : 0)); - - if (n + m > buf.capacity ()) - buf.capacity (n + m, n); - - if (i != b) - buf.data ()[n++] = ','; - - std::memcpy (buf.data () + n, i->c_str (), i->size ()); - n += i->size (); - } - } - }; - - template <> - class value_traits - { - public: - typedef string_ptr value_type; - typedef std::string query_type; - typedef details::buffer image_type; - - static void - set_value (string_ptr& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - v.reset (is_null ? 0 : new std::string (b.data (), n)); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const string_ptr& v) - { - is_null = v.get () == 0; - - if (!is_null) - { - n = v->size (); - - if (n > b.capacity ()) - b.capacity (n); - - if (n != 0) - std::memcpy (b.data (), v->c_str (), n); - } - } - }; - } -} - -#endif // TRAITS_HXX diff --git a/odb-tests/.gitignore b/odb-tests/.gitignore new file mode 100644 index 0000000..e3bbf5b --- /dev/null +++ b/odb-tests/.gitignore @@ -0,0 +1,41 @@ +# Compiler/linker output. +# +*.d +*.t +*.i +*.i.* +*.ii +*.ii.* +*.o +*.obj +*.gcm +*.pcm +*.ifc +*.so +*.dylib +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc + +# Test executables. +# +driver + +# ODB-generated files. +# +test-odb.?xx +test-odb-*.?xx +test.sql +test-*.sql + +# Testscript output directories (can be symlinks). +# +test +test-driver diff --git a/odb-tests/GPLv2 b/odb-tests/GPLv2 new file mode 100644 index 0000000..3912109 --- /dev/null +++ b/odb-tests/GPLv2 @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/odb-tests/LICENSE b/odb-tests/LICENSE new file mode 100644 index 0000000..9d92da1 --- /dev/null +++ b/odb-tests/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2009-2024 Code Synthesis Tools CC. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +For more information on ODB licensing as well as for answers to +some of the common licensing questions, visit the ODB License +page: + +http://www.codesynthesis.com/products/odb/license.xhtml + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/odb-tests/README.md b/odb-tests/README.md new file mode 100644 index 0000000..24d3bf7 --- /dev/null +++ b/odb-tests/README.md @@ -0,0 +1,4 @@ +# odb-tests - tests for ODB compiler + +This package contains tests for `odb`, object-relational mapping (ORM) +compiler for C++. diff --git a/odb-tests/boost/common/multi-index/driver.cxx b/odb-tests/boost/common/multi-index/driver.cxx new file mode 100644 index 0000000..a077008 --- /dev/null +++ b/odb-tests/boost/common/multi-index/driver.cxx @@ -0,0 +1,189 @@ +// file : boost/common/multi-index/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Boost multi-index container persistence. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + { + using namespace odb; + + assert (odb::access::container_traits::kind == ck_ordered); + assert (odb::access::container_traits::kind == ck_ordered); + assert (odb::access::container_traits::kind == ck_set); + + assert (odb::access::container_traits::kind == ck_ordered); + assert (odb::access::container_traits::kind == ck_ordered); + assert (odb::access::container_traits::kind == ck_set); + } + + try + { + auto_ptr db (create_database (argc, argv)); + + for (unsigned short i (0); i < 2; ++i) + { + object empty ("empty"), med ("medium"), full ("full"); + + // + // empty + // + + // + // med + // + med.il.push_back (234); + med.il.push_back (123); + + med.iv.push_back (234); + med.iv.push_back (123); + + med.is.insert (234); + med.is.insert (123); + + med.ils.push_back (234); + med.ils.push_back (123); + + med.csv.insert (comp (234, "bcd")); + med.csv.insert (comp (123, "abc")); + + med.css.insert (comp (234, "bcd")); + med.css.insert (comp (123, "abc")); + + // + // full + // + full.il.push_back (2345); + full.il.push_back (1234); + full.il.push_back (3456); + + full.iv.push_back (2345); + full.iv.push_back (1234); + full.iv.push_back (3456); + + full.is.insert (2345); + full.is.insert (1234); + full.is.insert (3456); + + full.ils.push_back (2345); + full.ils.push_back (1234); + full.ils.push_back (3456); + + full.csv.insert (comp (234, "bcde")); + full.csv.insert (comp (123, "abcd")); + full.csv.insert (comp (234, "cdef")); + + full.css.insert (comp (234, "bcde")); + full.css.insert (comp (123, "abcd")); + full.css.insert (comp (234, "cdef")); + + // persist + // + { + transaction t (db->begin ()); + db->persist (empty); + db->persist (med); + db->persist (full); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + auto_ptr e (db->load ("empty")); + auto_ptr m (db->load ("medium")); + auto_ptr f (db->load ("full")); + t.commit (); + + assert (empty == *e); + assert (med == *m); + assert (full == *f); + } + + // empty + // + empty.il.push_back (12); + empty.iv.push_back (12); + empty.is.insert (12); + empty.ils.push_back (12); + empty.csv.insert (comp (12, "ab")); + empty.css.insert (comp (12, "ab")); + + // med + // + med.il.clear (); + med.iv.clear (); + med.is.clear (); + med.ils.clear (); + med.csv.clear (); + med.css.clear (); + + // full + // + full.il.push_back (4567); + full.iv.push_back (4567); + full.is.insert (4567); + full.ils.push_back (4567); + full.csv.insert (comp (4567, "defg")); + full.css.insert (comp (4567, "defg")); + + // update + // + { + transaction t (db->begin ()); + db->update (empty); + db->update (med); + db->update (full); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + auto_ptr e (db->load ("empty")); + auto_ptr m (db->load ("medium")); + auto_ptr f (db->load ("full")); + t.commit (); + + assert (empty == *e); + assert (med == *m); + assert (full == *f); + } + + // erase + // + if (i == 0) + { + transaction t (db->begin ()); + db->erase ("empty"); + db->erase ("medium"); + db->erase ("full"); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/boost/common/multi-index/test.hxx b/odb-tests/boost/common/multi-index/test.hxx new file mode 100644 index 0000000..22b9ea4 --- /dev/null +++ b/odb-tests/boost/common/multi-index/test.hxx @@ -0,0 +1,113 @@ +// file : boost/common/multi-index/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include +#include +#include +#include + +#include + +namespace mi = boost::multi_index; + +#pragma db value +struct comp +{ + comp () {} + comp (int n, const std::string& s) : num (n), str (s) {} + + #pragma db column("number") + int num; + std::string str; +}; + +inline bool +operator== (const comp& x, const comp& y) +{ + return x.num == y.num && x.str == y.str; +} + +typedef +mi::multi_index_container< + int, + mi::indexed_by > +> int_lst; + +typedef +mi::multi_index_container< + int, + mi::indexed_by > +> int_vec; + +typedef +mi::multi_index_container< + int, + mi::indexed_by > > +> int_set; + +typedef +mi::multi_index_container< + int, + mi::indexed_by< + mi::sequenced<>, + mi::ordered_unique > + > +> int_lst_set; + +typedef +mi::multi_index_container< + comp, + mi::indexed_by< + mi::ordered_unique >, + mi::random_access<> + > +> comp_set_vec; + +typedef +mi::multi_index_container< + comp, + mi::indexed_by< + mi::ordered_unique >, + mi::ordered_unique > + > +> comp_set_set; + +#pragma db object +struct object +{ + object () {} + object (const std::string& id): id (id) {} + + #pragma db id + std::string id; + + int_lst il; + int_lst iv; + int_set is; + + int_lst_set ils; + comp_set_vec csv; + comp_set_set css; +}; + +inline bool +operator== (const object& x, const object& y) +{ + return + x.id == y.id && + + x.il == y.il && + x.iv == y.iv && + x.is == y.is && + + x.ils == y.ils && + x.csv == y.csv && + x.css == y.css; +} + +#endif // TEST_HXX diff --git a/odb-tests/boost/common/optional/driver.cxx b/odb-tests/boost/common/optional/driver.cxx new file mode 100644 index 0000000..c2e3079 --- /dev/null +++ b/odb-tests/boost/common/optional/driver.cxx @@ -0,0 +1,74 @@ +// file : boost/common/optional/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test boost::optional persistence. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + { + object o1 (1); + object o2 (2); + o2.str = "abc"; + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr o1 (db->load (1)); + auto_ptr o2 (db->load (2)); + t.commit (); + + assert (!o1->str); + assert (o2->str && *o2->str == "abc"); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + { + result r (db->query (query::str.is_null ())); + assert (!r.empty ()); + } + + { + result r (db->query (query::str == "abc")); + assert (!r.empty ()); + } + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/boost/common/optional/test.hxx b/odb-tests/boost/common/optional/test.hxx new file mode 100644 index 0000000..65d951e --- /dev/null +++ b/odb-tests/boost/common/optional/test.hxx @@ -0,0 +1,31 @@ +// file : boost/common/optional/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; + + boost::optional str; +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/common/smart-ptr/driver.cxx b/odb-tests/boost/common/smart-ptr/driver.cxx new file mode 100644 index 0000000..4bc6366 --- /dev/null +++ b/odb-tests/boost/common/smart-ptr/driver.cxx @@ -0,0 +1,202 @@ +// file : boost/common/smart-ptr/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test boost smart pointers. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; + +using namespace odb::boost; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + using boost::shared_ptr; + + try + { + auto_ptr db (create_database (argc, argv)); + + shared_ptr c1 (new cont (1)); + { + transaction t (db->begin ()); + db->persist (c1); + t.commit (); + } + + // Test comparison operators. + // + { + assert (lazy_shared_ptr () == lazy_shared_ptr ()); + assert (lazy_shared_ptr () != lazy_shared_ptr (c1)); + assert (lazy_shared_ptr (c1) == lazy_shared_ptr (c1)); + + lazy_shared_ptr lc1 (*db, 1); + assert (lc1 != lazy_shared_ptr ()); + assert (lc1 == lazy_shared_ptr (*db, c1)); + + shared_ptr c2 (new cont (2)); + assert (lc1 != lazy_shared_ptr (*db, c2)); + } + + // Test swap. + // + { + lazy_shared_ptr lx (*db, 1), ly; + assert (lx == lazy_shared_ptr (*db, c1)); + + swap (lx, ly); + assert (lx == lazy_shared_ptr ()); + assert (ly == lazy_shared_ptr (*db, c1)); + } + + // Test assignment from auto_ptr. + // + { + cont* p = new cont (3); + auto_ptr a (p); + lazy_shared_ptr l; + l = a; + + assert (l.get() == p); + assert (!a.get ()); + } + + shared_ptr o1 (new obj (1)); + shared_ptr o2 (new obj (2)); + shared_ptr o3 (new obj (3)); + shared_ptr o4 (new obj (4)); + shared_ptr c2 (new cont (2)); + + o1->c = c1; + o2->c = c1; + o3->c = c2; + o4->c = c2; + + // Persist. + // + { + transaction t (db->begin ()); + + db->persist (o1); + db->persist (o2); + db->persist (o3); + db->persist (o4); + db->persist (c2); + + t.commit (); + } + + // Load. + // + { + session s; + transaction t (db->begin ()); + + shared_ptr c (db->load (1)); + shared_ptr o (db->load (1)); + + // Ensure that lazy pointers are present but not loaded. + // + assert (c->o.size () == 2); + assert (!c->o[0].loaded ()); + assert (!c->o[1].loaded ()); + assert (!o->c.loaded ()); + + // Ensure that the correct object IDs were loaded. + // + assert (c->o[0].object_id () == 1); + assert (c->o[1].object_id () == 2); + assert (o->c.object_id () == 1); + + // Load the lazy pointer targets ensuring that the loaded + // targets correspond to the cached session objects. + // + shared_ptr cl (o->c.load ()); + shared_ptr ol (c->o[0].load ()); + + assert (c->o[0].loaded ()); + assert (o->c.loaded ()); + + assert (cl == c); + assert (ol == o); + + t.commit (); + } + + // Test lazy weak locking and reloading. + // + { + // No session. + // + transaction t (db->begin ()); + shared_ptr c (db->load (1)); + + // Lock. + // + assert (!c->o[1].loaded ()); + lazy_shared_ptr l (c->o[1].lock ()); + assert (!l.loaded ()); + assert (l.object_id () == c->o[1].object_id ()); + + // Reload. + // + assert (!c->o[1].loaded ()); + + shared_ptr ol (c->o[1].load ()); + assert (c->o[1].loaded ()); + + ol.reset (); + assert (!c->o[1].loaded ()); + + ol = c->o[1].load (); + assert (c->o[1].loaded ()); + + t.commit (); + } + + // + // Test shared_ptr as a value wrapper. + // + + { + obj2 o1 (1); + obj2 o2 (2); + o2.str.reset (new string ("abc")); + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + shared_ptr o1 (db->load (1)); + shared_ptr o2 (db->load (2)); + t.commit (); + + assert (!o1->str); + assert (o2->str && *o2->str == "abc"); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/boost/common/smart-ptr/test.hxx b/odb-tests/boost/common/smart-ptr/test.hxx new file mode 100644 index 0000000..26d7109 --- /dev/null +++ b/odb-tests/boost/common/smart-ptr/test.hxx @@ -0,0 +1,82 @@ +// file : boost/common/smart-ptr/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +#include +#include + +struct obj; + +using boost::shared_ptr; +using odb::boost::lazy_shared_ptr; +using odb::boost::lazy_weak_ptr; + +#pragma db object +struct cont +{ + cont () + { + } + + cont (unsigned long id) + : id (id) + { + } + + #pragma db id + unsigned long id; + + typedef std::vector > obj_list; + + #pragma db inverse(c) value_not_null + obj_list o; +}; + +#pragma db object +struct obj +{ + obj () + { + } + + obj (unsigned long id) + : id (id) + { + } + + #pragma db id + unsigned long id; + + #pragma db not_null + lazy_shared_ptr c; +}; + +// Test shared_ptr as a value wrapper. +// +#pragma db object +struct obj2 +{ + obj2 () + { + } + + obj2 (unsigned long id) + : id (id) + { + } + + #pragma db id + unsigned long id; + + #pragma db null + shared_ptr str; +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/common/template/driver.cxx b/odb-tests/boost/common/template/driver.cxx new file mode 100644 index 0000000..43e28c0 --- /dev/null +++ b/odb-tests/boost/common/template/driver.cxx @@ -0,0 +1,39 @@ +// file : boost/common/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/boost/common/template/template-vc10.vcxproj b/odb-tests/boost/common/template/template-vc10.vcxproj new file mode 100644 index 0000000..3c606f9 --- /dev/null +++ b/odb-tests/boost/common/template/template-vc10.vcxproj @@ -0,0 +1,177 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + + +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/common/template/template-vc10.vcxproj.filters b/odb-tests/boost/common/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..f3ee658 --- /dev/null +++ b/odb-tests/boost/common/template/template-vc10.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test-odb.cxx) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/common/template/template-vc11.vcxproj b/odb-tests/boost/common/template/template-vc11.vcxproj new file mode 100644 index 0000000..83d20c5 --- /dev/null +++ b/odb-tests/boost/common/template/template-vc11.vcxproj @@ -0,0 +1,181 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + + +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/common/template/template-vc11.vcxproj.filters b/odb-tests/boost/common/template/template-vc11.vcxproj.filters new file mode 100644 index 0000000..f3ee658 --- /dev/null +++ b/odb-tests/boost/common/template/template-vc11.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test-odb.cxx) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/common/template/template-vc12.vcxproj b/odb-tests/boost/common/template/template-vc12.vcxproj new file mode 100644 index 0000000..fd147f7 --- /dev/null +++ b/odb-tests/boost/common/template/template-vc12.vcxproj @@ -0,0 +1,185 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + + +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/common/template/template-vc12.vcxproj.filters b/odb-tests/boost/common/template/template-vc12.vcxproj.filters new file mode 100644 index 0000000..f3ee658 --- /dev/null +++ b/odb-tests/boost/common/template/template-vc12.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test-odb.cxx) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/common/template/template-vc8.vcproj b/odb-tests/boost/common/template/template-vc8.vcproj new file mode 100644 index 0000000..e0ac609 --- /dev/null +++ b/odb-tests/boost/common/template/template-vc8.vcproj @@ -0,0 +1,353 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/common/template/template-vc9.vcproj b/odb-tests/boost/common/template/template-vc9.vcproj new file mode 100644 index 0000000..b8bf4bc --- /dev/null +++ b/odb-tests/boost/common/template/template-vc9.vcproj @@ -0,0 +1,360 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/common/template/test.hxx b/odb-tests/boost/common/template/test.hxx new file mode 100644 index 0000000..1d2a5f3 --- /dev/null +++ b/odb-tests/boost/common/template/test.hxx @@ -0,0 +1,25 @@ +// file : boost/common/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/common/unordered/driver.cxx b/odb-tests/boost/common/unordered/driver.cxx new file mode 100644 index 0000000..eda5891 --- /dev/null +++ b/odb-tests/boost/common/unordered/driver.cxx @@ -0,0 +1,212 @@ +// file : boost/common/unordered/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Boost unordered containers persistence. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + for (unsigned short i (0); i < 2; ++i) + { + object empty ("empty"), med ("medium"), full ("full"); + + // + // empty + // + + // + // med + // + + // set + // + med.ns.insert (123); + med.ns.insert (234); + + med.ss.insert ("aaa"); + med.ss.insert ("bbbb"); + + med.cms.insert (comp (123, "aaa")); + med.cms.insert (comp (234, "bbbb")); + + // map + // + med.nsm[123] = "aaa"; + med.nsm[234] = "bbbb"; + + med.snm["aaa"] = 123; + med.snm["bbbb"] = 234; + + med.ncm[123] = comp (123, "aaa"); + med.ncm[234] = comp (234, "bbbb"); + + med.csmm.insert ( + comp_str_multimap::value_type (comp (123, "aaa"), "aaa")); + med.csmm.insert ( + comp_str_multimap::value_type (comp (234, "bbbb"), "bbbb")); + + // + // full + // + + // set + // + full.ns.insert (1234); + full.ns.insert (2345); + full.ns.insert (3456); + + full.ss.insert ("aaaa"); + full.ss.insert ("bbbbb"); + full.ss.insert ("cccccc"); + + full.cms.insert (comp (1234, "aaaa")); + full.cms.insert (comp (2345, "bbbbb")); + full.cms.insert (comp (3456, "cccccc")); + + // map + // + full.nsm[1234] = "aaaa"; + full.nsm[2345] = "bbbbb"; + full.nsm[3456] = "cccccc"; + + full.snm["aaaa"] = 1234; + full.snm["bbbbb"] = 2345; + full.snm["cccccc"] = 3456; + + full.ncm[1234] = comp (1234, "aaaa"); + full.ncm[2345] = comp (2345, "bbbbb"); + full.ncm[3456] = comp (3456, "cccccc"); + + full.csmm.insert ( + comp_str_multimap::value_type (comp (1234, "aaaa"), "aaaa")); + full.csmm.insert ( + comp_str_multimap::value_type (comp (2345, "bbbbb"), "bbbbb")); + full.csmm.insert ( + comp_str_multimap::value_type (comp (3456, "cccccc"), "cccccc")); + + // persist + // + { + transaction t (db->begin ()); + db->persist (empty); + db->persist (med); + db->persist (full); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + auto_ptr e (db->load ("empty")); + auto_ptr m (db->load ("medium")); + auto_ptr f (db->load ("full")); + t.commit (); + + assert (empty == *e); + assert (med == *m); + assert (full == *f); + } + + // empty + // + empty.ns.insert (12); + empty.ss.insert ("aa"); + empty.cms.insert (comp (12, "aa")); + + empty.nsm[12] = "aa"; + empty.snm["aa"] = 12; + empty.ncm[12] = comp (12, "aa"); + empty.csmm.insert ( + comp_str_multimap::value_type (comp (12, "aa"), "aa")); + + // med + // + med.ns.clear (); + med.ss.clear (); + med.cms.clear (); + + med.nsm.clear (); + med.snm.clear (); + med.ncm.clear (); + med.csmm.clear (); + + // full + // + full.ns.insert (4567); + full.ss.insert ("ddddddd"); + full.cms.insert (comp (4567, "ddddddd")); + + full.nsm[3456] += 'c'; + full.nsm[4567] = "ddddddd"; + full.snm["cccccc"]++; + full.snm["ddddddd"] = 4567; + full.ncm[3456].num++; + full.ncm[3456].str += 'c'; + full.ncm[4567] = comp (4567, "ddddddd"); + full.csmm.find (comp (3456, "cccccc"))->second += "c"; + full.csmm.insert ( + comp_str_multimap::value_type (comp (4567, "ddddddd"), "ddddddd")); + + // update + // + { + transaction t (db->begin ()); + db->update (empty); + db->update (med); + db->update (full); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + auto_ptr e (db->load ("empty")); + auto_ptr m (db->load ("medium")); + auto_ptr f (db->load ("full")); + t.commit (); + + assert (empty == *e); + assert (med == *m); + assert (full == *f); + } + + // erase + // + if (i == 0) + { + transaction t (db->begin ()); + db->erase ("empty"); + db->erase ("medium"); + db->erase ("full"); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/boost/common/unordered/test.hxx b/odb-tests/boost/common/unordered/test.hxx new file mode 100644 index 0000000..cd77845 --- /dev/null +++ b/odb-tests/boost/common/unordered/test.hxx @@ -0,0 +1,113 @@ +// file : boost/common/unordered/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include +#include + +#include + +#pragma db value +struct comp +{ + comp () {} + comp (int n, const std::string& s) : num (n), str (s) {} + + #pragma db column("number") + int num; + std::string str; +}; + +inline bool +operator== (const comp& x, const comp& y) +{ + return x.num == y.num && x.str == y.str; +} + +inline bool +operator!= (const comp& x, const comp& y) +{ + return !(x == y); +} + +inline bool +operator< (const comp& x, const comp& y) +{ + return x.num != y.num ? x.num < y.num : x.str < y.str; +} + +inline std::size_t +hash_value (const comp& x) +{ + std::size_t seed = 0; + boost::hash_combine (seed, x.num); + boost::hash_combine (seed, x.str); + return seed; +} + +using boost::unordered_set; +using boost::unordered_multiset; + +typedef unordered_set num_set; +typedef unordered_set str_set; +typedef unordered_multiset comp_multiset; + +using boost::unordered_map; +using boost::unordered_multimap; + +typedef unordered_map num_str_map; +typedef unordered_map str_num_map; +typedef unordered_map num_comp_map; +typedef unordered_multimap comp_str_multimap; + +#pragma db object +struct object +{ + object () + { + } + + object (const std::string& id) + : id (id) + { + } + + + #pragma db id + std::string id; + + // set + // + num_set ns; + str_set ss; + comp_multiset cms; + + // map + // + num_str_map nsm; + str_num_map snm; + num_comp_map ncm; + comp_str_multimap csmm; +}; + +inline bool +operator== (const object& x, const object& y) +{ + return + x.id == y.id && + + x.ns == y.ns && + x.ss == y.ss && + x.cms == y.cms && + + x.nsm == y.nsm && + x.snm == y.snm && + x.ncm == y.ncm && + x.csmm == y.csmm; +} + +#endif // TEST_HXX diff --git a/odb-tests/boost/common/uuid/driver.cxx b/odb-tests/boost/common/uuid/driver.cxx new file mode 100644 index 0000000..aed3390 --- /dev/null +++ b/odb-tests/boost/common/uuid/driver.cxx @@ -0,0 +1,69 @@ +// file : boost/common/uuid/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Boost UUID persistence. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace boost::uuids; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + object o (1); + o.uuid_ = random_generator() (); + o.null_ = nil_uuid (); + o.zero_ = nil_uuid (); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (o.id_)); + t.commit (); + + assert (*p == o); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::uuid == o.uuid_)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->id_ == o.id_); + assert (++i == r.end ()); + t.commit (); + } + + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/boost/common/uuid/test.hxx b/odb-tests/boost/common/uuid/test.hxx new file mode 100644 index 0000000..82ed95b --- /dev/null +++ b/odb-tests/boost/common/uuid/test.hxx @@ -0,0 +1,37 @@ +// file : boost/common/uuid/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object +struct object +{ + object () {} + object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + typedef boost::uuids::uuid uuid; + + uuid uuid_; + uuid null_; + + #pragma db not_null + uuid zero_; + + bool operator== (const object& x) const + { + return id_ == x.id_ && + uuid_ == x.uuid_ && + null_ == x.null_ && + zero_ == x.zero_; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/mssql/date-time/driver.cxx b/odb-tests/boost/mssql/date-time/driver.cxx new file mode 100644 index 0000000..e97a276 --- /dev/null +++ b/odb-tests/boost/mssql/date-time/driver.cxx @@ -0,0 +1,158 @@ +// file : boost/mssql/date-time/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test boost date/time type persistence. SQL Server version. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; + +using namespace boost::gregorian; +using namespace boost::posix_time; + +using namespace odb::core; + +bool +test_invalid_special_value (object&, auto_ptr&); + +bool +test_out_of_range_value (object&, auto_ptr&); + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + object o; + + // Test all valid date-time mappings. + // +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + o.dates.push_back (day_clock::local_day ()); + o.dates.push_back (date (not_a_date_time)); + o.dates.push_back (date (max_date_time)); + o.dates.push_back (date (min_date_time)); + + o.times.push_back (second_clock::local_time ()); + o.times.push_back (not_a_date_time); + o.times.push_back (min_date_time); + o.times.push_back (ptime (max_date_time)); +#endif + + // In DATETIME fractional seconds are rounded to .000, .003, or .007. + // + o.times_dt.push_back (ptime (date (2012, 1, 13), + time_duration (11, 57, 13, 7000))); + + // SMALLDATETIME doesn't have seconds (always 0). + // + o.times_sdt.push_back (ptime (date (2012, 1, 13), + time_duration (11, 57, 0, 0))); + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + o.durations.push_back (time_duration (1, 2, 3, 123456)); + o.durations.push_back (not_a_date_time); +#endif + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (*ol == o); + } + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + // Test invalid date mappings. + // + { + object sv1, sv2; + sv1.dates.push_back (date (neg_infin)); + sv2.dates.push_back (date (pos_infin)); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + // Test invalid ptime mappings. + // + { + object sv1, sv2; + sv1.times.push_back (neg_infin); + sv2.times.push_back (pos_infin); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + // Test invalid time_duration mappings. + // + { + object sv1, sv2, or1; + sv1.durations.push_back (pos_infin); + sv2.durations.push_back (neg_infin); + or1.durations.push_back (time_duration (50, 2, 3, 123456700)); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + + try + { + db->persist (or1); + assert (false); + } + catch (const odb::boost::date_time::value_out_of_range&) + { + } + + t.commit (); + } +#endif + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} + +bool +test_invalid_special_value (object& x, auto_ptr& db) +{ + try + { + db->persist (x); + return false; + } + catch (const odb::boost::date_time::special_value&) + { + } + + return true; +} diff --git a/odb-tests/boost/mssql/date-time/test.hxx b/odb-tests/boost/mssql/date-time/test.hxx new file mode 100644 index 0000000..ed2276b --- /dev/null +++ b/odb-tests/boost/mssql/date-time/test.hxx @@ -0,0 +1,58 @@ +// file : boost/mssql/date-time/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include +#include + +#include + +#pragma db object +struct object +{ + object () + { + } + + #pragma db id auto + unsigned long id; + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + std::vector dates; + + std::vector times; +#endif + + #pragma db value_type("DATETIME") + std::vector times_dt; + + #pragma db value_type("SMALLDATETIME") + std::vector times_sdt; + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + std::vector durations; +#endif + + bool + operator== (const object& x) const + { + return + id == x.id +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + && dates == x.dates + && times == x.times +#endif + && times_dt == x.times_dt + && times_sdt == x.times_sdt +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + && durations == x.durations +#endif + ; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/mssql/template/driver.cxx b/odb-tests/boost/mssql/template/driver.cxx new file mode 100644 index 0000000..37614c4 --- /dev/null +++ b/odb-tests/boost/mssql/template/driver.cxx @@ -0,0 +1,39 @@ +// file : boost/mssql/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/boost/mssql/template/template-vc10.vcxproj b/odb-tests/boost/mssql/template/template-vc10.vcxproj new file mode 100644 index 0000000..dcb625e --- /dev/null +++ b/odb-tests/boost/mssql/template/template-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/mssql/template/template-vc10.vcxproj.filters b/odb-tests/boost/mssql/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/mssql/template/template-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/mssql/template/template-vc11.vcxproj b/odb-tests/boost/mssql/template/template-vc11.vcxproj new file mode 100644 index 0000000..d5951f1 --- /dev/null +++ b/odb-tests/boost/mssql/template/template-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/mssql/template/template-vc11.vcxproj.filters b/odb-tests/boost/mssql/template/template-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/mssql/template/template-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/mssql/template/template-vc12.vcxproj b/odb-tests/boost/mssql/template/template-vc12.vcxproj new file mode 100644 index 0000000..e0cb56f --- /dev/null +++ b/odb-tests/boost/mssql/template/template-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/mssql/template/template-vc12.vcxproj.filters b/odb-tests/boost/mssql/template/template-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/mssql/template/template-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/mssql/template/template-vc8.vcproj b/odb-tests/boost/mssql/template/template-vc8.vcproj new file mode 100644 index 0000000..6d1c40b --- /dev/null +++ b/odb-tests/boost/mssql/template/template-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/mssql/template/template-vc9.vcproj b/odb-tests/boost/mssql/template/template-vc9.vcproj new file mode 100644 index 0000000..422fbd7 --- /dev/null +++ b/odb-tests/boost/mssql/template/template-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/mssql/template/test.hxx b/odb-tests/boost/mssql/template/test.hxx new file mode 100644 index 0000000..753498f --- /dev/null +++ b/odb-tests/boost/mssql/template/test.hxx @@ -0,0 +1,25 @@ +// file : boost/mssql/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/mysql/date-time/driver.cxx b/odb-tests/boost/mysql/date-time/driver.cxx new file mode 100644 index 0000000..8959f0c --- /dev/null +++ b/odb-tests/boost/mysql/date-time/driver.cxx @@ -0,0 +1,218 @@ +// file : boost/mysql/date-time/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test boost date/time type persistence. MySQL version. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; + +using namespace boost::gregorian; +using namespace boost::posix_time; + +using namespace odb::core; + +bool +test_invalid_special_value (object&, auto_ptr&); + +bool +test_out_of_range_value (object&, auto_ptr&); + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + mysql_version v; + { + transaction t (db->begin ()); + db->query ().begin ().load (v); + t.commit (); + } + + // If we are running against MySQL 5.6.4 or later alter the tables + // to allow sub-second precision. + // + bool fs (v.major > 5 || + (v.major == 5 && (v.minor > 6 || + (v.minor == 6 && v.release >= 4)))); + if (fs) + { + transaction t (db->begin ()); + + db->execute ("ALTER TABLE `boost_mysql_dt_object_durations`" \ + " MODIFY COLUMN `value` TIME(6)"); + + db->execute ("ALTER TABLE `boost_mysql_dt_object_times`" \ + " MODIFY COLUMN `value` DATETIME(6)"); + + db->execute ("ALTER TABLE `boost_mysql_dt_object_timestamps`" \ + " MODIFY COLUMN `value` TIMESTAMP(6) NULL"); + + t.commit (); + } + + object o; + + // Test all valid date-time mappings. + // + o.dates.push_back (day_clock::local_day ()); + o.dates.push_back (date (not_a_date_time)); + o.dates.push_back (date (max_date_time)); + o.dates.push_back (date (min_date_time)); + + if (fs) + o.times.push_back (microsec_clock::local_time ()); + else + o.times.push_back (second_clock::local_time ()); + o.times.push_back (not_a_date_time); + o.times.push_back (min_date_time); + + // MySQL prior to 5.6.4 does not support fraction seconds. Construct + // with zero fractional seconds so that comparison test does not fail + // for invalid reasons. + // + o.times.push_back ( + ptime ( + date (max_date_time), + time_duration ( + ptime (max_date_time).time_of_day ().hours (), + ptime (max_date_time).time_of_day ().minutes (), + ptime (max_date_time).time_of_day ().seconds ()))); + + if (fs) + o.timestamps.push_back (microsec_clock::local_time ()); + else + o.timestamps.push_back (second_clock::local_time ()); + o.timestamps.push_back (not_a_date_time); + + o.durations.push_back (time_duration (1, 2, 3)); + if (fs) + o.durations.back () += time_duration (microseconds (123456)); + o.durations.push_back (time_duration (-1, 2, 3)); + o.durations.push_back (not_a_date_time); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (*ol == o); + } + + { + // Test invalid date mappings. + // + object sv1, sv2; + sv1.dates.push_back (date (neg_infin)); + sv2.dates.push_back (date (pos_infin)); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + + { + // Test invalid ptime (DATETIME) mappings. + // + object sv1, sv2; + sv1.times.push_back (neg_infin); + sv2.times.push_back (pos_infin); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + { + // Test invalid ptime (TIMESTAMP) mappings. + // + object or1, or2, sv1, sv2; + or1.timestamps.push_back (min_date_time); + or2.timestamps.push_back (max_date_time); + sv1.timestamps.push_back (neg_infin); + sv2.timestamps.push_back (pos_infin); + + transaction t (db->begin ()); + assert (test_out_of_range_value (or1, db)); + assert (test_out_of_range_value (or2, db)); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + { + // Test invalid time_duration mappings. + // + object or1, or2, sv1, sv2; + or1.durations.push_back (time_duration (850, 0, 0)); + or2.durations.push_back (time_duration (-850, 0, 0)); + sv1.durations.push_back (pos_infin); + sv2.durations.push_back (neg_infin); + + transaction t (db->begin ()); + assert (test_out_of_range_value (or1, db)); + assert (test_out_of_range_value (or2, db)); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} + +bool +test_invalid_special_value (object& x, auto_ptr& db) +{ + try + { + db->persist (x); + return false; + } + catch (const odb::boost::date_time::special_value&) + { + } + + return true; +} + +bool +test_out_of_range_value (object& x, auto_ptr& db) +{ + try + { + db->persist (x); + return false; + } + catch (const odb::boost::date_time::value_out_of_range&) + { + } + + return true; +} diff --git a/odb-tests/boost/mysql/date-time/test.hxx b/odb-tests/boost/mysql/date-time/test.hxx new file mode 100644 index 0000000..bf73b09 --- /dev/null +++ b/odb-tests/boost/mysql/date-time/test.hxx @@ -0,0 +1,65 @@ +// file : boost/mysql/date-time/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include +#include + +#include + +#pragma db object +struct object +{ + object () + { + } + + bool + operator== (const object& x) const + { + return + id == x.id && + dates == x.dates && + times == x.times && + timestamps == x.timestamps && + durations == x.durations; + } + + #pragma db id auto + unsigned long id; + + std::vector dates; + std::vector times; + + // Make timestamp NULL-able to suppress the auto-initialization and + // auto-update characteristics of the TIMESTAMP datatype, and to + // allow NULL values. + // + #pragma db value_type ("TIMESTAMP") value_null + std::vector timestamps; + + std::vector durations; +}; + +// MySQL server version view. +// +#pragma db view query( \ + "SELECT " \ + "CAST(SUBSTRING_INDEX(@@version, '.', 1) AS UNSIGNED)," \ + "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '.', 2), '.', -1) AS UNSIGNED)," \ + "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '-', 1), '.', -1) AS UNSIGNED)," \ + "@@protocol_version") +struct mysql_version +{ + unsigned int major; + unsigned int minor; + unsigned int release; + + unsigned int protocol; +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/mysql/template/driver.cxx b/odb-tests/boost/mysql/template/driver.cxx new file mode 100644 index 0000000..1164950 --- /dev/null +++ b/odb-tests/boost/mysql/template/driver.cxx @@ -0,0 +1,39 @@ +// file : boost/mysql/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/boost/mysql/template/template-vc10.vcxproj b/odb-tests/boost/mysql/template/template-vc10.vcxproj new file mode 100644 index 0000000..3137abc --- /dev/null +++ b/odb-tests/boost/mysql/template/template-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/mysql/template/template-vc10.vcxproj.filters b/odb-tests/boost/mysql/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/mysql/template/template-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/mysql/template/template-vc11.vcxproj b/odb-tests/boost/mysql/template/template-vc11.vcxproj new file mode 100644 index 0000000..bc4b5a4 --- /dev/null +++ b/odb-tests/boost/mysql/template/template-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/mysql/template/template-vc11.vcxproj.filters b/odb-tests/boost/mysql/template/template-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/mysql/template/template-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/mysql/template/template-vc12.vcxproj b/odb-tests/boost/mysql/template/template-vc12.vcxproj new file mode 100644 index 0000000..e7d70bc --- /dev/null +++ b/odb-tests/boost/mysql/template/template-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/mysql/template/template-vc12.vcxproj.filters b/odb-tests/boost/mysql/template/template-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/mysql/template/template-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/mysql/template/template-vc8.vcproj b/odb-tests/boost/mysql/template/template-vc8.vcproj new file mode 100644 index 0000000..2ef0383 --- /dev/null +++ b/odb-tests/boost/mysql/template/template-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/mysql/template/template-vc9.vcproj b/odb-tests/boost/mysql/template/template-vc9.vcproj new file mode 100644 index 0000000..b60c7e2 --- /dev/null +++ b/odb-tests/boost/mysql/template/template-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/mysql/template/test.hxx b/odb-tests/boost/mysql/template/test.hxx new file mode 100644 index 0000000..7c97ca2 --- /dev/null +++ b/odb-tests/boost/mysql/template/test.hxx @@ -0,0 +1,25 @@ +// file : boost/mysql/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/oracle/date-time/driver.cxx b/odb-tests/boost/oracle/date-time/driver.cxx new file mode 100644 index 0000000..82294c7 --- /dev/null +++ b/odb-tests/boost/oracle/date-time/driver.cxx @@ -0,0 +1,136 @@ +// file : boost/oracle/date-time/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test boost date/time type persistence. Oracle version. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; + +using namespace boost::gregorian; +using namespace boost::posix_time; + +using namespace odb::core; + +bool +test_invalid_special_value (object&, auto_ptr&); + +bool +test_out_of_range_value (object&, auto_ptr&); + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + object o; + + // Test all valid date-time mappings. + // + o.dates.push_back (day_clock::local_day ()); + o.dates.push_back (date (not_a_date_time)); + o.dates.push_back (date (max_date_time)); + o.dates.push_back (date (min_date_time)); + + o.times.push_back (second_clock::local_time ()); + o.times.push_back (not_a_date_time); + o.times.push_back (min_date_time); + o.times.push_back (ptime (max_date_time)); + + o.times_d.push_back (ptime (date (2012, 6, 27), + time_duration (14, 17, 05, 0))); + o.times_d.push_back (not_a_date_time); + + o.durations.push_back (time_duration (1, 2, 3, 123456)); + o.durations.push_back (time_duration (-1, 2, 3)); + o.durations.push_back (not_a_date_time); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (*ol == o); + } + + // Test invalid date mappings. + // + { + object sv1, sv2; + sv1.dates.push_back (date (neg_infin)); + sv2.dates.push_back (date (pos_infin)); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + // Test invalid ptime mappings. + // + { + object sv1, sv2; + sv1.times.push_back (neg_infin); + sv2.times.push_back (pos_infin); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + // Test invalid time_duration mappings. + // + { + object sv1, sv2; + sv1.durations.push_back (pos_infin); + sv2.durations.push_back (neg_infin); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} + +bool +test_invalid_special_value (object& x, auto_ptr& db) +{ + try + { + db->persist (x); + return false; + } + catch (const odb::boost::date_time::special_value&) + { + } + + return true; +} diff --git a/odb-tests/boost/oracle/date-time/test.hxx b/odb-tests/boost/oracle/date-time/test.hxx new file mode 100644 index 0000000..5eaab88 --- /dev/null +++ b/odb-tests/boost/oracle/date-time/test.hxx @@ -0,0 +1,42 @@ +// file : boost/oracle/date-time/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include +#include + +#include + +#pragma db object +struct object +{ + object () + { + } + + bool + operator== (const object& x) const + { + return + id == x.id && + dates == x.dates && + times == x.times && + times_d == x.times_d && + durations == x.durations; + } + + #pragma db id auto + unsigned long id; + + std::vector dates; + std::vector times; + #pragma db value_type("DATE") + std::vector times_d; + std::vector durations; +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/oracle/template/driver.cxx b/odb-tests/boost/oracle/template/driver.cxx new file mode 100644 index 0000000..892b58f --- /dev/null +++ b/odb-tests/boost/oracle/template/driver.cxx @@ -0,0 +1,39 @@ +// file : boost/oracle/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/boost/oracle/template/template-vc10.vcxproj b/odb-tests/boost/oracle/template/template-vc10.vcxproj new file mode 100644 index 0000000..0c93020 --- /dev/null +++ b/odb-tests/boost/oracle/template/template-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/oracle/template/template-vc10.vcxproj.filters b/odb-tests/boost/oracle/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/oracle/template/template-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/oracle/template/template-vc11.vcxproj b/odb-tests/boost/oracle/template/template-vc11.vcxproj new file mode 100644 index 0000000..4df5f5b --- /dev/null +++ b/odb-tests/boost/oracle/template/template-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/oracle/template/template-vc11.vcxproj.filters b/odb-tests/boost/oracle/template/template-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/oracle/template/template-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/oracle/template/template-vc12.vcxproj b/odb-tests/boost/oracle/template/template-vc12.vcxproj new file mode 100644 index 0000000..0b942bc --- /dev/null +++ b/odb-tests/boost/oracle/template/template-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/oracle/template/template-vc12.vcxproj.filters b/odb-tests/boost/oracle/template/template-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/oracle/template/template-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/oracle/template/template-vc8.vcproj b/odb-tests/boost/oracle/template/template-vc8.vcproj new file mode 100644 index 0000000..c13f330 --- /dev/null +++ b/odb-tests/boost/oracle/template/template-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/oracle/template/template-vc9.vcproj b/odb-tests/boost/oracle/template/template-vc9.vcproj new file mode 100644 index 0000000..a3061ee --- /dev/null +++ b/odb-tests/boost/oracle/template/template-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/oracle/template/test.hxx b/odb-tests/boost/oracle/template/test.hxx new file mode 100644 index 0000000..141b6cd --- /dev/null +++ b/odb-tests/boost/oracle/template/test.hxx @@ -0,0 +1,25 @@ +// file : boost/oracle/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/pgsql/date-time/driver.cxx b/odb-tests/boost/pgsql/date-time/driver.cxx new file mode 100644 index 0000000..94fcc46 --- /dev/null +++ b/odb-tests/boost/pgsql/date-time/driver.cxx @@ -0,0 +1,157 @@ +// file : boost/pgsql/date-time/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test boost date/time type persistence. PostgreSQL version. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; + +using namespace boost::gregorian; +using namespace boost::posix_time; + +using namespace odb::core; + +bool +test_invalid_special_value (object&, auto_ptr&); + +bool +test_out_of_range_value (object&, auto_ptr&); + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + object o; + + // Test all valid date-time mappings. + // + o.dates.push_back (day_clock::local_day ()); + o.dates.push_back (date (not_a_date_time)); + o.dates.push_back (date (max_date_time)); + o.dates.push_back (date (min_date_time)); + + o.times.push_back (microsec_clock::local_time ()); + o.times.push_back (not_a_date_time); + o.times.push_back (pos_infin); + o.times.push_back (neg_infin); + o.times.push_back (ptime (date (max_date_time), + time_duration (16, 23, 0, 123456))); + o.times.push_back (ptime (date (min_date_time), + time_duration (3, 14, 7, 123456))); + o.times.push_back (ptime (date (1969, 12, 31), // Before PG epoch. + time_duration (23, 59, 59, 123000))); + + o.durations.push_back (time_duration (0, 0, 0)); + o.durations.push_back (time_duration (12, 3, 4, 123456)); + o.durations.push_back (time_duration (23, 59, 59, 123456)); + o.durations.push_back (not_a_date_time); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (*ol == o); + } + + { + // Test invalid date mappings. + // + object sv1, sv2; + sv1.dates.push_back (date (neg_infin)); + sv2.dates.push_back (date (pos_infin)); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + { + // Test invalid ptime mappings. + // + // object sv1, sv2; + // sv1.times.push_back (neg_infin); + // sv2.times.push_back (pos_infin); + + // transaction t (db->begin ()); + // assert (test_invalid_special_value (sv1, db)); + // assert (test_invalid_special_value (sv2, db)); + // t.commit (); + } + + { + // Test invalid time_duration mappings. + // + // object or1, sv1, sv2; + // or1.durations.push_back (time_duration (0, 0, -1)); + // sv1.durations.push_back (pos_infin); + // sv2.durations.push_back (neg_infin); + + // transaction t (db->begin ()); + // assert (test_out_of_range_value (or1, db)); + // assert (test_invalid_special_value (sv1, db)); + // assert (test_invalid_special_value (sv2, db)); + // t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} + +bool +test_invalid_special_value (object& x, auto_ptr& db) +{ + try + { + db->persist (x); + return false; + } + catch (const odb::boost::date_time::special_value&) + { + } + + return true; +} + +bool +test_out_of_range_value (object& x, auto_ptr& db) +{ + try + { + db->persist (x); + return false; + } + catch (const odb::boost::date_time::value_out_of_range&) + { + } + + return true; +} diff --git a/odb-tests/boost/pgsql/date-time/test.hxx b/odb-tests/boost/pgsql/date-time/test.hxx new file mode 100644 index 0000000..0b08093 --- /dev/null +++ b/odb-tests/boost/pgsql/date-time/test.hxx @@ -0,0 +1,39 @@ +// file : boost/pgsql/date-time/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include +#include + +#include + +#pragma db object +struct object +{ + object () + { + } + + bool + operator== (const object& x) const + { + return + id == x.id && + dates == x.dates && + times == x.times && + durations == x.durations; + } + + #pragma db id auto + unsigned long id; + + std::vector dates; + std::vector times; + std::vector durations; +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/pgsql/template/driver.cxx b/odb-tests/boost/pgsql/template/driver.cxx new file mode 100644 index 0000000..ed2d8a4 --- /dev/null +++ b/odb-tests/boost/pgsql/template/driver.cxx @@ -0,0 +1,39 @@ +// file : boost/pgsql/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/boost/pgsql/template/template-vc10.vcxproj b/odb-tests/boost/pgsql/template/template-vc10.vcxproj new file mode 100644 index 0000000..7bc0243 --- /dev/null +++ b/odb-tests/boost/pgsql/template/template-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/pgsql/template/template-vc10.vcxproj.filters b/odb-tests/boost/pgsql/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/pgsql/template/template-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/pgsql/template/template-vc11.vcxproj b/odb-tests/boost/pgsql/template/template-vc11.vcxproj new file mode 100644 index 0000000..9f8d2f0 --- /dev/null +++ b/odb-tests/boost/pgsql/template/template-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/pgsql/template/template-vc11.vcxproj.filters b/odb-tests/boost/pgsql/template/template-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/pgsql/template/template-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/pgsql/template/template-vc12.vcxproj b/odb-tests/boost/pgsql/template/template-vc12.vcxproj new file mode 100644 index 0000000..acbfc37 --- /dev/null +++ b/odb-tests/boost/pgsql/template/template-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/pgsql/template/template-vc12.vcxproj.filters b/odb-tests/boost/pgsql/template/template-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/pgsql/template/template-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/pgsql/template/template-vc8.vcproj b/odb-tests/boost/pgsql/template/template-vc8.vcproj new file mode 100644 index 0000000..65773c9 --- /dev/null +++ b/odb-tests/boost/pgsql/template/template-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/pgsql/template/template-vc9.vcproj b/odb-tests/boost/pgsql/template/template-vc9.vcproj new file mode 100644 index 0000000..db49496 --- /dev/null +++ b/odb-tests/boost/pgsql/template/template-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/pgsql/template/test.hxx b/odb-tests/boost/pgsql/template/test.hxx new file mode 100644 index 0000000..56eda31 --- /dev/null +++ b/odb-tests/boost/pgsql/template/test.hxx @@ -0,0 +1,25 @@ +// file : boost/pgsql/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/sqlite/date-time/driver.cxx b/odb-tests/boost/sqlite/date-time/driver.cxx new file mode 100644 index 0000000..97a7a0c --- /dev/null +++ b/odb-tests/boost/sqlite/date-time/driver.cxx @@ -0,0 +1,208 @@ +// file : boost/sqlite/date-time/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test boost date/time type persistence. SQLite version. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; + +using namespace boost::gregorian; +using namespace boost::posix_time; + +using namespace odb::core; + +bool +test_invalid_special_value (object&, auto_ptr&); + +bool +test_out_of_range_value (object&, auto_ptr&); + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + object o; + + // Test all valid date-time mappings. + // + o.dates.push_back (day_clock::local_day ()); + o.dates.push_back (date (not_a_date_time)); + o.dates.push_back (date (max_date_time)); + o.dates.push_back (date (min_date_time)); + + o.times.push_back (second_clock::local_time ()); + o.times.push_back (not_a_date_time); + o.times.push_back (min_date_time); + o.times.push_back (max_date_time); + + o.durations.push_back (time_duration (123, 4, 5)); + o.durations.push_back (not_a_date_time); + + o.u_dates.push_back (day_clock::local_day ()); + o.u_dates.push_back (date (not_a_date_time)); + + // Boost seems to handle 64 bit std::time_t incorrectly. + // Insert 32 bit minimum and maximum UNIX time values for now. + // + // o.u_dates.push_back (date (max_date_time)); + // o.u_dates.push_back (date (min_date_time)); + // + o.u_dates.push_back (date (2038, 1, 19)); + o.u_dates.push_back (date (1901, 12, 14)); + + o.u_times.push_back (second_clock::local_time ()); + o.u_times.push_back (not_a_date_time); + o.u_times.push_back (ptime (date (1930, 1, 1), time_duration (0, 0, 0))); + + o.s_durations.push_back (time_duration (123, 4, 5)); + o.s_durations.push_back (time_duration (-12, 3, 4)); + o.s_durations.push_back (not_a_date_time); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (*ol == o); + } + + { + // Test invalid date mappings. + // + object sv1, sv2; + sv1.dates.push_back (date (neg_infin)); + sv2.dates.push_back (date (pos_infin)); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + { + // Test invalid ptime mappings. + // + object sv1, sv2; + sv1.times.push_back (neg_infin); + sv2.times.push_back (pos_infin); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + { + // Test invalid time_duration mappings. + // + object or1, sv1, sv2; + or1.durations.push_back (time_duration (0, 0, -1)); + sv1.durations.push_back (pos_infin); + sv2.durations.push_back (neg_infin); + + transaction t (db->begin ()); + assert (test_out_of_range_value (or1, db)); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + { + // Test invalid UNIX date mappings. + // + object sv1, sv2; + sv1.u_dates.push_back (date (neg_infin)); + sv2.u_dates.push_back (date (pos_infin)); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + // Test invalid UNIX times mappings. + // + { + object sv1, sv2; + sv1.u_times.push_back (pos_infin); + sv2.u_times.push_back (neg_infin); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + + // Test invalid "seconds" duration mappings. + // + { + object sv1, sv2; + sv1.s_durations.push_back (pos_infin); + sv2.s_durations.push_back (neg_infin); + + transaction t (db->begin ()); + assert (test_invalid_special_value (sv1, db)); + assert (test_invalid_special_value (sv2, db)); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} + +bool +test_invalid_special_value (object& x, auto_ptr& db) +{ + try + { + db->persist (x); + return false; + } + catch (const odb::boost::date_time::special_value&) + { + } + + return true; +} + +bool +test_out_of_range_value (object& x, auto_ptr& db) +{ + try + { + db->persist (x); + return false; + } + catch (const odb::boost::date_time::value_out_of_range&) + { + } + + return true; +} diff --git a/odb-tests/boost/sqlite/date-time/test.hxx b/odb-tests/boost/sqlite/date-time/test.hxx new file mode 100644 index 0000000..924ce27 --- /dev/null +++ b/odb-tests/boost/sqlite/date-time/test.hxx @@ -0,0 +1,57 @@ +// file : boost/sqlite/date-time/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include +#include + +#include + +#pragma db object +struct object +{ + object () + { + } + + bool + operator== (const object& x) const + { + return + id == x.id && + dates == x.dates && + times == x.times && + durations == x.durations && + u_dates == x.u_dates && + u_times == x.u_times && + s_durations == x.s_durations; + } + + #pragma db id auto + unsigned long id; + + std::vector dates; + std::vector times; + std::vector durations; + + // Dates as UNIX time. + // + #pragma db value_type("INTEGER") + std::vector u_dates; + + // Times as UNIX time. + // + #pragma db value_type("INTEGER") + std::vector u_times; + + // Durations as seconds. + // + #pragma db value_type("INTEGER") + std::vector s_durations; +}; + +#endif // TEST_HXX diff --git a/odb-tests/boost/sqlite/template/driver.cxx b/odb-tests/boost/sqlite/template/driver.cxx new file mode 100644 index 0000000..3e51eef --- /dev/null +++ b/odb-tests/boost/sqlite/template/driver.cxx @@ -0,0 +1,39 @@ +// file : boost/sqlite/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/boost/sqlite/template/template-vc10.vcxproj b/odb-tests/boost/sqlite/template/template-vc10.vcxproj new file mode 100644 index 0000000..f94df08 --- /dev/null +++ b/odb-tests/boost/sqlite/template/template-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/sqlite/template/template-vc10.vcxproj.filters b/odb-tests/boost/sqlite/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/sqlite/template/template-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/sqlite/template/template-vc11.vcxproj b/odb-tests/boost/sqlite/template/template-vc11.vcxproj new file mode 100644 index 0000000..1c1a279 --- /dev/null +++ b/odb-tests/boost/sqlite/template/template-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/sqlite/template/template-vc11.vcxproj.filters b/odb-tests/boost/sqlite/template/template-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/sqlite/template/template-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/sqlite/template/template-vc12.vcxproj b/odb-tests/boost/sqlite/template/template-vc12.vcxproj new file mode 100644 index 0000000..034b16c --- /dev/null +++ b/odb-tests/boost/sqlite/template/template-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-boost-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;_SCL_SECURE_NO_WARNINGS;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-boost.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/boost/sqlite/template/template-vc12.vcxproj.filters b/odb-tests/boost/sqlite/template/template-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/boost/sqlite/template/template-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/boost/sqlite/template/template-vc8.vcproj b/odb-tests/boost/sqlite/template/template-vc8.vcproj new file mode 100644 index 0000000..df92637 --- /dev/null +++ b/odb-tests/boost/sqlite/template/template-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/sqlite/template/template-vc9.vcproj b/odb-tests/boost/sqlite/template/template-vc9.vcproj new file mode 100644 index 0000000..32fb152 --- /dev/null +++ b/odb-tests/boost/sqlite/template/template-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/boost/sqlite/template/test.hxx b/odb-tests/boost/sqlite/template/test.hxx new file mode 100644 index 0000000..b9daed6 --- /dev/null +++ b/odb-tests/boost/sqlite/template/test.hxx @@ -0,0 +1,25 @@ +// file : boost/sqlite/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/build/.gitignore b/odb-tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/odb-tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/odb-tests/build/bootstrap.build b/odb-tests/build/bootstrap.build new file mode 100644 index 0000000..2fb5824 --- /dev/null +++ b/odb-tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : build/bootstrap.build +# license : GNU GPL v2; see accompanying LICENSE file + +project = odb-tests + +using version +using config +using dist +using test diff --git a/odb-tests/build/export.build b/odb-tests/build/export.build new file mode 100644 index 0000000..3c073d3 --- /dev/null +++ b/odb-tests/build/export.build @@ -0,0 +1,9 @@ +# file : build/export.build +# license : GNU GPL v2; see accompanying LICENSE file + +$out_root/ +{ + include libcommon/ +} + +export $out_root/libcommon/$import.target diff --git a/odb-tests/build/root.build b/odb-tests/build/root.build new file mode 100644 index 0000000..5336399 --- /dev/null +++ b/odb-tests/build/root.build @@ -0,0 +1,270 @@ +# file : build/root.build +# license : GNU GPL v2; see accompanying LICENSE file + +cxx.std = latest + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +# List of the identifiers of the databases to compile and run the tests +# against. The valid identifiers are mysql, sqlite, pgsql, oracle, and mssql. +# +# @@ TODO: change to string_set once available. +# +config [strings] config.odb_tests.database + +assert ($defined(config.odb_tests.database) && \ + $size($config.odb_tests.database) > 0) \ +'at least one database must be configured via config.odb_tests.database variable' + +databases = $config.odb_tests.database + +mysql = false +sqlite = false +pgsql = false +oracle = false +mssql = false + +for db: $databases +{ + switch $db + { + case 'mysql' + mysql = true + + case 'sqlite' + sqlite = true + + case 'pgsql' + pgsql = true + + case 'oracle' + oracle = true + + case 'mssql' + mssql = true + + default + fail "invalid database '$db' specified in config.odb_tests.database value" + } +} + +# If true, then build and run the test drivers in the dynamic multi-database +# mode. +# +config [bool] config.odb_tests.multi_database ?= ($size($databases) > 1) +multi = $config.odb_tests.multi_database + +assert ($multi || $size($databases) == 1) \ +'only one database can be configured if config.odb_tests.multi_database value is false' + +# Database connections. +# + +# PostgreSQL +# +# The database user. Note that the named user must be allowed to connect to +# the database server without specifying credentials. +# +config [string] config.odb_tests.pgsql.user ?= 'odb_test' + +# The database name. Note that it WILL BE MODIFIED by the tests. +# +config [string] config.odb_tests.pgsql.database ?= 'odb_test' + +# The database host. Leaving this variable undefined results in using +# Unix-domain sockets. Machines without Unix-domain sockets will connect to +# localhost. +# +config [string] config.odb_tests.pgsql.host + +# The database port or the socket file name extension for Unix-domain +# connections. +# +config [string] config.odb_tests.pgsql.port + +# If true, then assume that libodb-pgsql supports the bulk operations. +# +# Note: config.odb_tests.pgsql.bulk_default is reflected from manifest. +# +config [bool] config.odb_tests.pgsql.bulk_default ?= false +config [bool] config.odb_tests.pgsql.bulk ?= ($cxx.target.class != 'windows' && \ + $config.odb_tests.pgsql.bulk_default) +pgsql_bulk = $config.odb_tests.pgsql.bulk + +# MySQL +# +# The database user. +# +config [string] config.odb_tests.mysql.user ?= 'odb_test' + +# The database password. +# +config [string] config.odb_tests.mysql.passwd + +# The database name. Note that it WILL BE MODIFIED by the tests. +# +config [string] config.odb_tests.mysql.database ?= 'odb_test' + +# The database host. +# +config [string] config.odb_tests.mysql.host + +# The database port. +# +config [uint64] config.odb_tests.mysql.port + +# The database socket path. +# +config [path] config.odb_tests.mysql.socket + +define sql: file +sql{*}: extension = sql + +define xml: file +xml{*}: extension = xml + +if ($build.mode != 'skeleton') +{ + if ($cxx.target.system == 'win32-msvc') + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + + switch $cxx.class + { + case 'gcc' + { + cxx.coptions += -Wno-unknown-pragmas + } + case 'msvc' + { + cxx.coptions += /wd4068 /wd4251 /wd4275 /wd4800 + } + } + + # @@ BUILD2 Clang issues the following warnings while compile the + # odb-generated headers: + # + # In file included from odb-tests/common/view/olv/test1-odb-sqlite.cxx:10: + # odb-tests/common/view/olv/test1-odb-sqlite.hxx:68:80: warning: instantiation of variable 'odb::query_columns>::id' required here, but no definition is available [-Wundefined-var-template] + # 68 | id (query_columns< ::test1::object1, id_common, typename A::common_traits >::id, + # | ^ + # odb-tests/common/view/olv/test1-odb.hxx:91:21: note: forward declaration of template entity is here + # 91 | static id_type_ id; + # | ^ + # odb-tests/common/view/olv/test1-odb-sqlite.hxx:68:80: note: add an explicit instantiation declaration to suppress this warning if 'odb::query_columns>::id' is explicitly instantiated in another translation unit + # 68 | id (query_columns< ::test1::object1, id_common, typename A::common_traits >::id, + # + # Note: -Wno-undefined-var-template is temporarily added to suppress them. + # + if ($cxx.id.type == 'clang') + cxx.coptions += -Wno-undefined-var-template + + # Import odb that we are testing. + # + import! [metadata] odb = odb%exe{odb} + + # Import the mysql client for creating the database schemas, etc. + # + if $mysql + { + import! mysql_client = mysql%exe{mysql} + testscript{*}: mysql_client = $mysql_client + } + + # Import the psql client for creating the database schemas, etc. + # + if $pgsql + { + import! pgsql_client = psql%exe{psql} + testscript{*}: pgsql_client = $pgsql_client + } + + # Note that we need ((-.+)?) instead of just (-.+)? because we use this + # capture as a back-reference in the pattern. + # + [rule_name=odb_compile] \ + : hxx{~'/\1/'} libue{~'/.+-meta/'} $odb + {{ + pops = $cxx.lib_poptions($<[1]) + depdb hash $pops + + hp = $path($>[0]) + bn = $base($leaf($hp)) + db = $regex.replace($bn, '.+-odb(-(.+))?', '\2') + + if ($db == '') # *-odb.?xx target group? + db = ($multi ? 'common' : $databases[0]) + end + + # If the external SQL schema file will be generated, then add it as a + # dynamic target group member. + # + # @@ BUILD2 Probably we should add support for --generate-dep ODB compiler + # option. Then presumably this will be take care of automatically. + # + # We assume that the '--generate-schema' and '--schema-format' strings + # will never appear as standalone option values. + # + if ($db != 'common' && $regex.find_match($odb_options, '--generate-schema')) + schema_format = ($db == 'sqlite' ? 'embedded' : 'sql') + + for o: $odb_options + if ($o == '--schema-format') + schema_format = [null] # Indicate that the schema format comes next. + elif ($schema_format == [null]) + schema_format = $o + end + end + else + schema_format = '' + end + + t = ($schema_format == 'sql' \ + ? $directory($hp)/$regex.replace($bn, '(.+)-odb(-.+)?', '\1\2').sql \ + : '') + + depdb dyndep --dyn-target --target-what 'generated schema' --format lines \ + -- echo "$t" + + $odb --std c++11 \ + ($multi ? --multi-database dynamic : ) \ + --database $db \ + --output-dir $out_base \ + $odb_options \ + "-I$src_base" \ + $pops \ + $path($<[0]) + }} + + # Every exe{} in this project is by default a test. + # + exe{*}: test = true + + # Specify the test target for cross-testing. + # + test.target = $cxx.target +} + +# The helper targets which can be used as prerequisites of test drivers +# which require either a specific database client or multiple clients for +# all the enabled databases. +# +alias{mysql-client}: $mysql_client: +{ + include = $mysql + clean = false +} + +alias{pgsql-client}: $pgsql_client: +{ + include = $pgsql + clean = false +} + +alias{database-client}: alias{mysql-client pgsql-client} diff --git a/odb-tests/buildfile b/odb-tests/buildfile new file mode 100644 index 0000000..2acd9fc --- /dev/null +++ b/odb-tests/buildfile @@ -0,0 +1,10 @@ +# file : buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +./: libcommon/ common/ doc{README.md} legal{GPLv2 LICENSE} manifest + +./: mysql/: include = ($mysql && !$multi) +./: sqlite/: include = ($sqlite && !$multi) +./: pgsql/: include = ($pgsql && !$multi) + +./: testscript{*}: include = adhoc diff --git a/odb-tests/common/access/buildfile b/odb-tests/common/access/buildfile new file mode 100644 index 0000000..f1264d9 --- /dev/null +++ b/odb-tests/common/access/buildfile @@ -0,0 +1,45 @@ +# file : common/access/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix access_ \ + --generate-schema \ + --accessor-regex '#(.+)#Get\u\1#' \ + --modifier-regex '#(.+)#Set\u\1#' + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +# @@ BUILD2: Eventually we should be able to mark it as test.input once +# this is supported for testscript tests. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/access/driver.cxx b/odb-tests/common/access/driver.cxx new file mode 100644 index 0000000..b40e73c --- /dev/null +++ b/odb-tests/common/access/driver.cxx @@ -0,0 +1,262 @@ +// file : common/access/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test accessor/modifier expressions. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test basic accessor/modifier functionality. + // + { + using namespace test1; + + object o (1, 623, 723); + o.i1 () = 123; + o.i2 (223); + o.i3 () = 323; + o.i4 () = 423; + o.set_i5 (523); + o.s1 ("1bc"); + memcpy (o.b1 (), "123456789012345", 16); + o.b2 ("123456789012345"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id ())); + t.commit (); + + assert (o == *p); + } + } + + // Test composite accessor/modifier functionality. + // + { + using namespace test2; + + object o (1); + + o.v1 () = value (1123, 1234); + o.v2 (value (2123, 2234)); + o.v3_i1 (3123); + o.v3_i2 (3223); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id ())); + t.commit (); + + assert (o == *p); + } + } + + // Test object pointer accessor/modifier functionality. + // + { + using namespace test3; + + object2 o (1); + o.p1 ().reset (new object1 (1)); + o.p2 (object1_ptr (new object1 (2))); + + { + transaction t (db->begin ()); + const object1_ptr& ptr (o.p1 ()); + db->persist (ptr); + db->persist (o.p2 ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id ())); + t.commit (); + + assert (p->p1 ()->id () == o.p1 ()->id () && + p->p2 ()->id () == o.p2 ()->id ()); + } + } + + // Test container accessor/modifier functionality. + // + { + using namespace test4; + + object o (1); + o.c1 ().push_back (1123); + o.c1 ().push_back (1124); + o.c1 ().push_back (1125); + + { + std::vector v; + v.push_back (2123); + v.push_back (2124); + v.push_back (2125); + o.c2 (v); + } + + o.v1 ().c1 ().push_back (1123); + o.v1 ().c1 ().push_back (1124); + o.v1 ().c1 ().push_back (1125); + + { + std::vector v; + v.push_back (2123); + v.push_back (2124); + v.push_back (2125); + o.v1 ().c2 (v); + } + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id ())); + t.commit (); + + assert (o == *p); + } + } + + // Test id accessor/modifier functionality. + // + { + using namespace test5; + + object1 o1; + object2 o2; + object3 o3; + object4 o4; + o4.id (uuid ("\x60\x1D\x17\xF0-\x60\x05-\x47\x23-\x95\x37-" + "\xC1\xF8\x94\x41\x2B\xEC")); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + db->persist (o4); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id ())); + unique_ptr p2 (db->load (o2.id ())); + unique_ptr p3 (db->load (o3.id_)); + unique_ptr p4 (db->load (o4.id ())); + t.commit (); + } + } + + // Test version accessor/modifier functionality. + // + { + using namespace test6; + + object1 o1 (1); + object2 o2; + object3 o3 (1); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + + assert (o1.version () == 1); + assert (o2.version () == 1); + assert (o3.version_ == 1); + } + + { + transaction t (db->begin ()); + db->update (o1); + db->update (o2); + db->update (o3); + t.commit (); + + assert (o1.version () == 2); + assert (o2.version () == 2); + assert (o3.version_ == 2); + } + } + + // Test basic accessor/modifier functionality. + // + { + using namespace test7; + + object o (1); + o.i1 () = 123; + o.set_i2 (223); + o.setI3 (323); + o.seti4 (423); + o.i5 () = 523; + o.i6 () = 623; + o.SetI7 (723); + memcpy (o.b1 (), "123456789012345", 16); + o.b2 ("123456789012345"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id_)); + t.commit (); + + assert (o == *p); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/access/test.hxx b/odb-tests/common/access/test.hxx new file mode 100644 index 0000000..3a3424d --- /dev/null +++ b/odb-tests/common/access/test.hxx @@ -0,0 +1,592 @@ +// file : common/access/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include // std::memcpy, std::memcmp, std::memset +#include // std::unique_ptr +#include // std::move + +#include + +#ifdef ODB_COMPILER +# if defined(ODB_DATABASE_MYSQL) +# define BINARY16_TYPE "BINARY(16)" +# elif defined(ODB_DATABASE_SQLITE) +# define BINARY16_TYPE "BLOB" +# elif defined(ODB_DATABASE_PGSQL) +# define BINARY16_TYPE "BYTEA" +# elif defined(ODB_DATABASE_ORACLE) +# define BINARY16_TYPE "RAW(16)" +# elif defined(ODB_DATABASE_MSSQL) +# define BINARY16_TYPE "BINARY(16)" +# elif defined(ODB_DATABASE_COMMON) +# define BINARY16_TYPE "" +# else +# error unknown database +# endif +#endif + +// Test basic accessor/modifier functionality. +// +#pragma db namespace table("t1_") +namespace test1 +{ + #pragma db object + struct object + { + object (): i6_ (0), i7_ (0) {} + object (unsigned long id, int i6, int i7): id_ (id), i6_ (i6), i7_ (i7) {} + + public: + unsigned long id () const {return id_;} + void id (unsigned long id) {id_ = id;} + private: + #pragma db id access(id) + unsigned long id_; + + public: + int i1 () const {return i1_;} + int& i1 () {return i1_;} + private: + #pragma db access(i1) + int i1_; + + public: + int i2 () const {return i2_;} + void i2 (int i2) {i2_ = i2;} + private: + #pragma db access(i2) + int i2_; + + // Prefer reference modifier. + // + public: + int i3 () const {return i3_;} + int& i3 () {return i3_;} + void i3 (int i3); + private: + #pragma db access(i3) + int i3_; + + // Prefer reference modifier (reverse function order). + // + public: + int i4 () const {return i4_;} + void i4 (int i4); + int& i4 () {return i4_;} + private: + #pragma db access(i4) + int i4_; + + public: + int get_i5 () const {return i5_;} + void set_i5 (int i5) {i5_ = i5;} + private: + #pragma db get(get_i5) set(set_i5) + int i5_; + + // Const member via reference. + // + public: + const int& i6 () const {return i6_;} + private: + #pragma db get(i6) set(const_cast (this.i6 ())) + const int i6_; + + // Const member via modifier. + // + public: + int i7 () const {return i7_;} + void i7 (int i7) const {const_cast (i7_) = i7;} + private: + #pragma db access(i7) + const int i7_; + + public: + const char* s1 () const {return s1_.c_str ();} + void s1 (const char* s1) {s1_ = s1;} + //std::string s1 () const {return s1_;} + //void s1 (std::string s1) {s1_ = s1;} + private: + #pragma db get(s1) set(s1((?).c_str ())) + //#pragma db access(s1) + std::string s1_; + + // Array member via ref. + // + public: + const char* b1 () const {return b1_;} + char* b1 () {return b1_;} + private: + #pragma db type(BINARY16_TYPE) access(b1) + char b1_[16]; + + // Array member via modifier. + // + public: + const char* b2 () const {return b2_;} + void b2 (const char* b2) {std::memcpy (b2_, b2, sizeof (b2_));} + private: + #pragma db type(BINARY16_TYPE) access(b2) + char b2_[16]; + + public: + bool operator== (const object& o) const + { + return id_ == o.id_ && + i1_ == o.i1_ && + i2_ == o.i2_ && + i3_ == o.i3_ && + i4_ == o.i4_ && + i5_ == o.i5_ && + i6_ == o.i6_ && + i7_ == o.i7_ && + s1_ == o.s1_ && + std::memcmp (b1_, o.b1_, sizeof (b1_)) == 0 && + std::memcmp (b2_, o.b2_, sizeof (b2_)) == 0; + } + }; +} + +// Test composite accessor/modifier functionality. +// +#pragma db namespace table("t2_") +namespace test2 +{ + #pragma db value + struct value + { + value () {} + value (int i1, int i2): i1_ (i1), i2_ (i2) {} + + bool operator== (const value& v) const + { + return i1_ == v.i1_ && i2_ == v.i2_; + } + + public: + int i1 () const {return i1_;} + int& i1 () {return i1_;} + private: + #pragma db access(i1) + int i1_; + + public: + int i2 () const {return i2_;} + void i2 (int i2) {i2_ = i2;} + private: + #pragma db access(i2) + int i2_; + }; + + #pragma db object + struct object + { + object () {} + object (unsigned long id): id_ (id) {} + + bool operator== (const object& o) const + { + return id_ == o.id_ && + v1_ == o.v1_ && + v2_ == o.v2_ && + v3_ == o.v3_; + } + + public: + unsigned long id () const {return id_;} + void id (unsigned long id) {id_ = id;} + private: + #pragma db id access(id) + unsigned long id_; + + public: + const value& v1 () const {return v1_;} + value& v1 () {return v1_;} + private: + #pragma db access(v1) + value v1_; + + public: + const value& v2 () const {return v2_;} + void v2 (const value& v2) {v2_ = v2;} + private: + #pragma db access(v2) + value v2_; + + public: + int v3_i1 () const {return v3_.i1 ();} + int v3_i2 () const {return v3_.i2 ();} + void v3_i1 (int i1) {v3_.i1 () = i1;} + void v3_i2 (int i2) {v3_.i2 (i2);} + private: + #pragma db get(test2::value (this.v3_i1 (), this.v3_i2 ())) \ + set(this.v3_i1 ((?).i1 ()); this.v3_i2 ((?).i2 ())) + value v3_; + }; +} + +// Test object pointer accessor/modifier functionality. +// +#pragma db namespace table("t3_") +namespace test3 +{ + struct object1; + + typedef std::unique_ptr object1_ptr; + + #pragma db object pointer(object1_ptr) + struct object1 + { + object1 () {} + object1 (unsigned long id): id_ (id) {} + + public: + unsigned long id () const {return id_;} + void id (unsigned long id) {id_ = id;} + private: + #pragma db id access(id) + unsigned long id_; + }; + + #pragma db object + struct object2 + { + object2 () {} + object2 (unsigned long id): id_ (id) {} + + public: + unsigned long id () const {return id_;} + void id (unsigned long id) {id_ = id;} + private: + #pragma db id access(id) + unsigned long id_; + + public: + const object1_ptr& p1 () const {return p1_;} + object1_ptr& p1 () {return p1_;} + private: + #pragma db access(p1) + object1_ptr p1_; + + public: + const object1_ptr& p2 () const {return p2_;} + + void p2 (object1_ptr p2) {p2_ = std::move (p2);} + + private: + #pragma db get(p2) set(p2 (std::move (?))) + + object1_ptr p2_; + }; +} + +// Test container accessor/modifier functionality. +// +#pragma db namespace table("t4_") +namespace test4 +{ + #pragma db value + struct value + { + value (): c3_ (3, 999) {} + value (int v): c1_ (3, v), c2_ (3, v + 1), c3_ (3, v + 2) {} + + bool operator== (const value& v) const + { + return c1_ == v.c1_ && c2_ == v.c2_ && c3_ == v.c3_; + } + + public: + const std::vector& c1 () const {return c1_;} + std::vector& c1 () {return c1_;} + private: + #pragma db access(c1) + std::vector c1_; + + public: + const std::vector& c2 () const {return c2_;} + void c2 (const std::vector& c2) {c2_ = c2;} + private: + #pragma db access(c2) + std::vector c2_; + + public: + const std::vector c3_; + }; + + #pragma db object + struct object + { + object () {} + object (unsigned long id): id_ (id), c3_ (3, 3123), v2_ (2123) {} + + bool operator== (const object& o) const + { + return id_ == o.id_ && + c1_ == o.c1_ && + c2_ == o.c2_ && + c3_ == o.c3_ && + v1_ == o.v1_ && + v2_ == o.v2_; + } + + public: + unsigned long id () const {return id_;} + void id (unsigned long id) {id_ = id;} + private: + #pragma db id access(id) + unsigned long id_; + + public: + const std::vector& c1 () const {return c1_;} + std::vector& c1 () {return c1_;} + private: + #pragma db access(c1) + std::vector c1_; + + public: + const std::vector& c2 () const {return c2_;} + void c2 (const std::vector& c2) {c2_ = c2;} + private: + #pragma db access(c2) + std::vector c2_; + + public: + const std::vector& c3 () const {return c3_;} + private: + #pragma db get(c3) set(const_cast&> (this.c3 ())) + const std::vector c3_; + + public: + const value& v1 () const {return v1_;} + value& v1 () {return v1_;} + private: + #pragma db access(v1) + value v1_; + + public: + const value v2_; + }; +} + +// Test id accessor/modifier functionality. +// +#pragma db namespace table("t5_") +namespace test5 +{ + #pragma db object + struct object1 + { + object1 (): id_ (0) {} + + public: + unsigned long id () const {return id_;} + void id (unsigned long id) {id_ = id;} + private: + #pragma db id auto access(id) + unsigned long id_; + }; + + #pragma db object + struct object2 + { + object2 (): id_ (0) {} + + public: + unsigned long id () const {return id_;} + unsigned long& id () {return id_;} + private: + #pragma db id auto access(id) + unsigned long id_; + }; + + #pragma db object + struct object3 + { + object3 (): id_ (0) {} + + #pragma db id auto + const unsigned long id_; + }; + + #pragma db value + struct uuid + { + uuid () {std::memset (data_, 0, sizeof (data_));} + explicit uuid (const char* d) {data (d);} + + public: + const char* data () const {return data_;} + void data (const char* d) {std::memcpy (data_, d, sizeof (data_));} + private: + #pragma db type(BINARY16_TYPE) column("") access(data) + char data_[16]; + }; + + #pragma db object + struct object4 + { + public: + const uuid& id () const {return id_;} + void id (const uuid& id) {id_ = id;} + private: + #pragma db id access(id) + uuid id_; + }; +} + +// Test version accessor/modifier functionality. +// +#pragma db namespace table("t6_") +namespace test6 +{ + #pragma db object optimistic + struct object1 + { + object1 (unsigned long id = 0): id_ (id), version_ (0) {} + + #pragma db id + unsigned long id_; + + public: + unsigned long version () const {return version_;} + void version (unsigned long version) {version_ = version;} + private: + #pragma db version access(version) + unsigned long version_; + }; + + #pragma db object optimistic + struct object2 + { + object2 (): version_ (0) {} + + #pragma db id auto + unsigned long id_; + + public: + unsigned long version () const {return version_;} + unsigned long& version () {return version_;} + private: + #pragma db version access(version) + unsigned long version_; + }; + + #pragma db object optimistic + struct object3 + { + object3 (unsigned long id = 0): id_ (id), version_ (0) {} + + #pragma db id + unsigned long id_; + + #pragma db version + const unsigned long version_; + }; +} + +// Test automatic discovery of accessor/modifier functions. +// +#pragma db namespace table("t7_") +namespace test7 +{ + #pragma db object + struct object + { + object () {} + object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + public: + int i1 () const {return i1_;} + int& i1 () {return i1_;} + private: + int i1_; + + public: + const int& get_i2 () const {return i2_;} + void set_i2 (int i2) {i2_ = i2;} + private: + int i2_; + + public: + const int& getI3 () const {return i3_;} + void setI3 (const int& i3) {i3_ = i3;} + private: + int i3_; + + public: + int geti4 () const {return i4;} + int seti4 (int v) {int r (i4); i4 = v; return r;} + private: + int i4; + + // Prefer reference modifier. + // + public: + int i5 () const {return i5_;} + int& i5 () {return i5_;} + void i5 (int i5); + private: + int i5_; + + // Prefer reference modifier (reverse function order). + // + public: + int i6 () const {return i6_;} + void i6 (int i6); + int& i6 () {return i6_;} + private: + int i6_; + + // Custom accessor/modifier regex. + // + public: + int GetI7 () const {return i7_;} + void SetI7 (int i7) {i7_ = i7;} + private: + int i7_; + + // Array member via ref. + // + public: + const char* b1 () const {return b1_;} + char* b1 () {return b1_;} + private: + #pragma db type(BINARY16_TYPE) + char b1_[16]; + + // Array member via modifier. + // + public: + const char* b2 () const {return b2_;} + void b2 (const char* b2) {std::memcpy (b2_, b2, sizeof (b2_));} + private: + #pragma db type(BINARY16_TYPE) + char b2_[16]; + + public: + bool operator== (const object& o) const + { + return id_ == o.id_ && + i1_ == o.i1_ && + i2_ == o.i2_ && + i3_ == o.i3_ && + i4 == o.i4 && + i5_ == o.i5_ && + i6_ == o.i6_ && + i7_ == o.i7_ && + std::memcmp (b1_, o.b1_, sizeof (b1_)) == 0 && + std::memcmp (b2_, o.b2_, sizeof (b2_)) == 0; + } + }; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/access/testscript b/odb-tests/common/access/testscript new file mode 100644 index 0000000..04f0ec0 --- /dev/null +++ b/odb-tests/common/access/testscript @@ -0,0 +1,33 @@ +# file : common/access/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/as/buildfile b/odb-tests/common/as/buildfile new file mode 100644 index 0000000..dcdc961 --- /dev/null +++ b/odb-tests/common/as/buildfile @@ -0,0 +1,49 @@ +# file : common/as/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix as_ \ + --generate-schema \ + --generate-query \ + --generate-session + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# @@ BUILD@ Temporarily suppress the following warning: +# +# test-odb.cxx(6234): warning C4244: 'argument': conversion from 'id_type::value_type' to 'test5::version_type::value_type', possible loss of data +# +if ($cxx.class == 'msvc') + cxx.coptions += /wd4244 + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/as/driver.cxx b/odb-tests/common/as/driver.cxx new file mode 100644 index 0000000..578eb23 --- /dev/null +++ b/odb-tests/common/as/driver.cxx @@ -0,0 +1,348 @@ +// file : common/as/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test C++ type mapping (#pragma map type as ...). +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test basic type mapping functionality. + // + { + using namespace test1; + + object o1 (true, green, 123, 234); + o1.m[false] = 123; + o1.v.push_back (o1.ip); + o1.cv.push_back (red); + o1.cv.push_back (green); + + object o2 (false, blue, 234, 456); + o2.m[true] = 234; + o2.v.push_back (o2.ip); + o2.cv.push_back (green); + o2.cv.push_back (blue); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + + o1.b = false; + o1.c = blue; + o1.ip.first++; + o1.ip.second--; + o1.m[false]++; + o1.m[true] = 234; + o1.v.back () = o1.ip; + o1.cv.modify_front () = green; + o1.cv.push_back (red); + + o2.b = true; + o2.c = red; + o2.ip.first--; + o2.ip.second++; + o2.m[true]--; + o2.m[false] = 345; + o2.v.push_back (o2.ip); + o2.cv.pop_back (); + + { + transaction t (db->begin ()); + db->update (o1); + db->update (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + } + + // Test wrapped simple type mapping. + // + { + using namespace test2; + + object o1; + o1.v.push_back (null_bool ()); + o1.v.push_back (false); + + object o2; + o2.b = true; + o2.v.push_back (true); + o2.v.push_back (null_bool ()); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + + o1.b = false; + o1.v[0] = true; + o1.v[1].reset (); + + o2.b.reset (); + o2.v.push_back (false); + + { + transaction t (db->begin ()); + db->update (o1); + db->update (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + } + + // Test wrapped composite type mapping. + // + { + using namespace test3; + + object o1; + o1.ip = intp (0, 0); // NULL + o1.npv.push_back (o1.np); + o1.ipv.push_back (o1.ip); + + object o2; + o2.np = intp (123, 234); + o1.ip = intp (234, 123); + o2.npv.push_back (o2.np); + o2.ipv.push_back (o2.ip); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + + o1.np = o1.npv[0] = intp (234, 456); + o1.ip = o1.ipv.modify_at (0) = intp (456, 234); + + o2.np.reset (); + o2.npv[0].reset (); + o2.ip = o2.ipv.modify_at (0) = intp (0, 0); // NULL + + { + transaction t (db->begin ()); + db->update (o1); + db->update (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + } + + // Test id type mapping. + // + { + using namespace test4; + + object o1 (123); + o1.v.push_back (1); + o1.v.push_back (2); + o1.v.push_back (3); + + object o2 (234); + o2.v.push_back (3); + o2.v.push_back (2); + o2.v.push_back (1); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + + o1.i++; + o1.v.pop_back (); + o1.v.modify_front ()++; + + o2.i--; + o2.v.clear (); + o2.v.push_back (4); + + { + transaction t (db->begin ()); + db->update (o1); + db->update (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + } + + // Test version type mapping. + // + { + using namespace test5; + + object o1 (100, 123); + object o2 (200, 234); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + + assert (*p1 == o1); + assert (*p2 == o2); + + p1->i--; + p2->i++; + + db->update (*p1); + db->update (*p2); + + t.commit (); + } + + { + transaction t (db->begin ()); + + for (;;) + { + o1.i++; + o2.i--; + + try + { + + db->update (o1); + db->update (o2); + break; + } + catch (const odb::object_changed&) + { + db->reload (o1); + db->reload (o2); + } + } + + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/as/test.hxx b/odb-tests/common/as/test.hxx new file mode 100644 index 0000000..963abeb --- /dev/null +++ b/odb-tests/common/as/test.hxx @@ -0,0 +1,270 @@ +// file : common/as/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include +#include // pair + +#include +#include +#include + +// Test basic type mapping functionality. +// +#pragma db namespace table("t1_") +namespace test1 +{ + enum color {red, green, blue}; + + inline const char* + color_to_string (color c) + { + return c == red ? "RED" : (c == green ? "GREEN" : "BLUE"); + } + + inline color + string_to_color (const std::string& s) + { + return s == "RED" ? red : (s == "GREEN" ? green : blue); + } + + #pragma db map type(color) as(std::string) \ + to(test1::color_to_string (?)) \ + from(test1::string_to_color (?)) + + typedef std::pair intp; + + #pragma db value + struct comp + { + comp () {} + comp (int n1_, int n2_): n1 (n1_), n2 (n2_) {} + + int n1; + int n2; + }; + + #pragma db map type(intp) as(comp) \ + to(test1::comp ((?).first, (?).second)) \ + from(test1::intp ((?).n1, (?).n2)) + + #pragma db object + struct object + { + // Class-scope mapping. + // + #pragma db map type(bool) as(std::string) \ + to((?) ? "true" : "false") \ + from((?) == "true") + + #pragma db id auto + unsigned long id; + + bool b; + color c; + intp ip; + + std::map m; + std::vector v; + odb::vector cv; + + object () {} + object (bool b_, color c_, int n1, int n2): b (b_), c (c_), ip (n1, n2) {} + }; + + inline bool + operator== (const object& x, const object y) + { + return + x.b == y.b && + x.c == y.c && + x.ip == y.ip && + x.m == y.m && + x.v == y.v && + x.cv == y.cv; + } +} + +// Test wrapped simple type mapping. +// +#pragma db namespace table("t2_") +namespace test2 +{ + #pragma db map type(bool) as(std::string) \ + to((?) ? "true" : "false") \ + from((?) == "true") + + typedef odb::nullable null_bool; + typedef odb::nullable null_string; + + /* + #pragma db map type(null_bool) as(null_string) \ + to((?) \ + ? test2::null_string (*(?) ? "true" : "false") \ + : test2::null_string ()) \ + from((?) \ + ? test2::null_bool (*(?) == "true") \ + : test2::null_bool ()) + */ + + #pragma db map type(null_bool) as(std::string) \ + to((?) ? (*(?) ? "true" : "false") : "null") \ + from((?) != "null" \ + ? test2::null_bool ((?) == "true") \ + : test2::null_bool ()) + + #pragma db object + struct object + { + #pragma db id auto + unsigned long id; + + odb::nullable b; + std::vector > v; + }; + + inline bool + operator== (const object& x, const object y) + { + return x.b == y.b && x.v == y.v; + } +} + +// Test wrapped simple type mapping. +// +#pragma db namespace table("t3_") +namespace test3 +{ + typedef std::pair intp; + + #pragma db value + struct comp + { + comp () {} + comp (int n1_, int n2_): n1 (n1_), n2 (n2_) {} + + int n1; + int n2; + }; + + typedef odb::nullable null_intp; + typedef odb::nullable null_comp; + + #pragma db map type(null_intp) as(null_comp) \ + to((?) \ + ? test3::null_comp (test3::comp ((?)->first, (?)->second)) \ + : test3::null_comp ()) \ + from((?) \ + ? test3::null_intp (test3::intp ((?)->n1, (?)->n2)) \ + : test3::null_intp ()) + + // Map int pair with both members equal 0 to NULL comp. + // + #pragma db map type(intp) as(null_comp) \ + to((?).first != 0 || (?).second != 0 \ + ? test3::null_comp (test3::comp ((?).first, (?).second)) \ + : test3::null_comp ()) \ + from((?) \ + ? test3::intp (test3::intp ((?)->n1, (?)->n2)) \ + : test3::intp (0, 0)) + + #pragma db object + struct object + { + #pragma db id auto + unsigned long id; + + odb::nullable np; + intp ip; + + std::vector > npv; + odb::vector ipv; + }; + + inline bool + operator== (const object& x, const object y) + { + return x.np == y.np && x.ip == y.ip && x.npv == y.npv && x.ipv == y.ipv; + } +} + +// Test id type mapping. +// +struct id_type +{ + typedef unsigned long value_type; + value_type value; + + id_type (value_type v = 0): value (v) {} + operator value_type () const {return value;} +}; + +#pragma db map type(id_type) as(id_type::value_type) + +#pragma db namespace table("t4_") +namespace test4 +{ + #pragma db object + struct object + { + #pragma db id auto + id_type id; + + int i; + odb::vector v; + + object () {} + object (int i_): i (i_) {} + }; + + inline bool + operator== (const object& x, const object y) + { + return x.id == y.id && x.i == y.i && x.v == y.v; + } +} + +// Test version type mapping. +// +#pragma db namespace table("t5_") +namespace test5 +{ + struct version_type + { + typedef unsigned short value_type; + value_type value; + + version_type (value_type v = 0): value (v) {} + operator value_type () const {return value;} + version_type& operator++ () {value++; return *this;} + }; + + #pragma db map type(version_type) as(id_type::value_type) + + #pragma db object optimistic + struct object + { + #pragma db id + id_type id; + + #pragma db version + version_type v; + + int i; + + object () {} + object (id_type id_, int i_): id (id_), i (i_) {} + }; + + inline bool + operator== (const object& x, const object y) + { + return x.id == y.id && x.v == y.v && x.i == y.i; + } +} + +#endif // TEST_HXX diff --git a/odb-tests/common/as/testscript b/odb-tests/common/as/testscript new file mode 100644 index 0000000..12d9753 --- /dev/null +++ b/odb-tests/common/as/testscript @@ -0,0 +1,33 @@ +# file : common/as/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/blob/buildfile b/odb-tests/common/blob/buildfile new file mode 100644 index 0000000..cc6d164 --- /dev/null +++ b/odb-tests/common/blob/buildfile @@ -0,0 +1,40 @@ +# file : common/blob/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix blob_ \ + --generate-schema + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/blob/driver.cxx b/odb-tests/common/blob/driver.cxx new file mode 100644 index 0000000..269f415 --- /dev/null +++ b/odb-tests/common/blob/driver.cxx @@ -0,0 +1,76 @@ +// file : common/blob/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test BLOB mapping. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + const char data[] = + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" + "cccccccccccccccccccccccccccccccccccccccccccccccc" + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" + "dddddddddddddddddddddddddddddddddddddddddddddddd" + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" + "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" + "ffffffffffffffffffffffffffffffffffffffffffffffff"; + + const unsigned char* udata = reinterpret_cast (data); + + object o (1); + o.vc.assign (data, data + sizeof (data)); + o.vuc.assign (udata, udata + sizeof (data)); + memcpy (o.c, data, sizeof (data)); + memcpy (o.uc, udata, sizeof (data)); + memcpy (o.a.data (), data, sizeof (data)); + memcpy (o.ua.data (), udata, sizeof (data)); + o.cont.push_back (1); + o.cont.push_back (2); + o.cont.push_back (3); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/blob/test.hxx b/odb-tests/common/blob/test.hxx new file mode 100644 index 0000000..9602ca2 --- /dev/null +++ b/odb-tests/common/blob/test.hxx @@ -0,0 +1,71 @@ +// file : common/blob/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include // std::memcmp + +#include + +#ifdef ODB_COMPILER +# if defined(ODB_DATABASE_PGSQL) +# define BLOB_TYPE "BYTEA" +# elif defined(ODB_DATABASE_MSSQL) +//# define BLOB_TYPE "VARBINARY(1024)" +# define BLOB_TYPE "VARBINARY(max)" +# else +//# define BLOB_TYPE "RAW(1024)" +# define BLOB_TYPE "BLOB" +# endif +#endif + +#pragma db object +struct object +{ + object () {} + object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db type(BLOB_TYPE) + std::vector vc; + + #pragma db type(BLOB_TYPE) + std::vector vuc; + + #pragma db type(BLOB_TYPE) + char c[1024]; + + #pragma db type(BLOB_TYPE) + unsigned char uc[1024]; + + #pragma db type(BLOB_TYPE) + std::array a; + + #pragma db type(BLOB_TYPE) + std::array ua; + + // Make sure we can still use std::vector and std::array + // as containers. + // + std::vector cont; +}; + +inline bool +operator== (const object& x, const object& y) +{ + return x.id_ == y.id_ + && x.vc == y.vc + && x.vuc == y.vuc + && std::memcmp (x.c, y.c, sizeof (x.c)) == 0 + && std::memcmp (x.uc, y.uc, sizeof (x.uc)) == 0 + && x.a == y.a + && x.ua == y.ua + && x.cont == y.cont; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/blob/testscript b/odb-tests/common/blob/testscript new file mode 100644 index 0000000..4fb9955 --- /dev/null +++ b/odb-tests/common/blob/testscript @@ -0,0 +1,33 @@ +# file : common/blob/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/buildfile b/odb-tests/common/buildfile new file mode 100644 index 0000000..cb9c748 --- /dev/null +++ b/odb-tests/common/buildfile @@ -0,0 +1,6 @@ +# file : common/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +./: {*/ -bulk/} + +./: bulk/: include = (!$pgsql || $pgsql_bulk || $size($databases) != 1) diff --git a/odb-tests/common/bulk/buildfile b/odb-tests/common/bulk/buildfile new file mode 100644 index 0000000..417eb22 --- /dev/null +++ b/odb-tests/common/bulk/buildfile @@ -0,0 +1,49 @@ +# file : common/bulk/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert (!$pgsql || $pgsql_bulk || $size($databases) != 1) \ +"bulk operations are disabled for pgsql which is specified as single database" + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases +{ + if ($db != 'pgsql' || $pgsql_bulk) + import libs += libodb-$db%lib{odb-$db} +} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: \ + include = ($multi && ($db != 'pgsql' || $pgsql_bulk)) + + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix bulk_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/bulk/driver.cxx b/odb-tests/common/bulk/driver.cxx new file mode 100644 index 0000000..23b49ad --- /dev/null +++ b/odb-tests/common/bulk/driver.cxx @@ -0,0 +1,1203 @@ +// file : common/bulk/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test bulk database operations. +// + +#include // std::unique_ptr +#include +#include +#include + +#include +#include + +#include + +#include // DATABASE_* +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +// Sun CC with non-standard STL does not have iterator_traits in which +// case we assume iterator is just a pointer. +// +template ::value_type +#else + typename T = typename odb::details::meta::remove_pointer::result +#endif + > +struct element_traits; + +template +struct element_traits +{ + typedef T type; + typedef T* pointer; + typedef std::unique_ptr unique_ptr; + + static T& ref (T& x) {return x;} + static T* ptr (T* p) {return p;} +}; + +template +struct element_traits +{ + typedef T type; + typedef T* pointer; + typedef std::unique_ptr unique_ptr; + + static T& ref (T* p) {return *p;} + static T* ptr (T* p) {return p;} +}; + +template +struct element_traits > +{ + typedef T type; + typedef std::unique_ptr pointer; + typedef std::unique_ptr unique_ptr; + + static T& ref (const unique_ptr& p) {return *p;} + static T* ptr (const unique_ptr& p) {return p.get ();} +}; + +template +void +persist (const unique_ptr& db, I b, I e, bool cont = true) +{ + typedef element_traits traits; + typedef typename traits::type type; + typedef typename traits::unique_ptr unique_ptr; + + { + transaction t (db->begin ()); + db->persist (b, e, cont); + t.commit (); + } + + // Verify we can load the objects via their ids. + // + { + transaction t (db->begin ()); + + for (I i (b); i != e; ++i) + { + type& x (traits::ref (*i)); + unique_ptr p (db->load (x.id)); + assert (p->n == x.n && p->s == x.s); + } + + t.commit (); + } +} + +template +void +try_persist (const unique_ptr& db, I b, I e, bool cont = true) +{ + try + { + persist (db, b, e, cont); + assert (false); + } + catch (const multiple_exceptions& e) + { + cout << e.what () << endl << endl; + } +} + +template +void +update (const unique_ptr& db, I b, I e, + bool modify = true, bool cont = true) +{ + typedef element_traits traits; + typedef typename traits::type type; + typedef typename traits::unique_ptr unique_ptr; + + if (modify) + { + for (I i (b); i != e; ++i) + { + type& x (traits::ref (*i)); + x.n++; + x.s[0]++; + } + } + + { + transaction t (db->begin ()); + db->update (b, e, cont); + t.commit (); + } + + // Verify changes. + // + { + transaction t (db->begin ()); + + for (I i (b); i != e; ++i) + { + type& x (traits::ref (*i)); + unique_ptr p (db->load (x.id)); + assert (p->n == x.n && p->s == x.s); + } + + t.commit (); + } +} + +template +void +try_update (const unique_ptr& db, I b, I e, bool cont = true) +{ + try + { + update (db, b, e, false, cont); + assert (false); + } + catch (const multiple_exceptions& e) + { + cout << e.what () << endl << endl; + } +} + +template +void +erase (const unique_ptr& db, I b, I e) +{ + typedef element_traits traits; + typedef typename traits::type type; + + { + transaction t (db->begin ()); + db->erase (b, e); + t.commit (); + } + + // Verify the objects are gone. + // + { + transaction t (db->begin ()); + + for (I i (b); i != e; ++i) + { + type& x (traits::ref (*i)); + typename traits::pointer p (db->find (x.id)); + assert (traits::ptr (p) == 0); + } + + t.commit (); + } +} + +template +void +erase_id (const unique_ptr& db, I b, I e, bool cont = true) +{ + typedef element_traits traits; + typedef T type; + + { + transaction t (db->begin ()); + db->erase (b, e, cont); + t.commit (); + } + + // Verify the objects are gone. + // + { + transaction t (db->begin ()); + + for (I i (b); i != e; ++i) + assert (traits::ptr (db->find (*i)) == 0); + + t.commit (); + } +} + +template +void +try_erase (const unique_ptr& db, const A& a, bool cont = true) +{ + try + { + erase_id (db, a, a + sizeof (a) / sizeof (a[0]), cont); + assert (false); + } + catch (const multiple_exceptions& e) + { + cout << e.what () << endl << endl; + } +} + + +template +void +test (const unique_ptr& db, I b, I e) +{ + persist (db, b, e); + update (db, b, e); + erase (db, b, e); +} + +template +vector +fill (std::size_t count) +{ + vector r; + + unsigned int n (1); + std::string s ("a"); + + for (size_t i (0); i != count; ++i) + { + r.push_back (T (n, s)); + n++; + s[0] = (s[0] == 'z' ? 'a' : s[0] + 1); + } + + return r; +} + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + +#if !defined(MULTI_DATABASE) && \ + (defined(DATABASE_ORACLE) || \ + defined(DATABASE_MSSQL) || \ + defined(DATABASE_PGSQL)) + + // Test database class API with various forms of containers + // and elements (test #6 is a copy). + // + { + using namespace test1; + + { + object a[2]; + a[0] = object (1, "a"); + a[1] = object (2, "b"); + test (db, a, a + sizeof (a) / sizeof (a[0])); + } + + { + vector v; + v.push_back (object (1, "a")); + v.push_back (object (2, "b")); + test (db, v.begin (), v.end ()); + } + + { + object o1 (1, "a"); + object o2 (2, "b"); + object* a[2] = {&o1, &o2}; + test (db, a, a + sizeof (a) / sizeof (a[0])); + } + + { + object o1 (1, "a"); + object o2 (2, "b"); + vector v; + v.push_back (&o1); + v.push_back (&o2); + test (db, v.begin (), v.end ()); + } + + { + vector> v; + v.push_back (unique_ptr (new unique_object (1, "a"))); + v.push_back (unique_ptr (new unique_object (2, "b"))); + test (db, v.begin (), v.end ()); + } + + { + vector v; + v.push_back (object (1, "a")); + v.push_back (object (2, "b")); + persist (db, v.begin (), v.end ()); + + unsigned long id[2] = {v[0].id, v[1].id}; + erase_id (db, id, id + sizeof (id) / sizeof (id[0])); + } + + { + vector v; + v.push_back (object (1, "a")); + v.push_back (object (2, "b")); + persist (db, v.begin (), v.end ()); + + vector id; + id.push_back (v[0].id); + id.push_back (v[1].id); + erase_id (db, id.begin (), id.end ()); + } + } + + // Test various batch sizes. + // + { + using namespace test1; + + { + vector v; // 0 + test (db, v.begin (), v.end ()); + } + + { + vector v (fill (1)); // 1 + test (db, v.begin (), v.end ()); + } + + { + vector v (fill (2)); // batch - 1 + test (db, v.begin (), v.end ()); + } + + { + vector v (fill (3)); // batch + test (db, v.begin (), v.end ()); + } + + { + vector v (fill (4)); // batch + 1 + test (db, v.begin (), v.end ()); + } + + { + vector v (fill (5)); // 2 * batch - 1 + test (db, v.begin (), v.end ()); + } + + { + vector v (fill (6)); // 2 * batch + test (db, v.begin (), v.end ()); + } + + { + vector v (fill (100)); // 100 + test (db, v.begin (), v.end ()); + } + } + + // Test object with manually assigned id. + // + { + using namespace test2; + + { + vector v; + v.push_back (object ("1", 1, "a")); + v.push_back (object ("2", 2, "b")); + test (db, v.begin (), v.end ()); + } + + { + typedef unique_ptr unique_ptr; + + vector v; + v.push_back (unique_ptr (new unique_object ("1", 1, "a"))); + v.push_back (unique_ptr (new unique_object ("2", 2, "b"))); + test (db, v.begin (), v.end ()); + } + + // Test const objects. + // + + { + const object a[1]; + const object* e (a + sizeof (a) / sizeof (a[0])); + + transaction t (db->begin ()); + db->persist (a, e); + db->erase (a, e); + t.commit (); + } + + { + object o1 ("1", 1, "a"); + object o2 ("2", 2, "b"); + + vector v; + v.push_back (&o1); + v.push_back (&o2); + + transaction t (db->begin ()); + db->persist (v.begin (), v.end ()); + db->erase (v.begin (), v.end ()); + t.commit (); + } + } + + // Test failure. + // + { + using namespace test3; + + vector v; + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + v.push_back (object (8, 8)); + v.push_back (object (9, 9)); + v.push_back (object (10, 10)); + v.push_back (object (11, 11)); + + persist (db, v.begin (), v.end ()); + + // persist + // + { + { + vector v; // 1 + v.push_back (object (6, 6)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // 2 + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // batch + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + v.push_back (object (8, 8)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // batch + 1 + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + v.push_back (object (8, 8)); + v.push_back (object (9, 9)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // 2 x batch - 1 + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + v.push_back (object (8, 8)); + v.push_back (object (9, 9)); + v.push_back (object (10, 10)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // 2 x batch + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + v.push_back (object (8, 8)); + v.push_back (object (9, 9)); + v.push_back (object (10, 10)); + v.push_back (object (11, 11)); + try_persist (db, v.begin (), v.end ()); + } + + // Mixture of success and failure. + // + + { + vector v; // 1 + v.push_back (object (0, 0)); + v.push_back (object (6, 6)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // 1 + v.push_back (object (6, 6)); + v.push_back (object (0, 0)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // 2 + v.push_back (object (0, 0)); + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // 2 + v.push_back (object (6, 6)); + v.push_back (object (0, 0)); + v.push_back (object (7, 7)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // 2 + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + v.push_back (object (0, 0)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // batch + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + v.push_back (object (0, 0)); + v.push_back (object (8, 8)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // batch + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + v.push_back (object (8, 8)); + v.push_back (object (0, 0)); + try_persist (db, v.begin (), v.end ()); + } + + { + vector v; // mixture + v.push_back (object (0, 0)); + v.push_back (object (6, 6)); + v.push_back (object (1, 1)); + v.push_back (object (7, 7)); + v.push_back (object (2, 2)); + v.push_back (object (8, 8)); + v.push_back (object (3, 3)); + try_persist (db, v.begin (), v.end ()); + } + + // Test stopping after failure. + // + { + vector v; // batch + v.push_back (object (0, 0)); + v.push_back (object (1, 1)); + v.push_back (object (6, 6)); + v.push_back (object (2, 2)); + v.push_back (object (3, 3)); + try_persist (db, v.begin (), v.end (), false); + } + } + + // update + // + { + { + vector v; // 1 + v.push_back (object (0, 0)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // 2 + v.push_back (object (0, 0)); + v.push_back (object (1, 1)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // batch + v.push_back (object (0, 0)); + v.push_back (object (1, 1)); + v.push_back (object (2, 2)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // batch + 1 + v.push_back (object (0, 0)); + v.push_back (object (1, 1)); + v.push_back (object (2, 2)); + v.push_back (object (3, 3)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // 2 x batch - 1 + v.push_back (object (0, 0)); + v.push_back (object (1, 1)); + v.push_back (object (2, 2)); + v.push_back (object (3, 3)); + v.push_back (object (4, 4)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // 2 x batch + v.push_back (object (0, 0)); + v.push_back (object (1, 1)); + v.push_back (object (2, 2)); + v.push_back (object (3, 3)); + v.push_back (object (4, 4)); + v.push_back (object (5, 5)); + try_update (db, v.begin (), v.end ()); + } + + // Mixture of success and failure. + // + + { + vector v; // 1 + v.push_back (object (6, 6)); + v.push_back (object (0, 0)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // 1 + v.push_back (object (0, 0)); + v.push_back (object (6, 6)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // 2 + v.push_back (object (6, 6)); + v.push_back (object (0, 0)); + v.push_back (object (1, 1)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // 2 + v.push_back (object (0, 0)); + v.push_back (object (6, 6)); + v.push_back (object (1, 1)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // 2 + v.push_back (object (0, 0)); + v.push_back (object (1, 1)); + v.push_back (object (6, 6)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // batch + v.push_back (object (0, 0)); + v.push_back (object (1, 1)); + v.push_back (object (6, 6)); + v.push_back (object (2, 2)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // batch + v.push_back (object (0, 0)); + v.push_back (object (1, 1)); + v.push_back (object (2, 2)); + v.push_back (object (6, 6)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // mixture + v.push_back (object (0, 0)); + v.push_back (object (6, 6)); + v.push_back (object (2, 2)); + v.push_back (object (7, 7)); + v.push_back (object (3, 3)); + v.push_back (object (8, 8)); + v.push_back (object (4, 4)); + try_update (db, v.begin (), v.end ()); + } + + { + vector v; // mixture + v.push_back (object (0, 0)); + v.push_back (object (2, 2)); + v.push_back (object (3, 3)); + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + v.push_back (object (8, 8)); + v.push_back (object (4, 4)); + try_update (db, v.begin (), v.end ()); + } + + // Test stopping after failure. + // + { + vector v; // batch + v.push_back (object (6, 6)); + v.push_back (object (7, 7)); + v.push_back (object (0, 0)); + v.push_back (object (8, 8)); + v.push_back (object (9, 9)); + try_update (db, v.begin (), v.end (), false); + } + + // Test a database exception (unique constraint violation) + // + try + { + v[0].n++; + v[2].n++; + + update (db, v.begin (), v.begin () + 3, false); + assert (false); + } + catch (const multiple_exceptions& e) + { +#ifndef DATABASE_PGSQL + assert (e.attempted () == 3 && e.failed () == 2); + assert (e[0] != 0 && e[1] == 0 && e[2] != 0); +#else + // In PosgreSQL no further statements are attempted after the first + // failure. + // + assert (e.attempted () == 1 && e.failed () == 1); + assert (e[0] != 0); +#endif + } + } + + // erase + // + { + { + unsigned long a[] = {0}; // 1 + try_erase (db, a); + } + + { + unsigned long a[] = {0, 1}; // 2 + try_erase (db, a); + } + + { + unsigned long a[] = {0, 1, 2}; // batch + try_erase (db, a); + } + + { + unsigned long a[] = {0, 1, 2, 3}; // batch + 1 + try_erase (db, a); + } + + { + unsigned long a[] = {0, 1, 2, 3, 4}; // 2 x batch - 1 + try_erase (db, a); + } + + { + unsigned long a[] = {0, 1, 2, 3, 4, 5}; // 2 x batch + try_erase (db, a); + } + + // Mixture of success and failure. + // + + { + unsigned long a[] = {6, 0}; // 2 + try_erase (db, a); + } + + { + unsigned long a[] = {0, 6}; // 2 + try_erase (db, a); + } + + { + unsigned long a[] = {6, 0, 1}; // batch + try_erase (db, a); + } + + { + unsigned long a[] = {0, 6, 1}; // batch + try_erase (db, a); + } + + { + unsigned long a[] = {0, 1, 6}; // batch + try_erase (db, a); + } + + { + unsigned long a[] = {6, 0, 1, 2}; // batch + 1 + try_erase (db, a); + } + + { + unsigned long a[] = {0, 6, 1, 2}; // batch + 1 + try_erase (db, a); + } + + { + unsigned long a[] = {0, 1, 6, 2}; // batch + 1 + try_erase (db, a); + } + + { + unsigned long a[] = {0, 1, 2, 6}; // batch + 1 + try_erase (db, a); + } + + { + unsigned long a[] = {6, 0, 7, 1, 8, 2, 9, 3}; // mixture + try_erase (db, a); + } + + { + unsigned long a[] = {0, 1, 2, 6, 7, 8, 3, 4, 5, 9}; // mixture + try_erase (db, a); + } + + // Test stopping after failure. + // + { + unsigned long a[] = {6, 7, 0, 8, 9}; + try_erase (db, a, false); + } + } + + erase (db, v.begin (), v.end ()); + } + + // Test a large batch. + // + { + using namespace test4; + + vector v (fill (5000)); + test (db, v.begin (), v.end ()); + } + + // Test object without id. + // + { + using namespace test5; + + vector v; + v.push_back (object (1, "a")); + v.push_back (object (2, "b")); + + { + transaction t (db->begin ()); + db->persist (v.begin (), v.end ()); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query ("ORDER BY" + query::n)); + result::iterator i (r.begin ()); + + assert (i != r.end () && i->n == 1 && i->s == "a"); + assert (++i != r.end () && i->n == 2 && i->s == "b"); + assert (++i == r.end ()); + + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase_query (); + t.commit (); + } + } + + // Test API with persistent class template instantiations (copy of + // test #1). + { + using namespace test6; + + // Make sure we can still call the non-bulk API. + // + { + object o (0, "z"); + transaction t (db->begin ()); + db->persist (o); + db->update (o); + db->reload (o); + db->erase (o); + t.commit (); + } + + + // The rest is a copy of test #1. + // + { + object a[2]; + a[0] = object (1, "a"); + a[1] = object (2, "b"); + test (db, a, a + sizeof (a) / sizeof (a[0])); + } + + { + vector v; + v.push_back (object (1, "a")); + v.push_back (object (2, "b")); + test (db, v.begin (), v.end ()); + } + + { + object o1 (1, "a"); + object o2 (2, "b"); + object* a[2] = {&o1, &o2}; + test (db, a, a + sizeof (a) / sizeof (a[0])); + } + + { + object o1 (1, "a"); + object o2 (2, "b"); + vector v; + v.push_back (&o1); + v.push_back (&o2); + test (db, v.begin (), v.end ()); + } + + { + vector> v; + v.push_back (unique_ptr (new unique_object (1, "a"))); + v.push_back (unique_ptr (new unique_object (2, "b"))); + test (db, v.begin (), v.end ()); + } + + { + vector v; + v.push_back (object (1, "a")); + v.push_back (object (2, "b")); + persist (db, v.begin (), v.end ()); + + unsigned long id[2] = {v[0].id, v[1].id}; + erase_id (db, id, id + sizeof (id) / sizeof (id[0])); + } + + { + vector v; + v.push_back (object (1, "a")); + v.push_back (object (2, "b")); + persist (db, v.begin (), v.end ()); + + vector id; + id.push_back (v[0].id); + id.push_back (v[1].id); + erase_id (db, id.begin (), id.end ()); + } + } + + // Test optimistic concurrency. + // + { + using namespace test7; + + std::vector v (fill (4)); + + // persist + // + { + transaction t (db->begin ()); + db->persist (v.begin (), v.end ()); + t.commit (); + + assert (v[0].v != 0 && + v[1].v != 0 && + v[2].v != 0 && + v[3].v != 0); + } + + // update + // + { + std::vector c (v); + + transaction t (db->begin ()); + db->update (v.begin (), v.end ()); + t.commit (); + + assert (v[0].v > c[0].v && + v[1].v > c[1].v && + v[2].v > c[2].v && + v[3].v > c[3].v); + } + + { + object o2 (v[1]); + object o4 (v[3]); + + o2.n++; + o4.n++; + + transaction t (db->begin ()); + db->update (o2); + db->update (o4); + t.commit (); + } + + try + { + // Some updates may succeed spoiling the version for erase tests. + // + std::vector c (v); + + transaction t (db->begin ()); + db->update (c.begin (), c.end ()); + assert (false); + } + catch (const multiple_exceptions& e) + { + cout << e.what () << endl << endl; + } + + // erase + // + try + { + transaction t (db->begin ()); + db->erase (v.begin (), v.end ()); + assert (false); + } + catch (const multiple_exceptions& e) + { + cout << e.what () << endl << endl; + } + + { + transaction t (db->begin ()); + db->reload (v[1]); + db->reload (v[3]); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (v.begin (), v.end ()); + t.commit (); + } + } + + // Test SQL Server optimistic concurrency with ROWVERSION. + // +#ifdef DATABASE_MSSQL + { + using namespace test8; + + std::vector v (fill (4)); + + v[0].id = 1; + v[1].id = 2; + v[2].id = 3; + v[3].id = 4; + + + // persist + // + { + transaction t (db->begin ()); + db->persist (v.begin (), v.end ()); + t.commit (); + + assert (v[0].v != 0 && + v[1].v != 0 && + v[2].v != 0 && + v[3].v != 0); + + //cerr << v[0].v << endl + // << v[1].v << endl + // << v[2].v << endl + // << v[3].v << endl; + } + + // update + // + + /* + { + std::vector c (v); + + transaction t (db->begin ()); + db->update (v.begin (), v.end ()); + t.commit (); + + assert (v[0].v > c[0].v && + v[1].v > c[1].v && + v[2].v > c[2].v && + v[3].v > c[3].v); + } + */ + + { + object o2 (v[1]); + object o4 (v[3]); + + o2.n++; + o4.n++; + + transaction t (db->begin ()); + db->update (o2); + db->update (o4); + t.commit (); + } + + /* + try + { + transaction t (db->begin ()); + db->update (v.begin (), v.end ()); + assert (false); + } + catch (const multiple_exceptions& e) + { + cout << e.what () << endl << endl; + } + */ + + // erase + // + try + { + transaction t (db->begin ()); + db->erase (v.begin (), v.end ()); + assert (false); + } + catch (const multiple_exceptions& e) + { + assert (e.attempted () == 4 && e.failed () == 4); + } + + { + transaction t (db->begin ()); + db->reload (v[1]); + db->reload (v[3]); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (v.begin (), v.end ()); + t.commit (); + } + } +#endif + +#endif + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/bulk/test.hxx b/odb-tests/common/bulk/test.hxx new file mode 100644 index 0000000..71755f2 --- /dev/null +++ b/odb-tests/common/bulk/test.hxx @@ -0,0 +1,211 @@ +// file : common/bulk/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include // std::unique_ptr + +#include + +// Test basic functionality. +// +#pragma db namespace table("t1_") +namespace test1 +{ + #pragma db object bulk(3) session + struct object + { + object (unsigned int n_ = 0, std::string s_ = "") + : id (0), n (n_), s (s_) {} + + #pragma db id auto + unsigned long id; + + unsigned int n; + + #pragma db oracle:type("CLOB") mssql:type("VARCHAR(max)") // Long data. + std::string s; + }; + + #pragma db object bulk(3) pointer(std::unique_ptr) + struct unique_object + { + unique_object (unsigned int n_ = 0, std::string s_ = "") + : id (0), n (n_), s (s_) {} + + #pragma db id auto + unsigned long id; + + unsigned int n; + std::string s; + }; +} + +// Test object with manually assigned id. +// +#pragma db namespace table("t2_") +namespace test2 +{ + #pragma db object bulk(3) session + struct object + { + // Can't use empty id because of Oracle. + // + object (std::string id_ = "!", unsigned int n_ = 0, std::string s_ = "") + : id (id_), n (n_), s (s_) {} + + #pragma db id + std::string id; + + unsigned int n; + std::string s; + }; + +#pragma db object bulk(3) pointer(std::unique_ptr) + struct unique_object + { + unique_object (std::string id_ = "", + unsigned int n_ = 0, + std::string s_ = "") + : id (id_), n (n_), s (s_) {} + + #pragma db id + std::string id; + + unsigned int n; + std::string s; + }; +} + +// Test failure. +// +#pragma db namespace table("t3_") +namespace test3 +{ + #pragma db object bulk(3) + struct object + { + object (unsigned long id_ = 0, unsigned int n_ = 0) + : id (id_), n (n_), s ("abc") {} + + #pragma db id + unsigned long id; + + #pragma db unique + unsigned int n; + std::string s; + }; +} + +// Test a large batch. +// +#pragma db namespace table("t4_") +namespace test4 +{ + #pragma db object bulk(3000) + struct object + { + object (unsigned int n_ = 0, std::string s_ = "") + : id (0), n (n_), s (s_) {} + + #pragma db id auto + unsigned long id; + + unsigned int n; + + #pragma db oracle:type("CLOB") mssql:type("VARCHAR(max)") // Long data. + std::string s; + }; +} + +// Test object without id. +// +#pragma db namespace table("t5_") +namespace test5 +{ + #pragma db object no_id bulk(3) + struct object + { + object (unsigned int n_ = 0, std::string s_ = ""): n (n_), s (s_) {} + + unsigned int n; + std::string s; + }; +} + +// Test API with persistent class template instantiations. +// +#pragma db namespace table("t6_") +namespace test6 +{ + template + struct object_template + { + object_template (unsigned int n_ = 0, std::string s_ = "") + : id (0), n (n_), s (s_) {} + + unsigned long id; + unsigned int n; + std::string s; + }; + + typedef object_template<1> object; + + #pragma db object(object) bulk(3) + #pragma db member(object::id) id auto + + typedef object_template<3> unique_object; + + #pragma db object(unique_object) bulk(3) pointer(std::unique_ptr) + #pragma db member(unique_object::id) id auto +} + +// Test optimistic concurrency. +// +#pragma db namespace table("t7_") +namespace test7 +{ + #pragma db object optimistic bulk(3) + struct object + { + object (unsigned int n_ = 0, std::string s_ = "") + : id (0), v (0), n (n_), s (s_) {} + + #pragma db id auto + unsigned long long id; + + #pragma db version + unsigned long long v; + + unsigned int n; + std::string s; + }; +} + +// Test SQL Server optimistic concurrency with ROWVERSION. +// +#if defined(ODB_DATABASE_MSSQL) || defined(DATABASE_MSSQL) +#pragma db namespace table("t8_") +namespace test8 +{ + #pragma db object optimistic bulk(3) + struct object + { + object (unsigned int n_ = 0, std::string s_ = "") + : id (0), v (0), n (n_), s (s_) {} + + #pragma db id + unsigned long long id; + + #pragma db version type("ROWVERSION") + unsigned long long v; + + unsigned int n; + std::string s; + }; +} +#endif + +#endif // TEST_HXX diff --git a/odb-tests/common/bulk/testscript b/odb-tests/common/bulk/testscript new file mode 100644 index 0000000..e7567c9 --- /dev/null +++ b/odb-tests/common/bulk/testscript @@ -0,0 +1,503 @@ +# file : common/bulk/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + ++cat <=output + multiple exceptions, 1 element attempted, 1 failed: + [0] object already persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0] object already persistent + [1] object already persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0] object already persistent + [1] object already persistent + [2] object already persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0] object already persistent + [1] object already persistent + [2] object already persistent + [3] object already persistent + + multiple exceptions, 5 elements attempted, 5 failed: + [0] object already persistent + [1] object already persistent + [2] object already persistent + [3] object already persistent + [4] object already persistent + + multiple exceptions, 6 elements attempted, 6 failed: + [0] object already persistent + [1] object already persistent + [2] object already persistent + [3] object already persistent + [4] object already persistent + [5] object already persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [1] object already persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [0] object already persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [1] object already persistent + [2] object already persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object already persistent + [2] object already persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object already persistent + [1] object already persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object already persistent + [1] object already persistent + [3] object already persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object already persistent + [1] object already persistent + [2] object already persistent + + multiple exceptions, 7 elements attempted, 3 failed: + [1] object already persistent + [3] object already persistent + [5] object already persistent + + multiple exceptions, 3 elements attempted, 1 failed: + [2] object already persistent + + multiple exceptions, 1 element attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 5 elements attempted, 5 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + + multiple exceptions, 6 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + [5] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0-1] (some) object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0-1] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 7 elements attempted, 7 failed: + [0-5] (some) object not persistent + [6] object not persistent + + multiple exceptions, 7 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [6] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 1 element attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 5 elements attempted, 5 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + + multiple exceptions, 6 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + [5] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0-1] (some) object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0-1] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 8 elements attempted, 8 failed: + [0-7] (some) object not persistent + + multiple exceptions, 10 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [6] object not persistent + [7] object not persistent + [8] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0-2] (some) object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object changed concurrently + [3] object changed concurrently + + multiple exceptions, 4 elements attempted, 4 failed: + [0-2] (some) object changed concurrently + [3] object changed concurrently + + EOI + ++cat <=pgsql-output + multiple exceptions, 1 element attempted, 1 failed: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [1] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 2 elements attempted, 1 failed, fatal: + [1] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 1 element attempted, 1 failed, fatal: + [0] object already persistent + + multiple exceptions, 2 elements attempted, 1 failed, fatal: + [1] object already persistent + + multiple exceptions, 3 elements attempted, 1 failed: + [2] object already persistent + + multiple exceptions, 1 element attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 5 elements attempted, 5 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + + multiple exceptions, 6 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + [5] object not persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [1] object not persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [1] object not persistent + [2] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object not persistent + [2] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 7 elements attempted, 4 failed: + [0] object not persistent + [2] object not persistent + [4] object not persistent + [6] object not persistent + + multiple exceptions, 7 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [6] object not persistent + + multiple exceptions, 3 elements attempted, 1 failed: + [2] object not persistent + + multiple exceptions, 1 element attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 2 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 3 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 4 elements attempted, 4 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 5 elements attempted, 5 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + + multiple exceptions, 6 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [3] object not persistent + [4] object not persistent + [5] object not persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [1] object not persistent + + multiple exceptions, 2 elements attempted, 1 failed: + [0] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [1] object not persistent + [2] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object not persistent + [2] object not persistent + + multiple exceptions, 3 elements attempted, 2 failed: + [0] object not persistent + [1] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [1] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [2] object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [3] object not persistent + + multiple exceptions, 4 elements attempted, 3 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + + multiple exceptions, 8 elements attempted, 4 failed: + [1] object not persistent + [3] object not persistent + [5] object not persistent + [7] object not persistent + + multiple exceptions, 10 elements attempted, 6 failed: + [0] object not persistent + [1] object not persistent + [2] object not persistent + [6] object not persistent + [7] object not persistent + [8] object not persistent + + multiple exceptions, 3 elements attempted, 1 failed: + [2] object not persistent + + multiple exceptions, 4 elements attempted, 2 failed: + [1] object changed concurrently + [3] object changed concurrently + + multiple exceptions, 4 elements attempted, 2 failed: + [1] object changed concurrently + [3] object changed concurrently + + EOI + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if ($pgsql && $pgsql_bulk) +{ + .include ../../pgsql.testscript + + $create_schema; + + # Query the PostgreSQL server version and only run the test if it is 7.4 or + # above. + # + $pgsql_client_cmd --tuples-only -c 'SELECT VERSION()' | \ + sed -n -e 's/.*PostgreSQL (\d+\.\d+).*/\1/p' | \ + set version [string]; + + if ("$version" == "") + exit "unable to obtain PostgreSQL server version" + end; + + sed -n -e 's/(.+)\..+/\1/p' <"$version" | set major_version [uint64]; + sed -n -e 's/.+\.(.+)/\1/p' <"$version" | set minor_version [uint64]; + + if (($major_version == 7 && minor_version >= 4) || $major_version > 7) + if $multi + $* # Noop. + else + $* >>>../pgsql-output + end + end +} diff --git a/odb-tests/common/callback/buildfile b/odb-tests/common/callback/buildfile new file mode 100644 index 0000000..2ecc3b8 --- /dev/null +++ b/odb-tests/common/callback/buildfile @@ -0,0 +1,41 @@ +# file : common/callback/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix callback_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/callback/driver.cxx b/odb-tests/common/callback/driver.cxx new file mode 100644 index 0000000..80513c6 --- /dev/null +++ b/odb-tests/common/callback/driver.cxx @@ -0,0 +1,184 @@ +// file : common/callback/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test database operation callbacks. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +const char* events[] = +{ + "pre_persist", + "post_persist", + "pre_load", + "post_load", + "pre_update", + "post_update", + "pre_erase", + "post_erase" +}; + +void object:: +db_callback (callback_event e, database& db) +{ + cout << " " << events[e] << " " << id_ << endl; + + // Test custom recursive loading. + // + if (e == callback_event::post_load && ref != 0) + { + robj = db.load (ref); + cout << " " << id_ << ' ' << ref << ' ' << robj->id_ << endl; + } +} + +void object:: +db_callback (callback_event e, database&) const +{ + cout << " " << events[e] << " " << id_ << " const" << endl; +} + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Persist. + // + cout << "persist" << endl; + { + object o1 (1, 1); + object const o2 (2, 2); + transaction t (db->begin ()); + db->persist (o1); + db->persist (&o2); + t.commit (); + } + cout << "***" << endl; + + // Load. + // + cout << "load" << endl; + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + object o2; + db->load (2, o2); + t.commit (); + } + cout << "***" << endl; + + // Query. + // + cout << "query" << endl; + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query ((query::id < 3) + "ORDER BY" + query::id)); + + for (result::iterator i (r.begin ()); i != r.end (); ++i) + { + if (i->id_ > 3) // Load. + break; + } + + t.commit (); + } + cout << "***" << endl; + + // Update. + // + cout << "update" << endl; + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + unique_ptr o2 (db->load (2)); + o1->data++; + o2->data++; + db->update (o1.get ()); + db->update (static_cast (*o2)); + t.commit (); + } + cout << "***" << endl; + + // Erase. + // + cout << "erase" << endl; + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + unique_ptr o2 (db->load (2)); + db->erase (static_cast (o1.get ())); + db->erase (*o2); + t.commit (); + } + cout << "***" << endl; + + // Delayed (recursive) load. + // + cout << "delayed load" << endl; + { + { + object o1 (1, 1); + object o2 (2, 2); + object o3 (3, 3); + object o4 (4, 4); + + o1.pobj = &o2; + o1.ref = 4; + + o2.pobj = &o3; + o2.ref = 4; + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + db->persist (o4); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + object* o2 (o1->pobj); + + cout << o1->id_ << ' ' << o1->ref << ' ' << o1->robj->id_ << endl; + cout << o2->id_ << ' ' << o2->ref << ' ' << o2->robj->id_ << endl; + + delete o1->robj; + delete o2->robj; + + delete o2->pobj; + delete o2; + t.commit (); + } + } + cout << "***" << endl; + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/callback/test.hxx b/odb-tests/common/callback/test.hxx new file mode 100644 index 0000000..bd30907 --- /dev/null +++ b/odb-tests/common/callback/test.hxx @@ -0,0 +1,43 @@ +// file : common/callback/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object callback(db_callback) +struct object +{ + object (unsigned long id, unsigned long d) + : id_ (id), data (d), pobj (0), robj (0), ref (0) + { + } + + object () + : id_ (0), pobj (0), robj (0) + { + } + + #pragma db id + unsigned long id_; + + unsigned long data; + + object* pobj; + + // Test custom recursive loading. + // + #pragma db transient + object* robj; + unsigned long ref; // Unless 0, reference to another object. + + void + db_callback (odb::callback_event, odb::database&); + + void + db_callback (odb::callback_event, odb::database&) const; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/callback/testscript b/odb-tests/common/callback/testscript new file mode 100644 index 0000000..c7d03ee --- /dev/null +++ b/odb-tests/common/callback/testscript @@ -0,0 +1,100 @@ +# file : common/callback/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + ++cat <=output + persist + pre_persist 1 const + post_persist 1 const + pre_persist 2 const + post_persist 2 const + *** + load + pre_load 0 + post_load 1 + pre_load 0 + post_load 2 + *** + query + pre_load 0 + post_load 1 + pre_load 0 + post_load 2 + *** + update + pre_load 0 + post_load 1 + pre_load 0 + post_load 2 + pre_update 1 const + post_update 1 const + pre_update 2 const + post_update 2 const + *** + erase + pre_load 0 + post_load 1 + pre_load 0 + post_load 2 + pre_erase 1 const + post_erase 1 const + pre_erase 2 const + post_erase 2 const + *** + delayed load + pre_persist 1 const + post_persist 1 const + pre_persist 2 const + post_persist 2 const + pre_persist 3 const + post_persist 3 const + pre_persist 4 const + post_persist 4 const + pre_load 0 + pre_load 0 + pre_load 0 + post_load 3 + post_load 2 + pre_load 0 + post_load 4 + 2 4 4 + post_load 1 + pre_load 0 + post_load 4 + 1 4 4 + 1 4 4 + 2 4 4 + *** + EOI + +test.redirects += >>>../output + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/changelog/.gitignore b/odb-tests/common/changelog/.gitignore new file mode 100644 index 0000000..5352a2b --- /dev/null +++ b/odb-tests/common/changelog/.gitignore @@ -0,0 +1,3 @@ +# Generate ODB options file. +# +odb.options diff --git a/odb-tests/common/changelog/add-column-mssql-diff.xml b/odb-tests/common/changelog/add-column-mssql-diff.xml new file mode 100644 index 0000000..4f9ba09 --- /dev/null +++ b/odb-tests/common/changelog/add-column-mssql-diff.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-column-mssql-patch.xml b/odb-tests/common/changelog/add-column-mssql-patch.xml new file mode 100644 index 0000000..4f396d9 --- /dev/null +++ b/odb-tests/common/changelog/add-column-mssql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-column-mysql-diff.xml b/odb-tests/common/changelog/add-column-mysql-diff.xml new file mode 100644 index 0000000..992306d --- /dev/null +++ b/odb-tests/common/changelog/add-column-mysql-diff.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-column-mysql-patch.xml b/odb-tests/common/changelog/add-column-mysql-patch.xml new file mode 100644 index 0000000..14f3f01 --- /dev/null +++ b/odb-tests/common/changelog/add-column-mysql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-column-oracle-diff.xml b/odb-tests/common/changelog/add-column-oracle-diff.xml new file mode 100644 index 0000000..fa1dac6 --- /dev/null +++ b/odb-tests/common/changelog/add-column-oracle-diff.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-column-oracle-patch.xml b/odb-tests/common/changelog/add-column-oracle-patch.xml new file mode 100644 index 0000000..38fb8d6 --- /dev/null +++ b/odb-tests/common/changelog/add-column-oracle-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-column-pgsql-diff.xml b/odb-tests/common/changelog/add-column-pgsql-diff.xml new file mode 100644 index 0000000..9524d9d --- /dev/null +++ b/odb-tests/common/changelog/add-column-pgsql-diff.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-column-pgsql-patch.xml b/odb-tests/common/changelog/add-column-pgsql-patch.xml new file mode 100644 index 0000000..7f7d9a0 --- /dev/null +++ b/odb-tests/common/changelog/add-column-pgsql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-column-sqlite-diff.xml b/odb-tests/common/changelog/add-column-sqlite-diff.xml new file mode 100644 index 0000000..b59cc72 --- /dev/null +++ b/odb-tests/common/changelog/add-column-sqlite-diff.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-column-sqlite-patch.xml b/odb-tests/common/changelog/add-column-sqlite-patch.xml new file mode 100644 index 0000000..fbe4428 --- /dev/null +++ b/odb-tests/common/changelog/add-column-sqlite-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-column.hxx b/odb-tests/common/changelog/add-column.hxx new file mode 100644 index 0000000..54eab42 --- /dev/null +++ b/odb-tests/common/changelog/add-column.hxx @@ -0,0 +1,20 @@ +// file : common/changelog/add-column.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ADD_COLUMN_HXX +#define ADD_COLUMN_HXX + +#pragma db model version(BVER, CVER, open) + +#pragma db object +struct object +{ + #pragma db id auto + int id; + +#if CVER > 1 + int num; +#endif +}; + +#endif // ADD_COLUMN_HXX diff --git a/odb-tests/common/changelog/add-foreign-key-diff.xml b/odb-tests/common/changelog/add-foreign-key-diff.xml new file mode 100644 index 0000000..d4f29ad --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key-diff.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-foreign-key-mssql-diff.xml b/odb-tests/common/changelog/add-foreign-key-mssql-diff.xml new file mode 100644 index 0000000..76ebce3 --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key-mssql-diff.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-foreign-key-mssql-patch.xml b/odb-tests/common/changelog/add-foreign-key-mssql-patch.xml new file mode 100644 index 0000000..6d75709 --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key-mssql-patch.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-foreign-key-mysql-diff.xml b/odb-tests/common/changelog/add-foreign-key-mysql-diff.xml new file mode 100644 index 0000000..acdfd5b --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key-mysql-diff.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-foreign-key-mysql-patch.xml b/odb-tests/common/changelog/add-foreign-key-mysql-patch.xml new file mode 100644 index 0000000..adc9081 --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key-mysql-patch.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-foreign-key-oracle-diff.xml b/odb-tests/common/changelog/add-foreign-key-oracle-diff.xml new file mode 100644 index 0000000..6bd8bc3 --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key-oracle-diff.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-foreign-key-oracle-patch.xml b/odb-tests/common/changelog/add-foreign-key-oracle-patch.xml new file mode 100644 index 0000000..7aa01ea --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key-oracle-patch.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-foreign-key-pgsql-diff.xml b/odb-tests/common/changelog/add-foreign-key-pgsql-diff.xml new file mode 100644 index 0000000..793b009 --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key-pgsql-diff.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-foreign-key-pgsql-patch.xml b/odb-tests/common/changelog/add-foreign-key-pgsql-patch.xml new file mode 100644 index 0000000..a256831 --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key-pgsql-patch.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-foreign-key-sqlite-diff.xml b/odb-tests/common/changelog/add-foreign-key-sqlite-diff.xml new file mode 100644 index 0000000..1510470 --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key-sqlite-diff.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-foreign-key-sqlite-patch.xml b/odb-tests/common/changelog/add-foreign-key-sqlite-patch.xml new file mode 100644 index 0000000..1c2d0ea --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key-sqlite-patch.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-foreign-key.hxx b/odb-tests/common/changelog/add-foreign-key.hxx new file mode 100644 index 0000000..2a43eea --- /dev/null +++ b/odb-tests/common/changelog/add-foreign-key.hxx @@ -0,0 +1,29 @@ +// file : common/changelog/add-foreign-key.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ADD_FOREIGN_KEY_HXX +#define ADD_FOREIGN_KEY_HXX + +#pragma db model version(BVER, CVER, open) + +struct object1; + +#pragma db object +struct object +{ + #pragma db id auto + int id; + +#if CVER > 1 + object1* o1; +#endif +}; + +#pragma db object +struct object1 +{ + #pragma db id + int id; +}; + +#endif // ADD_FOREIGN_KEY_HXX diff --git a/odb-tests/common/changelog/add-index-mssql-diff.xml b/odb-tests/common/changelog/add-index-mssql-diff.xml new file mode 100644 index 0000000..58c623f --- /dev/null +++ b/odb-tests/common/changelog/add-index-mssql-diff.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-index-mssql-patch.xml b/odb-tests/common/changelog/add-index-mssql-patch.xml new file mode 100644 index 0000000..2b10e65 --- /dev/null +++ b/odb-tests/common/changelog/add-index-mssql-patch.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-index-mysql-diff.xml b/odb-tests/common/changelog/add-index-mysql-diff.xml new file mode 100644 index 0000000..a54a7e3 --- /dev/null +++ b/odb-tests/common/changelog/add-index-mysql-diff.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-index-mysql-patch.xml b/odb-tests/common/changelog/add-index-mysql-patch.xml new file mode 100644 index 0000000..a2454b8 --- /dev/null +++ b/odb-tests/common/changelog/add-index-mysql-patch.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-index-oracle-diff.xml b/odb-tests/common/changelog/add-index-oracle-diff.xml new file mode 100644 index 0000000..80f8ecc --- /dev/null +++ b/odb-tests/common/changelog/add-index-oracle-diff.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-index-oracle-patch.xml b/odb-tests/common/changelog/add-index-oracle-patch.xml new file mode 100644 index 0000000..a9bafea --- /dev/null +++ b/odb-tests/common/changelog/add-index-oracle-patch.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-index-pgsql-diff.xml b/odb-tests/common/changelog/add-index-pgsql-diff.xml new file mode 100644 index 0000000..3988643 --- /dev/null +++ b/odb-tests/common/changelog/add-index-pgsql-diff.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-index-pgsql-patch.xml b/odb-tests/common/changelog/add-index-pgsql-patch.xml new file mode 100644 index 0000000..e9c564c --- /dev/null +++ b/odb-tests/common/changelog/add-index-pgsql-patch.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-index-sqlite-diff.xml b/odb-tests/common/changelog/add-index-sqlite-diff.xml new file mode 100644 index 0000000..c1f7fdc --- /dev/null +++ b/odb-tests/common/changelog/add-index-sqlite-diff.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-index-sqlite-patch.xml b/odb-tests/common/changelog/add-index-sqlite-patch.xml new file mode 100644 index 0000000..b9512e0 --- /dev/null +++ b/odb-tests/common/changelog/add-index-sqlite-patch.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-index.hxx b/odb-tests/common/changelog/add-index.hxx new file mode 100644 index 0000000..645cee2 --- /dev/null +++ b/odb-tests/common/changelog/add-index.hxx @@ -0,0 +1,24 @@ +// file : common/changelog/add-index.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ADD_INDEX_HXX +#define ADD_INDEX_HXX + +#pragma db model version(BVER, CVER, open) + +#pragma db object +struct object +{ + #pragma db id auto + int id; + + int x; + +#if CVER > 1 + int y; + #pragma db index ("xy_i") unique member(x) member(y, "DESC") +#endif + +}; + +#endif // ADD_INDEX_HXX diff --git a/odb-tests/common/changelog/add-table-mssql-diff.xml b/odb-tests/common/changelog/add-table-mssql-diff.xml new file mode 100644 index 0000000..8bf0e30 --- /dev/null +++ b/odb-tests/common/changelog/add-table-mssql-diff.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-table-mssql-patch.xml b/odb-tests/common/changelog/add-table-mssql-patch.xml new file mode 100644 index 0000000..9dd41f3 --- /dev/null +++ b/odb-tests/common/changelog/add-table-mssql-patch.xml @@ -0,0 +1,44 @@ + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-table-mysql-diff.xml b/odb-tests/common/changelog/add-table-mysql-diff.xml new file mode 100644 index 0000000..57f741b --- /dev/null +++ b/odb-tests/common/changelog/add-table-mysql-diff.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-table-mysql-patch.xml b/odb-tests/common/changelog/add-table-mysql-patch.xml new file mode 100644 index 0000000..0db1e9f --- /dev/null +++ b/odb-tests/common/changelog/add-table-mysql-patch.xml @@ -0,0 +1,44 @@ + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-table-oracle-diff.xml b/odb-tests/common/changelog/add-table-oracle-diff.xml new file mode 100644 index 0000000..70ec7c6 --- /dev/null +++ b/odb-tests/common/changelog/add-table-oracle-diff.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-table-oracle-patch.xml b/odb-tests/common/changelog/add-table-oracle-patch.xml new file mode 100644 index 0000000..969c2e0 --- /dev/null +++ b/odb-tests/common/changelog/add-table-oracle-patch.xml @@ -0,0 +1,44 @@ + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-table-pgsql-diff.xml b/odb-tests/common/changelog/add-table-pgsql-diff.xml new file mode 100644 index 0000000..9b48062 --- /dev/null +++ b/odb-tests/common/changelog/add-table-pgsql-diff.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-table-pgsql-patch.xml b/odb-tests/common/changelog/add-table-pgsql-patch.xml new file mode 100644 index 0000000..b04a933 --- /dev/null +++ b/odb-tests/common/changelog/add-table-pgsql-patch.xml @@ -0,0 +1,44 @@ + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-table-sqlite-diff.xml b/odb-tests/common/changelog/add-table-sqlite-diff.xml new file mode 100644 index 0000000..573bc69 --- /dev/null +++ b/odb-tests/common/changelog/add-table-sqlite-diff.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-table-sqlite-patch.xml b/odb-tests/common/changelog/add-table-sqlite-patch.xml new file mode 100644 index 0000000..3506410 --- /dev/null +++ b/odb-tests/common/changelog/add-table-sqlite-patch.xml @@ -0,0 +1,44 @@ + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/add-table.hxx b/odb-tests/common/changelog/add-table.hxx new file mode 100644 index 0000000..a22e206 --- /dev/null +++ b/odb-tests/common/changelog/add-table.hxx @@ -0,0 +1,34 @@ +// file : common/changelog/add-table.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ADD_TABLE_HXX +#define ADD_TABLE_HXX + +#include + +#pragma db model version(BVER, CVER, open) + +struct object1; + +#if CVER > 1 +#pragma db object +struct object +{ + #pragma db id auto + int id; + int num; + + std::vector nums; + object1* o1; +}; +#endif + +#pragma db object +struct object1 +{ + #pragma db id + int id; + int num; +}; + +#endif // ADD_TABLE_HXX diff --git a/odb-tests/common/changelog/alter-column-mssql-diff.xml b/odb-tests/common/changelog/alter-column-mssql-diff.xml new file mode 100644 index 0000000..6c1fb6a --- /dev/null +++ b/odb-tests/common/changelog/alter-column-mssql-diff.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/alter-column-mssql-patch.xml b/odb-tests/common/changelog/alter-column-mssql-patch.xml new file mode 100644 index 0000000..15db347 --- /dev/null +++ b/odb-tests/common/changelog/alter-column-mssql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/alter-column-mysql-diff.xml b/odb-tests/common/changelog/alter-column-mysql-diff.xml new file mode 100644 index 0000000..39ad6ef --- /dev/null +++ b/odb-tests/common/changelog/alter-column-mysql-diff.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/alter-column-mysql-patch.xml b/odb-tests/common/changelog/alter-column-mysql-patch.xml new file mode 100644 index 0000000..0131466 --- /dev/null +++ b/odb-tests/common/changelog/alter-column-mysql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/alter-column-oracle-diff.xml b/odb-tests/common/changelog/alter-column-oracle-diff.xml new file mode 100644 index 0000000..d41d333 --- /dev/null +++ b/odb-tests/common/changelog/alter-column-oracle-diff.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/alter-column-oracle-patch.xml b/odb-tests/common/changelog/alter-column-oracle-patch.xml new file mode 100644 index 0000000..0e0794d --- /dev/null +++ b/odb-tests/common/changelog/alter-column-oracle-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/alter-column-pgsql-diff.xml b/odb-tests/common/changelog/alter-column-pgsql-diff.xml new file mode 100644 index 0000000..fd97fa0 --- /dev/null +++ b/odb-tests/common/changelog/alter-column-pgsql-diff.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/alter-column-pgsql-patch.xml b/odb-tests/common/changelog/alter-column-pgsql-patch.xml new file mode 100644 index 0000000..dade1a3 --- /dev/null +++ b/odb-tests/common/changelog/alter-column-pgsql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/alter-column-sqlite-diff.xml b/odb-tests/common/changelog/alter-column-sqlite-diff.xml new file mode 100644 index 0000000..7ecea06 --- /dev/null +++ b/odb-tests/common/changelog/alter-column-sqlite-diff.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/alter-column-sqlite-patch.xml b/odb-tests/common/changelog/alter-column-sqlite-patch.xml new file mode 100644 index 0000000..de2762e --- /dev/null +++ b/odb-tests/common/changelog/alter-column-sqlite-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/alter-column.hxx b/odb-tests/common/changelog/alter-column.hxx new file mode 100644 index 0000000..02f091d --- /dev/null +++ b/odb-tests/common/changelog/alter-column.hxx @@ -0,0 +1,21 @@ +// file : common/changelog/alter-column.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ALTER_COLUMN_HXX +#define ALTER_COLUMN_HXX + +#pragma db model version(BVER, CVER, open) + +#pragma db object +struct object +{ + #pragma db id auto + int id; + +#if CVER > 1 + #pragma db null +#endif + int num; +}; + +#endif // ALTER_COLUMN_HXX diff --git a/odb-tests/common/changelog/buildfile b/odb-tests/common/changelog/buildfile new file mode 100644 index 0000000..04e0685 --- /dev/null +++ b/odb-tests/common/changelog/buildfile @@ -0,0 +1,30 @@ +# file : common/changelog/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +./: file{odb.options} xml{*} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the below ad hoc recipe. +# +libue{test-meta}: $libodb + +file{odb.options}: libue{test-meta} +{{ + pops = $cxx.lib_poptions($<[0]) + depdb hash $pops + + f = $path($>[0]) + rm -f $f + + for o: $pops + echo $o >+$f + end +}} + +# Testscript's run-time prerequisites. +# +testscript@./: test = $odb + +./: $odb: clean = false diff --git a/odb-tests/common/changelog/drop-column-mssql-diff.xml b/odb-tests/common/changelog/drop-column-mssql-diff.xml new file mode 100644 index 0000000..f2bab96 --- /dev/null +++ b/odb-tests/common/changelog/drop-column-mssql-diff.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-column-mssql-patch.xml b/odb-tests/common/changelog/drop-column-mssql-patch.xml new file mode 100644 index 0000000..32402a3 --- /dev/null +++ b/odb-tests/common/changelog/drop-column-mssql-patch.xml @@ -0,0 +1,12 @@ + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-column-mysql-diff.xml b/odb-tests/common/changelog/drop-column-mysql-diff.xml new file mode 100644 index 0000000..2bb321d --- /dev/null +++ b/odb-tests/common/changelog/drop-column-mysql-diff.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-column-mysql-patch.xml b/odb-tests/common/changelog/drop-column-mysql-patch.xml new file mode 100644 index 0000000..6572ebe --- /dev/null +++ b/odb-tests/common/changelog/drop-column-mysql-patch.xml @@ -0,0 +1,12 @@ + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-column-oracle-diff.xml b/odb-tests/common/changelog/drop-column-oracle-diff.xml new file mode 100644 index 0000000..e920a12 --- /dev/null +++ b/odb-tests/common/changelog/drop-column-oracle-diff.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-column-oracle-patch.xml b/odb-tests/common/changelog/drop-column-oracle-patch.xml new file mode 100644 index 0000000..b113664 --- /dev/null +++ b/odb-tests/common/changelog/drop-column-oracle-patch.xml @@ -0,0 +1,12 @@ + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-column-pgsql-diff.xml b/odb-tests/common/changelog/drop-column-pgsql-diff.xml new file mode 100644 index 0000000..d2e91ba --- /dev/null +++ b/odb-tests/common/changelog/drop-column-pgsql-diff.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-column-pgsql-patch.xml b/odb-tests/common/changelog/drop-column-pgsql-patch.xml new file mode 100644 index 0000000..06cc73d --- /dev/null +++ b/odb-tests/common/changelog/drop-column-pgsql-patch.xml @@ -0,0 +1,12 @@ + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-column-sqlite-diff.xml b/odb-tests/common/changelog/drop-column-sqlite-diff.xml new file mode 100644 index 0000000..1c9d138 --- /dev/null +++ b/odb-tests/common/changelog/drop-column-sqlite-diff.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-column-sqlite-patch.xml b/odb-tests/common/changelog/drop-column-sqlite-patch.xml new file mode 100644 index 0000000..6887530 --- /dev/null +++ b/odb-tests/common/changelog/drop-column-sqlite-patch.xml @@ -0,0 +1,12 @@ + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-column.hxx b/odb-tests/common/changelog/drop-column.hxx new file mode 100644 index 0000000..3de237d --- /dev/null +++ b/odb-tests/common/changelog/drop-column.hxx @@ -0,0 +1,20 @@ +// file : common/changelog/drop-column.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef DROP_COLUMN_HXX +#define DROP_COLUMN_HXX + +#pragma db model version(BVER, CVER, open) + +#pragma db object +struct object +{ + #pragma db id auto + int id; + +#if CVER == 1 + int num; +#endif +}; + +#endif // DROP_COLUMN_HXX diff --git a/odb-tests/common/changelog/drop-foreign-key-mssql-diff.xml b/odb-tests/common/changelog/drop-foreign-key-mssql-diff.xml new file mode 100644 index 0000000..da3ce73 --- /dev/null +++ b/odb-tests/common/changelog/drop-foreign-key-mssql-diff.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-foreign-key-mssql-patch.xml b/odb-tests/common/changelog/drop-foreign-key-mssql-patch.xml new file mode 100644 index 0000000..cd1a372 --- /dev/null +++ b/odb-tests/common/changelog/drop-foreign-key-mssql-patch.xml @@ -0,0 +1,18 @@ + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-foreign-key-mysql-diff.xml b/odb-tests/common/changelog/drop-foreign-key-mysql-diff.xml new file mode 100644 index 0000000..aa179f2 --- /dev/null +++ b/odb-tests/common/changelog/drop-foreign-key-mysql-diff.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-foreign-key-mysql-patch.xml b/odb-tests/common/changelog/drop-foreign-key-mysql-patch.xml new file mode 100644 index 0000000..67f026e --- /dev/null +++ b/odb-tests/common/changelog/drop-foreign-key-mysql-patch.xml @@ -0,0 +1,18 @@ + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-foreign-key-oracle-diff.xml b/odb-tests/common/changelog/drop-foreign-key-oracle-diff.xml new file mode 100644 index 0000000..aa407d3 --- /dev/null +++ b/odb-tests/common/changelog/drop-foreign-key-oracle-diff.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-foreign-key-oracle-patch.xml b/odb-tests/common/changelog/drop-foreign-key-oracle-patch.xml new file mode 100644 index 0000000..56253f0 --- /dev/null +++ b/odb-tests/common/changelog/drop-foreign-key-oracle-patch.xml @@ -0,0 +1,18 @@ + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-foreign-key-pgsql-diff.xml b/odb-tests/common/changelog/drop-foreign-key-pgsql-diff.xml new file mode 100644 index 0000000..9a6259a --- /dev/null +++ b/odb-tests/common/changelog/drop-foreign-key-pgsql-diff.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-foreign-key-pgsql-patch.xml b/odb-tests/common/changelog/drop-foreign-key-pgsql-patch.xml new file mode 100644 index 0000000..df024b4 --- /dev/null +++ b/odb-tests/common/changelog/drop-foreign-key-pgsql-patch.xml @@ -0,0 +1,18 @@ + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-foreign-key-sqlite-diff.xml b/odb-tests/common/changelog/drop-foreign-key-sqlite-diff.xml new file mode 100644 index 0000000..6f9f994 --- /dev/null +++ b/odb-tests/common/changelog/drop-foreign-key-sqlite-diff.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-foreign-key-sqlite-patch.xml b/odb-tests/common/changelog/drop-foreign-key-sqlite-patch.xml new file mode 100644 index 0000000..6e63218 --- /dev/null +++ b/odb-tests/common/changelog/drop-foreign-key-sqlite-patch.xml @@ -0,0 +1,18 @@ + + + + + + + + + +
+ + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-foreign-key.hxx b/odb-tests/common/changelog/drop-foreign-key.hxx new file mode 100644 index 0000000..ba3005f --- /dev/null +++ b/odb-tests/common/changelog/drop-foreign-key.hxx @@ -0,0 +1,29 @@ +// file : common/changelog/drop-foreign-key.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef DROP_FOREIGN_KEY_HXX +#define DROP_FOREIGN_KEY_HXX + +#pragma db model version(BVER, CVER, open) + +struct object1; + +#pragma db object +struct object +{ + #pragma db id auto + int id; + +#if CVER == 1 + object1* o1; +#endif +}; + +#pragma db object +struct object1 +{ + #pragma db id + int id; +}; + +#endif // DROP_FOREIGN_KEY_HXX diff --git a/odb-tests/common/changelog/drop-index-mssql-diff.xml b/odb-tests/common/changelog/drop-index-mssql-diff.xml new file mode 100644 index 0000000..ac95db5 --- /dev/null +++ b/odb-tests/common/changelog/drop-index-mssql-diff.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-index-mssql-patch.xml b/odb-tests/common/changelog/drop-index-mssql-patch.xml new file mode 100644 index 0000000..4f396d9 --- /dev/null +++ b/odb-tests/common/changelog/drop-index-mssql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-index-mysql-diff.xml b/odb-tests/common/changelog/drop-index-mysql-diff.xml new file mode 100644 index 0000000..f8c95ef --- /dev/null +++ b/odb-tests/common/changelog/drop-index-mysql-diff.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-index-mysql-patch.xml b/odb-tests/common/changelog/drop-index-mysql-patch.xml new file mode 100644 index 0000000..14f3f01 --- /dev/null +++ b/odb-tests/common/changelog/drop-index-mysql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-index-oracle-diff.xml b/odb-tests/common/changelog/drop-index-oracle-diff.xml new file mode 100644 index 0000000..d174802 --- /dev/null +++ b/odb-tests/common/changelog/drop-index-oracle-diff.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-index-oracle-patch.xml b/odb-tests/common/changelog/drop-index-oracle-patch.xml new file mode 100644 index 0000000..38fb8d6 --- /dev/null +++ b/odb-tests/common/changelog/drop-index-oracle-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-index-pgsql-diff.xml b/odb-tests/common/changelog/drop-index-pgsql-diff.xml new file mode 100644 index 0000000..375a3d8 --- /dev/null +++ b/odb-tests/common/changelog/drop-index-pgsql-diff.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-index-pgsql-patch.xml b/odb-tests/common/changelog/drop-index-pgsql-patch.xml new file mode 100644 index 0000000..7f7d9a0 --- /dev/null +++ b/odb-tests/common/changelog/drop-index-pgsql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-index-sqlite-diff.xml b/odb-tests/common/changelog/drop-index-sqlite-diff.xml new file mode 100644 index 0000000..bf54f9d --- /dev/null +++ b/odb-tests/common/changelog/drop-index-sqlite-diff.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-index-sqlite-patch.xml b/odb-tests/common/changelog/drop-index-sqlite-patch.xml new file mode 100644 index 0000000..fbe4428 --- /dev/null +++ b/odb-tests/common/changelog/drop-index-sqlite-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-index.hxx b/odb-tests/common/changelog/drop-index.hxx new file mode 100644 index 0000000..08fecba --- /dev/null +++ b/odb-tests/common/changelog/drop-index.hxx @@ -0,0 +1,21 @@ +// file : common/changelog/drop-index.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef DROP_INDEX_HXX +#define DROP_INDEX_HXX + +#pragma db model version(BVER, CVER, open) + +#pragma db object +struct object +{ + #pragma db id auto + int id; + +#if CVER == 1 + #pragma db index +#endif + int num; +}; + +#endif // DROP_INDEX_HXX diff --git a/odb-tests/common/changelog/drop-table-mssql-diff.xml b/odb-tests/common/changelog/drop-table-mssql-diff.xml new file mode 100644 index 0000000..399d8bc --- /dev/null +++ b/odb-tests/common/changelog/drop-table-mssql-diff.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-table-mssql-patch.xml b/odb-tests/common/changelog/drop-table-mssql-patch.xml new file mode 100644 index 0000000..c5dda75 --- /dev/null +++ b/odb-tests/common/changelog/drop-table-mssql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-table-mysql-diff.xml b/odb-tests/common/changelog/drop-table-mysql-diff.xml new file mode 100644 index 0000000..3ccd553 --- /dev/null +++ b/odb-tests/common/changelog/drop-table-mysql-diff.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-table-mysql-patch.xml b/odb-tests/common/changelog/drop-table-mysql-patch.xml new file mode 100644 index 0000000..250bd20 --- /dev/null +++ b/odb-tests/common/changelog/drop-table-mysql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-table-oracle-diff.xml b/odb-tests/common/changelog/drop-table-oracle-diff.xml new file mode 100644 index 0000000..589d64b --- /dev/null +++ b/odb-tests/common/changelog/drop-table-oracle-diff.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-table-oracle-patch.xml b/odb-tests/common/changelog/drop-table-oracle-patch.xml new file mode 100644 index 0000000..5f222dc --- /dev/null +++ b/odb-tests/common/changelog/drop-table-oracle-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-table-pgsql-diff.xml b/odb-tests/common/changelog/drop-table-pgsql-diff.xml new file mode 100644 index 0000000..168ec46 --- /dev/null +++ b/odb-tests/common/changelog/drop-table-pgsql-diff.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-table-pgsql-patch.xml b/odb-tests/common/changelog/drop-table-pgsql-patch.xml new file mode 100644 index 0000000..ebb7000 --- /dev/null +++ b/odb-tests/common/changelog/drop-table-pgsql-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-table-sqlite-diff.xml b/odb-tests/common/changelog/drop-table-sqlite-diff.xml new file mode 100644 index 0000000..6a258c4 --- /dev/null +++ b/odb-tests/common/changelog/drop-table-sqlite-diff.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-table-sqlite-patch.xml b/odb-tests/common/changelog/drop-table-sqlite-patch.xml new file mode 100644 index 0000000..45c6f00 --- /dev/null +++ b/odb-tests/common/changelog/drop-table-sqlite-patch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/drop-table.hxx b/odb-tests/common/changelog/drop-table.hxx new file mode 100644 index 0000000..2919e52 --- /dev/null +++ b/odb-tests/common/changelog/drop-table.hxx @@ -0,0 +1,34 @@ +// file : common/changelog/drop-table.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef DROP_TABLE_HXX +#define DROP_TABLE_HXX + +#include + +#pragma db model version(BVER, CVER, open) + +struct object1; + +#if CVER == 1 +#pragma db object +struct object +{ + #pragma db id auto + int id; + int num; + + std::vector nums; + object1* o1; +}; +#endif + +#pragma db object +struct object1 +{ + #pragma db id + int id; + int num; +}; + +#endif // DROP_TABLE_HXX diff --git a/odb-tests/common/changelog/model-mssql-diff.xml b/odb-tests/common/changelog/model-mssql-diff.xml new file mode 120000 index 0000000..e1f812d --- /dev/null +++ b/odb-tests/common/changelog/model-mssql-diff.xml @@ -0,0 +1 @@ +model-mssql.xml \ No newline at end of file diff --git a/odb-tests/common/changelog/model-mssql-patch.xml b/odb-tests/common/changelog/model-mssql-patch.xml new file mode 120000 index 0000000..e1f812d --- /dev/null +++ b/odb-tests/common/changelog/model-mssql-patch.xml @@ -0,0 +1 @@ +model-mssql.xml \ No newline at end of file diff --git a/odb-tests/common/changelog/model-mssql.xml b/odb-tests/common/changelog/model-mssql.xml new file mode 100644 index 0000000..509a210 --- /dev/null +++ b/odb-tests/common/changelog/model-mssql.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/model-mysql-diff.xml b/odb-tests/common/changelog/model-mysql-diff.xml new file mode 120000 index 0000000..9100280 --- /dev/null +++ b/odb-tests/common/changelog/model-mysql-diff.xml @@ -0,0 +1 @@ +model-mysql.xml \ No newline at end of file diff --git a/odb-tests/common/changelog/model-mysql-patch.xml b/odb-tests/common/changelog/model-mysql-patch.xml new file mode 120000 index 0000000..9100280 --- /dev/null +++ b/odb-tests/common/changelog/model-mysql-patch.xml @@ -0,0 +1 @@ +model-mysql.xml \ No newline at end of file diff --git a/odb-tests/common/changelog/model-mysql.xml b/odb-tests/common/changelog/model-mysql.xml new file mode 100644 index 0000000..ffbcf8d --- /dev/null +++ b/odb-tests/common/changelog/model-mysql.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/model-oracle-diff.xml b/odb-tests/common/changelog/model-oracle-diff.xml new file mode 120000 index 0000000..36e4479 --- /dev/null +++ b/odb-tests/common/changelog/model-oracle-diff.xml @@ -0,0 +1 @@ +model-oracle.xml \ No newline at end of file diff --git a/odb-tests/common/changelog/model-oracle-patch.xml b/odb-tests/common/changelog/model-oracle-patch.xml new file mode 120000 index 0000000..36e4479 --- /dev/null +++ b/odb-tests/common/changelog/model-oracle-patch.xml @@ -0,0 +1 @@ +model-oracle.xml \ No newline at end of file diff --git a/odb-tests/common/changelog/model-oracle.xml b/odb-tests/common/changelog/model-oracle.xml new file mode 100644 index 0000000..1824690 --- /dev/null +++ b/odb-tests/common/changelog/model-oracle.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/model-pgsql-diff.xml b/odb-tests/common/changelog/model-pgsql-diff.xml new file mode 120000 index 0000000..b39ce26 --- /dev/null +++ b/odb-tests/common/changelog/model-pgsql-diff.xml @@ -0,0 +1 @@ +model-pgsql.xml \ No newline at end of file diff --git a/odb-tests/common/changelog/model-pgsql-patch.xml b/odb-tests/common/changelog/model-pgsql-patch.xml new file mode 120000 index 0000000..b39ce26 --- /dev/null +++ b/odb-tests/common/changelog/model-pgsql-patch.xml @@ -0,0 +1 @@ +model-pgsql.xml \ No newline at end of file diff --git a/odb-tests/common/changelog/model-pgsql.xml b/odb-tests/common/changelog/model-pgsql.xml new file mode 100644 index 0000000..13aee6b --- /dev/null +++ b/odb-tests/common/changelog/model-pgsql.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/model-sqlite-diff.xml b/odb-tests/common/changelog/model-sqlite-diff.xml new file mode 120000 index 0000000..3454f51 --- /dev/null +++ b/odb-tests/common/changelog/model-sqlite-diff.xml @@ -0,0 +1 @@ +model-sqlite.xml \ No newline at end of file diff --git a/odb-tests/common/changelog/model-sqlite-patch.xml b/odb-tests/common/changelog/model-sqlite-patch.xml new file mode 120000 index 0000000..3454f51 --- /dev/null +++ b/odb-tests/common/changelog/model-sqlite-patch.xml @@ -0,0 +1 @@ +model-sqlite.xml \ No newline at end of file diff --git a/odb-tests/common/changelog/model-sqlite.xml b/odb-tests/common/changelog/model-sqlite.xml new file mode 100644 index 0000000..d0199ed --- /dev/null +++ b/odb-tests/common/changelog/model-sqlite.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + +
+
+
diff --git a/odb-tests/common/changelog/model.hxx b/odb-tests/common/changelog/model.hxx new file mode 100644 index 0000000..aa8891a --- /dev/null +++ b/odb-tests/common/changelog/model.hxx @@ -0,0 +1,46 @@ +// file : common/changelog/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_HXX +#define MODEL_HXX + +#include + +#pragma db model version(1, 1, open) + +#pragma db value +struct value +{ + int x; + int y; +}; + +struct object1; + +#pragma db object +struct object +{ + #pragma db id auto + int id; + + #pragma db null default(0) options("DUMMY=1") + int num; + + #pragma db index unique member(num, "DESC") method("BTREE") options("DUMMY=1") + + #pragma db index + value v; // Multi-column. + + std::vector nums; + object1* o1; +}; + +#pragma db object +struct object1 +{ + #pragma db id + value id; // Multi-column. + int num; +}; + +#endif // MODEL_HXX diff --git a/odb-tests/common/changelog/testscript b/odb-tests/common/changelog/testscript new file mode 100644 index 0000000..9368938 --- /dev/null +++ b/odb-tests/common/changelog/testscript @@ -0,0 +1,66 @@ +# file : common/changelog/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +headers = [paths] $path_search($src_base/*.hxx) + +odb_options = --generate-schema-only \ + --schema-format sql \ + --suppress-migration \ + --options-file $out_base/odb.options + +: mysql +: +if $mysql +{ + odb_options += --database 'mysql' --changelog-dir $~ + + for h: $headers + n = $base($leaf($h)) + + $* $odb_options -DBVER=1 -DCVER=1 --init-changelog $h &$(n).xml &$(n).sql + + $* $odb_options -DBVER=1 -DCVER=2 $h + diff $src_base/$n-mysql-diff.xml $(n).xml + + $* $odb_options -DBVER=2 -DCVER=3 $h + diff $src_base/$n-mysql-patch.xml $(n).xml + end +} + +: sqlite +: +if $sqlite +{ + odb_options += --database 'sqlite' --changelog-dir $~ + + for h: $headers + n = $base($leaf($h)) + + $* $odb_options -DBVER=1 -DCVER=1 --init-changelog $h &$(n).xml &$(n).sql + + $* $odb_options -DBVER=1 -DCVER=2 $h + diff $src_base/$n-sqlite-diff.xml $(n).xml + + $* $odb_options -DBVER=2 -DCVER=3 $h + diff $src_base/$n-sqlite-patch.xml $(n).xml + end +} + +: pgsql +: +if $pgsql +{ + odb_options += --database 'pgsql' --changelog-dir $~ + + for h: $headers + n = $base($leaf($h)) + + $* $odb_options -DBVER=1 -DCVER=1 --init-changelog $h &$(n).xml &$(n).sql + + $* $odb_options -DBVER=1 -DCVER=2 $h + diff $src_base/$n-pgsql-diff.xml $(n).xml + + $* $odb_options -DBVER=2 -DCVER=3 $h + diff $src_base/$n-pgsql-patch.xml $(n).xml + end +} diff --git a/odb-tests/common/circular/multiple/.gitignore b/odb-tests/common/circular/multiple/.gitignore new file mode 100644 index 0000000..5d39d39 --- /dev/null +++ b/odb-tests/common/circular/multiple/.gitignore @@ -0,0 +1,6 @@ +# ODB-generated files. +# +test1-odb.?xx +test1-odb-*.?xx +test2-odb.?xx +test2-odb-*.?xx diff --git a/odb-tests/common/circular/multiple/buildfile b/odb-tests/common/circular/multiple/buildfile new file mode 100644 index 0000000..b060cb5 --- /dev/null +++ b/odb-tests/common/circular/multiple/buildfile @@ -0,0 +1,49 @@ +# file : common/circular/multiple/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +hs = test1 test2 + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +for h: $hs +{ + exe{driver}: {hxx ixx cxx}{$h-odb} + + <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} + + for db: $databases + { + exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi + <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} + } +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix circular_m_ \ + --generate-schema \ + --generate-query \ + --schema-format embedded + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/circular/multiple/driver.cxx b/odb-tests/common/circular/multiple/driver.cxx new file mode 100644 index 0000000..4887ac2 --- /dev/null +++ b/odb-tests/common/circular/multiple/driver.cxx @@ -0,0 +1,69 @@ +// file : common/circular/multiple/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test cases of circular dependencies between persistent classes, multiple +// files version. +// + +#include // std::unique_ptr +#include + +#include +#include +#include +#include + +#include + +#include "test1.hxx" +#include "test2.hxx" + +#include "test2-odb.hxx" +#include "test1-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv, false)); + + // Create the database schema. + // + { + connection_ptr c (db->connection ()); + + // Temporarily disable foreign key constraints for MySQL and SQLite. + // For these databases this is the only way to drop circularly- + // dependant tables. + // + if (db->id () == odb::id_mysql) + c->execute ("SET FOREIGN_KEY_CHECKS=0"); + else if (db->id () == odb::id_sqlite) + c->execute ("PRAGMA foreign_keys=OFF"); + + transaction t (c->begin ()); + schema_catalog::create_schema (*db); + t.commit (); + + if (db->id () == odb::id_mysql) + c->execute ("SET FOREIGN_KEY_CHECKS=1"); + else if (db->id () == odb::id_sqlite) + c->execute ("PRAGMA foreign_keys=ON"); + } + + query bq (query::d->id != 0); + query dq (query::b->id != 0); + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/circular/multiple/test1.hxx b/odb-tests/common/circular/multiple/test1.hxx new file mode 100644 index 0000000..36df963 --- /dev/null +++ b/odb-tests/common/circular/multiple/test1.hxx @@ -0,0 +1,27 @@ +// file : common/circular/multiple/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#include + +#pragma db object +struct derived; + +#pragma db object polymorphic +struct base +{ + virtual ~base () {} + + #pragma db id + unsigned long id_; + + derived* d_; +}; + +#ifdef ODB_COMPILER +# include "test2.hxx" +#endif + +#endif // TEST1_HXX diff --git a/odb-tests/common/circular/multiple/test2.hxx b/odb-tests/common/circular/multiple/test2.hxx new file mode 100644 index 0000000..49e9ed2 --- /dev/null +++ b/odb-tests/common/circular/multiple/test2.hxx @@ -0,0 +1,17 @@ +// file : common/circular/multiple/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#include + +#include "test1.hxx" + +#pragma db object +struct derived: base +{ + base* b_; +}; + +#endif // TEST2_HXX diff --git a/odb-tests/common/circular/multiple/testscript b/odb-tests/common/circular/multiple/testscript new file mode 100644 index 0000000..6a05dc6 --- /dev/null +++ b/odb-tests/common/circular/multiple/testscript @@ -0,0 +1,31 @@ +# file : common/circular/multiple/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $* +} diff --git a/odb-tests/common/circular/single/buildfile b/odb-tests/common/circular/single/buildfile new file mode 100644 index 0000000..740ce91 --- /dev/null +++ b/odb-tests/common/circular/single/buildfile @@ -0,0 +1,41 @@ +# file : common/circular/single/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix circular_s_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/circular/single/driver.cxx b/odb-tests/common/circular/single/driver.cxx new file mode 100644 index 0000000..9bcb135 --- /dev/null +++ b/odb-tests/common/circular/single/driver.cxx @@ -0,0 +1,40 @@ +// file : common/circular/single/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test cases of circular dependencies between persistent classes, single +// file version. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + query bq (query::d->id != 0); + query dq (query::b->id != 0); + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/circular/single/test.hxx b/odb-tests/common/circular/single/test.hxx new file mode 100644 index 0000000..7f95dea --- /dev/null +++ b/odb-tests/common/circular/single/test.hxx @@ -0,0 +1,28 @@ +// file : common/circular/single/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +struct derived; + +#pragma db object polymorphic +struct base +{ + virtual ~base () {} + + #pragma db id + unsigned long id_; + + derived* d_; +}; + +#pragma db object +struct derived: base +{ + base* b_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/circular/single/testscript b/odb-tests/common/circular/single/testscript new file mode 100644 index 0000000..b870306 --- /dev/null +++ b/odb-tests/common/circular/single/testscript @@ -0,0 +1,33 @@ +# file : common/circular/single/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/composite/buildfile b/odb-tests/common/composite/buildfile new file mode 100644 index 0000000..0a60638 --- /dev/null +++ b/odb-tests/common/composite/buildfile @@ -0,0 +1,41 @@ +# file : common/composite/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_comp_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/composite/driver.cxx b/odb-tests/common/composite/driver.cxx new file mode 100644 index 0000000..06b24b2 --- /dev/null +++ b/odb-tests/common/composite/driver.cxx @@ -0,0 +1,229 @@ +// file : common/composite/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test composite value types. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +#undef NDEBUG +#include + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test basic composite functionality. + // + for (unsigned short i (0); i < 2; ++i) + { + using namespace test1; + + person p (1); + p.name_.first = "Joe"; + p.name_.last = "Dirt"; + p.name_.title = "Mr"; + p.name_.alias.first = "Anthony"; + p.name_.alias.last = "Clean"; + p.name_.nick = "Squeaky"; + p.name_.flags.nick = true; + p.name_.flags.alias = false; + p.age_ = 32; + + // persist + // + { + transaction t (db->begin ()); + db->persist (p); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (1)); + t.commit (); + + assert (p == *p1); + } + + p.name_.title = "Mrs"; + p.name_.alias.first = "Anthonia"; + p.name_.flags.nick = false; + p.name_.flags.alias = true; + + // update + // + { + transaction t (db->begin ()); + db->update (p); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (1)); + t.commit (); + + assert (p == *p1); + } + + typedef odb::query query; + typedef odb::result result; + + // query + // + { + transaction t (db->begin ()); + + result r (db->query (query::name.first == "Joe")); + + assert (!r.empty ()); + assert (*r.begin () == p); + assert (size (r) == 1); + + t.commit (); + } + + // query + // + { + transaction t (db->begin ()); + + result r (db->query (query::name.flags.alias)); + + assert (!r.empty ()); + assert (*r.begin () == p); + assert (size (r) == 1); + + t.commit (); + } + + // erase + // + if (i == 0) + { + transaction t (db->begin ()); + db->erase (1); + t.commit (); + } + } + + // Test composite class template instantiation. + // + { + using namespace test2; + + object o (1); + + o.comp_.num = 123; + o.comp_.str = "abc"; + o.comp_.vec.push_back (int_str_pair (123, "abc")); + o.comp_.vec.push_back (int_str_pair (234, "bcd")); + o.comp_.vec.push_back (int_str_pair (345, "cde")); + + o.pair_.first = 123; + o.pair_.second = "abc"; + + o.vec_.push_back (int_str_pair (123, "abc")); + o.vec_.push_back (int_str_pair (234, "bcd")); + o.vec_.push_back (int_str_pair (345, "cde")); + + // persist + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + } + + // Test empty column name. + // + { + using namespace test3; + + object o (1); + o.c_.str = "abc"; + + // persist + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + } + + // Test composite definition inside object. + { + using namespace test4; + + object o (1); + o.str ("abc"); + o.x (123); + o.y (234); + + // persist + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/composite/test.hxx b/odb-tests/common/composite/test.hxx new file mode 100644 index 0000000..13b2025 --- /dev/null +++ b/odb-tests/common/composite/test.hxx @@ -0,0 +1,250 @@ +// file : common/composite/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include // std::pair + +#include + +// Test basic composite functionality. +// +#pragma db namespace table("t1_") +namespace test1 +{ + #pragma db value + struct name + { + std::string first; + std::string last; + }; + + #pragma db value + struct name_title + { + std::string title; + }; + + #pragma db value + struct name_title_ex: name_title + { + // Test value types without data members. + }; + + #pragma db value + struct name_flags + { + bool nick; + bool alias; + }; + + #pragma db value + struct name_ex: name, name_title_ex + { + name alias; + std::string nick; + + #pragma db column("show_") + name_flags flags; + }; + + #pragma db object + struct person + { + person () {} + person (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db column("") + name_ex name_; + + unsigned short age_; + }; + + inline bool + operator== (const person& x, const person& y) + { + return x.id_ == y.id_ && + x.name_.first == y.name_.first&& + x.name_.last == y.name_.last && + x.name_.title == y.name_.title && + x.name_.alias.first == y.name_.alias.first && + x.name_.alias.last == y.name_.alias.last && + x.name_.nick == y.name_.nick && + x.name_.flags.nick == y.name_.flags.nick && + x.name_.flags.alias == y.name_.flags.alias && + x.age_ == y.age_; + } +} + +// Test composite class template instantiation. +// +#pragma db namespace table("t2_") +namespace test2 +{ + template + struct comp + { + I num; + S str; + std::vector > vec; + }; + + template + inline bool + operator== (const comp& x, const comp& y) + { + return x.num == y.num && x.str == y.str && x.vec == y.vec; + } + + typedef std::pair int_str_pair; + #pragma db value(int_str_pair) + + // Make sure we use the name that was specified in the pragma. + // +#ifdef ODB_COMPILER + typedef comp int_str_comp1; +#endif + + typedef comp int_str_comp; + #pragma db value(int_str_comp) + + #pragma db object + struct object + { + object () {} + object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + comp comp_; + std::pair pair_; + std::vector vec_; + }; + + inline bool + operator== (const object& x, const object& y) + { + return x.id_ == y.id_ && + x.comp_ == y.comp_ && + x.pair_ == y.pair_ && + x.vec_ == y.vec_; + } +} + +// Test empty column name. +// +#pragma db namespace table("t3_") +namespace test3 +{ + #pragma db value + struct comp + { + #pragma db column("") + std::string str; + }; + + #pragma db object + struct object + { + object () {} + object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + comp c_; + }; + + inline bool + operator== (const object& x, const object& y) + { + return x.id_ == y.id_ && x.c_.str == y.c_.str; + } +} + +// Test composite definition inside object. +// +#pragma db namespace table("t4_") +namespace test4 +{ + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + unsigned long id () const {return id_;} + + void str (const std::string& s) {c_.str = s;} + const std::string& str () const {return c_.str;} + + void x (int i) {p_.first = i;} + int x () const {return p_.first;} + + void y (int i) {p_.second = i;} + int y () const {return p_.second;} + + private: + friend class odb::access; + + #pragma db id + unsigned long id_; + + #pragma db value + struct comp + { + std::string str; + }; + + comp c_; + + typedef std::pair int_pair; + #pragma db value(int_pair) + + int_pair p_; + }; + + inline bool + operator== (const object& x, const object& y) + { + return x.id () == y.id () && x.str () == y.str () && + x.x () == y.x () && x.y () == y.y (); + } +} + +// Test composite name clashes in query columns (compilation test) +// +#pragma db namespace table("t5_") +namespace test5 +{ + // Class-member conflict. + // + #pragma db value + struct value {int value_;}; + + // Class-class conflict. + // + #pragma db value + struct inner {int value;}; + + #pragma db value + struct outer {inner value;}; + + #pragma db object + struct object + { + #pragma db id + int id; + + outer value; + test5::value v; + }; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/composite/testscript b/odb-tests/common/composite/testscript new file mode 100644 index 0000000..0747507 --- /dev/null +++ b/odb-tests/common/composite/testscript @@ -0,0 +1,33 @@ +# file : common/composite/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/const-member/buildfile b/odb-tests/common/const-member/buildfile new file mode 100644 index 0000000..868f7fd --- /dev/null +++ b/odb-tests/common/const-member/buildfile @@ -0,0 +1,40 @@ +# file : common/const-member/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix constm_ \ + --generate-schema + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/const-member/driver.cxx b/odb-tests/common/const-member/driver.cxx new file mode 100644 index 0000000..0c71dfa --- /dev/null +++ b/odb-tests/common/const-member/driver.cxx @@ -0,0 +1,119 @@ +// file : common/const-member/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test const data members. The readonly test tests that const +// members are automatically treated as read-only. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Const ids. + // + { + const_id o (1); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + db->load (1, o); + t.commit (); + assert (o.id == 1); + } + } + + { + { + const_auto_id o; + transaction t (db->begin ()); + db->persist (o); + t.commit (); + assert (o.id == 1); + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (1)); + t.commit (); + assert (o->id == 1); + } + } + + // Container. + // + { + container o (1, 1); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (1)); + t.commit (); + + assert (o->ccom.vec.size () == 1 && o->ccom.vec[0] == 1 && + o->ccom.cvec.size () == 1 && o->ccom.cvec[0] == 1 && + o->cvec.size () == 1 && o->cvec[0] == 1); + } + } + + // Wrapper. + // + { + wrapper o (1, "abc", 1); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (1)); + t.commit (); + + assert (*o->str == "abc" && + o->com->str == "abc" && o->com->num == 1 && + o->com->vec.size () == 1 && o->com->vec[0] == 1 && + o->vec->size () == 1 && (*o->vec)[0] == 1); + } + } + + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/const-member/test.hxx b/odb-tests/common/const-member/test.hxx new file mode 100644 index 0000000..ab75c55 --- /dev/null +++ b/odb-tests/common/const-member/test.hxx @@ -0,0 +1,109 @@ +// file : common/const-member/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include // std::auto_ptr + +#include + +// Const ids. +// +#pragma db object +struct const_id +{ + const_id (unsigned long i): id (i) {} + const_id (): id (0) {} + + #pragma db id + const unsigned long id; +}; + +#pragma db object +struct const_auto_id +{ + const_auto_id (): id (0) {} + + #pragma db id auto + const unsigned long id; +}; + +// Container. +// +#pragma db value +struct container_value +{ + container_value (unsigned long x) + { + vec.push_back (x); + const_cast&> (cvec).push_back (x); + } + + container_value () {} + + std::vector vec; + const std::vector cvec; +}; + +#pragma db object +struct container +{ + container (unsigned long i, unsigned long x) + : id (i), ccom (x) + { + const_cast&> (cvec).push_back (x); + } + + container () {} + + #pragma db id + unsigned long id; + + const container_value ccom; + const std::vector cvec; +}; + +// Wrapper. +// +#pragma db value +struct wrapped_value +{ + wrapped_value (const std::string& s, unsigned long n) + : str (s), num (n) + { + vec.push_back (n); + } + + wrapped_value () {} + + const std::string str; + unsigned long num; + std::vector vec; +}; + +#pragma db object +struct wrapper +{ + wrapper (unsigned long i, const std::string& s, unsigned long n) + : id (i), + str (new std::string (s)), + com (new wrapped_value (s, n)), + vec (new std::vector) + { + const_cast&> (*vec).push_back (n); + } + + wrapper () {} + + #pragma db id + unsigned long id; + + const std::unique_ptr str; + const std::unique_ptr com; + const std::unique_ptr> vec; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/const-member/testscript b/odb-tests/common/const-member/testscript new file mode 100644 index 0000000..c81d856 --- /dev/null +++ b/odb-tests/common/const-member/testscript @@ -0,0 +1,33 @@ +# file : common/const-member/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/const-object/buildfile b/odb-tests/common/const-object/buildfile new file mode 100644 index 0000000..853c831 --- /dev/null +++ b/odb-tests/common/const-object/buildfile @@ -0,0 +1,41 @@ +# file : common/const-object/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix consto_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/const-object/driver.cxx b/odb-tests/common/const-object/driver.cxx new file mode 100644 index 0000000..7ef48ee --- /dev/null +++ b/odb-tests/common/const-object/driver.cxx @@ -0,0 +1,216 @@ +// file : common/const-object/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test database operations with const objects. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + aggr a (1); + aggr ca_ (2); // o1 and o2 are NULL + const aggr& ca (ca_); + + obj1* o1 (new obj1 (1)); + obj1* co1_ (new obj1 (2)); + const obj1* co1 (co1_); + a.o1 = co1; + + unique_ptr o2 (new obj2 (1)); + obj2* co2_ (new obj2 (2)); + a.o2.reset (co2_); + unique_ptr& co2 (a.o2); + + // persist via references + // + { + transaction t (db->begin ()); + db->persist (*o1); + db->persist (*co1); + db->persist (*o2); + db->persist (*co2); + db->persist (a); + db->persist (ca); + t.commit (); + } + + // persist via pointers + // + o1->id += 2; + co1_->id += 2; + o2->id += 2; + co2_->id += 2; + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (co1); + db->persist (o2); + db->persist (co2); + t.commit (); + } + + // load & compare + // + { + transaction t (db->begin ()); + + unique_ptr a (db->load (1)); + unique_ptr ca (db->load (2)); + + t.commit (); + + assert (a->o1->id == 2); + assert (a->o2->id == 2); + + assert (ca->o1 == 0); + assert (ca->o2.get () == 0); + } + + // update via references + // + { + transaction t (db->begin ()); + db->update (*o1); + db->update (*co1); + db->update (*o2); + db->update (*co2); + db->update (a); + db->update (ca); + t.commit (); + } + + // update via pointers + // + { + transaction t (db->begin ()); + db->update (o1); + db->update (co1); + db->update (o2); + db->update (co2); + t.commit (); + } + + // query + // + typedef odb::query query1; + typedef odb::query query2; + + typedef odb::result result1; + typedef odb::result result2; + + { + transaction t (db->begin ()); + result1 r1 (db->query (query1::id < 3)); + // odb::result ur (r1); // error + size_t n1 (0); + + for (result1::iterator i (r1.begin ()); i != r1.end (); ++i) + { + // i->f (); // error + i->cf (); + // obj1* p (i.load ()); // error + const obj1* p (i.load ()); + obj1 o (0); + i.load (o); + assert (p->id == o.id); + delete p; + n1++; + } + + assert (n1 == 2); + + result2 r2 (db->query (query2::id < 3)); + size_t n2 (0); + + for (result2::iterator i (r2.begin ()); i != r2.end (); ++i) + { + // i->f (); // error + i->cf (); + //unique_ptr p (i.load ()); // error + unique_ptr p (i.load ()); + obj2 o (0); + i.load (o); + assert (p->id == o.id); + n2++; + } + + assert (n2 == 2); + + t.commit (); + } + + // erase via references + // + { + transaction t (db->begin ()); + db->erase (*o1); + db->erase (*co1); + db->erase (*o2); + db->erase (*co2); + db->erase (a); + db->erase (ca); + t.commit (); + } + + // erase via pointers + // + o1->id -= 2; + co1_->id -= 2; + o2->id -= 2; + co2_->id -= 2; + + { + transaction t (db->begin ()); + db->erase (o1); + db->erase (co1); + db->erase (o2); + db->erase (co2); + t.commit (); + } + + // Test session and const/non-const object handling + // + { + session s; + transaction t (db->begin ()); + + obj1 o1 (1); + const obj1& co1 (o1); + db->persist (co1); + + assert (db->load (1) == &o1); + + t.commit (); + } + + delete o1; + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/const-object/test.hxx b/odb-tests/common/const-object/test.hxx new file mode 100644 index 0000000..4e66231 --- /dev/null +++ b/odb-tests/common/const-object/test.hxx @@ -0,0 +1,51 @@ +// file : common/const-object/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object pointer (obj1*) session +struct obj1 +{ + obj1 () {} + obj1 (int i): id (i) {} + + #pragma db id + int id; + + void f () {} + void cf () const {} +}; + +#pragma db object pointer (std::unique_ptr) +struct obj2 +{ + obj2 () {} + obj2 (int i): id (i) {} + + #pragma db id + int id; + + void f () {} + void cf () const {} +}; + +#pragma db object +struct aggr +{ + aggr (int i): id (i), o1 (0) {} + aggr (): o1 (0) {} + ~aggr () {delete o1;} + + #pragma db id + int id; + + const obj1* o1; + + std::unique_ptr o2; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/const-object/testscript b/odb-tests/common/const-object/testscript new file mode 100644 index 0000000..3885e96 --- /dev/null +++ b/odb-tests/common/const-object/testscript @@ -0,0 +1,33 @@ +# file : common/const-object/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/container/basics/buildfile b/odb-tests/common/container/basics/buildfile new file mode 100644 index 0000000..f83444e --- /dev/null +++ b/odb-tests/common/container/basics/buildfile @@ -0,0 +1,40 @@ +# file : common/container/basics/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_cont_bs_ \ + --generate-schema + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/container/basics/driver.cxx b/odb-tests/common/container/basics/driver.cxx new file mode 100644 index 0000000..14e1984 --- /dev/null +++ b/odb-tests/common/container/basics/driver.cxx @@ -0,0 +1,523 @@ +// file : common/container/basics/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test basic container persistence. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + for (unsigned short i (0); i < 2; ++i) + { + object empty ("empty"), med ("medium"), full ("full"); + + // + // empty + // + + empty.num = 0; + empty.str = ""; + + // array + // + empty.na[0] = 123; + empty.na[1] = 234; + empty.na[2] = 345; + + empty.sa[0] = "aaa"; + empty.sa[1] = "bbbb"; + empty.sa[2] = "ccccc"; + + empty.ca[0] = comp (123, "aaa"); + empty.ca[1] = comp (234, "bbbb"); + empty.ca[2] = comp (345, "ccccc"); + + + // + // med + // + + med.num = 999; + med.str = "xxx"; + + // vector + // + med.nv.push_back (123); + med.nv.push_back (234); + + med.sv.push_back ("aaa"); + med.sv.push_back ("bbbb"); + + med.cv.push_back (comp (123, "aaa")); + med.cv.push_back (comp (234, "bbbb")); + + med.uv.push_back (123); + med.uv.push_back (234); + + // list + // + med.sl.push_back ("aaa"); + med.sl.push_back ("bbbb"); + + // deque + // + med.nd.push_back (123); + med.nd.push_back (234); + + // set + // + med.ns.insert (123); + med.ns.insert (234); + + med.ss.insert ("aaa"); + med.ss.insert ("bbbb"); + + med.cs.insert (comp (123, "aaa")); + med.cs.insert (comp (234, "bbbb")); + + // map + // + med.nsm[123] = "aaa"; + med.nsm[234] = "bbbb"; + + med.snm["aaa"] = 123; + med.snm["bbbb"] = 234; + + med.ncm[123] = comp (123, "aaa"); + med.ncm[234] = comp (234, "bbbb"); + + med.csm[comp (123, "aaa")] = "aaa"; + med.csm[comp (234, "bbbb")] = "bbbb"; + + // array + // + med.na[0] = 123; + med.na[1] = 234; + med.na[2] = 345; + + med.sa[0] = "aaa"; + med.sa[1] = "bbbb"; + med.sa[2] = "ccccc"; + + med.ca[0] = comp (123, "aaa"); + med.ca[1] = comp (234, "bbbb"); + med.ca[2] = comp (345, "ccccc"); + + // forward_list + // + med.nfl.push_front (234); + med.nfl.push_front (123); + + med.sfl.push_front ("bbbb"); + med.sfl.push_front ("aaa"); + + med.cfl.push_front (comp (234, "bbbb")); + med.cfl.push_front (comp (123, "aaa")); + + // unordered_set + // + med.nus.insert (123); + med.nus.insert (234); + + med.sus.insert ("aaa"); + med.sus.insert ("bbbb"); + + med.cus.insert (comp (123, "aaa")); + med.cus.insert (comp (234, "bbbb")); + + // unordered_map + // + med.nsum[123] = "aaa"; + med.nsum[234] = "bbbb"; + + med.snum["aaa"] = 123; + med.snum["bbbb"] = 234; + + med.ncum[123] = comp (123, "aaa"); + med.ncum[234] = comp (234, "bbbb"); + + med.csum[comp (123, "aaa")] = "aaa"; + med.csum[comp (234, "bbbb")] = "bbbb"; + + // + // full + // + + full.num = 9999; + full.str = "xxxx"; + + // vector + // + full.nv.push_back (1234); + full.nv.push_back (2345); + full.nv.push_back (3456); + + full.sv.push_back ("aaaa"); + full.sv.push_back ("bbbbb"); + full.sv.push_back ("cccccc"); + + full.cv.push_back (comp (1234, "aaaa")); + full.cv.push_back (comp (2345, "bbbbb")); + full.cv.push_back (comp (3456, "cccccc")); + + full.uv.push_back (1234); + full.uv.push_back (2345); + full.uv.push_back (3456); + + // list + // + full.sl.push_back ("aaaa"); + full.sl.push_back ("bbbbb"); + full.sl.push_back ("cccccc"); + + // deque + // + full.nd.push_back (1234); + full.nd.push_back (2345); + full.nd.push_back (3456); + + // set + // + full.ns.insert (1234); + full.ns.insert (2345); + full.ns.insert (3456); + + full.ss.insert ("aaaa"); + full.ss.insert ("bbbbb"); + full.ss.insert ("cccccc"); + + full.cs.insert (comp (1234, "aaaa")); + full.cs.insert (comp (2345, "bbbbb")); + full.cs.insert (comp (3456, "cccccc")); + + // map + // + full.nsm[1234] = "aaaa"; + full.nsm[2345] = "bbbbb"; + full.nsm[3456] = "cccccc"; + + full.snm["aaaa"] = 1234; + full.snm["bbbbb"] = 2345; + full.snm["cccccc"] = 3456; + + full.ncm[1234] = comp (1234, "aaaa"); + full.ncm[2345] = comp (2345, "bbbbb"); + full.ncm[3456] = comp (3456, "cccccc"); + + full.csm[comp (1234, "aaaa")] = "aaaa"; + full.csm[comp (2345, "bbbbb")] = "bbbbb"; + full.csm[comp (3456, "cccccc")] = "cccccc"; + + // array + // + full.na[0] = 123; + full.na[1] = 234; + full.na[2] = 345; + + full.sa[0] = "aaa"; + full.sa[1] = "bbbb"; + full.sa[2] = "ccccc"; + + full.ca[0] = comp (123, "aaa"); + full.ca[1] = comp (234, "bbbb"); + full.ca[2] = comp (345, "ccccc"); + + // forward_list + // + full.nfl.push_front (345); + full.nfl.push_front (234); + full.nfl.push_front (123); + + full.sfl.push_front ("ccccc"); + full.sfl.push_front ("bbbb"); + full.sfl.push_front ("aaa"); + + full.cfl.push_front (comp (345, "ccccc")); + full.cfl.push_front (comp (234, "bbbb")); + full.cfl.push_front (comp (123, "aaa")); + + // unordered_set + // + full.nus.insert (1234); + full.nus.insert (2345); + full.nus.insert (3456); + + full.sus.insert ("aaaa"); + full.sus.insert ("bbbbb"); + full.sus.insert ("cccccc"); + + full.cus.insert (comp (1234, "aaaa")); + full.cus.insert (comp (2345, "bbbbb")); + full.cus.insert (comp (3456, "cccccc")); + + // unordered_map + // + full.nsum[1234] = "aaaa"; + full.nsum[2345] = "bbbbb"; + full.nsum[3456] = "cccccc"; + + full.snum["aaaa"] = 1234; + full.snum["bbbbb"] = 2345; + full.snum["cccccc"] = 3456; + + full.ncum[1234] = comp (1234, "aaaa"); + full.ncum[2345] = comp (2345, "bbbbb"); + full.ncum[3456] = comp (3456, "cccccc"); + + full.csum[comp (1234, "aaaa")] = "aaaa"; + full.csum[comp (2345, "bbbbb")] = "bbbbb"; + full.csum[comp (3456, "cccccc")] = "cccccc"; + + // persist + // + { + transaction t (db->begin ()); + db->persist (empty); + db->persist (med); + db->persist (full); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + unique_ptr e (db->load ("empty")); + unique_ptr m (db->load ("medium")); + unique_ptr f (db->load ("full")); + t.commit (); + + assert (empty == *e); + assert (med == *m); + assert (full == *f); + } + + // + // empty + // + + empty.num = 99; + empty.str = "xx"; + + empty.nv.push_back (12); + empty.sv.push_back ("aa"); + empty.cv.push_back (comp (12, "aa")); + empty.uv.push_back (12); + empty.sl.push_back ("aa"); + empty.nd.push_back (12); + + empty.ns.insert (12); + empty.ss.insert ("aa"); + empty.cs.insert (comp (12, "aa")); + + empty.nsm[12] = "aa"; + empty.snm["aa"] = 12; + empty.ncm[12] = comp (12, "aa"); + empty.csm[comp (12, "aa")] = "aa"; + + empty.nfl.push_front (12); + empty.sfl.push_front ("aa"); + empty.cfl.push_front (comp (12, "aa")); + + empty.nus.insert (12); + empty.sus.insert ("aa"); + empty.cus.insert (comp (12, "aa")); + + empty.nsum[12] = "aa"; + empty.snum["aa"] = 12; + empty.ncum[12] = comp (12, "aa"); + empty.csum[comp (12, "aa")] = "aa"; + + // + // med + // + + med.num = 0; + med.str = ""; + + med.nv.clear (); + med.sv.clear (); + med.cv.clear (); + med.uv.clear (); + + med.sl.clear (); + + med.nd.clear (); + + med.ns.clear (); + med.ss.clear (); + med.cs.clear (); + + med.nsm.clear (); + med.snm.clear (); + med.ncm.clear (); + med.csm.clear (); + + med.nfl.clear (); + med.sfl.clear (); + med.cfl.clear (); + + med.nus.clear (); + med.sus.clear (); + med.cus.clear (); + + med.nsum.clear (); + med.snum.clear (); + med.ncum.clear (); + med.csum.clear (); + + // + // full + // + + full.num++; + full.str += "x"; + + // vector + // + full.nv.back ()++; + full.nv.push_back (4567); + + full.sv.back () += "c"; + full.sv.push_back ("ddddddd"); + + full.cv.back ().num++; + full.cv.back ().str += "c"; + full.cv.push_back (comp (4567, "ddddddd")); + + full.uv.back ()++; + full.uv.push_back (4567); + + // list + // + full.sl.back () += "c"; + full.sl.push_back ("ddddddd"); + + // deque + // + full.nd.push_front (456); + + // set + // + full.ns.insert (4567); + full.ss.insert ("ddddddd"); + full.cs.insert (comp (4567, "ddddddd")); + + // map + // + full.nsm[3456] += 'c'; + full.nsm[4567] = "ddddddd"; + + full.snm["cccccc"]++; + full.snm["ddddddd"] = 4567; + + full.ncm[3456].num++; + full.ncm[3456].str += 'c'; + full.ncm[4567] = comp (4567, "ddddddd"); + + full.csm[comp (3456, "cccccc")] += "c"; + full.csm[comp (4567, "ddddddd")] = "ddddddd"; + + // array + // + full.na[0]++; + full.sa[0] += 'a'; + full.ca[0].num++; + full.ca[0].str += 'a'; + + // forward_list + // + full.nfl.front ()++; + full.nfl.push_front (4567); + + full.sfl.front () += 'a'; + full.sfl.push_front ("ddddddd"); + + full.cfl.front ().num++; + full.cfl.front ().str += 'a'; + full.cfl.push_front (comp (4567, "ddddddd")); + + // unordered_set + // + full.nus.insert (4567); + full.sus.insert ("ddddddd1"); // 1 is to preserve order in VC++ 10. + full.cus.insert (comp (4567, "ddddddd1")); + + // unordered_map + // + full.nsum[3456] += 'c'; + full.nsum[4567] = "ddddddd"; + + full.snum["cccccc"]++; + full.snum["ddddddd1"] = 4567; + + full.ncum[3456].num++; + full.ncum[3456].str += 'c'; + full.ncum[4567] = comp (4567, "ddddddd"); + + full.csum[comp (3456, "cccccc")] += "c"; + full.csum[comp (4567, "ddddddd1")] = "ddddddd"; + + // update + // + { + transaction t (db->begin ()); + db->update (empty); + db->update (med); + db->update (full); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + unique_ptr e (db->load ("empty")); + unique_ptr m (db->load ("medium")); + unique_ptr f (db->load ("full")); + t.commit (); + + assert (empty == *e); + assert (med == *m); + assert (full == *f); + } + + // erase + // + if (i == 0) + { + transaction t (db->begin ()); + db->erase ("empty"); + db->erase ("medium"); + db->erase ("full"); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/container/basics/test.hxx b/odb-tests/common/container/basics/test.hxx new file mode 100644 index 0000000..e8e329e --- /dev/null +++ b/odb-tests/common/container/basics/test.hxx @@ -0,0 +1,245 @@ +// file : common/container/basics/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#pragma db value +struct comp +{ + comp () {} + comp (int n, const std::string& s) : num (n), str (s) {} + + #pragma db column("number") + int num = 0; + std::string str; +}; + +inline bool +operator== (const comp& x, const comp& y) +{ + return x.num == y.num && x.str == y.str; +} + +inline bool +operator!= (const comp& x, const comp& y) +{ + return !(x == y); +} + +inline bool +operator< (const comp& x, const comp& y) +{ + return x.num != y.num ? x.num < y.num : x.str < y.str; +} + +typedef std::list str_list; +typedef std::deque num_deque; + +typedef std::vector num_vector; +typedef std::vector str_vector; + +typedef std::set num_set; +typedef std::set str_set; +typedef std::set comp_set; + +typedef std::map num_str_map; +typedef std::map str_num_map; +typedef std::map num_comp_map; +typedef std::map comp_str_map; + +struct comp_hash +{ + std::size_t + operator() (const comp& x) const {return nh (x.num) + sh (x.str);} + + std::hash nh; + std::hash sh; +}; + +typedef std::array num_array; +typedef std::array str_array; +typedef std::array comp_array; + +typedef std::forward_list num_flist; +typedef std::forward_list str_flist; +typedef std::forward_list comp_flist; + +typedef std::unordered_set num_uset; +typedef std::unordered_set str_uset; +typedef std::unordered_set comp_uset; + +typedef std::unordered_map num_str_umap; +typedef std::unordered_map str_num_umap; +typedef std::unordered_map num_comp_umap; +typedef std::unordered_map comp_str_umap; + +#pragma db value +struct cont_comp1 +{ + // This composite value does not have any columns. + // + num_vector sv; // Have the name "conflic" with the one in the object. +}; + +#pragma db value +struct cont_comp2 +{ + cont_comp2 (): num (777), str ("ggg") {} + + int num; + str_list sl; + std::string str; +}; + +#pragma db object +struct object +{ + object (): nv (comp1_.sv), sl (comp2_.sl) {} + object (const std::string& id) : id_ (id), nv (comp1_.sv), sl (comp2_.sl) {} + + #pragma db id + std::string id_; + + int num; + + cont_comp1 comp1_; + cont_comp2 comp2_; + + // vector + // + #pragma db transient + num_vector& nv; + + #pragma db table("object_strings") id_column ("obj_id") + str_vector sv; + + #pragma db value_column("") + std::vector cv; + + #pragma db unordered + num_vector uv; + + // list + // + #pragma db transient + str_list& sl; + + // deque + // + num_deque nd; + + // set + // + num_set ns; + str_set ss; + comp_set cs; + + // map + // + num_str_map nsm; + str_num_map snm; + num_comp_map ncm; + comp_str_map csm; + + // array + // + num_array na; + str_array sa; + comp_array ca; + + // forward_list + // + num_flist nfl; + str_flist sfl; + comp_flist cfl; + + // unordered_set + // + num_uset nus; + str_uset sus; + comp_uset cus; + + // unordered_map + // + num_str_umap nsum; + str_num_umap snum; + num_comp_umap ncum; + comp_str_umap csum; + + std::string str; +}; + +inline bool +operator== (const object& x, const object& y) +{ + if (x.uv.size () != y.uv.size ()) + return false; + + int xs (0), ys (0); + + for (num_vector::size_type i (0); i < x.uv.size (); ++i) + { + xs += x.uv[i]; + ys += y.uv[i]; + } + + return + x.id_ == y.id_ && + x.num == y.num && + + x.comp2_.num == y.comp2_.num && + x.comp2_.str == y.comp2_.str && + + x.nv == y.nv && + x.sv == y.sv && + x.cv == y.cv && + xs == ys && + + x.sl == y.sl && + + x.nd == y.nd && + + x.ns == y.ns && + x.ss == y.ss && + x.cs == y.cs && + + x.nsm == y.nsm && + x.snm == y.snm && + x.ncm == y.ncm && + x.csm == y.csm && + + x.na == y.na && + x.sa == y.sa && + x.ca == y.ca && + + x.nfl == y.nfl && + x.sfl == y.sfl && + x.cfl == y.cfl && + + x.nus == y.nus && + x.sus == y.sus && + x.cus == y.cus && + + x.nsum == y.nsum && + x.snum == y.snum && + x.ncum == y.ncum && + x.csum == y.csum && + + x.str == y.str; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/container/basics/testscript b/odb-tests/common/container/basics/testscript new file mode 100644 index 0000000..ea99498 --- /dev/null +++ b/odb-tests/common/container/basics/testscript @@ -0,0 +1,33 @@ +# file : common/container/basics/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/container/change-tracking/buildfile b/odb-tests/common/container/change-tracking/buildfile new file mode 100644 index 0000000..1dda818 --- /dev/null +++ b/odb-tests/common/container/change-tracking/buildfile @@ -0,0 +1,40 @@ +# file : common/container/change-tracking/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_cont_changet_ \ + --generate-schema + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/container/change-tracking/driver.cxx b/odb-tests/common/container/change-tracking/driver.cxx new file mode 100644 index 0000000..4894ed9 --- /dev/null +++ b/odb-tests/common/container/change-tracking/driver.cxx @@ -0,0 +1,729 @@ +// file : common/container/change-tracking/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test change-tracking containers. +// + +#include // std::unique_ptr +#include // std::move +#include + +#include +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +struct counting_tracer: odb::tracer +{ + void + reset (transaction& tr) {u = i = d = s = t = 0; tr.tracer (*this);} + + virtual void + execute (odb::connection&, const char* stmt) + { + string p (stmt, 6); + if (p == "UPDATE") + u++; + else if (p == "INSERT") + i++; + else if (p == "DELETE") + d++; + else if (p == "SELECT") + s++; + t++; + } + + size_t u, i, d, s, t; +}; + +static counting_tracer tr; + +// Compilation test: instantiate all the functions. In C++11 mode only +// do this if we have a fairly conforming compiler that implements the +// complete std::vector interface. +// + +#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC +#if defined (__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 7 +struct item {}; +template class odb::vector; +template class odb::vector_iterator, + std::vector::iterator>; +template class odb::vector_iterator, + std::vector::reverse_iterator>; +#endif +#endif + +void +f (const std::vector&) {} + +int +main (int argc, char* argv[]) +{ + try + { + // Test extended interface. + // + { + typedef odb::vector vector; + + vector ov; + std::vector sv; + f (ov); // Implicit conversion to std::vector. + vector ov1 (sv); // Initialization from std::vector. + ov = sv; // Assignement from std::vector. + + // Container comparison. + // + if (ov != ov1 || + ov != sv || + sv != ov1) + ov.clear (); + + // Iterator comparison/conversion. + // + vector::const_iterator i (ov.begin ()); + if (i != ov.end ()) + i = ov.end (); + + // Things are just really borken in Sun CC, no matter which STL + // you use. + // +#ifndef __SUNPRO_CC + vector::const_reverse_iterator j (ov.rbegin ()); + if (j != ov.rend ()) + j = ov.rend (); +#endif + } + + unique_ptr db (create_database (argc, argv)); + + // Test traits logic. + // + { + object o ("1"); + o.i = 123; + o.s.push_back ("a"); + + assert (!o.s._tracking ()); + + // persist + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + assert (o.s._tracking ()); + + // load + // + { + transaction t (db->begin ()); + unique_ptr p (db->load ("1")); + assert (p->s._tracking ()); + t.commit (); + } + + // update + // + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + assert (o.s._tracking ()); + + // erase + // + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + + assert (!o.s._tracking ()); + } + + // Test change tracking. + // + object o ("1"); + o.i = 123; + o.s.push_back ("a"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // push_back/pop_back + // + { + o.s.push_back ("b"); // insert + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.i == 1 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.pop_back (); + o.s.push_back ("c"); // update + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 2 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.pop_back (); + for (int i (0); i != 1024; ++i) + o.s.push_back ("x"); // realloc + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 2 && tr.i == 1023 && tr.t == 1025); + assert (*db->load ("1") == o); + t.commit (); + } + + { + for (int i (0); i != 1024; ++i) + o.s.pop_back (); // delete + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.d == 1 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.push_back ("b"); + o.s.pop_back (); // no-op + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.t == 1); + assert (*db->load ("1") == o); + t.commit (); + } + + // insert + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.insert (o.s.begin (), "a1"); // insert front + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 3 && tr.i == 1 && tr.t == 4); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.insert (o.s.begin () + 1, "a2"); // insert middle + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 3 && tr.i == 1 && tr.t == 4); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.insert (o.s.end (), "b1"); // insert back + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.i == 1 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + // erase + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + o.s.push_back ("d"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.erase (o.s.begin ()); // erase front + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 4 && tr.d == 1 && tr.t == 5); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.erase (o.s.begin () + 1); // erase middle + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 2 && tr.d == 1 && tr.t == 3); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.erase (o.s.end () - 1); // erase back + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.d == 1 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + // modify + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + o.s.push_back ("d"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.modify (1) += 'b'; + o.s.modify_at (2) += 'c'; + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 3 && tr.t == 3); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.modify_front () += 'a'; + o.s.modify_back () += 'd'; + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 3 && tr.t == 3); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.begin ().modify () += 'a'; +#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC + o.s.rbegin ().modify () += 'c'; +#endif + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); +#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC + assert (tr.u == 3 && tr.t == 3); +#else + assert (tr.u == 2 && tr.t == 2); +#endif + assert (*db->load ("1") == o); + t.commit (); + } + +#ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC + { + (o.s.rbegin () + 1).modify (1) += 'a'; + (o.s.rbegin () + 1).modify (-1) += 'c'; + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 3 && tr.t == 3); + assert (*db->load ("1") == o); + t.commit (); + } +#endif + + { + o.s.mbegin (); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 5 && tr.t == 5); + assert (*db->load ("1") == o); + t.commit (); + } + + // clear + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.clear (); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.d == 1 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + // assign + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.assign (4, "x"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 4 && tr.i == 1 && tr.t == 5); + assert (*db->load ("1") == o); + t.commit (); + } + + // resize + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.pop_back (); + o.s.resize (4, "x"); // expand + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 2 && tr.i == 1 && tr.t == 3); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.push_back ("y"); + o.s.resize (3); // shrink + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.d == 1 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + // Transaction rollback. + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + { + o.s.push_back ("d"); + + transaction t (db->begin ()); + db->update (o); + t.rollback (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.i == 4 && tr.d == 1 && tr.t == 6); + t.commit (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.t == 1); + t.commit (); + } + } + + // Armed copy. + // + { + unique_ptr c; + + { + o.s.pop_back (); + + transaction t (db->begin ()); + db->update (o); + c.reset (new object (o)); + t.rollback (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.i == 3 && tr.d == 1 && tr.t == 5); + t.commit (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.t == 1); + t.commit (); + } + } + + // Armed swap. + // + { + object c (o); + + { + o.s.push_back ("d"); + + transaction t (db->begin ()); + db->update (o); + assert (o.s._tracking () && !c.s._tracking ()); + c.s.swap (o.s); + assert (!o.s._tracking () && c.s._tracking ()); + t.rollback (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.i == 4 && tr.d == 1 && tr.t == 6); + t.commit (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.t == 1); + t.commit (); + } + } + + // Armed move. + // + { + unique_ptr c; + + { + o.s.pop_back (); + + transaction t (db->begin ()); + db->update (o); + assert (o.s._tracking ()); + c.reset (new object (std::move (o))); + assert (!o.s._tracking () && c->s._tracking ()); + t.rollback (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.i == 2 && tr.d == 1 && tr.t == 4); + t.commit (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.t == 1); + t.commit (); + } + } + + // Test mixing "smart" and "dumb" container (specifically, erase(obj)). + // + { + mix_object o (1); + o.ov.assign (3, 123); + o.sv.assign (3, 123); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test using change tracking container as inverse member. + // + { + inv_object1 o1; + inv_object2 o2; + o1.o2 = &o2; + + { + transaction t (db->begin ()); + db->persist (o2); + db->persist (o1); + t.commit (); + } + + assert (!o2.o1._tracking ()); + + { + session s; + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id_)); + unique_ptr p2 (db->load (o2.id_)); + assert (p2->o1[0] == p1.get ()); + assert (!p2->o1._tracking ()); + t.commit (); + } + } + + // Test read-only values. + { + ro_object o (1); + o.v.push_back (ro_value (1, 1)); + o.v.push_back (ro_value (2, 2)); + o.v.push_back (ro_value (3, 3)); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + o.v.erase (o.v.begin ()); + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + assert (db->load (1)->v == o.v); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/container/change-tracking/test.hxx b/odb-tests/common/container/change-tracking/test.hxx new file mode 100644 index 0000000..8e06f4a --- /dev/null +++ b/odb-tests/common/container/change-tracking/test.hxx @@ -0,0 +1,106 @@ +// file : common/container/change-tracking/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include +#include // std::move + +#include +#include + +#pragma db object pointer(std::unique_ptr) +struct object +{ + object () {} + object (const std::string& id): id_ (id) {} + + object (const object& x): id_ (x.id_), i (x.i), s (x.s) {} + object (object&& x): id_ (std::move (x.id_)), i (x.i), s (std::move (x.s)) {} + + #pragma db id + std::string id_; + + unsigned int i; + + odb::vector s; + + inline bool + operator== (const object& o) const {return id_ == o.id_ && i == o.i && s == o.s;} +}; + +// Test mixing "smart" and "dumb" container (specifically, erase(obj)). +// +#pragma db object +struct mix_object +{ + mix_object () {} + mix_object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + odb::vector ov; + std::vector sv; +}; + +// Test using change tracking container as inverse member. +// +struct inv_object2; + +#pragma db object session +struct inv_object1 +{ + #pragma db id auto + unsigned long id_; + + inv_object2* o2; +}; + +#pragma db object session +struct inv_object2 +{ + #pragma db id auto + unsigned long id_; + + #pragma db inverse(o2) + odb::vector o1; +}; + +// Test read-only values (we still need to include them in the UPDATE +// statement). +// +#pragma db value +struct ro_value +{ + ro_value (int i_ = 0, int j_ = 0): i (i_), j (j_) {} + + #pragma db readonly + int i; + + #pragma db readonly + int j; +}; + +inline bool +operator== (const ro_value& x, const ro_value& y) +{ + return x.i == y.i && x.j == y.j; +} + +#pragma db object +struct ro_object +{ + ro_object () {} + ro_object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + odb::vector v; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/container/change-tracking/testscript b/odb-tests/common/container/change-tracking/testscript new file mode 100644 index 0000000..2169869 --- /dev/null +++ b/odb-tests/common/container/change-tracking/testscript @@ -0,0 +1,33 @@ +# file : common/container/change-tracking/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/ctor/buildfile b/odb-tests/common/ctor/buildfile new file mode 100644 index 0000000..a9892bc --- /dev/null +++ b/odb-tests/common/ctor/buildfile @@ -0,0 +1,41 @@ +# file : common/ctor/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix ctor_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/ctor/driver.cxx b/odb-tests/common/ctor/driver.cxx new file mode 100644 index 0000000..c9b445d --- /dev/null +++ b/odb-tests/common/ctor/driver.cxx @@ -0,0 +1,79 @@ +// file : common/ctor/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test support for persistent objects without default constructors. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + typedef odb::query query; + typedef odb::result result; + + unique_ptr db (create_database (argc, argv)); + + person p1 ("John", "Doe", 30); + person p2 ("Jane", "Doe", 29); + person p3 ("Joe", "Dirt", 31); + + { + transaction t (db->begin ()); + + db->persist (p1); + db->persist (p2); + db->persist (p3); + + t.commit (); + } + + { + person p ("", "", 0); + + transaction t (db->begin ()); + + db->load (p1.id_, p); + + assert (p.first_ == p1.first_); + assert (p.last_ == p1.last_); + assert (p.age_ == p1.age_); + + result r (db->query (query::age < 30)); + + assert (!r.empty ()); + + result::iterator i (r.begin ()); + i.load (p); + assert (p.first_ == "Jane"); + assert (p.last_ == "Doe"); + assert (p.age_ == 29); + + assert (size (r) == 1); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/ctor/test.hxx b/odb-tests/common/ctor/test.hxx new file mode 100644 index 0000000..2a2becd --- /dev/null +++ b/odb-tests/common/ctor/test.hxx @@ -0,0 +1,29 @@ +// file : common/ctor/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object +struct person +{ + person (const std::string& first, + const std::string& last, + unsigned short age) + : first_ (first), last_ (last), age_ (age) + { + } + + #pragma db id auto + unsigned long id_; + + std::string first_; + std::string last_; + unsigned short age_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/ctor/testscript b/odb-tests/common/ctor/testscript new file mode 100644 index 0000000..8946ddb --- /dev/null +++ b/odb-tests/common/ctor/testscript @@ -0,0 +1,33 @@ +# file : common/ctor/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/default/buildfile b/odb-tests/common/default/buildfile new file mode 100644 index 0000000..e25bd08 --- /dev/null +++ b/odb-tests/common/default/buildfile @@ -0,0 +1,41 @@ +# file : common/default/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix default_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/default/driver.cxx b/odb-tests/common/default/driver.cxx new file mode 100644 index 0000000..2d3ef01 --- /dev/null +++ b/odb-tests/common/default/driver.cxx @@ -0,0 +1,81 @@ +// file : common/default/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test default values. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Insert an object using an ad-hoc SQL statement. This way + // we get all the default values. + // + { + transaction t (db->begin ()); + + if (db->id () != odb::id_oracle) + db->execute ("INSERT INTO default_object (obj_id) VALUES (1)"); + else + db->execute ("INSERT INTO \"default_object\" (\"obj_id\") VALUES (1)"); + + t.commit (); + } + + // Now load the object and check all the values. + // + { + transaction t (db->begin ()); + unique_ptr o (db->load (1)); + t.commit (); + + assert (o->b); + assert (o->pi == 1234); + assert (o->ni == -1234); + assert (o->zi == 0); + assert (o->pf == 1.234); + assert (o->nf == -1.234); + assert (o->zf == 0.0); + assert (o->sf == 1.123e+10); + assert (o->str == "Someone's string"); + assert (o->e == green); + } + + // Check the NULL default value using a query. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::null.is_null ())); + assert (!r.empty ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/default/test.hxx b/odb-tests/common/default/test.hxx new file mode 100644 index 0000000..7f35ed4 --- /dev/null +++ b/odb-tests/common/default/test.hxx @@ -0,0 +1,67 @@ +// file : common/default/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +enum color {red, green, blue}; + +#pragma db value(unsigned long) default(0) + +#pragma db object +struct object +{ + #pragma db id + unsigned long obj_id; + + // NULL. + // + #pragma db null default(null) + unsigned long null; + + // Boolean. + // + #pragma db default(true) + bool b; + + // Integers. + // + #pragma db default(1234) + unsigned long pi; + + #pragma db default(-1234) + long ni; + + // 0 default taken from the type. + unsigned long zi; + + // Floats. + // + #pragma db default(1.234) + double pf; + + #pragma db default(-1.234) + double nf; + + #pragma db default(0.0) + double zf; + + #pragma db default(1.123e+10) + double sf; + + // Strings. MySQL doesn't support default values on TEXT + // columns, so make the type VARCHAR. + // + #pragma db type("VARCHAR(64)") default("Someone's string") + std::string str; + + // Enums. + // + #pragma db default(green) + color e; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/default/testscript b/odb-tests/common/default/testscript new file mode 100644 index 0000000..f29cef4 --- /dev/null +++ b/odb-tests/common/default/testscript @@ -0,0 +1,33 @@ +# file : common/default/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/definition/.gitignore b/odb-tests/common/definition/.gitignore new file mode 100644 index 0000000..5838670 --- /dev/null +++ b/odb-tests/common/definition/.gitignore @@ -0,0 +1,6 @@ +# ODB-generated files. +# +time-mapping-odb.?xx +time-mapping-odb-*.?xx +time-mapping.sql +time-mapping-*.sql diff --git a/odb-tests/common/definition/buildfile b/odb-tests/common/definition/buildfile new file mode 100644 index 0000000..09ad1db --- /dev/null +++ b/odb-tests/common/definition/buildfile @@ -0,0 +1,52 @@ +# file : common/definition/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +hs = test time-mapping + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +for h: $hs +{ + exe{driver}: {hxx ixx cxx}{$h-odb} + + <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} + + for db: $databases + { + exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi + <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} + } +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix definition_ \ + --generate-schema + +<{hxx ixx cxx}{time-mapping-odb}>: odb_options = + +for db: $databases + {hxx ixx cxx}{time-mapping-odb-$db}: odb_options = + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/definition/driver.cxx b/odb-tests/common/definition/driver.cxx new file mode 100644 index 0000000..223eeaf --- /dev/null +++ b/odb-tests/common/definition/driver.cxx @@ -0,0 +1,56 @@ +// file : common/definition/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test overriding composite value definition point. This is primarily +// useful to make composite values out of third-party types. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + object o; + o.time.tv_sec = 1; + o.time.tv_usec = 1000; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + t.commit (); + + assert (p->time.tv_sec == o.time.tv_sec && + p->time.tv_usec == o.time.tv_usec); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/definition/test.hxx b/odb-tests/common/definition/test.hxx new file mode 100644 index 0000000..38fc02a --- /dev/null +++ b/odb-tests/common/definition/test.hxx @@ -0,0 +1,26 @@ +// file : common/definition/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#ifdef _WIN32 +# include // timeval +#else +# include // timeval +#endif + +#include + +#include "time-mapping.hxx" + +#pragma db object +struct object +{ + #pragma db id auto + unsigned long id; + + timeval time; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/definition/testscript b/odb-tests/common/definition/testscript new file mode 100644 index 0000000..c9dea6d --- /dev/null +++ b/odb-tests/common/definition/testscript @@ -0,0 +1,33 @@ +# file : common/definition/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/definition/time-mapping.hxx b/odb-tests/common/definition/time-mapping.hxx new file mode 100644 index 0000000..469cfb7 --- /dev/null +++ b/odb-tests/common/definition/time-mapping.hxx @@ -0,0 +1,17 @@ +// file : common/definition/time-mapping.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TIME_MAPPING_HXX +#define TIME_MAPPING_HXX + +#ifdef _WIN32 +# include // timeval +#else +# include // timeval +#endif + +#pragma db value(timeval) definition +#pragma db member(timeval::tv_sec) column("sec") +#pragma db member(timeval::tv_usec) column("usec") + +#endif // TIME_MAPPING_HXX diff --git a/odb-tests/common/enum/buildfile b/odb-tests/common/enum/buildfile new file mode 100644 index 0000000..eb3a29a --- /dev/null +++ b/odb-tests/common/enum/buildfile @@ -0,0 +1,41 @@ +# file : common/enum/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix enum_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/enum/driver.cxx b/odb-tests/common/enum/driver.cxx new file mode 100644 index 0000000..ed3eb59 --- /dev/null +++ b/odb-tests/common/enum/driver.cxx @@ -0,0 +1,84 @@ +// file : common/enum/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test automatic C++ enum mapping. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + typedef odb::query query; + typedef odb::result result; + + unique_ptr db (create_database (argc, argv)); + + object o; + o.color_ = green; + o.taste_ = object::sweet; + o.position_ = object::left; + + o.gender_ = object::gender::female; + o.scale_ = object::scale::ten; + o.yesno_ = object::yesno::yes; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (o.id_)); + t.commit (); + + assert (o == *o1); + } + + { + transaction t (db->begin ()); + + result r1 (db->query (query::color == blue)); + result r2 (db->query (query::taste == object::sweet)); + result r3 (db->query (query::position == object::left)); + + assert (r1.empty ()); + assert (!r2.empty ()); + assert (!r3.empty ()); + + result r4 (db->query (query::gender == object::gender::female)); + result r5 (db->query (query::scale == object::scale::ten)); + result r6 (db->query (query::yesno == object::yesno::yes)); + + assert (!r4.empty ()); + assert (!r5.empty ()); + assert (!r6.empty ()); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/enum/test.hxx b/odb-tests/common/enum/test.hxx new file mode 100644 index 0000000..a279112 --- /dev/null +++ b/odb-tests/common/enum/test.hxx @@ -0,0 +1,47 @@ +// file : common/enum/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +enum color {red, green, blue}; + +#pragma db object +struct object +{ + #pragma db id auto + unsigned long id_; + + color color_; + enum taste {bitter, sweet, sour}; + taste taste_; + + enum position {left = -1, center = 0, right = 1}; + position position_; + + + enum class gender {male, female}; + enum class scale: unsigned char {one = 1, ten = 10, hundred = 100}; + enum class yesno: bool {no, yes}; + + gender gender_; + scale scale_; + yesno yesno_; +}; + +inline bool +operator == (const object& x, const object& y) +{ + return + x.id_ == y.id_ + && x.color_ == y.color_ + && x.taste_ == y.taste_ + && x.position_ == y.position_ + && x.gender_ == y.gender_ + && x.scale_ == y.scale_ + && x.yesno_ == y.yesno_; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/enum/testscript b/odb-tests/common/enum/testscript new file mode 100644 index 0000000..d2ca28c --- /dev/null +++ b/odb-tests/common/enum/testscript @@ -0,0 +1,33 @@ +# file : common/enum/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/erase-query/buildfile b/odb-tests/common/erase-query/buildfile new file mode 100644 index 0000000..d833b6e --- /dev/null +++ b/odb-tests/common/erase-query/buildfile @@ -0,0 +1,41 @@ +# file : common/erase-query/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix erase_query_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/erase-query/driver.cxx b/odb-tests/common/erase-query/driver.cxx new file mode 100644 index 0000000..6c11957 --- /dev/null +++ b/odb-tests/common/erase-query/driver.cxx @@ -0,0 +1,181 @@ +// file : common/erase-query/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test query-based erase. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +void +persist (database& db) +{ + object o1 (1); + object o2 (2); + object o3 (3); + object o4 (4); + + transaction t (db.begin ()); + db.persist (o1); + db.persist (o2); + db.persist (o3); + db.persist (o4); + t.commit (); +} + +int +main (int argc, char* argv[]) +{ + try + { + typedef odb::query query; + + unique_ptr db (create_database (argc, argv)); + + // erase_query() + // + persist (*db); + + { + transaction t (db->begin ()); + assert (db->erase_query () == 4); + t.commit (); + } + + // erase_query(const char*) + // + persist (*db); + + { + transaction t (db->begin ()); + + if (db->id () != odb::id_oracle) + assert (db->erase_query ( + "erase_query_object.id < 3") == 2); + else + assert (db->erase_query ( + "\"erase_query_object\".\"id\" < 3") == 2); + + db->erase_query (); + t.commit (); + } + + // erase_query(query) + // + persist (*db); + + { + transaction t (db->begin ()); + assert (db->erase_query (query::id == 2 || query::id == 4) == 2); + db->erase_query (); + t.commit (); + } + + // Test predicates involving object pointers (DELETE JOIN). + // + /* + { + object o11 (1); + object o12 (2); + object o13 (3); + object2 o2; + + o11.o2 = &o2; + o2.num = 123; + + o12.o1 = &o13; + o13.num = 123; + + transaction t (db->begin ()); + db->persist (o2); + db->persist (o13); + db->persist (o12); + db->persist (o11); + t.commit (); + } + + { + transaction t (db->begin ()); + assert (db->erase_query (query::o1::num == 123) == 1); + assert (db->erase_query (query::o2::num == 123) == 1); + db->erase_query (); + t.commit (); + } + */ + + // For now we can only do column-based tests, like is_null(). + // + { + object o11 (1); + object o12 (2); + object o13 (3); + object2 o2; + + o12.o2 = &o2; + + transaction t (db->begin ()); + db->persist (o2); + db->persist (o13); + db->persist (o12); + db->persist (o11); + t.commit (); + } + + { + transaction t (db->begin ()); + assert (db->erase_query (query::o2.is_null ()) == 2); + db->erase_query (); + t.commit (); + } + + // Make sure container data is deleted. + // + { + object o (1); + o.v.push_back (1); + o.v.push_back (2); + o.v.push_back (3); + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + assert (db->erase_query () == 1); + t.commit (); + } + + { + transaction t (db->begin ()); + + if (db->id () != odb::id_oracle) + assert (db->execute ("SELECT * FROM erase_query_object_v " + "WHERE object_id = 1") == 0); + else + assert (db->execute ("SELECT * FROM \"erase_query_object_v\" " + "WHERE \"object_id\" = 1") == 0); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/erase-query/test.hxx b/odb-tests/common/erase-query/test.hxx new file mode 100644 index 0000000..9e73f12 --- /dev/null +++ b/odb-tests/common/erase-query/test.hxx @@ -0,0 +1,46 @@ +// file : common/erase-query/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +struct object2; + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id), o1 (0), o2 (0) + { + } + + object () + : o1 (0), o2 (0) + { + } + + #pragma db id + unsigned long id_; + + std::vector v; + + int num; + + object* o1; + object2* o2; +}; + +#pragma db object +struct object2 +{ + #pragma db id auto + unsigned long id_; + + int num; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/erase-query/testscript b/odb-tests/common/erase-query/testscript new file mode 100644 index 0000000..90862ab --- /dev/null +++ b/odb-tests/common/erase-query/testscript @@ -0,0 +1,33 @@ +# file : common/erase-query/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/id/auto/buildfile b/odb-tests/common/id/auto/buildfile new file mode 100644 index 0000000..c340200 --- /dev/null +++ b/odb-tests/common/id/auto/buildfile @@ -0,0 +1,40 @@ +# file : common/id/auto/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_id_auto_ \ + --generate-schema + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/id/auto/driver.cxx b/odb-tests/common/id/auto/driver.cxx new file mode 100644 index 0000000..d294e69 --- /dev/null +++ b/odb-tests/common/id/auto/driver.cxx @@ -0,0 +1,96 @@ +// file : common/id/auto/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test automatic id assignment. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // object + // + { + unsigned long id1, id2, id3; + { + object o1 ("one"); + object o2 ("two"); + object o3 ("three"); + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + + id1 = o1.id_; + id2 = o2.id_; + id3 = o3.id_; + + assert (id1 != id2); + assert (id1 != id3); + assert (id2 != id3); + } + + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (id1)); + unique_ptr o2 (db->load (id2)); + unique_ptr o3 (db->load (id3)); + t.commit (); + + assert (o1->id_ == id1 && o1->str_ == "one"); + assert (o2->id_ == id2 && o2->str_ == "two"); + assert (o3->id_ == id3 && o3->str_ == "three"); + } + } + + // auto_only + // + { + unsigned short id; + { + auto_only o; + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + id = o.id_; + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (id)); + t.commit (); + + assert (o->id_ == id); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/id/auto/test.hxx b/odb-tests/common/id/auto/test.hxx new file mode 100644 index 0000000..233c79f --- /dev/null +++ b/odb-tests/common/id/auto/test.hxx @@ -0,0 +1,40 @@ +// file : common/id/auto/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object +struct object +{ + object (const std::string& str) + : id_ (1), str_ (str) + { + } + + #pragma db auto id + unsigned long id_; + std::string str_; + +private: + object () + { + } + + friend class odb::access; +}; + +// Test the case where the object has just the auto id. +// +#pragma db object +struct auto_only +{ + #pragma db auto id pgsql:type("BIGINT") + unsigned short id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/id/auto/testscript b/odb-tests/common/id/auto/testscript new file mode 100644 index 0000000..bb2a3a4 --- /dev/null +++ b/odb-tests/common/id/auto/testscript @@ -0,0 +1,33 @@ +# file : common/id/auto/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/id/composite/buildfile b/odb-tests/common/id/composite/buildfile new file mode 100644 index 0000000..4bc9f9a --- /dev/null +++ b/odb-tests/common/id/composite/buildfile @@ -0,0 +1,42 @@ +# file : common/id/composite/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_id_comp_ \ + --generate-schema \ + --generate-query \ + --generate-session + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/id/composite/driver.cxx b/odb-tests/common/id/composite/driver.cxx new file mode 100644 index 0000000..3d66101 --- /dev/null +++ b/odb-tests/common/id/composite/driver.cxx @@ -0,0 +1,731 @@ +// file : common/id/composite/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test composite object ids. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test 1. + // + { + using namespace test1; + + object o1 (scomp ("aaa", "bbb", "ccc"), 123); + o1.vec.push_back (scomp ("xxx", "xxx", "xxx")); + o1.vec.push_back (scomp ("yyy", "yyy", "yyy")); + + object o2 (scomp ("aaa", "bbb", "ccd"), 234); + o2.vec.push_back (scomp ("zzz", "", "zzz")); + + object o3 (scomp ("baa", "bbb", "ccc"), 345); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + unique_ptr p3 (db->load (o3.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + assert (*p3 == o3); + } + + // Update. + // + { + transaction t (db->begin ()); + unique_ptr p (db->load (o1.id)); + p->num++; + db->update (*p); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o1.id)); + t.commit (); + + assert (p->num == o1.num + 1); + } + + // Erase. + // + { + transaction t (db->begin ()); + db->erase (o1.id); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->find (o1.id)); + assert (p.get () == 0); + t.commit (); + } + } + + // Test 2. + // + { + using namespace test2; + + object2 o2 (ncomp (2, 0, 1)); + o2.o1 = new object1 (scomp ("o1", "o2", "aaa")); + + object3 o3 (ncomp (3, 0, 1)); + o3.o1.push_back (new object1 (scomp ("o1", "o3", "aaa"))); + o3.o1.push_back (new object1 (scomp ("o1", "o3", "bbb"))); + + object4 o4 (ncomp (4, 0, 1)); + o4.c.o2 = new object2 (ncomp (2, 4, 1)); + o4.c.o2->o1 = new object1 (scomp ("o1", "o2", "ccc")); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o2.o1); + db->persist (o2); + db->persist (o3.o1[0]); + db->persist (o3.o1[1]); + db->persist (o3); + db->persist (o4.c.o2->o1); + db->persist (o4.c.o2); + db->persist (o4); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + unique_ptr p2 (db->load (o2.id)); + unique_ptr p3 (db->load (o3.id)); + unique_ptr p4 (db->load (o4.id)); + t.commit (); + + assert (p2->o1->id == o2.o1->id); + assert (p3->o1.size () == o3.o1.size ()); + assert (p3->o1[0]->id == o3.o1[0]->id); + assert (p3->o1[1]->id == o3.o1[1]->id); + assert (p4->c.o2->id == o4.c.o2->id); + assert (p4->c.o2->o1->id == o4.c.o2->o1->id); + } + + // Update. + // + { + scomp id2, id3; + + { + transaction t (db->begin ()); + + unique_ptr p2 (db->load (o2.id)); + delete p2->o1; + p2->o1 = new object1 (scomp ("o1", "o2", "bbb")); + id2 = db->persist (p2->o1); + db->update (*p2); + + unique_ptr p3 (db->load (o3.id)); + delete p3->o1.back (); + p3->o1.pop_back (); + p3->o1.push_back (new object1 (scomp ("o1", "o3", "ccc"))); + id3 = db->persist (p3->o1.back ()); + db->update (*p3); + + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p2 (db->load (o2.id)); + unique_ptr p3 (db->load (o3.id)); + t.commit (); + + assert (p2->o1->id == id2); + assert (p3->o1.back ()->id == id3); + } + } + + // Query. + // + { + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + { + result r (db->query (query::o1->id.str3 == "bbb")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->id == o2.id); + assert (++i == r.end ()); + } + + { + // As id (dual interface). + // + result r (db->query (query::o1.str3 == "bbb")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->id == o2.id); + assert (++i == r.end ()); + } + + t.commit (); + } + + // Second level composite object pointer. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query (query::c.o2->o1.str3 == "ccc")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->id == o4.id); + assert (++i == r.end ()); + + t.commit (); + } + } + + // View. + // + { + transaction t (db->begin ()); + + { + typedef odb::query query; + typedef odb::result result; + + result r (db->query (query::object2::id.num2 == 0)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->num == 1 && i->str == "bbb"); + assert (++i == r.end ()); + } + + { + typedef odb::query query; + typedef odb::result result; + + result r (db->query ((query::object3::id.num2 == 0) + + "ORDER BY" + query::object1::id.str3)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->num == 1 && i->str == "aaa"); + assert (++i != r.end ()); + assert (i->num == 1 && i->str == "ccc"); + assert (++i == r.end ()); + } + + { + typedef odb::query query; + typedef odb::result result; + + result r (db->query (query::object4::id.num2 == 0)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->num4 == 1 && i->num2 == 1 && i->str == "ccc"); + assert (++i == r.end ()); + } + + t.commit (); + } + } + + // Test 3. + // + { + using namespace test3; + + object2 o2 (ncomp (2, 0, 1)); + o2.o1 = new object1 (scomp ("o1", "o2", "aaa")); + o2.o1->o2 = &o2; + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o2.o1); + db->persist (o2); + t.commit (); + } + + // Load. + // + { + session s; + transaction t (db->begin ()); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (p2->o1->o2->id == o2.id); + } + + // Query. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + { + session s; + + result r (db->query (query::o2->id.num2 == 0)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->id == o2.o1->id); + + i->o2->o1 = 0; + delete i->o2; + + assert (++i == r.end ()); + } + + t.commit (); + } + + // View. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query (query::object1::id.str2 == "o2")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->num == 1 && i->str == "aaa"); + assert (++i == r.end ()); + + t.commit (); + } + } + + // Test 4. + // + { + using namespace test4; + + object2 o2 (ncomp (2, 0, 1)); + + o2.o1.push_back (new object1 (scomp ("o1", "o2", "aaa"))); + o2.o1.back ()->o2 = &o2; + + o2.o1.push_back (new object1 (scomp ("o1", "o2", "bbb"))); + o2.o1.back ()->o2 = &o2; + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o2.o1[0]); + db->persist (o2.o1[1]); + db->persist (o2); + t.commit (); + } + + // Load. + // + { + session s; + transaction t (db->begin ()); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (p2->o1.size () == 2); + assert (p2->o1[0]->o2->id == o2.id); + assert (p2->o1[1]->o2->id == o2.id); + } + + // Query. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + { + session s; + + result r (db->query (query::o2->id.num2 == 0)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->id == o2.o1[0]->id); + i->o2->o1.clear (); + + assert (++i != r.end ()); + assert (i->id == o2.o1[1]->id); + + i->o2->o1.clear (); + delete i->o2; + + assert (++i == r.end ()); + } + + t.commit (); + } + + // View. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query (query::object1::id.str3 == "bbb")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->num == 1 && i->str == "bbb"); + assert (++i == r.end ()); + + t.commit (); + } + } + + // Test 5. + // + { + using namespace test5; + + object2 o2 (ncomp (2, 0, 1)); + + o2.o1.push_back (new object1 (scomp ("o1", "o2", "aaa"))); + o2.o1.back ()->o2 = &o2; + + o2.o1.push_back (new object1 (scomp ("o1", "o2", "bbb"))); + o2.o1.back ()->o2 = &o2; + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o2.o1[0]); + db->persist (o2.o1[1]); + db->persist (o2); + t.commit (); + } + + // Load. + // + { + session s; + transaction t (db->begin ()); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (p2->o1.size () == 2); + + assert (p2->o1[0]->id == o2.o1[0]->id); + assert (p2->o1[0]->o2->id == o2.id); + + assert (p2->o1[1]->id == o2.o1[1]->id); + assert (p2->o1[1]->o2->id == o2.id); + } + + // View. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query ((query::object2::id.num2 == 0) + + "ORDER BY" + query::object1::id.str3)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->num == 1 && i->str == "aaa"); + assert (++i != r.end ()); + assert (i->num == 1 && i->str == "bbb"); + assert (++i == r.end ()); + + t.commit (); + } + } + + // Test 6. + // + { + using namespace test6; + + object2 o2 (ncomp (2, 0, 1)); + + o2.o1.push_back (new object1 (scomp ("o1", "o2", "aaa"))); + o2.o1.back ()->o2.push_back (&o2); + + o2.o1.push_back (new object1 (scomp ("o1", "o2", "bbb"))); + o2.o1.back ()->o2.push_back (&o2); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o2.o1[0]); + db->persist (o2.o1[1]); + db->persist (o2); + t.commit (); + } + + // Load. + // + { + session s; + transaction t (db->begin ()); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (p2->o1.size () == 2); + + assert (p2->o1[0]->id == o2.o1[0]->id); + assert (p2->o1[0]->o2[0]->id == o2.id); + + assert (p2->o1[1]->id == o2.o1[1]->id); + assert (p2->o1[1]->o2[0]->id == o2.id); + } + + // View. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query ((query::object2::id.num2 == 0) + + "ORDER BY" + query::object1::id.str3)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->num == 1 && i->str == "aaa"); + assert (++i != r.end ()); + assert (i->num == 1 && i->str == "bbb"); + assert (++i == r.end ()); + + t.commit (); + } + } + + // Test 7. + // + { + using namespace test7; + + object o (scomp ("aaa", "bbb", "ccc"), 123); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + t.commit (); + + assert (*p == o); + } + + // Update. + // + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + p->num++; + db->update (*p); + + try + { + db->update (o); + assert (false); + } + catch (const object_changed&) + { + } + + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + t.commit (); + + assert (p->num == o.num + 1); + } + + // Erase. + // + { + transaction t (db->begin ()); + + try + { + db->update (o); + assert (false); + } + catch (const object_changed&) + { + } + + t.commit (); + } + } + + // Test 8. + // + { + using namespace test8; + + object2 o2a, o2b; + object3 o3; + + o2b.o1 = new object1 (scomp ("222", "aaa", "bbb"), 123); + o3.o1.push_back (0); + o3.o1.push_back (new object1 (scomp ("333", "aaa", "bbb"), 234)); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o2a); + db->persist (o2b); + db->persist (o2b.o1); + db->persist (o3); + db->persist (o3.o1[1]); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + unique_ptr p2a (db->load (o2a.id)); + unique_ptr p2b (db->load (o2b.id)); + unique_ptr p3 (db->load (o3.id)); + t.commit (); + + assert (p2a->o1 == 0); + assert (p2b->o1 != 0 && *p2b->o1 == *o2b.o1); + assert (p3->o1[0] == 0); + assert (p3->o1[1] != 0 && *p3->o1[1] == *o3.o1[1]); + } + + // Update. + // + { + object1* o1 (o3.o1[1]); + + o3.o1.clear (); + o3.o1.push_back (o2b.o1); + o3.o1.push_back (0); + + o2a.o1 = o1; + o2b.o1 = 0; + + transaction t (db->begin ()); + db->update (o2a); + db->update (o2b); + db->update (o3); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p2a (db->load (o2a.id)); + unique_ptr p2b (db->load (o2b.id)); + unique_ptr p3 (db->load (o3.id)); + t.commit (); + + assert (p2a->o1 != 0 && *p2a->o1 == *o2a.o1); + assert (p2b->o1 == 0); + assert (p3->o1[0] != 0 && *p3->o1[0] == *o3.o1[0]); + assert (p3->o1[1] == 0); + } + } + + // Test 9. + { + using namespace test9; + + object o (123, "abc"); + o.v.push_back (123); + + // persist + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + result r (db->query ()); + result::iterator i (r.begin ()); + assert (i != r.end () && o == *i && ++i == r.end ()); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/id/composite/test.hxx b/odb-tests/common/id/composite/test.hxx new file mode 100644 index 0000000..70856a6 --- /dev/null +++ b/odb-tests/common/id/composite/test.hxx @@ -0,0 +1,519 @@ +// file : common/id/composite/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +#pragma db value +struct scomp +{ + scomp () {} + scomp (const std::string& s1, const std::string& s2, const std::string& s3) + : str1 (s1), str2 (s2), str3 (s3) + { + } + + std::string str1; + std::string str2; + std::string str3; +}; + +inline bool +operator== (const scomp& x, const scomp& y) +{ + return x.str1 == y.str1 && x.str2 == y.str2 && x.str3 == y.str3; +} + +inline bool +operator< (const scomp& x, const scomp& y) +{ + return x.str1 < y.str1 || + (x.str1 == y.str1 && x.str2 < y.str2) || + (x.str1 == y.str1 && x.str2 == y.str2 && x.str3 < y.str3); +} + +#pragma db value +struct ncomp +{ + ncomp () {} + ncomp (unsigned short n1, unsigned short n2, unsigned short n3) + : num1 (n1), num2 (n2), num3 (n3) + { + } + + unsigned short num1; + unsigned short num2; + unsigned short num3; +}; + +inline bool +operator== (const ncomp& x, const ncomp& y) +{ + return x.num1 == y.num1 && x.num2 == y.num2 && x.num3 == y.num3; +} + +inline bool +operator< (const ncomp& x, const ncomp& y) +{ + return x.num1 < y.num1 || + (x.num1 == y.num1 && x.num2 < y.num2) || + (x.num1 == y.num1 && x.num2 == y.num2 && x.num3 < y.num3); +} + +// Test object with composite id, container. +// +#pragma db namespace table("t1_") +namespace test1 +{ + #pragma db object + struct object + { + object () {} + object (const scomp& i, unsigned long n): id (i), num (n) {} + + #pragma db id + scomp id; + + unsigned long num; + std::vector vec; + }; + + inline bool + operator== (const object& x, const object& y) + { + return x.id == y.id && x.num == y.num && x.vec == y.vec; + } +} + +// Test to-one and to-many relationships with composite id as well as +// queries and views. +// +#pragma db namespace table("t2_") +namespace test2 +{ + #pragma db object + struct object1 + { + object1 () {} + object1 (const scomp& i): id (i) {} + + #pragma db id + scomp id; + }; + + #pragma db object + struct object2 + { + object2 (): o1 (0) {} + object2 (const ncomp& i): id (i), o1 (0) {} + ~object2 () {delete o1;} + + #pragma db id + ncomp id; + + object1* o1; + }; + + #pragma db object + struct object3 + { + object3 () {} + object3 (const ncomp& i): id (i) {} + + ~object3 () + { + for (std::vector::iterator i (o1.begin ()); + i != o1.end (); ++i) + delete *i; + } + + #pragma db id + ncomp id; + + std::vector o1; + }; + + // Test second-level query pointer test as well as pointers in + // composite types. + // + #pragma db value + struct comp + { + comp (): o2 (0) {} + ~comp () {delete o2;} + + object2* o2; + }; + + #pragma db object + struct object4 + { + object4 () {} + object4 (const ncomp& i): id (i) {} + + #pragma db id + ncomp id; + + comp c; + }; + + #pragma db view object(object2) object(object1) + struct view2 + { + #pragma db column (object2::id.num3) + unsigned short num; + + #pragma db column (object1::id.str3) + std::string str; + }; + + #pragma db view object(object3) object(object1) + struct view3 + { + #pragma db column (object3::id.num3) + unsigned short num; + + #pragma db column (object1::id.str3) + std::string str; + }; + + #pragma db view object(object4) object(object2) object(object1) + struct view4 + { + #pragma db column (object4::id.num3) + unsigned short num4; + + #pragma db column (object2::id.num3) + unsigned short num2; + + #pragma db column (object1::id.str3) + std::string str; + }; +} + +// Test one-to-one(i) relationship with composite id. +// +#pragma db namespace table("t3_") +namespace test3 +{ + struct object2; + + #pragma db object + struct object1 + { + object1 () {} + object1 (const scomp& i): id (i) {} + + #pragma db id + scomp id; + + #pragma db inverse(o1) + object2* o2; + }; + + #pragma db object + struct object2 + { + object2 (): o1 (0) {} + object2 (const ncomp& i): id (i), o1 (0) {} + ~object2 () {delete o1;} + + #pragma db id + ncomp id; + + object1* o1; + }; + + #pragma db view object(object2) object(object1) + struct view + { + #pragma db column (object2::id.num3) + unsigned short num; + + #pragma db column (object1::id.str3) + std::string str; + }; +} + +// Test many-to-one(i) relationship with composite id. +// +#pragma db namespace table("t4_") +namespace test4 +{ + struct object2; + + #pragma db object + struct object1 + { + object1 () {} + object1 (const scomp& i): id (i) {} + + #pragma db id + scomp id; + + #pragma db inverse(o1) + object2* o2; + }; + + #pragma db object + struct object2 + { + object2 () {} + object2 (const ncomp& i): id (i) {} + + ~object2 () + { + for (std::vector::iterator i (o1.begin ()); + i != o1.end (); ++i) + delete *i; + } + + #pragma db id + ncomp id; + + std::vector o1; + }; + + #pragma db view object(object2) object(object1) + struct view + { + #pragma db column (object2::id.num3) + unsigned short num; + + #pragma db column (object1::id.str3) + std::string str; + }; +} + +// Test one-to-many(i) relationship with composite id. +// +#pragma db namespace table("t5_") +namespace test5 +{ + struct object2; + + #pragma db object + struct object1 + { + object1 () {} + object1 (const scomp& i): id (i) {} + + #pragma db id + scomp id; + + object2* o2; + }; + + #pragma db object + struct object2 + { + object2 () {} + object2 (const ncomp& i): id (i) {} + + ~object2 () + { + for (std::vector::iterator i (o1.begin ()); + i != o1.end (); ++i) + delete *i; + } + + #pragma db id + ncomp id; + + #pragma db inverse(o2) + std::vector o1; + }; + + #pragma db view object(object2) object(object1) + struct view + { + #pragma db column (object2::id.num3) + unsigned short num; + + #pragma db column (object1::id.str3) + std::string str; + }; +} + +// Test many-to-many(i) relationship with composite id. +// +#pragma db namespace table("t6_") +namespace test6 +{ + struct object2; + + #pragma db object + struct object1 + { + object1 () {} + object1 (const scomp& i): id (i) {} + + #pragma db id + scomp id; + + std::vector o2; + }; + + #pragma db object + struct object2 + { + object2 () {} + object2 (const ncomp& i): id (i) {} + + ~object2 () + { + for (std::vector::iterator i (o1.begin ()); + i != o1.end (); ++i) + delete *i; + } + + #pragma db id + ncomp id; + + #pragma db inverse(o2) + std::vector o1; + }; + + #pragma db view object(object2) object(object1) + struct view + { + #pragma db column (object2::id.num3) + unsigned short num; + + #pragma db column (object1::id.str3) + std::string str; + }; +} + +// Test object with composite id and version (optimistic concurrency). +// +#pragma db namespace table("t7_") +namespace test7 +{ + #pragma db object optimistic + struct object + { + object () {} + object (const scomp& i, unsigned long n): id (i), num (n) {} + + #pragma db id + scomp id; + + #pragma db version + unsigned long ver; + + unsigned long num; + }; + + inline bool + operator== (const object& x, const object& y) + { + return x.id == y.id && x.ver == y.ver && x.num == y.num; + } +} + +// Test composite NULL pointers. +// +#pragma db namespace table("t8_") +namespace test8 +{ + #pragma db object + struct object1 + { + object1 () {} + object1 (const scomp& i, unsigned long n): id (i), num (n) {} + + #pragma db id + scomp id; + + unsigned long num; + }; + + inline bool + operator== (const object1& x, const object1& y) + { + return x.id == y.id && x.num == y.num; + } + + #pragma db object + struct object2 + { + object2 (): o1 (0) {} + ~object2 () {delete o1;} + + #pragma db id auto + unsigned long id; + + object1* o1; + }; + + #pragma db object + struct object3 + { + ~object3 () + { + for (std::vector::iterator i (o1.begin ()); + i != o1.end (); ++i) + delete *i; + } + + #pragma db id auto + unsigned long id; + + std::vector o1; + }; +} + +// Test composite id definition inside object. +// +#pragma db namespace table("t9_") +namespace test9 +{ + #pragma db object + struct object + { + object (unsigned long n = 0, const std::string& s = "") + { + id_.num = n; + id_.str = s; + } + + unsigned long num () const {return id_.num;} + const std::string& str () const {return id_.str;} + + std::vector v; + + private: + friend class odb::access; + + #pragma db value + struct comp + { + unsigned long num; + std::string str; + + bool + operator< (const comp& x) const + { + return num < x.num || (num == x.num && str < x.str); + } + }; + + #pragma db id + comp id_; + }; + + inline bool + operator== (const object& x, const object& y) + { + return x.num () == y.num () && x.str () == y.str () && x.v == y.v; + } +} + + +#endif // TEST_HXX diff --git a/odb-tests/common/id/composite/testscript b/odb-tests/common/id/composite/testscript new file mode 100644 index 0000000..f87d4bc --- /dev/null +++ b/odb-tests/common/id/composite/testscript @@ -0,0 +1,33 @@ +# file : common/id/composite/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/id/nested/buildfile b/odb-tests/common/id/nested/buildfile new file mode 100644 index 0000000..777cb65 --- /dev/null +++ b/odb-tests/common/id/nested/buildfile @@ -0,0 +1,41 @@ +# file : common/nested/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_id_nested_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/id/nested/driver.cxx b/odb-tests/common/id/nested/driver.cxx new file mode 100644 index 0000000..92a80f6 --- /dev/null +++ b/odb-tests/common/id/nested/driver.cxx @@ -0,0 +1,266 @@ +// file : common/id/nested/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test nested ids. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +struct failed {}; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + + // Simple nested id. + // + { + using namespace test1; + + object o1 (1, "a", 3); + o1.v.push_back (123); + + object o2 (4, "b", 6); + o2.v.push_back (234); + + object1 o (new object (10, "abc", 11)); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o.p); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id.y)); + unique_ptr p2 (db->load (o2.id.y)); + unique_ptr p (db->load (o.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + assert (*p == o); + } + + o1.z++; + o1.v.pop_back (); + o1.v.push_back (234); + + o2.z--; + o2.v.back ()++; + o2.v.push_back (123); + + delete o.p; + o.p = new object (20, "xyz", 11); + + { + transaction t (db->begin ()); + db->update (o1); + db->update (o2); + db->persist (o.p); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id.y)); + unique_ptr p2 (db->load (o2.id.y)); + unique_ptr p (db->load (o.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + assert (*p == o); + } + } + + // Composite nested id. + // + { + using namespace test2; + + object o1 (1, 2, "a", 123); + o1.v.push_back (123); + + object o2 (1, 3, "b", 234); + o2.v.push_back (234); + + object1 o (new object (2, 2, "abc", 123)); + o.p->v.push_back (345); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o.p); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id.c)); + unique_ptr p2 (db->load (o2.id.c)); + unique_ptr p (db->load (o.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + assert (*p == o); + } + + o1.z++; + o1.v.pop_back (); + o1.v.push_back (234); + + o2.z--; + o2.v.modify_back ()++; + o2.v.push_back (123); + + delete o.p; + o.p = new object (2, 3, "xyz", 234); + + { + transaction t (db->begin ()); + db->update (o1); + db->update (o2); + db->persist (o.p); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id.c)); + unique_ptr p2 (db->load (o2.id.c)); + unique_ptr p (db->load (o.id)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + assert (*p == o); + } + } + + // Custom/by-value access. + // + { + using namespace test3; + + object o1 (1, "a", 3); + object o2 (4, "b", 6); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id.y)); + unique_ptr p2 (db->load (o2.id.y)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + + o1.z++; + o2.z--; + + { + transaction t (db->begin ()); + db->update (o1); + db->update (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id.y)); + unique_ptr p2 (db->load (o2.id.y)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + } + + // Polymorphic. + // + { + using namespace test4; + + base o1 (1, "a"); + object o2 (2, "b", 1); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id.y)); + unique_ptr p2 (db->load (o2.id.y)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + + o2.z--; + + { + transaction t (db->begin ()); + db->update (o1); + db->update (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id.y)); + unique_ptr p2 (db->load (o2.id.y)); + t.commit (); + + assert (*p1 == o1); + assert (*p2 == o2); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/id/nested/test.hxx b/odb-tests/common/id/nested/test.hxx new file mode 100644 index 0000000..06ee6b8 --- /dev/null +++ b/odb-tests/common/id/nested/test.hxx @@ -0,0 +1,217 @@ +// file : common/id/nested/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include +#include + +// Simple nested id. +// +#pragma db namespace table("t1_") +namespace test1 +{ + #pragma db value + struct comp + { + int x; + std::string y; + }; + + #pragma db object + struct object + { + #pragma db id(y) + comp id; + + int z; + std::vector v; + + object () {} + object (int x, std::string y, int z_): z (z_) {id.x = x; id.y = y;} + }; + + inline bool + operator== (object a, object b) + { + return a.id.x == b.id.x && a.id.y == b.id.y && a.z == b.z && a.v == b.v; + } + + #pragma db object + struct object1 + { + #pragma db id auto + int id; + + object* p; + + object1 (object* p_ = 0): p (p_) {} + ~object1 () {delete p;} + }; + + inline bool + operator== (const object1& a, const object1& b) + { + return a.id == b.id && *a.p == *b.p; + } +} + +// Composite nested id. +// +#pragma db namespace table("t2_") +namespace test2 +{ + #pragma db value + struct comp1 + { + int x; + int y; + }; + + #pragma db value + struct comp2 + { + comp1 c; + std::string s; + }; + + #pragma db object + struct object + { + #pragma db id(c) + comp2 id; + + int z; + odb::vector v; + + object () {} + object (int x, int y, std::string s, int z_) + : z (z_) {id.c.x = x; id.c.y = y; id.s = s;} + }; + + inline bool + operator== (object a, object b) + { + return a.id.c.x == b.id.c.x && a.id.c.y == b.id.c.y && + a.id.s == b.id.s && a.z == b.z && a.v == b.v; + } + + #pragma db object + struct object1 + { + #pragma db id auto + int id; + + object* p; + + object1 (object* p_ = 0): p (p_) {} + ~object1 () {delete p;} + }; + + inline bool + operator== (const object1& a, const object1& b) + { + return a.id == b.id && *a.p == *b.p; + } + + // Multiple levels of nesting, just a compile test. + // + #pragma db object + struct object2 + { + #pragma db id(c.x) + comp2 id; + + int z; + }; +} + +// Custom/by-value access. +// +#pragma db namespace table("t3_") +namespace test3 +{ + #pragma db value + struct comp + { + int x; + + std::string get_y () const {return y;} + void set_y (std::string v) {y = v;} + + #pragma db get(get_y) set(set_y) + std::string y; + }; + + #pragma db object + struct object + { + comp get_id () const {return id;} + void set_id (comp v) {id = v;} + + #pragma db id(y) get(get_id) set(set_id) + comp id; + + int z; + + object () {} + object (int x, std::string y, int z_): z (z_) {id.x = x; id.y = y;} + }; + + inline bool + operator== (object a, object b) + { + return a.id.x == b.id.x && a.id.y == b.id.y && a.z == b.z; + } +} + +// Polymorphic. +// +#pragma db namespace table("t4_") +namespace test4 +{ + #pragma db value + struct comp + { + int x; + std::string y; + }; + + #pragma db object polymorphic + struct base + { + #pragma db id(y) + comp id; + + virtual ~base () {} + base () {} + base (int x, std::string y) {id.x = x; id.y = y;} + }; + + inline bool + operator== (const base& a, const base& b) + { + return a.id.x == b.id.x && a.id.y == b.id.y; + } + + #pragma db object + struct object: base + { + int z; + + object () {} + object (int x, std::string y, int z_): base (x, y), z (z_) {} + }; + + inline bool + operator== (const object& a, const object& b) + { + return a.id.x == b.id.x && a.id.y == b.id.y && a.z == b.z; + } +} + +#endif // TEST_HXX diff --git a/odb-tests/common/id/nested/testscript b/odb-tests/common/id/nested/testscript new file mode 100644 index 0000000..89e8d7a --- /dev/null +++ b/odb-tests/common/id/nested/testscript @@ -0,0 +1,33 @@ +# file : common/nested/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/include/.gitignore b/odb-tests/common/include/.gitignore new file mode 100644 index 0000000..d52f166 --- /dev/null +++ b/odb-tests/common/include/.gitignore @@ -0,0 +1,17 @@ +# ODB-generated files. +# +obj1-odb.?xx +obj1-odb-*.?xx +obj2-odb.?xx +obj2-odb-*.?xx +obj3-odb.?xx +obj3-odb-*.?xx + +test1-odb.?xx +test1-odb-*.?xx +test2-odb.?xx +test2-odb-*.?xx +test3-odb.?xx +test3-odb-*.?xx +test4-odb.?xx +test4-odb-*.?xx diff --git a/odb-tests/common/include/buildfile b/odb-tests/common/include/buildfile new file mode 100644 index 0000000..6db878c --- /dev/null +++ b/odb-tests/common/include/buildfile @@ -0,0 +1,51 @@ +# file : common/include/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +hs = obj1 obj2 obj3 test1 test2 test3 test4 + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +for h: $hs +{ + exe{driver}: {hxx ixx cxx}{$h-odb} + + <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} + + for db: $databases + { + exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi + <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} + } +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). Also see driver.cxx for the details on +# the -I options usage. +# +odb_options = --table-prefix include_ \ + "-I$out_base" \ + "-I$src_base/.." \ + "-I$src_base/../.." + +cxx.poptions =+ "-I$out_base" "-I$src_base" \ + "-I$out_base/../.." "-I$src_base/../.." + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/include/driver.cxx b/odb-tests/common/include/driver.cxx new file mode 100644 index 0000000..561746a --- /dev/null +++ b/odb-tests/common/include/driver.cxx @@ -0,0 +1,42 @@ +// file : common/include/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test inclusion of -odb files (compilation test). +// +// The setup of this test is as follows: the ODB compiler has two +// additional include directories in its search path: .. and ../.. +// while the C++ compiler has only ../.. . This way, if a ..-based +// path is used in the generated code, the C++ compilation will +// fail. +// + +#include +#include + +#include +#include + +#include + +#include "test1.hxx" +#include "test1-odb.hxx" + +#include "test2.hxx" +#include "test2-odb.hxx" + +#include "test3.hxx" +#include "test3-odb.hxx" + +#include "test4.hxx" +#include "test4-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main () +{ +} diff --git a/odb-tests/common/include/obj1.hxx b/odb-tests/common/include/obj1.hxx new file mode 100644 index 0000000..33ae0d6 --- /dev/null +++ b/odb-tests/common/include/obj1.hxx @@ -0,0 +1,25 @@ +// file : common/include/obj1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJ1_HXX +#define OBJ1_HXX + +#include + +#pragma db object +struct object1 +{ + object1 (unsigned long id) + : id_ (id) + { + } + + object1 () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // OBJ1_HXX diff --git a/odb-tests/common/include/obj2.hxx b/odb-tests/common/include/obj2.hxx new file mode 100644 index 0000000..2f20f58 --- /dev/null +++ b/odb-tests/common/include/obj2.hxx @@ -0,0 +1,25 @@ +// file : common/include/obj2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJ2_HXX +#define OBJ2_HXX + +#include + +#pragma db object +struct object2 +{ + object2 (unsigned long id) + : id_ (id) + { + } + + object2 () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // OBJ2_HXX diff --git a/odb-tests/common/include/obj3.hxx b/odb-tests/common/include/obj3.hxx new file mode 100644 index 0000000..432145b --- /dev/null +++ b/odb-tests/common/include/obj3.hxx @@ -0,0 +1,25 @@ +// file : common/include/obj3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJ3_HXX +#define OBJ3_HXX + +#include + +#pragma db object +struct object3 +{ + object3 (unsigned long id) + : id_ (id) + { + } + + object3 () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // OBJ3_HXX diff --git a/odb-tests/common/include/objs1.hxx b/odb-tests/common/include/objs1.hxx new file mode 100644 index 0000000..6e949e2 --- /dev/null +++ b/odb-tests/common/include/objs1.hxx @@ -0,0 +1,13 @@ +// file : common/include/objs1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJS1_HXX +#define OBJS1_HXX + +#ifdef ODB_COMPILER +# include +# include +# include +#endif + +#endif // OBJS1_HXX diff --git a/odb-tests/common/include/objs2.hxx b/odb-tests/common/include/objs2.hxx new file mode 100644 index 0000000..4f8133b --- /dev/null +++ b/odb-tests/common/include/objs2.hxx @@ -0,0 +1,13 @@ +// file : common/include/objs2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJS2_HXX +#define OBJS2_HXX + +#ifdef ODB_COMPILER +# include "include/obj1.hxx" +# include "include/obj2.hxx" +# include "include/obj3.hxx" +#endif + +#endif // OBJS2_HXX diff --git a/odb-tests/common/include/objs3.hxx b/odb-tests/common/include/objs3.hxx new file mode 100644 index 0000000..2f7aaff --- /dev/null +++ b/odb-tests/common/include/objs3.hxx @@ -0,0 +1,11 @@ +// file : common/include/objs3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJS3_HXX +#define OBJS3_HXX + +#include "../include/obj1.hxx" +#include "../include/obj2.hxx" +#include "../include/obj3.hxx" + +#endif // OBJS3_HXX diff --git a/odb-tests/common/include/objs4.hxx b/odb-tests/common/include/objs4.hxx new file mode 100644 index 0000000..d766fe6 --- /dev/null +++ b/odb-tests/common/include/objs4.hxx @@ -0,0 +1,11 @@ +// file : common/include/objs1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef OBJS4_HXX +#define OBJS4_HXX + +#include +#include +#include + +#endif // OBJS4_HXX diff --git a/odb-tests/common/include/test1.hxx b/odb-tests/common/include/test1.hxx new file mode 100644 index 0000000..1914ddb --- /dev/null +++ b/odb-tests/common/include/test1.hxx @@ -0,0 +1,16 @@ +// file : common/include/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +// Test include directive parsing. +// +#include"obj1.hxx" + + # include \ + + +/*comment*/ # /*comment*/ include /* comment */ "obj3.hxx" // comment + +#endif // TEST1_HXX diff --git a/odb-tests/common/include/test2.hxx b/odb-tests/common/include/test2.hxx new file mode 100644 index 0000000..6017ac4 --- /dev/null +++ b/odb-tests/common/include/test2.hxx @@ -0,0 +1,15 @@ +// file : common/include/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +// Test preference of includes from the main file. +// +#include "objs1.hxx" + +#include "obj1.hxx" +#include "obj2.hxx" +#include "obj3.hxx" + +#endif // TEST2_HXX diff --git a/odb-tests/common/include/test3.hxx b/odb-tests/common/include/test3.hxx new file mode 100644 index 0000000..e55ecdb --- /dev/null +++ b/odb-tests/common/include/test3.hxx @@ -0,0 +1,12 @@ +// file : common/include/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +// Test preference of longer (more qualified) paths. +// +#include "objs2.hxx" +#include "objs3.hxx" + +#endif // TEST3_HXX diff --git a/odb-tests/common/include/test4.hxx b/odb-tests/common/include/test4.hxx new file mode 100644 index 0000000..b58e679 --- /dev/null +++ b/odb-tests/common/include/test4.hxx @@ -0,0 +1,12 @@ +// file : common/include/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +// Test preference of <> over "". +// +#include "objs2.hxx" +#include "objs4.hxx" + +#endif // TEST3_HXX diff --git a/odb-tests/common/include/testscript b/odb-tests/common/include/testscript new file mode 100644 index 0000000..089f7a1 --- /dev/null +++ b/odb-tests/common/include/testscript @@ -0,0 +1,31 @@ +# file : common/include/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* &!odb-test.db +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $* +} diff --git a/odb-tests/common/index/buildfile b/odb-tests/common/index/buildfile new file mode 100644 index 0000000..535bd26 --- /dev/null +++ b/odb-tests/common/index/buildfile @@ -0,0 +1,40 @@ +# file : common/index/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix index_ \ + --generate-schema + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/index/driver.cxx b/odb-tests/common/index/driver.cxx new file mode 100644 index 0000000..7a22a7c --- /dev/null +++ b/odb-tests/common/index/driver.cxx @@ -0,0 +1,44 @@ +// file : common/index/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test index creation with db pragma index. See also database-specific +// tests. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + // This is just a schema creation test. + // + unique_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/index/test.hxx b/odb-tests/common/index/test.hxx new file mode 100644 index 0000000..f27783f --- /dev/null +++ b/odb-tests/common/index/test.hxx @@ -0,0 +1,142 @@ +// file : common/index/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +// Test basic functionality. +// +#pragma db namespace table("t1_") +namespace test1 +{ + #pragma db object + struct object + { + #pragma db id auto + unsigned long id_; + + #pragma db index + int i1; + + #pragma db unique + int i2; + + #pragma db unique index + int i3; + + int i4; + #pragma db index unique member(i4) + + int i5; + #pragma db index type("UNIQUE") member(i5) + + int i6; + #pragma db index("object_i6_index") member(i6) + + int i7; + int i8; + int i9; + + int i10; + #pragma db index member(i10, "ASC") + }; + + #pragma db index(object) member(i7) + #pragma db index(object::"object_i8_index") member(i8) +} + +#pragma db index(test1::object::"object_i9_index") member(i9) + +// Test composite indexes. +// +#pragma db namespace table("t2_") +namespace test2 +{ + #pragma db value + struct nested + { + int x; + int y; + }; + + #pragma db value + struct comp + { + int x; + int y; + nested n; + }; + + #pragma db object + struct object + { + #pragma db id auto + unsigned long id_; + + int i1a; + int i1b; + #pragma db index("object_i1_i") member(i1a) member(i1b) + + int i2a; + int i2b; + #pragma db index("object_i2_i") members(i2a, i2b) + + #pragma db index + comp c1; + + #pragma db index column("") + comp c2; + + comp c3; + #pragma db index member(c3.x) + #pragma db index member(c3.y) + + comp c4; + #pragma db index("object_c4_i") members(c4.x, c4.y, c4.n.x) + + comp c5; + int i5; + #pragma db index("object_ci5_i") member(c5) member(i5) + }; +} + +// Test container indexes. +// +#pragma db namespace table("t3_") +namespace test3 +{ + #pragma db value + struct id + { + int x; + int y; + }; + + #pragma db value + struct comp + { + int x; + std::vector v; + }; + + #pragma db object + struct object + { + #pragma db id + id id_; + + std::vector v; + #pragma db index unique member(v.id) + #pragma db index("object_v_index_index") member(v.index) + + comp c; + #pragma db index("object_c_v_id_index") member(c.v.id) + #pragma db index unique member(c.v.index) + }; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/index/testscript b/odb-tests/common/index/testscript new file mode 100644 index 0000000..cbce341 --- /dev/null +++ b/odb-tests/common/index/testscript @@ -0,0 +1,33 @@ +# file : common/index/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/inheritance/polymorphism/.gitignore b/odb-tests/common/inheritance/polymorphism/.gitignore new file mode 100644 index 0000000..f183a6f --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/.gitignore @@ -0,0 +1,76 @@ +# ODB-generated files. +# +test1-odb.?xx +test1-odb-*.?xx +test1.sql +test1-*.sql + +test2-odb.?xx +test2-odb-*.?xx +test2.sql +test2-*.sql + +test3-odb.?xx +test3-odb-*.?xx +test3.sql +test3-*.sql + +test4-odb.?xx +test4-odb-*.?xx +test4.sql +test4-*.sql + +test5-odb.?xx +test5-odb-*.?xx +test5.sql +test5-*.sql + +test6-odb.?xx +test6-odb-*.?xx +test6.sql +test6-*.sql + +test7-odb.?xx +test7-odb-*.?xx +test7.sql +test7-*.sql + +test8-odb.?xx +test8-odb-*.?xx +test8.sql +test8-*.sql + +test9-odb.?xx +test9-odb-*.?xx +test9.sql +test9-*.sql + +test10-odb.?xx +test10-odb-*.?xx +test10.sql +test10-*.sql + +test11-odb.?xx +test11-odb-*.?xx +test11.sql +test11-*.sql + +test12-odb.?xx +test12-odb-*.?xx +test12.sql +test12-*.sql + +test13-odb.?xx +test13-odb-*.?xx +test13.sql +test13-*.sql + +test14-odb.?xx +test14-odb-*.?xx +test14.sql +test14-*.sql + +test15-odb.?xx +test15-odb-*.?xx +test15.sql +test15-*.sql diff --git a/odb-tests/common/inheritance/polymorphism/buildfile b/odb-tests/common/inheritance/polymorphism/buildfile new file mode 100644 index 0000000..846eb12 --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/buildfile @@ -0,0 +1,52 @@ +# file : common/inheritance/polymorphism/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +hs = test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 \ + test12 test13 test14 test15 + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +for h: $hs +{ + exe{driver}: {hxx ixx cxx}{$h-odb} + + <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} + + for db: $databases + { + exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi + <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} + } +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix inhrt_p_ \ + --generate-schema \ + --generate-query \ + --generate-prepared + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc + +testscript@./: schemas = $hs diff --git a/odb-tests/common/inheritance/polymorphism/driver.cxx b/odb-tests/common/inheritance/polymorphism/driver.cxx new file mode 100644 index 0000000..12f4666 --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/driver.cxx @@ -0,0 +1,2093 @@ +// file : common/inheritance/polymorphism/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test polymorphic object inheritance. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test1.hxx" +#include "test2.hxx" +#include "test3.hxx" +#include "test4.hxx" +#include "test5.hxx" +#include "test6.hxx" +#include "test7.hxx" +#include "test8.hxx" +#include "test9.hxx" +#include "test10.hxx" +#include "test11.hxx" +#include "test12.hxx" +#include "test13.hxx" +#include "test14.hxx" +#include "test15.hxx" + +#include "test1-odb.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" +#include "test4-odb.hxx" +#include "test5-odb.hxx" +#include "test6-odb.hxx" +#include "test7-odb.hxx" +#include "test8-odb.hxx" +#include "test9-odb.hxx" +#include "test10-odb.hxx" +#include "test11-odb.hxx" +#include "test12-odb.hxx" +#include "test13-odb.hxx" +#include "test14-odb.hxx" +#include "test15-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +const char* events[] = +{ + "pre_persist", + "post_persist", + "pre_load", + "post_load", + "pre_update", + "post_update", + "pre_erase", + "post_erase" +}; + +namespace test6 +{ + void base:: + db_callback (callback_event e, database&) + { + cout << "base " << events[e] << " " << id << endl; + } + + void base:: + db_callback (callback_event e, database&) const + { + cout << "base " << events[e] << " " << id << " const" << endl; + } + + void derived:: + db_callback (callback_event e, database&) const + { + cout << "derived " << events[e] << " " << id << " const" << endl; + } +} + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test 1: basic polymorphism functionality. + // + { + using namespace test1; + + root r (1, 1); + base b (2, 2, "bbb"); + derived d (3, 3, "ddd"); + + r.strs.push_back ("a"); + r.strs.push_back ("aa"); + r.strs.push_back ("aaa"); + + b.nums.push_back (21); + b.nums.push_back (22); + b.nums.push_back (23); + b.strs.push_back ("b"); + b.strs.push_back ("bb"); + b.strs.push_back ("bbb"); + + d.nums.push_back (31); + d.nums.push_back (32); + d.nums.push_back (33); + d.strs.push_back ("d"); + d.strs.push_back ("dd"); + d.strs.push_back ("ddd"); + + { + transaction t (db->begin ()); + + // Static persist. + // + db->persist (r); + db->persist (b); + + // Dynamic persist. + // + root& r (d); + db->persist (r); + + t.commit (); + } + + // Static load. + // + { + transaction t (db->begin ()); + unique_ptr pr (db->load (r.id)); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + t.commit (); + + assert (*pr == r); + assert (*pb == b); + assert (*pd == d); + } + + // Dynamic load. + // + { + transaction t (db->begin ()); + unique_ptr pb (db->load (b.id)); + unique_ptr pd1 (db->load (d.id)); + unique_ptr pd2 (db->load (d.id)); + t.commit (); + + assert (*pb == b); + assert (*pd1 == d); + assert (*pd2 == d); + } + + // Invalid load. + // + { + transaction t (db->begin ()); + + try + { + unique_ptr p (db->load (r.id)); + assert (false); + } + catch (const object_not_persistent&) {} + + try + { + unique_ptr p (db->load (b.id)); + assert (false); + } + catch (const object_not_persistent&) {} + + t.commit (); + } + + // Static load into existing instance. + // + { + transaction t (db->begin ()); + root r1; + db->load (r.id, r1); + base b1; + db->load (b.id, b1); + derived d1; + db->load (d.id, d1); + t.commit (); + + assert (r1 == r); + assert (b1 == b); + assert (d1 == d); + } + + // Dynamic load into existing instance. + // + { + transaction t (db->begin ()); + base b1; + db->load (b.id, static_cast (b1)); + derived d1; + db->load (d.id, static_cast (d1)); + t.commit (); + + assert (b1 == b); + assert (d1 == d); + } + + // Invalid load into existing instance. + // + { + transaction t (db->begin ()); + + try + { + base b; + db->load (r.id, static_cast (b)); + assert (false); + } + catch (const object_not_persistent&) {} + + try + { + derived d; + db->load (b.id, static_cast (d)); + assert (false); + } + catch (const object_not_persistent&) {} + + t.commit (); + } + + // Slicing load. + // + { + transaction t (db->begin ()); + root b1; + db->load (b.id, b1); + base d1; + db->load (d.id, d1); + t.commit (); + + assert (b1 == static_cast (b)); + assert (d1 == static_cast (d)); + } + + // Static reload. + // + { + transaction t (db->begin ()); + root r1; + r1.id = r.id; + db->reload (r1); + base b1; + b1.id = b.id; + db->reload (b1); + derived d1; + d1.id = d.id; + db->reload (d1); + t.commit (); + + assert (r1 == r); + assert (b1 == b); + assert (d1 == d); + } + + // Dynamic reload. + // + { + transaction t (db->begin ()); + base b1; + b1.id = b.id; + db->reload (static_cast (b1)); + derived d1; + d1.id = d.id; + db->reload (static_cast (d1)); + t.commit (); + + assert (b1 == b); + assert (d1 == d); + } + + // Invalid reload. + // + { + transaction t (db->begin ()); + + try + { + base b; + b.id = r.id; + db->reload (static_cast (b)); + assert (false); + } + catch (const object_not_persistent&) {} + + try + { + derived d; + d.id = b.id; + db->reload (static_cast (d)); + assert (false); + } + catch (const object_not_persistent&) {} + + t.commit (); + } + + // Slicing reload. + // + { + transaction t (db->begin ()); + root b1; + b1.id = b.id; + db->reload (b1); + base d1; + d1.id = d.id; + db->reload (d1); + t.commit (); + + assert (b1 == static_cast (b)); + assert (d1 == static_cast (d)); + } + + // Query. + // + { + typedef odb::query root_query; + typedef odb::result root_result; + + typedef odb::query base_query; + typedef odb::result base_result; + + typedef odb::result derived_result; + + transaction t (db->begin ()); + + // Test loading via root. + // + { + root_result qr (db->query ("ORDER BY" + root_query::id)); + root_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && *i == r); + assert (++i != e && *i == b); + assert (++i != e && *i == d); + assert (++i == e); + } + + // Test loading via base. + // + { + base_result qr (db->query ("ORDER BY" + base_query::id)); + base_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && *i == b); + assert (++i != e && *i == d); + assert (++i == e); + } + + // Test loading via derived. + // + { + derived_result qr (db->query ()); + derived_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && *i == d); + assert (++i == e); + } + + // Test loading into an existing instance. + // + { + root_result qr (db->query ()); + + unsigned short mask (0); + + for (root_result::iterator i (qr.begin ()); i != qr.end (); ++i) + { + string ds (i.discriminator ()); + + if (ds == "test1::root") + { + root r1; + i.load (r1); + assert (r1 == r); + mask |= 1; + } + else if (ds == "test1::base") + { + base b1; + i.load (b1); + assert (b1 == b); + mask |= 2; + } + else if (ds == "test1::derived") + { + derived d1; + i.load (d1); + assert (d1 == d); + mask |= 4; + } + else + assert (false); + } + + assert (mask == 7); + } + + // Test query conditions with columns from multiple tables. + // + { + base_result qr ( + db->query ( + base_query::num == 3 && base_query::str == "ddd")); + + base_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && *i == d); + assert (++i == e); + } + + // Test discriminator access. + // + { + base_result qr (db->query (base_query::id == 3)); + base_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && i.discriminator () == "test1::derived"); + assert (++i == e); + } + + // Test loading of an object from the same hierarchy during + // query result iteration (tests image copying via change + // callbacks in some databases). + // + { + base_result qr (db->query ()); + + unsigned short mask (0); + + for (base_result::iterator i (qr.begin ()); i != qr.end (); ++i) + { + string ds (i.discriminator ()); + + if (ds == "test1::base") + { + unique_ptr d1 (db->load (d.id)); + assert (*d1 == d); + assert (*i == b); + mask |= 1; + } + else if (ds == "test1::derived") + { + unique_ptr b1 (db->load (b.id)); + assert (*b1 == b); + assert (*i == d); + mask |= 2; + } + } + + assert (mask == 3); + } + + t.commit (); + } + + // Views. + // + { + typedef odb::query root_query; + typedef odb::result root_result; + + typedef odb::query base_query; + typedef odb::result base_result; + + typedef odb::result derived_result; + + transaction t (db->begin ()); + + // root + // + { + root_result qr (db->query ("ORDER BY" + root_query::id)); + root_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && i->typeid_ == "test1::root" && i->num == r.num); + assert (++i != e && i->typeid_ == "test1::base" && i->num == b.num); + assert (++i != e && i->typeid_ == "test1::derived" && i->num == d.num); + assert (++i == e); + } + + // base + // + { + base_result qr (db->query ("ORDER BY" + base_query::id)); + base_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && + i->id == b.id && i->num == b.num && i->str == b.str); + assert (++i != e && + i->id == d.id && i->num == d.num && i->str == d.str); + assert (++i == e); + } + + // derived + // + { + derived_result qr (db->query ()); + derived_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && + i->num == d.num && i->str == d.str && + i->dnum == d.dnum && i->dstr == d.dstr); + assert (++i == e); + } + + t.commit (); + } + + // Update. + // + r.num++; + r.strs.push_back ("aaaa"); + + b.num++; + b.str += "b"; + b.nums.push_back (24); + b.strs.push_back ("bbbb"); + + d.num++; + d.str += "d"; + d.dnum++; + d.dstr += "d"; + d.nums.push_back (34); + d.strs.push_back ("dddd"); + + { + transaction t (db->begin ()); + + // Static update. + // + db->update (r); + db->update (b); + + // Dynamic update. + // + root& r (d); + db->update (r); + + t.commit (); + } + + // Verify update. + // + { + transaction t (db->begin ()); + unique_ptr pr (db->load (r.id)); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + t.commit (); + + assert (*pr == r); + assert (*pb == b); + assert (*pd == d); + } + + // Invalid erase via id. + // + { + transaction t (db->begin ()); + + try + { + db->erase (r.id); + assert (false); + } + catch (const object_not_persistent&) {} + + try + { + db->erase (b.id); + assert (false); + } + catch (const object_not_persistent&) {} + + t.commit (); + } + + // Static erase via id. + // + { + transaction t (db->begin ()); + db->erase (r.id); + db->erase (b.id); + t.commit (); + } + + // Dynamic erase via id. + // + { + transaction t (db->begin ()); + db->erase (d.id); + t.commit (); + } + + { + transaction t (db->begin ()); + db->persist (r); + db->persist (b); + db->persist (d); + t.commit (); + } + + // Static erase via object. + // + { + transaction t (db->begin ()); + db->erase (r); + db->erase (b); + t.commit (); + } + + // Dynamic erase via object. + // + { + const root& r (d); + transaction t (db->begin ()); + db->erase (r); + t.commit (); + } + } + + // Test 2: inverse object pointers in polymorhic bases. + // + { + using namespace test2; + + derived d (1, "d", 1); + root_pointer rp (&d); + base_pointer bp (&d); + + { + transaction t (db->begin ()); + db->persist (rp); + db->persist (bp); + + d.rp.reset (*db, &rp); + d.bp.reset (*db, &bp); + + db->persist (d); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + unique_ptr pb (db->load (d.id)); + unique_ptr pr (db->load (d.id)); + t.commit (); + + assert (pd->rp.object_id () == rp.id && + pd->bp.object_id () == bp.id); + + derived* p (dynamic_cast (pb.get ())); + assert (p != 0 && + p->rp.object_id () == rp.id && + p->bp.object_id () == bp.id); + + p = dynamic_cast (pr.get ()); + assert (p != 0 && + p->rp.object_id () == rp.id && + p->bp.object_id () == bp.id); + } + + // Query. + // + { + typedef odb::query base_query; + typedef odb::result base_result; + + transaction t (db->begin ()); + + // Test query conditions with columns in pointed-to objects from + // multiple tables. + // + { + base_result qr ( + db->query ( + base_query::rp->id == rp.id && + base_query::bp->id == bp.id)); + + base_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && i.discriminator () == "test2::derived"); + assert (++i == e); + } + + t.commit (); + } + + // Views. + // + { + typedef odb::result root_result; + typedef odb::result base_result; + + transaction t (db->begin ()); + + // root + // + { + root_result qr (db->query ()); + root_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && i->rp_id == rp.id && i->r_id == d.id); + assert (++i == e); + } + + // base + // + { + base_result qr (db->query ()); + base_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && + i->bp_id == bp.id && i->b_id == d.id && i->str == d.str); + assert (++i == e); + } + + t.commit (); + } + } + + // Test 3: delayed loading. + // + { + using namespace test3; + + base b1 (21, 21); + base b2 (22, 22); + base b3 (23, 23); + + derived d1 (31, 31, "d"); + derived d2 (32, 32, "dd"); + derived d3 (33, 33, "ddd"); + + b1.rptr = new root (1); + b2.rptr = new base (2, 2); + b3.rptr = new derived (3, 3, "b3"); + + d1.rptr = new root (4); + d2.rptr = new base (5, 5); + d3.rptr = new derived (6, 6, "d3"); + + d2.bptr = new base (7, 7); + d3.bptr = new derived (8, 8, "d3b"); + + { + transaction t (db->begin ()); + db->persist (b1); + db->persist (b2); + db->persist (b3); + + db->persist (d1); + db->persist (d2); + db->persist (d3); + + db->persist (b1.rptr); + db->persist (b2.rptr); + db->persist (b3.rptr); + + db->persist (d1.rptr); + db->persist (d2.rptr); + db->persist (d3.rptr); + + db->persist (d2.bptr); + db->persist (d3.bptr); + + t.commit (); + } + + { + transaction t (db->begin ()); + + { + unique_ptr p1 (db->load (b1.id)); + unique_ptr p2 (db->load (b2.id)); + unique_ptr p3 (db->load (b3.id)); + assert (*p1 == b1); + assert (*p2 == b2); + assert (*p3 == b3); + } + + { + unique_ptr p1 (db->load (d1.id)); + unique_ptr p2 (db->load (d2.id)); + unique_ptr p3 (db->load (d3.id)); + assert (*p1 == d1); + assert (*p2 == d2); + assert (*p3 == d3); + } + + t.commit (); + } + + // Query. + // + { + typedef odb::query derived_query; + typedef odb::result derived_result; + + transaction t (db->begin ()); + + // Test query conditions with columns in pointed-to objects from + // multiple tables. + // + { + derived_result qr ( + db->query ( + derived_query::rptr->id == 6 && + derived_query::bptr->id == 8 && + derived_query::bptr->num == 8)); + + derived_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && *i == d3); + assert (++i == e); + } + + t.commit (); + } + + // Views. + // + { + typedef odb::query base_query; + typedef odb::result base_result; + + typedef odb::query derived_query; + typedef odb::result derived_result; + + typedef odb::query root_query; + typedef odb::result root_result; + + transaction t (db->begin ()); + + // base + // + { + base_result qr ( + db->query ( + base_query::base::num == b2.num && + base_query::base::id == b2.id && + base_query::r::id == b2.rptr->id)); + + base_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && + i->b_id == b2.id && + i->r_id == b2.rptr->id && + i->num == b2.num); + assert (++i == e); + } + + // derived + // + { + derived_result qr ( + db->query ( + derived_query::d::str == d3.str && + derived_query::d::num == d3.num && + derived_query::b::num == d3.bptr->num && + derived_query::d::id == d3.id && + derived_query::b::id == d3.bptr->id && + derived_query::r::id == d3.rptr->id)); + + derived_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && + i->d_id == d3.id && + i->b_id == d3.bptr->id && + i->r_id == d3.rptr->id && + i->d_num == d3.num && + i->b_num == d3.bptr->num && + i->str == d3.str); + assert (++i == e); + } + + // root + // + { + root_result qr ( + db->query ( + root_query::r::id.in (b2.rptr->id, d2.rptr->id))); + + root_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && + i->r_id == d2.rptr->id && + i->d_id == d2.id && + i->str == d2.str); + assert (++i == e); + } + + t.commit (); + } + } + + // Test 4: views. + // + { + using namespace test4; + + base1 b1 (21, 1); + + root2 r2 (11, 0); + base2 b2 (21, 1, "abc"); + + { + transaction t (db->begin ()); + db->persist (b1); + db->persist (r2); + db->persist (b2); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + { + result qr ( + db->query ( + query::base1::num == b1.num)); + + result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && i->str == "abc"); + assert (++i == e); + } + + t.commit (); + } + + { + typedef odb::result result; + + transaction t (db->begin ()); + + { + result qr (db->query ()); + result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && i->min_num == 1); + assert (++i == e); + } + + t.commit (); + } + + { + typedef odb::result result; + + transaction t (db->begin ()); + + { + result qr (db->query ()); + result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && i->str == "abc"); + assert (++i == e); + } + + t.commit (); + } + } + + // Test 5: polymorphism and optimistic concurrency. + // + { + using namespace test5; + + root r (1, 1); + base b (2, 2, "bbb"); + derived d (3, 3, "ddd"); + + r.strs.push_back ("a"); + r.strs.push_back ("aa"); + r.strs.push_back ("aaa"); + + b.nums.push_back (21); + b.nums.push_back (22); + b.nums.push_back (23); + b.strs.push_back ("b"); + b.strs.push_back ("bb"); + b.strs.push_back ("bbb"); + + d.nums.push_back (31); + d.nums.push_back (32); + d.nums.push_back (33); + d.strs.push_back ("d"); + d.strs.push_back ("dd"); + d.strs.push_back ("ddd"); + + { + transaction t (db->begin ()); + db->persist (r); + db->persist (b); + db->persist (d); + t.commit (); + } + + // Update. + // + { + transaction t (db->begin ()); + + // Root. + // + { + unique_ptr p (db->load (r.id)); + + r.num++; + r.strs.push_back ("aaaa"); + db->update (r); + + p->num--; + p->strs.pop_back (); + try + { + db->update (p); + assert (false); + } + catch (const odb::object_changed&) {} + + // Make sure the object is intact. + // + db->reload (p); + assert (r == *p); + } + + // Base. + // + { + unique_ptr p (db->load (b.id)); + + b.num++; + b.str += "b"; + b.strs.push_back ("bbbb"); + b.nums.push_back (24); + db->update (b); + + p->num--; + p->str += "B"; + p->strs.pop_back (); + p->nums.pop_back (); + try + { + db->update (p); + assert (false); + } + catch (const odb::object_changed&) {} + + // Make sure the object is intact. + // + db->reload (p); + assert (b == *p); + } + + // Derived. + // + { + unique_ptr p (db->load (d.id)); // Via root. + + d.num++; + d.str += "d"; + d.strs.push_back ("dddd"); + d.nums.push_back (24); + d.dnum++; + d.dstr += "d"; + db->update (d); + + derived& d1 (static_cast (*p)); + d1.num--; + d1.str += "D"; + d1.strs.pop_back (); + d1.nums.pop_back (); + d1.dnum--; + d1.dstr += "D"; + try + { + db->update (p); + assert (false); + } + catch (const odb::object_changed&) {} + + // Make sure the object is intact. + // + db->reload (p); + assert (d == *p); + } + + t.commit (); + } + + // Reload. + // + { + transaction t (db->begin ()); + + // Make sure reload doesn't modify the object if the versions + // match. + // + derived d1 (d); + d1.num++; + d1.str += "d"; + d1.strs.push_back ("dddd"); + d1.nums.push_back (24); + d1.dnum++; + d1.dstr += "d"; + derived d2 (d1); + + db->reload (d1); + assert (d1 == d2); + + t.commit (); + } + + // Erase. + // + { + transaction t (db->begin ()); + + // Root. + // + { + unique_ptr p (db->load (r.id)); + + r.num++; + r.strs.push_back ("aaaaa"); + db->update (r); + + try + { + db->erase (p); + assert (false); + } + catch (const odb::object_changed&) {} + + db->reload (p); + db->erase (p); + } + + // Base. + // + { + unique_ptr p (db->load (b.id)); + + b.num++; + b.str += "b"; + b.strs.push_back ("bbbb"); + b.nums.push_back (24); + db->update (b); + + try + { + db->erase (p); + assert (false); + } + catch (const odb::object_changed&) {} + + db->reload (p); + db->erase (p); + } + + // Derived. + // + { + unique_ptr p (db->load (d.id)); // Via root. + + d.num++; + d.str += "d"; + d.strs.push_back ("dddd"); + d.nums.push_back (24); + d.dnum++; + d.dstr += "d"; + db->update (d); + + try + { + db->erase (p); + assert (false); + } + catch (const odb::object_changed&) {} + + db->reload (p); + db->erase (p); + } + + // Try to update non-existent object. + // + { + try + { + db->update (d); + assert (false); + } + catch (const odb::object_changed&) {} + } + + // Try to erase non-existent object. + // + { + try + { + db->erase (d); + assert (false); + } + catch (const odb::object_changed&) {} + } + + t.commit (); + } + } + + // Test 6: polymorphism and callbacks. + // + { + using namespace test6; + + base b (1, 1, "bbb"); + + unique_ptr d (new derived (2, 2, "ddd")); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (b); + db->persist (d); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d->id)); + + db->load (b.id, *pb); + db->load (d->id, *pd); + + db->reload (*pb); + db->reload (*pd); + + t.commit (); + } + + // Update. + // + { + b.num++; + d->num++; + + transaction t (db->begin ()); + db->update (b); + db->update (d); + t.commit (); + } + + // Query. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query ("ORDER BY" + query::id)); + for (result::iterator i (r.begin ()); i != r.end (); ++i) + *i; + + t.commit (); + } + + // Erase. + // + { + transaction t (db->begin ()); + db->erase (b); + db->erase (d); + t.commit (); + } + + // Recursive (delayed) loading. + // + { + derived d (3, 3, "dddd"); + d.ptr.reset (new derived (4, 4, "ddddd")); + + { + transaction t (db->begin ()); + db->persist (d); + db->persist (d.ptr); + t.commit (); + } + + { + transaction t (db->begin ()); + + unique_ptr p (db->load (d.id)); + t.commit (); + } + } + } + + // Test 7: polymorphism and object cache (session). + // + { + using namespace test7; + + shared_ptr r (new root (1, 1)); + shared_ptr b (new base (2, 2, "b")); + shared_ptr d (new derived (3, 3, "d")); + + // Persist. + // + { + session s; + + { + transaction t (db->begin ()); + db->persist (r); + db->persist (b); + db->persist (d); + t.commit (); + } + + assert (db->load (r->id) == r); + assert (db->load (b->id) == b); + assert (db->load (d->id) == d); + } + + // Load. + // + { + session s; + + transaction t (db->begin ()); + shared_ptr r1 (db->load (r->id)); + shared_ptr b1 (db->load (b->id)); + shared_ptr d1 (db->load (d->id)); + t.commit (); + + assert (db->load (r->id) == r1); + assert (db->load (b->id) == b1); + assert (db->load (d->id) == d1); + + assert (!db->find (b->id)); + } + + // Query. + // + { + typedef odb::query query; + typedef odb::result result; + + session s; + + transaction t (db->begin ()); + shared_ptr r1 (db->load (r->id)); + shared_ptr b1 (db->load (b->id)); + shared_ptr d1 (db->load (d->id)); + t.commit (); + + { + transaction t (db->begin ()); + + result r (db->query ("ORDER BY" + query::id)); + result::iterator i (r.begin ()), e (r.end ()); + + assert (i != e && i.load () == r1); + assert (++i != e && i.load () == b1); + assert (++i != e && i.load () == d1); + assert (++i == e); + + t.commit (); + } + } + + // Erase. + // + { + session s; + + { + transaction t (db->begin ()); + db->load (r->id); + db->load (b->id); + db->load (d->id); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (r); + db->erase (b); + db->erase (d); + t.commit (); + } + + { + transaction t (db->begin ()); + assert (!db->find (r->id)); + assert (!db->find (b->id)); + assert (!db->find (d->id)); + t.commit (); + } + } + } + + // Test 8: polymorphism and abstract bases. + // + { + using namespace test8; + + base b (1, 1, "b"); + interm i (2, 2, "i", true); + derived1 d1 (3, 3, "d1", true); + derived2 d2 (4, 4, "d2", false); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (b); + db->persist (static_cast (d1)); + db->persist (static_cast (d2)); + + try + { + db->persist (i); + assert (false); + } + catch (const odb::abstract_class&) {} + + try + { + db->persist (static_cast (i)); + assert (false); + } + catch (const odb::no_type_info&) {} + + t.commit (); + } + + // Load. + // + { + base vb; + interm vi; + derived1 vd1; + derived2 vd2; + + transaction t (db->begin ()); + + // load (id) + // + unique_ptr pb (db->load (b.id)); + unique_ptr pd1 (db->load (d1.id)); + unique_ptr pd2 (db->load (d2.id)); + + assert (*pb == b); + assert (*pd1 == d1); + assert (*pd2 == d2); + + // load (id, obj) + // + db->load (b.id, static_cast (vb)); + db->load (d1.id, static_cast (vd1)); + db->load (d2.id, static_cast (vd2)); + + assert (vb == b); + assert (vd1 == d1); + assert (vd2 == d2); + + try + { + db->load (i.id, static_cast (vi)); + assert (false); + } + catch (const odb::no_type_info&) {} + + // reload (obj) + // + vb.num = 0; + vd1.num = 0; + vd2.num = 0; + + db->reload (static_cast (vb)); + db->reload (static_cast (vd1)); + db->reload (static_cast (vd2)); + + assert (vb == b); + assert (vd1 == d1); + assert (vd2 == d2); + + try + { + db->reload (static_cast (vi)); + assert (false); + } + catch (const odb::no_type_info&) {} + + t.commit (); + } + + // Update. + // + { + b.num++; + b.str += 'b'; + d1.num++; + d1.str += "d1"; + d2.num++; + d2.str += "d1"; + + { + transaction t (db->begin ()); + db->update (static_cast (b)); + db->update (d1); + db->update (static_cast (d2)); + + try + { + db->update (i); + assert (false); + } + catch (const odb::abstract_class&) {} + + try + { + db->update (static_cast (i)); + assert (false); + } + catch (const odb::no_type_info&) {} + + t.commit (); + } + + { + transaction t (db->begin ()); + + unique_ptr pb (db->load (b.id)); + unique_ptr pd1 (db->load (d1.id)); + unique_ptr pd2 (db->load (d2.id)); + + t.commit (); + + assert (*pb == b); + assert (*pd1 == d1); + assert (*pd2 == d2); + } + } + + // Erase. + // + { + transaction t (db->begin ()); + db->erase (b); + db->erase (d1.id); + db->erase (static_cast (d2)); + + try + { + db->erase (i); + assert (false); + } + catch (const odb::abstract_class&) {} + + try + { + db->erase (static_cast (i)); + assert (false); + } + catch (const odb::no_type_info&) {} + + t.commit (); + } + } + + // Test 9: polymorphism and readonly classes. + // + { + using namespace test9; + + ro_root ro_r (1, 1); + rw_base rw_b (2, 2, "b"); + ro_derived ro_d (3, 3, "d"); + + rw_root rw_r (1, 1); + ro_base ro_b (2, 2, "b"); + rw_derived rw_d (3, 3, "d"); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (ro_r); + db->persist (rw_b); + db->persist (ro_d); + + db->persist (rw_r); + db->persist (ro_b); + db->persist (rw_d); + t.commit (); + } + + // Update. + // + { + ro_root ro_r1 (ro_r); + rw_base rw_b1 (rw_b); + ro_derived ro_d1 (ro_d); + + ro_base ro_b1 (ro_b); + rw_derived rw_d1 (rw_d); + + ro_r1.num++; + ro_r1.strs.push_back ("b"); + + rw_b1.num++; + rw_b1.strs.push_back ("b"); + rw_b1.str += "b"; + rw_b1.nums.push_back (2); + rw_b.str += "b"; + rw_b.nums.push_back (2); + + ro_d1.num++; + ro_d1.strs.push_back ("d"); + ro_d1.str += "d"; + ro_d1.nums.push_back (3); + ro_d1.dnum++; + ro_d1.dstr += "d"; + + rw_r.num++; + rw_r.strs.push_back ("b"); + + ro_b1.num++; + ro_b1.strs.push_back ("b"); + ro_b1.str += "b"; + ro_b1.nums.push_back (2); + + rw_d1.num++; + rw_d1.strs.push_back ("d"); + rw_d1.str += "d"; + rw_d1.nums.push_back (3); + rw_d1.dnum++; + rw_d1.dstr += "d"; + rw_d.dnum++; + rw_d.dstr += "d"; + + { + // These should be no-ops. + // + db->update (ro_r1); + db->update (static_cast (ro_d1)); + db->update (ro_b1); + + transaction t (db->begin ()); + db->update (static_cast (rw_b1)); + db->update (rw_r); + db->update (static_cast (rw_d1)); + t.commit (); + } + } + + // Load. + // + { + transaction t (db->begin ()); + + unique_ptr p_ro_r (db->load (ro_r.id)); + unique_ptr p_rw_b (db->load (rw_b.id)); + unique_ptr p_ro_d (db->load (ro_d.id)); + + unique_ptr p_rw_r (db->load (rw_r.id)); + unique_ptr p_ro_b (db->load (ro_b.id)); + unique_ptr p_rw_d (db->load (rw_d.id)); + + t.commit (); + + assert (*p_ro_r == ro_r); + assert (*p_rw_b == rw_b); + assert (*p_ro_d == ro_d); + + assert (*p_rw_r == rw_r); + assert (*p_ro_b == ro_b); + assert (*p_rw_d == rw_d); + } + } + + // Test 10: empty polymorphic classes. + // + { + using namespace test10; + + base b (1, 1); + derived d (2, 2); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (b); + db->persist (static_cast (d)); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + t.commit (); + + assert (*pb == b); + assert (*pd == d); + } + + // Update. + // + { + b.num++; + d.num++; + + transaction t (db->begin ()); + db->update (static_cast (b)); + db->update (d); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + t.commit (); + + assert (*pb == b); + assert (*pd == d); + } + } + + // Test 11: reuse and polymorphic inheritance. + // + { + using namespace test11; + + base b (1, 1, "b"); + derived d (2, 2, "d"); + + b.strs.push_back ("b"); + b.nums.push_back (1); + + d.strs.push_back ("d"); + d.nums.push_back (1); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (b); + db->persist (static_cast (d)); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + t.commit (); + + assert (*pb == b); + assert (*pd == d); + } + + // Update. + // + { + b.num++; + b.str += "b"; + b.strs.push_back ("bb"); + b.nums.push_back (2); + + d.num++; + d.str += "d"; + d.strs.push_back ("dd"); + d.nums.push_back (2); + d.dnum++; + d.dstr += "d"; + + transaction t (db->begin ()); + db->update (b); + db->update (d); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + t.commit (); + + assert (*pb == b); + assert (*pd == d); + } + + // Query. + // + { + typedef odb::query base_query; + typedef odb::result base_result; + + typedef odb::query derived_query; + typedef odb::result derived_result; + + transaction t (db->begin ()); + + { + base_result qr (db->query (base_query::num == 2)); + base_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && *i == b); + assert (++i == e); + } + + { + derived_result qr (db->query (derived_query::num == 3)); + derived_result::iterator i (qr.begin ()), e (qr.end ()); + + assert (i != e && *i == d); + assert (++i == e); + } + + t.commit (); + } + } + + // Test 12: polymorphic objects with auto id. + // + { + using namespace test12; + + base b (1); + derived d (2); + + unsigned long id1, id2; + + // Persist. + // + { + transaction t (db->begin ()); + id1 = db->persist (b); + id2 = db->persist (static_cast (d)); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + + unique_ptr pb (db->load (id1)); + unique_ptr pd (db->load (id2)); + + t.commit (); + + assert (*pb == b); + assert (*pd == d); + } + } + + // Test 13: polymorphic derived without any non-container data members + // (which results in an empty SELECT statement). + // + { + using namespace test13; + + base b; + b.nums.push_back (123); + derived d; + d.nums.push_back (123); + d.strs.push_back ("abc"); + + base1 b1; + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (b); + db->persist (d); + db->persist (b1); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + + unique_ptr pbr (db->load (b.id)); + unique_ptr pdr (db->load (d.id)); + unique_ptr pdb (db->load (d.id)); + unique_ptr pb1r (db->load (b1.id)); + t.commit (); + + base& rb (static_cast (*pbr)); + derived& rd1 (static_cast (*pdr)); + derived& rd2 (static_cast (*pdb)); + base1 rb1 (static_cast (*pb1r)); + + assert (rb.id == b.id && rb.nums == b.nums); + assert (rd1.id == d.id && rd1.nums == rd1.nums && + rd1.strs == rd1.strs); + assert (rd2.id == d.id && rd2.nums == rd2.nums && + rd2.strs == rd2.strs); + assert (rb1.id == b1.id); + } + } + + // Test 14: inverse pointer in polymorphic base. + // + { + using namespace test14; + + derived d; + d.num = 123; + + d.o1 = new object1; + d.o2 = new object2; + d.o3.push_back (new object3); + d.o4.push_back (new object4); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (d.o1); + db->persist (d.o2); + db->persist (d.o3[0]); + db->persist (d.o4[0]); + db->persist (d); + t.commit (); + } + + // Load. + // + { + session s; + + transaction t (db->begin ()); + object1* p1 (db->load (d.o1->id)); + object2* p2 (db->load (d.o2->id)); + object3* p3 (db->load (d.o3[0]->id)); + object4* p4 (db->load (d.o4[0]->id)); + t.commit (); + + assert (p1->d->num == d.num); + assert (p2->d[0]->num == d.num); + assert (p3->d[0]->num == d.num); + assert (p4->d->num == d.num); + delete p1->d; + } + + // Query. + // + { + typedef odb::query query; + typedef odb::result result; + + session s; + transaction t (db->begin ()); + + result r (db->query (query::d->num == d.num)); + result::iterator i (r.begin ()), e (r.end ()); + + assert (i != e && i->d->num == d.num); + delete i.load ()->d; + assert (++i == e); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + session s; + transaction t (db->begin ()); + + result r (db->query (query::d->num == d.num)); + result::iterator i (r.begin ()), e (r.end ()); + + assert (i != e && i->d->num == d.num); + delete i.load ()->d; + assert (++i == e); + t.commit (); + } + } + + // Test 15: LOB/long data and polymorphism. + // + { + using namespace test15; + + const char data[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B"; + + derived d; + d.blob.assign (data, data + sizeof (data)); + + // Persist. + // + { + transaction t (db->begin ()); + base* b (&d); + db->persist (b); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + + unique_ptr pb (db->load (d.id)); + t.commit (); + + derived* pd (dynamic_cast (pb.get ())); + assert (pd != 0 && pd->blob == d.blob); + } + + // Query. + // + { + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query ()); + result::iterator i (r.begin ()), e (r.end ()); + + assert (i != e); + + derived* pd (dynamic_cast (&*i)); + assert (pd != 0 && pd->blob == d.blob); + + assert (++i == e); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/inheritance/polymorphism/test1.hxx b/odb-tests/common/inheritance/polymorphism/test1.hxx new file mode 100644 index 0000000..7f598de --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test1.hxx @@ -0,0 +1,115 @@ +// file : common/inheritance/polymorphism/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#include +#include +#include + +#include + +// Test basic polymorphism functionality. +// +#pragma db namespace table("t1_") +namespace test1 +{ + #pragma db object polymorphic + struct root + { + virtual ~root () {} + root () {} + root (unsigned long i, unsigned long n): id (i), num (n) {} + + #pragma db id column("object_id") + unsigned long id; + + unsigned long num; + std::vector strs; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (root)) + return false; + + return id == r.id && num == r.num && strs == r.strs; + } + }; + + inline bool + operator== (const root& x, const root& y) {return x.compare (y);} + + #pragma db object + struct base: root + { + base () {} + base (unsigned long i, unsigned long n, const std::string& s) + : root (i, n), str (s) {} + + std::string str; + std::vector nums; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (base)) + return false; + + const base& b (static_cast (r)); + return root::compare (r, false) && str == b.str && nums == b.nums; + } + }; + + #pragma db object + struct derived: base + { + derived () {} + derived (unsigned long i, unsigned long n, const std::string& s) + : base (i, n, s), dnum (n + 1), dstr (s + 'd') {} + + unsigned long dnum; + std::string dstr; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (derived)) + return false; + + const derived& d (static_cast (r)); + return base::compare (r, false) && dnum == d.dnum && dstr == d.dstr; + } + }; + + // Views. + // + #pragma db view object(root) + struct root_view + { + //#pragma db column(root::typeid_) + std::string typeid_; // @@ tmp + + unsigned long num; + }; + + #pragma db view object(base = b) + struct base_view + { + unsigned long id; + unsigned long num; + std::string str; + }; + + #pragma db view object(derived) + struct derived_view + { + unsigned long num; + std::string str; + unsigned long dnum; + std::string dstr; + }; +} + +#endif // TEST1_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test10.hxx b/odb-tests/common/inheritance/polymorphism/test10.hxx new file mode 100644 index 0000000..63673a1 --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test10.hxx @@ -0,0 +1,78 @@ +// file : common/inheritance/polymorphism/test10.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST10_HXX +#define TEST10_HXX + +#include + +#include + +// Test empty polymorphic classes. +// +#pragma db namespace table("t10_") +namespace test10 +{ + #pragma db object polymorphic + struct root + { + virtual ~root () = 0; // Auto-abstract. + root () {} + root (unsigned long i): id (i) {} + + #pragma db id + unsigned long id; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (root)) + return false; + + return id == r.id; + } + }; + + inline root:: + ~root () {} + + inline bool + operator== (const root& x, const root& y) {return x.compare (y);} + + #pragma db object + struct base: root + { + base () {} + base (unsigned long i, unsigned long n): root (i), num (n) {} + + unsigned long num; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (base)) + return false; + + const base& b (static_cast (r)); + return root::compare (r, false) && num == b.num; + } + }; + + #pragma db object + struct derived: base + { + derived () {} + derived (unsigned long i, unsigned long n): base (i, n) {} + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (derived)) + return false; + + return base::compare (r, false); + } + }; +} + +#endif // TEST10_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test11.hxx b/odb-tests/common/inheritance/polymorphism/test11.hxx new file mode 100644 index 0000000..2d38a6c --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test11.hxx @@ -0,0 +1,78 @@ +// file : common/inheritance/polymorphism/test11.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST11_HXX +#define TEST11_HXX + +#include +#include +#include + +#include + +// Test mixing reuse and polymorphic inheritance. +// +#pragma db namespace table("t11_") +namespace test11 +{ + #pragma db object abstract + struct root + { + root () {} + root (unsigned long i, unsigned long n): id (i), num (n) {} + + #pragma db id + unsigned long id; + + unsigned long num; + std::vector strs; + }; + + #pragma db object polymorphic + struct base: root + { + virtual ~base () {} + base () {} + base (unsigned long i, unsigned long n, const std::string& s) + : root (i, n), str (s) {} + + std::string str; + std::vector nums; + + virtual bool + compare (const base& b, bool tc = true) const + { + if (tc && typeid (b) != typeid (base)) + return false; + + return id == b.id && num == b.num && strs == b.strs && + str == b.str && nums == b.nums; + } + }; + + inline bool + operator== (const base& x, const base& y) {return x.compare (y);} + + #pragma db object + struct derived: base + { + derived () {} + derived (unsigned long i, unsigned long n, const std::string& s) + : base (i, n, s), dnum (n + 1), dstr (s + 'd') {} + + unsigned long dnum; + std::string dstr; + + virtual bool + compare (const base& b, bool tc = true) const + { + if (tc && typeid (b) != typeid (derived)) + return false; + + const derived& d (static_cast (b)); + return base::compare (b, false) && dnum == d.dnum && dstr == d.dstr; + } + }; +} + +#endif // TEST11_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test12.hxx b/odb-tests/common/inheritance/polymorphism/test12.hxx new file mode 100644 index 0000000..85000ac --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test12.hxx @@ -0,0 +1,79 @@ +// file : common/inheritance/polymorphism/test12.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST12_HXX +#define TEST12_HXX + +#include + +#include + +// Test polymorphic classes with private auto id. +// +#pragma db namespace table("t12_") +namespace test12 +{ + #pragma db object polymorphic + struct root + { + virtual ~root () = 0; // Auto-abstract. + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (root)) + return false; + + return id_ == r.id_; + } + + unsigned long id () const {return id_;} + void id (unsigned long id) {id_ = id;} + private: + #pragma db id auto access(id) + unsigned long id_; + }; + + inline root:: + ~root () {} + + inline bool + operator== (const root& x, const root& y) {return x.compare (y);} + + #pragma db object + struct base: root + { + base () {} + base (unsigned long n): num (n) {} + + unsigned long num; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (base)) + return false; + + const base& b (static_cast (r)); + return root::compare (r, false) && num == b.num; + } + }; + + #pragma db object + struct derived: base + { + derived () {} + derived (unsigned long n): base (n) {} + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (derived)) + return false; + + return base::compare (r, false); + } + }; +} + +#endif // TEST12_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test13.hxx b/odb-tests/common/inheritance/polymorphism/test13.hxx new file mode 100644 index 0000000..3240a9a --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test13.hxx @@ -0,0 +1,46 @@ +// file : common/inheritance/polymorphism/test13.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST13_HXX +#define TEST13_HXX + +#include +#include + +#include + +// Test polymorphic derived without any non-container data members (which +// results in an empty SELECT statement). +// +#pragma db namespace table("t13_") +namespace test13 +{ + #pragma db object polymorphic + struct root + { + virtual ~root () {} + + #pragma db id auto + unsigned long id; + }; + + #pragma db object + struct base: root + { + std::vector nums; + }; + + #pragma db object + struct derived: base + { + std::vector strs; + }; + + #pragma db object + struct base1: root + { + // Nothing. + }; +} + +#endif // TEST13_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test14.hxx b/odb-tests/common/inheritance/polymorphism/test14.hxx new file mode 100644 index 0000000..1050861 --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test14.hxx @@ -0,0 +1,99 @@ +// file : common/inheritance/polymorphism/test14.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST14_HXX +#define TEST14_HXX + +#include + +#include + +// Test inverse pointer in polymorphic base. +// +#pragma db namespace table("t14_") +namespace test14 +{ + struct object1; + struct object2; + struct object3; + struct object4; + + #pragma db object polymorphic session + struct base + { + virtual ~base (); + + #pragma db id auto + unsigned long id; + + object1* o1; + object2* o2; + std::vector o3; + std::vector o4; + }; + + #pragma db object + struct derived: base + { + unsigned long num; + }; + + // one-to-one(i) + // + #pragma db object session + struct object1 + { + #pragma db id auto + unsigned long id; + + #pragma db inverse(o1) + derived* d; + }; + + // one-to-many(i) + // + #pragma db object session + struct object2 + { + #pragma db id auto + unsigned long id; + + #pragma db inverse(o2) + std::vector d; + }; + + // many-to-many(i) + // + #pragma db object session + struct object3 + { + #pragma db id auto + unsigned long id; + + #pragma db inverse(o3) + std::vector d; + }; + + // many-to-one(i) + // + #pragma db object session + struct object4 + { + #pragma db id auto + unsigned long id; + + #pragma db inverse(o4) + derived* d; + }; + + inline base:: + ~base () + { + delete o1; + delete o2; + delete o3[0]; + delete o4[0]; + } +} + +#endif // TEST14_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test15.hxx b/odb-tests/common/inheritance/polymorphism/test15.hxx new file mode 100644 index 0000000..5799ace --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test15.hxx @@ -0,0 +1,44 @@ +// file : common/inheritance/polymorphism/test15.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST15_HXX +#define TEST15_HXX + +#include + +#include + +#ifdef ODB_COMPILER +# if defined(ODB_DATABASE_PGSQL) +# define BLOB_TYPE "BYTEA" +# elif defined(ODB_DATABASE_MSSQL) +# define BLOB_TYPE "VARBINARY(max)" +# else +# define BLOB_TYPE "BLOB" +# endif +#endif + + +// Test LOB/long data and polymorphism. +// +#pragma db namespace table("t15_") +namespace test15 +{ + #pragma db object polymorphic + struct base + { + virtual ~base () {} + + #pragma db id auto + unsigned long id; + }; + + #pragma db object + struct derived: base + { + #pragma db type(BLOB_TYPE) + std::vector blob; + }; +} + +#endif // TEST15_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test2.hxx b/odb-tests/common/inheritance/polymorphism/test2.hxx new file mode 100644 index 0000000..9890e02 --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test2.hxx @@ -0,0 +1,105 @@ +// file : common/inheritance/polymorphism/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#include +#include + +#include +#include + +// Test inverse object pointers in polymorhic bases. +// +#pragma db namespace table("t2_") +namespace test2 +{ + struct root; + + #pragma db object + struct root_pointer + { + root_pointer (root* r = 0): p (r) {} + + #pragma db id auto + unsigned long id; + + root* p; + }; + + #pragma db object polymorphic + struct root + { + virtual ~root () {} + root () {} + root (unsigned long i): id (i) {} + + #pragma db id + unsigned long id; + + #pragma db inverse(p) + odb::lazy_ptr rp; + }; + + struct base; + + #pragma db object + struct base_pointer + { + base_pointer (base* b = 0) {if (b != 0) vp.push_back (b);} + + #pragma db id auto + unsigned long id; + + std::vector vp; + }; + + #pragma db object + struct base: root + { + base () {} + base (unsigned long i, const std::string& s): root (i), str (s) {} + + std::string str; + + #pragma db inverse(vp) + odb::lazy_ptr bp; + }; + + #pragma db object + struct derived: base + { + derived () {} + derived (unsigned long i, const std::string& s, unsigned long n) + : base (i, s), num (n) {} + + unsigned long num; + }; + + // Views. + // + #pragma db view object(root_pointer = rp) object(root) + struct root_view + { + #pragma db column(rp::id) + unsigned long rp_id; + + #pragma db column(root::id) + unsigned long r_id; + }; + + #pragma db view object(base_pointer) object(base = b) + struct base_view + { + #pragma db column(base_pointer::id) + unsigned long bp_id; + + #pragma db column(b::id) + unsigned long b_id; + + std::string str; + }; +} + +#endif // TEST2_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test3.hxx b/odb-tests/common/inheritance/polymorphism/test3.hxx new file mode 100644 index 0000000..fd68f24 --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test3.hxx @@ -0,0 +1,146 @@ +// file : common/inheritance/polymorphism/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#include +#include + +#include + +// Test delayed loading. +// +#pragma db namespace table("t3_") +namespace test3 +{ + #pragma db object polymorphic + struct root + { + virtual ~root () {} + root () {} + root (unsigned long i): id (i) {} + + #pragma db id + unsigned long id; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (root)) + return false; + + return id == r.id; + } + }; + + inline bool + operator== (const root& x, const root& y) {return x.compare (y);} + + #pragma db object + struct base: root + { + virtual ~base () {delete rptr;} + base (): rptr (0) {} + base (unsigned long i, unsigned long n): root (i), num (n), rptr (0) {} + + unsigned long num; + root* rptr; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (base)) + return false; + + const base& b (static_cast (r)); + return + root::compare (r, false) && + num == b.num && + ((rptr == 0 && b.rptr == 0) || rptr->compare (*b.rptr)); + } + }; + + #pragma db object + struct derived: base + { + virtual ~derived () {delete bptr;} + derived (): bptr (0) {} + derived (unsigned long i, unsigned long n, const std::string& s) + : base (i, n), str (s), bptr (0) {} + + std::string str; + base* bptr; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (derived)) + return false; + + const derived& d (static_cast (r)); + return + base::compare (r, false) && + str == d.str && + ((bptr == 0 && d.bptr == 0) || bptr->compare (*d.bptr)); + } + }; + + // Views. + // + #pragma db view object(base) object(root = r) + struct base_view + { + #pragma db column(base::id) + unsigned long b_id; + + #pragma db column(r::id) + unsigned long r_id; + + unsigned long num; + }; + + #pragma db view \ + object(derived = d) \ + object(base = b) \ + object(root = r: d::rptr) + struct derived_view + { + #pragma db column(d::id) + unsigned long d_id; + + #pragma db column(b::id) + unsigned long b_id; + + #pragma db column(r::id) + unsigned long r_id; + + #pragma db column(d::num) + unsigned long d_num; + + #pragma db column(b::num) + unsigned long b_num; + + std::string str; + }; + + // This is an example of a pathological case, where the right-hand-side + // of the join condition comes from one of the bases. As a result, we + // join the base table first, which means we will get both bases and + // derived objects instead of just derived. + // + //#pragma db view object(root = r) object(derived = d) + #pragma db view object(derived = d) object(root = r) + struct root_view + { + #pragma db column(r::id) + unsigned long r_id; + + #pragma db column(d::id) + unsigned long d_id; + + std::string str; + }; +} + +#endif // TEST3_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test4.hxx b/odb-tests/common/inheritance/polymorphism/test4.hxx new file mode 100644 index 0000000..148c53c --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test4.hxx @@ -0,0 +1,84 @@ +// file : common/inheritance/polymorphism/test4.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST4_HXX +#define TEST4_HXX + +#include + +#include + +// Test views. +// +#pragma db namespace table("t4_") +namespace test4 +{ + #pragma db object polymorphic + struct root1 + { + virtual ~root1 () {} + root1 () {} + root1 (unsigned long i): id (i) {} + + #pragma db id + unsigned long id; + }; + + #pragma db object + struct base1: root1 + { + base1 () {} + base1 (unsigned long i, unsigned long n): root1 (i), num (n) {} + + unsigned long num; + }; + + #pragma db object polymorphic + struct root2 + { + virtual ~root2 () {} + root2 () {} + root2 (unsigned long i, unsigned long n): id (i), num (n) {} + + #pragma db id + unsigned long id; + + unsigned long num; + }; + + #pragma db object + struct base2: root2 + { + base2 () {} + base2 (unsigned long i, unsigned long n, const std::string& s) + : root2 (i, n), str (s) {} + + std::string str; + }; + + // Test custom join condition. + // + #pragma db view object(base2) object(base1: base2::num == base1::num) + struct view1 + { + std::string str; + }; + + #pragma db view object(base2) + struct view2 + { + #pragma db column("min(" + base2::num + ")") + unsigned long min_num; + }; + + // Test custom join condition that uses object id. It cannot come + // from the base since the base table hasn't been join'ed yet. + // + #pragma db view object(base1) object(base2: base2::id == base1::id) + struct view3 + { + std::string str; + }; +} + +#endif // TEST4_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test5.hxx b/odb-tests/common/inheritance/polymorphism/test5.hxx new file mode 100644 index 0000000..172e7e8 --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test5.hxx @@ -0,0 +1,92 @@ +// file : common/inheritance/polymorphism/test5.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST5_HXX +#define TEST5_HXX + +#include +#include +#include +#include + +#include + +// Test polymorphism and optimistic concurrency. +// +#pragma db namespace table("t5_") +namespace test5 +{ + #pragma db object polymorphic optimistic pointer(std::unique_ptr) + struct root + { + virtual ~root () {} + root () {} + root (unsigned long i, unsigned long n): id (i), num (n) {} + + #pragma db id + unsigned long id; + + #pragma db version + unsigned long version; + + unsigned long num; + std::vector strs; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (root)) + return false; + + return id == r.id && version == r.version && + num == r.num && strs == r.strs; + } + }; + + inline bool + operator== (const root& x, const root& y) {return x.compare (y);} + + #pragma db object + struct base: root + { + base () {} + base (unsigned long i, unsigned long n, const std::string& s) + : root (i, n), str (s) {} + + std::string str; + std::vector nums; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (base)) + return false; + + const base& b (static_cast (r)); + return root::compare (r, false) && str == b.str && nums == b.nums; + } + }; + + #pragma db object + struct derived: base + { + derived () {} + derived (unsigned long i, unsigned long n, const std::string& s) + : base (i, n, s), dnum (n + 1), dstr (s + 'd') {} + + unsigned long dnum; + std::string dstr; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (derived)) + return false; + + const derived& d (static_cast (r)); + return base::compare (r, false) && dnum == d.dnum && dstr == d.dstr; + } + }; +} + +#endif // TEST5_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test6.hxx b/odb-tests/common/inheritance/polymorphism/test6.hxx new file mode 100644 index 0000000..b0f9a16 --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test6.hxx @@ -0,0 +1,64 @@ +// file : common/inheritance/polymorphism/test6.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST6_HXX +#define TEST6_HXX + +#include +#include + +#include +#include + +// Test polymorphism and callbacks. +// +#pragma db namespace table("t6_") +namespace test6 +{ + #pragma db object polymorphic pointer(std::unique_ptr) + struct root + { + virtual ~root () {} + root (): id (0) {} + root (unsigned long i, unsigned long n): id (i), num (n) {} + + #pragma db id + unsigned long id; + + unsigned long num; + }; + + #pragma db object callback(db_callback) + struct base: root + { + base () {} + base (unsigned long i, unsigned long n, const std::string& s) + : root (i, n), str (s) {} + + std::string str; + + void + db_callback (odb::callback_event, odb::database&); + + void + db_callback (odb::callback_event, odb::database&) const; + }; + + #pragma db object callback(db_callback) + struct derived: base + { + derived () {} + derived (unsigned long i, unsigned long n, const std::string& s) + : base (i, n, s), dnum (n + 1), dstr (s + 'd') {} + + unsigned long dnum; + std::string dstr; + + std::unique_ptr ptr; + + void + db_callback (odb::callback_event, odb::database&) const; + }; +} + +#endif // TEST6_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test7.hxx b/odb-tests/common/inheritance/polymorphism/test7.hxx new file mode 100644 index 0000000..60da98e --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test7.hxx @@ -0,0 +1,54 @@ +// file : common/inheritance/polymorphism/test7.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST7_HXX +#define TEST7_HXX + +#include +#include + +#include + +// Test polymorphism and object cache (session). +// +#pragma db namespace table("t7_") +namespace test7 +{ + using std::shared_ptr; + + #pragma db object polymorphic pointer(shared_ptr) session + struct root + { + virtual ~root () {} + root (): id (0) {} + root (unsigned long i, unsigned long n): id (i), num (n) {} + + #pragma db id + unsigned long id; + + unsigned long num; + }; + + #pragma db object + struct base: root + { + base () {} + base (unsigned long i, unsigned long n, const std::string& s) + : root (i, n), str (s) {} + + std::string str; + }; + + #pragma db object + struct derived: base + { + derived () {} + derived (unsigned long i, unsigned long n, const std::string& s) + : base (i, n, s), dnum (n + 1), dstr (s + 'd') {} + + unsigned long dnum; + std::string dstr; + }; +} + +#endif // TEST7_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test8.hxx b/odb-tests/common/inheritance/polymorphism/test8.hxx new file mode 100644 index 0000000..84b6688 --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test8.hxx @@ -0,0 +1,129 @@ +// file : common/inheritance/polymorphism/test8.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST8_HXX +#define TEST8_HXX + +#include +#include +#include + +#include + +// Test polymorphism and abstract bases. +// +#pragma db namespace table("t8_") +namespace test8 +{ + #pragma db object polymorphic + struct root + { + virtual ~root () = 0; // Auto-abstract. + root () {} + root (unsigned long i, unsigned long n): id (i), num (n) {} + + #pragma db id + unsigned long id; + + unsigned long num; + std::vector strs; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (root)) + return false; + + return id == r.id && num == r.num && strs == r.strs; + } + }; + + inline root:: + ~root () {} + + inline bool + operator== (const root& x, const root& y) {return x.compare (y);} + + #pragma db object + struct base: root + { + base () {} + base (unsigned long i, unsigned long n, const std::string& s) + : root (i, n), str (s) {} + + std::string str; + std::vector nums; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (base)) + return false; + + const base& b (static_cast (r)); + return root::compare (r, false) && str == b.str && nums == b.nums; + } + }; + + #pragma db object abstract + struct interm: base + { + interm () {} + interm (unsigned long i, unsigned long n, const std::string& s, bool b) + : base (i, n, s), bln (b) {} + + bool bln; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (interm)) + return false; + + const interm& i (static_cast (r)); + return base::compare (r, false) && bln == i.bln; + } + }; + + #pragma db object + struct derived1: interm + { + derived1 () {} + derived1 (unsigned long i, unsigned long n, const std::string& s, bool b) + : interm (i, n, s, b), dnum (n + 1) {} + + unsigned long dnum; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (derived1)) + return false; + + const derived1& d (static_cast (r)); + return interm::compare (r, false) && dnum == d.dnum; + } + }; + + #pragma db object + struct derived2: interm + { + derived2 () {} + derived2 (unsigned long i, unsigned long n, const std::string& s, bool b) + : interm (i, n, s, b), dstr (s + 'd') {} + + std::string dstr; + + virtual bool + compare (const root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (derived2)) + return false; + + const derived2& d (static_cast (r)); + return interm::compare (r, false) && dstr == d.dstr; + } + }; +} + +#endif // TEST8_HXX diff --git a/odb-tests/common/inheritance/polymorphism/test9.hxx b/odb-tests/common/inheritance/polymorphism/test9.hxx new file mode 100644 index 0000000..cdc97ae --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/test9.hxx @@ -0,0 +1,161 @@ +// file : common/inheritance/polymorphism/test9.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST9_HXX +#define TEST9_HXX + +#include +#include +#include + +#include + +// Test polymorphism and readonly classes. +// +#pragma db namespace table("t9_") +namespace test9 +{ + // + // ro_root, rw_base, ro_derived + // + #pragma db object polymorphic readonly + struct ro_root + { + virtual ~ro_root () {} + ro_root () {} + ro_root (unsigned long i, unsigned long n): id (i), num (n) {} + + #pragma db id + unsigned long id; + + unsigned long num; + std::vector strs; + + virtual bool + compare (const ro_root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (ro_root)) + return false; + + return id == r.id && num == r.num && strs == r.strs; + } + }; + + inline bool + operator== (const ro_root& x, const ro_root& y) {return x.compare (y);} + + #pragma db object + struct rw_base: ro_root + { + rw_base () {} + rw_base (unsigned long i, unsigned long n, const std::string& s) + : ro_root (i, n), str (s) {} + + std::string str; + std::vector nums; + + virtual bool + compare (const ro_root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (rw_base)) + return false; + + const rw_base& b (static_cast (r)); + return ro_root::compare (r, false) && str == b.str && nums == b.nums; + } + }; + + #pragma db object readonly + struct ro_derived: rw_base + { + ro_derived () {} + ro_derived (unsigned long i, unsigned long n, const std::string& s) + : rw_base (i, n, s), dnum (n + 1), dstr (s + 'd') {} + + unsigned long dnum; + std::string dstr; + + virtual bool + compare (const ro_root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (ro_derived)) + return false; + + const ro_derived& d (static_cast (r)); + return rw_base::compare (r, false) && dnum == d.dnum && dstr == d.dstr; + } + }; + + // + // rw_root, ro_base, rw_derived + // + #pragma db object polymorphic + struct rw_root + { + virtual ~rw_root () {} + rw_root () {} + rw_root (unsigned long i, unsigned long n): id (i), num (n) {} + + #pragma db id + unsigned long id; + + unsigned long num; + std::vector strs; + + virtual bool + compare (const rw_root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (rw_root)) + return false; + + return id == r.id && num == r.num && strs == r.strs; + } + }; + + inline bool + operator== (const rw_root& x, const rw_root& y) {return x.compare (y);} + + #pragma db object readonly + struct ro_base: rw_root + { + ro_base () {} + ro_base (unsigned long i, unsigned long n, const std::string& s) + : rw_root (i, n), str (s) {} + + std::string str; + std::vector nums; + + virtual bool + compare (const rw_root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (ro_base)) + return false; + + const ro_base& b (static_cast (r)); + return rw_root::compare (r, false) && str == b.str && nums == b.nums; + } + }; + + #pragma db object + struct rw_derived: ro_base + { + rw_derived () {} + rw_derived (unsigned long i, unsigned long n, const std::string& s) + : ro_base (i, n, s), dnum (n + 1), dstr (s + 'd') {} + + unsigned long dnum; + std::string dstr; + + virtual bool + compare (const rw_root& r, bool tc = true) const + { + if (tc && typeid (r) != typeid (rw_derived)) + return false; + + const rw_derived& d (static_cast (r)); + return ro_base::compare (r, false) && dnum == d.dnum && dstr == d.dstr; + } + }; +} + +#endif // TEST9_HXX diff --git a/odb-tests/common/inheritance/polymorphism/testscript b/odb-tests/common/inheritance/polymorphism/testscript new file mode 100644 index 0000000..89e5726 --- /dev/null +++ b/odb-tests/common/inheritance/polymorphism/testscript @@ -0,0 +1,80 @@ +# file : common/inheritance/polymorphism/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + ++cat <=output + base pre_persist 1 const + base post_persist 1 const + derived pre_persist 2 const + derived post_persist 2 const + base pre_load 0 + base post_load 1 + derived pre_load 0 const + derived post_load 2 const + base pre_load 1 + base post_load 1 + derived pre_load 2 const + derived post_load 2 const + base pre_load 1 + base post_load 1 + derived pre_load 2 const + derived post_load 2 const + base pre_update 1 const + base post_update 1 const + derived pre_update 2 const + derived post_update 2 const + base pre_load 0 + base post_load 1 + derived pre_load 0 const + derived post_load 2 const + base pre_erase 1 const + base post_erase 1 const + derived pre_erase 2 const + derived post_erase 2 const + derived pre_persist 3 const + derived post_persist 3 const + derived pre_persist 4 const + derived post_persist 4 const + derived pre_load 0 const + derived pre_load 0 const + derived post_load 4 const + derived post_load 3 const + EOI + +test.redirects += >>>../output + +: mysql +: +if $mysql +{ + .include ../../../mysql-schema.testscript + + for s: $schemas + cat $out_base/"$s"($multi ? '-mysql' : '').sql | $create_schema_cmd + end; + + $* ($multi ? 'mysql' : ) $mysql_options +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql-schema.testscript + + for s: $schemas + $create_schema_cmd -f $out_base/"$s"($multi ? '-pgsql' : '').sql + end; + + $* ($multi ? 'pgsql' : ) $pgsql_options +} diff --git a/odb-tests/common/inheritance/reuse/buildfile b/odb-tests/common/inheritance/reuse/buildfile new file mode 100644 index 0000000..b82439a --- /dev/null +++ b/odb-tests/common/inheritance/reuse/buildfile @@ -0,0 +1,41 @@ +# file : common/inheritance/reuse/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix inhrt_r_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/inheritance/reuse/driver.cxx b/odb-tests/common/inheritance/reuse/driver.cxx new file mode 100644 index 0000000..e6122bb --- /dev/null +++ b/odb-tests/common/inheritance/reuse/driver.cxx @@ -0,0 +1,237 @@ +// file : common/inheritance/reuse/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test reuse object inheritance. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + base b; + b.comp_.bools.push_back (true); + b.comp_.obools.push_back (true); + b.comp_.num = 10; + b.comp_.str = "comp bbb"; + b.comp_.nums.push_back (101); + b.comp_.nums.push_back (102); + b.comp_.onums.push_back (101); + b.comp_.onums.push_back (102); + b.num_ = 0; + b.str_ = "bbb"; + b.strs_.push_back ("bbb one"); + b.strs_.push_back ("bbb two"); + b.ostrs_.push_back ("bbb one"); + b.ostrs_.push_back ("bbb two"); + + object1 o1; + o1.comp_.bools.push_back (false); + o1.comp_.obools.push_back (false); + o1.comp_.num = 11; + o1.comp_.str = "comp o1o1o1"; + o1.comp_.nums.push_back (111); + o1.comp_.nums.push_back (112); + o1.comp_.onums.push_back (111); + o1.comp_.onums.push_back (112); + static_cast (o1).num_ = 1; + o1.num1_ = 21; + o1.str_ = "base o1o1o1"; + o1.strs_.push_back ("base o1o1o1 one"); + o1.strs_.push_back ("base o1o1o1 two"); + o1.ostrs_.push_back ("base o1o1o1 one"); + o1.ostrs_.push_back ("base o1o1o1 two"); + + object2 o2; + o2.comp_.bools.push_back (true); + o2.comp_.bools.push_back (false); + o2.comp_.obools.push_back (true); + o2.comp_.obools.push_back (false); + o2.comp_.num = 12; + o2.comp_.str = "comp o2o2o2"; + o2.comp_.nums.push_back (121); + o2.comp_.nums.push_back (122); + o2.comp_.onums.push_back (121); + o2.comp_.onums.push_back (122); + o2.num_ = 2; + static_cast (o2).str_ = "base o2o2o2"; + o2.str_ = "o2o2o2"; + o2.strs_.push_back ("base o2o2o2 one"); + o2.strs_.push_back ("base o2o2o2 two"); + o2.ostrs_.push_back ("base o2o2o2 one"); + o2.ostrs_.push_back ("base o2o2o2 two"); + + object3 o3; + o3.comp_.bools.push_back (false); + o3.comp_.bools.push_back (false); + o3.comp_.obools.push_back (false); + o3.comp_.obools.push_back (false); + o3.comp_.num = 13; + o3.comp_.str = "comp o3o3o3"; + o3.comp_.nums.push_back (131); + o3.comp_.nums.push_back (132); + o3.comp_.onums.push_back (131); + o3.comp_.onums.push_back (132); + o3.num_ = 3; + o3.str_ = "base o3o3o3"; + o3.strs_.push_back ("base o3o3o3 one"); + o3.strs_.push_back ("base o3o3o3 two"); + o3.ostrs_.push_back ("base o3o3o3 one"); + o3.ostrs_.push_back ("base o3o3o3 two"); + + reference r; + r.o1_ = &o1; + + empty_object e; + e.comp_.bools.push_back (true); + e.comp_.bools.push_back (true); + e.comp_.obools.push_back (true); + e.comp_.obools.push_back (true); + e.comp_.num = 14; + e.comp_.str = "comp eee"; + e.comp_.nums.push_back (141); + e.comp_.nums.push_back (142); + e.comp_.onums.push_back (141); + e.comp_.onums.push_back (142); + e.num_ = 4; + e.str_ = "base eee"; + e.strs_.push_back ("base eee one"); + e.strs_.push_back ("base eee two"); + e.ostrs_.push_back ("base eee one"); + e.ostrs_.push_back ("base eee two"); + + // persist + // + { + transaction t (db->begin ()); + db->persist (b); + db->persist (o1); + db->persist (o2); + db->persist (o3); + db->persist (r); + db->persist (e); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + unique_ptr lb (db->load (b.id_)); + unique_ptr lo1 (db->load (o1.id_)); + unique_ptr lo2 (db->load (o2.id_)); + unique_ptr lo3 (db->load (o3.id_)); + unique_ptr le (db->load (e.id_)); + unique_ptr lr (db->load (r.id_)); + t.commit (); + + assert (b == *lb); + assert (o1 == *lo1); + assert (o2 == *lo2); + assert (o3 == *lo3); + assert (lr->o1_->id_ == r.o1_->id_); + assert (e == *le); + + delete lr->o1_; + } + + // update + // + { + transaction t (db->begin ()); + db->update (b); + db->update (o1); + db->update (o2); + db->update (o3); + db->update (r); + db->update (e); + t.commit (); + } + + // query + // + { + typedef odb::query b_query; + typedef odb::query o1_query; + typedef odb::query o2_query; + typedef odb::query r_query; + + typedef odb::result r_result; + + transaction t (db->begin ()); + + assert (!db->query (b_query::comp.num == 10).empty ()); + assert (!db->query (o1_query::num1 == 21).empty ()); + assert (!db->query (o2_query::num == 2).empty ()); + + // Query condition with hidden members. + // + assert ( + !db->query (o2_query::base::str == "base o2o2o2").empty ()); + + // Query condition with referenced composite member in base class. + // + { + r_result r (db->query (r_query::o1->comp.num == 11)); + assert (!r.empty ()); + delete r.begin ()->o1_; + } + + t.commit (); + } + + // views + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query (query::num == o2.num_)); + result::iterator i (r.begin ()); + assert (i != r.end () && + i->num == o2.num_ && i->id == o2.id_ && i->str == o2.str_); + assert (++i == r.end ()); + + t.commit (); + } + + // erase + // + { + transaction t (db->begin ()); + db->erase (b); + db->erase (o1); + db->erase (o2); + db->erase (o3); + db->erase (r); + db->erase (e); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/inheritance/reuse/test.hxx b/odb-tests/common/inheritance/reuse/test.hxx new file mode 100644 index 0000000..48f474f --- /dev/null +++ b/odb-tests/common/inheritance/reuse/test.hxx @@ -0,0 +1,163 @@ +// file : common/inheritance/reuse/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include +#include + +#pragma db value +struct comp_base +{ + std::vector bools; + odb::vector obools; + + bool + operator== (const comp_base& y) const + { + return bools == y.bools && obools == y.obools; + } +}; + +#pragma db value +struct comp: comp_base +{ + unsigned int num; + std::string str; + + std::vector nums; + odb::vector onums; + + bool + operator== (const comp& y) const + { + return + static_cast (*this) == y && + num == y.num && + str == y.str && + nums == y.nums && + onums == y.onums; + } +}; + +#pragma db object abstract +struct abstract_base +{ + comp comp_; + + unsigned int num_; + std::string str_; + + std::vector strs_; + odb::vector ostrs_; + + bool + operator== (const abstract_base& y) const + { + return + comp_ == y.comp_ && + num_ == y.num_ && + str_ == y.str_ && + strs_ == y.strs_ && + ostrs_ == y.ostrs_; + } +}; + +#pragma db object +struct base: abstract_base +{ + #pragma db id auto + unsigned long id_; + + bool + operator== (const base& y) const + { + return id_ == y.id_ && static_cast (*this) == y; + } +}; + +#pragma db object +struct object1: base +{ + unsigned int num1_; + + bool + operator== (const object1& y) const + { + return static_cast (*this) == y && num1_ == y.num1_; + } +}; + +#pragma db object +struct object2: base +{ + #pragma db column("derived_str") + std::string str_; + + bool + operator== (const object2& y) const + { + return static_cast (*this) == y && str_ == y.str_; + } +}; + +// Reference to derived object. +// +#pragma db object +struct reference +{ + #pragma db id auto + unsigned long id_; + + object1* o1_; +}; + +// Multiple inheritance. +// +#pragma db object abstract +struct id_base +{ + #pragma db id auto + unsigned long id_; + + bool + operator== (const id_base& y) const + { + return id_ == y.id_; + } +}; + +#pragma db object +struct object3: abstract_base, id_base +{ + bool + operator== (const object3& y) const + { + return + static_cast (*this) == y && + static_cast (*this) == y; + } +}; + +// Empty derived object. +// +#pragma db object +struct empty_object: base +{ +}; + +// View based on the derived object. +// +#pragma db view object(object2) +struct object2_view +{ + unsigned int num; // from abstract_base + unsigned long id; // from base + std::string str; // from object2, hides one from abstract_base +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/inheritance/reuse/testscript b/odb-tests/common/inheritance/reuse/testscript new file mode 100644 index 0000000..995b3f5 --- /dev/null +++ b/odb-tests/common/inheritance/reuse/testscript @@ -0,0 +1,33 @@ +# file : common/inheritance/reuse/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/inheritance/transient/buildfile b/odb-tests/common/inheritance/transient/buildfile new file mode 100644 index 0000000..1961abc --- /dev/null +++ b/odb-tests/common/inheritance/transient/buildfile @@ -0,0 +1,41 @@ +# file : common/inheritance/transient/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix inhrt_t_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/inheritance/transient/driver.cxx b/odb-tests/common/inheritance/transient/driver.cxx new file mode 100644 index 0000000..1caae6c --- /dev/null +++ b/odb-tests/common/inheritance/transient/driver.cxx @@ -0,0 +1,80 @@ +// file : common/inheritance/transient/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test transient inheritance of objects, composite value types, and views. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + object o; + o.num = 1; + o.str = "abc"; + o.strs.push_back ("abc 1"); + o.strs.push_back ("abc 2"); + o.c.num = 11; + o.c.str = "comp abc"; + o.c.nums.push_back (111); + o.c.nums.push_back (112); + + // persist + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id_)); + t.commit (); + + assert (*p == o); + } + + // view + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query (query::id == o.id_)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->num == o.num && i->str == o.str); + assert (++i == r.end ()); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/inheritance/transient/test.hxx b/odb-tests/common/inheritance/transient/test.hxx new file mode 100644 index 0000000..394ee8f --- /dev/null +++ b/odb-tests/common/inheritance/transient/test.hxx @@ -0,0 +1,60 @@ +// file : common/inheritance/transient/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +struct object; + +struct base +{ + int n; + std::vector v; + object* p; +}; + +#pragma db value +struct comp: base +{ + unsigned int num; + std::string str; + std::vector nums; + + bool + operator== (const comp& y) const + { + return num == y.num && str == y.str && nums == y.nums; + } +}; + +#pragma db object +struct object: base +{ + #pragma db id auto + unsigned int id_; + + unsigned int num; + std::string str; + std::vector strs; + comp c; + + bool + operator== (const object& y) const + { + return num == y.num && str == y.str && strs == y.strs && c == y.c; + } +}; + +#pragma db view object(object) +struct view: base +{ + unsigned int num; + std::string str; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/inheritance/transient/testscript b/odb-tests/common/inheritance/transient/testscript new file mode 100644 index 0000000..bce91de --- /dev/null +++ b/odb-tests/common/inheritance/transient/testscript @@ -0,0 +1,33 @@ +# file : common/inheritance/transient/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/inverse/buildfile b/odb-tests/common/inverse/buildfile new file mode 100644 index 0000000..63fa1cb --- /dev/null +++ b/odb-tests/common/inverse/buildfile @@ -0,0 +1,42 @@ +# file : common/inverse/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_inverse_ \ + --generate-schema \ + --generate-query \ + --generate-session + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/inverse/driver.cxx b/odb-tests/common/inverse/driver.cxx new file mode 100644 index 0000000..842438e --- /dev/null +++ b/odb-tests/common/inverse/driver.cxx @@ -0,0 +1,502 @@ +// file : common/inverse/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test bidirectional relationships with inverse sides. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test raw pointers. + // + { + using namespace test1; + + obj1_ptr o1_1 (new obj1); + obj1_ptr o1_2 (new obj1); + obj2_ptr o2 (new obj2); + obj3_ptr o3_1 (new obj3); + obj3_ptr o3_2 (new obj3); + obj4_ptr o4_1 (new obj4); + obj4_ptr o4_2 (new obj4); + obj5_ptr o5_1 (new obj5); + obj5_ptr o5_2 (new obj5); + obj5_ptr o5_3 (new obj5); + obj5_ptr o5_4 (new obj5); + + o1_1->id = "obj1 1"; + o1_1->o2 = o2; + o1_1->o3.insert (o3_1); + o1_1->o3.insert (o3_2); + o1_1->o4 = o4_1; + o1_1->o5.insert (o5_1); + o1_1->o5.insert (o5_2); + + o1_2->id = "obj1 2"; + o1_2->o2 = 0; + o1_2->o3.clear (); + o1_2->o4 = o4_2; + o1_2->o5.insert (o5_3); + o1_2->o5.insert (o5_4); + + o2->str = "obj2"; + o2->o1 = o1_1; + + o3_1->str = "obj3 1"; + o3_1->o1 = o1_1; + + o3_2->str = "obj3 2"; + o3_2->o1 = o1_1; + + o4_1->str = "obj4 1"; + o4_1->o1.insert (o1_1); + + o4_2->str = "obj4 2"; + o4_2->o1.insert (o1_2); + + o5_1->str = "obj5 1"; + o5_1->o1.insert (o1_1); + + o5_2->str = "obj5 2"; + o5_2->o1.insert (o1_1); + + o5_3->str = "obj5 3"; + o5_3->o1.insert (o1_2); + + o5_4->str = "obj5 4"; + o5_4->o1.insert (o1_2); + + // persist + // + { + transaction t (db->begin ()); + + // objN come before obj1 to get object id assigned. + // + db->persist (o5_1); + db->persist (o5_2); + db->persist (o5_3); + db->persist (o5_4); + db->persist (o4_1); + db->persist (o4_2); + db->persist (o3_1); + db->persist (o3_2); + db->persist (o2); + db->persist (o1_1); + db->persist (o1_2); + + t.commit (); + } + + // load + // + { + session s; + transaction t (db->begin ()); + obj2_ptr x2 (db->load (o2->id)); + obj3_ptr x3_1 (db->load (o3_1->id)); + obj3_ptr x3_2 (db->load (o3_2->id)); + obj4_ptr x4_1 (db->load (o4_1->id)); + obj4_ptr x4_2 (db->load (o4_2->id)); + obj5_ptr x5_1 (db->load (o5_1->id)); + obj5_ptr x5_2 (db->load (o5_2->id)); + obj5_ptr x5_3 (db->load (o5_3->id)); + obj5_ptr x5_4 (db->load (o5_4->id)); + t.commit (); + + assert (x2->str == o2->str); + assert (x2->o1->id == o1_1->id); + assert (x2->o1->o2 == x2); + + assert (x3_1->str == o3_1->str); + assert (x3_2->str == o3_2->str); + assert (x3_1->o1 == x3_2->o1); + assert (x3_1->o1->id == o1_1->id); + assert (x3_1->o1->o3.find (x3_1) != x3_1->o1->o3.end ()); + assert (x3_1->o1->o3.find (x3_2) != x3_1->o1->o3.end ()); + + assert (x4_1->str == o4_1->str); + assert (x4_2->str == o4_2->str); + assert ((*x4_1->o1.begin ())->id == o1_1->id); + assert ((*x4_2->o1.begin ())->id == o1_2->id); + assert ((*x4_1->o1.begin ())->o4 == x4_1); + assert ((*x4_2->o1.begin ())->o4 == x4_2); + + assert (x5_1->str == o5_1->str); + assert (x5_2->str == o5_2->str); + assert ((*x5_1->o1.begin ())->id == o1_1->id); + assert ((*x5_2->o1.begin ())->id == o1_1->id); + assert ((*x5_3->o1.begin ())->id == o1_2->id); + assert ((*x5_4->o1.begin ())->id == o1_2->id); + assert ((*x5_1->o1.begin ())->o5.find (x5_1) != + (*x5_1->o1.begin ())->o5.end ()); + assert ((*x5_2->o1.begin ())->o5.find (x5_2) != + (*x5_2->o1.begin ())->o5.end ()); + assert ((*x5_3->o1.begin ())->o5.find (x5_3) != + (*x5_3->o1.begin ())->o5.end ()); + assert ((*x5_4->o1.begin ())->o5.find (x5_4) != + (*x5_4->o1.begin ())->o5.end ()); + + delete *x4_1->o1.begin (); + delete *x4_2->o1.begin (); + } + + // query + // + { + // one(i)-to-one + // + typedef odb::query query; + typedef odb::result result; + + session s; + transaction t (db->begin ()); + + result r (db->query (query::o1->id == "obj1 1")); + assert (!r.empty ()); + assert (r.begin ()->id == o2->id); + assert (r.begin ()->o1->id == o1_1->id); + assert (size (r) == 1); + + t.commit (); + } + + { + // one(i)-to-many + // + typedef odb::query query; + typedef odb::result result; + + session s; + transaction t (db->begin ()); + + result r (db->query (query::o1->id == "obj1 1")); + size_t n (0); + + for (result::iterator i (r.begin ()); i != r.end (); ++i) + { + assert (i->id == o3_1->id || i->id == o3_2->id); + assert (i->o1->id == o1_1->id); + n++; + } + + assert (n == 2); + + t.commit (); + } + + delete o1_1; + delete o1_2; + } + + // Test shared_ptr/weak_ptr. + // + { + using namespace test2; + + obj1_ptr o1_1 (new obj1); + obj1_ptr o1_2 (new obj1); + obj2_ptr o2 (new obj2); + obj3_ptr o3_1 (new obj3); + obj3_ptr o3_2 (new obj3); + obj4_ptr o4 (new obj4); + obj5_ptr o5_1 (new obj5); + obj5_ptr o5_2 (new obj5); + + o1_1->id = "obj1 1"; + o1_1->o2 = o2; + o1_1->o3.push_back (o3_1); + o1_1->o3.push_back (o3_2); + o1_1->o4 = o4; + o1_1->o5.push_back (o5_1); + o1_1->o5.push_back (o5_2); + + o1_2->id = "obj1 2"; + o1_2->o2 = obj2_ptr (); + o1_2->o3.clear (); + o1_2->o4 = o4; + o1_2->o5.push_back (o5_1); + + o2->str = "obj2"; + o2->o1 = o1_1; + + o3_1->str = "obj3 1"; + o3_1->o1 = o1_1; + + o3_2->str = "obj3 3"; + o3_2->o1 = o1_1; + + o4->str = "obj4"; + o4->o1.push_back (o1_1); + o4->o1.push_back (o1_2); + + o5_1->str = "obj5 1"; + o5_1->o1.push_back (o1_1); + o5_1->o1.push_back (o1_2); + + o5_2->str = "obj5 2"; + o5_2->o1.push_back (o1_1); + + // persist + // + { + transaction t (db->begin ()); + + // objN come before obj1 to get object id assigned. + // + db->persist (o5_1); + db->persist (o5_2); + db->persist (o4); + db->persist (o3_1); + db->persist (o3_2); + db->persist (o2); + db->persist (o1_1); + db->persist (o1_2); + + t.commit (); + } + + // load + // + { + session s; + transaction t (db->begin ()); + obj2_ptr x2 (db->load (o2->id)); + obj3_ptr x3_1 (db->load (o3_1->id)); + obj3_ptr x3_2 (db->load (o3_2->id)); + obj4_ptr x4 (db->load (o4->id)); + obj5_ptr x5_1 (db->load (o5_1->id)); + obj5_ptr x5_2 (db->load (o5_2->id)); + t.commit (); + + assert (x2->str == o2->str); + assert (x2->o1.lock ()->id == o1_1->id); + assert (x2->o1.lock ()->o2 == x2); + + assert (x3_1->str == o3_1->str); + assert (x3_2->str == o3_2->str); + assert (x3_1->o1.lock () == x3_2->o1.lock ()); + assert (x3_1->o1.lock ()->id == o1_1->id); + assert (x3_1->o1.lock ()->o3[0] == x3_1); + assert (x3_1->o1.lock ()->o3[1] == x3_2); + + { + assert (x4->str == o4->str); + + obj1_ptr t1 (x4->o1[0].lock ()), t2 (x4->o1[1].lock ()); + + assert (t1->id == o1_1->id || t2->id == o1_1->id); + assert (t1->id == o1_2->id || t2->id == o1_2->id); + } + + { + assert (x5_1->str == o5_1->str); + assert (x5_2->str == o5_2->str); + + obj1_ptr t1 (x5_1->o1[0].lock ()), t2 (x5_1->o1[1].lock ()), + t3 (x5_2->o1[0].lock ()); + + assert (t1->id == o1_1->id || t2->id == o1_1->id); + assert (t1->id == o1_2->id || t2->id == o1_2->id); + assert (t3->id == o1_1->id); + } + } + } + + // Test inverse based on points_to. + // + { + using namespace test3; + + { + obj1 o1 (1, 2); + o1.o2 = new obj2; + + { + transaction t (db->begin ()); + + o1.o2->o1 = db->persist (o1); + db->persist (o1.o2); + + t.commit (); + } + + { + transaction t (db->begin ()); + + unique_ptr p (db->load (o1.id)); + assert (p->o2->id == o1.o2->id); + + t.commit (); + } + + { + typedef odb::query query; + + transaction t (db->begin ()); + + unique_ptr p (db->query_one (query::o2->o1.i == o1.id.i && + query::o2->o1.j == o1.id.j)); + assert (p->o2->id == o1.o2->id); + + t.commit (); + } + } + + { + obj3 o3; + o3.o4.push_back (new obj4); + o3.o4.push_back (new obj4); + + { + transaction t (db->begin ()); + + o3.o4[0]->o3 = o3.o4[1]->o3 = db->persist (o3); + db->persist (o3.o4[0]); + db->persist (o3.o4[1]); + + t.commit (); + } + + { + transaction t (db->begin ()); + + unique_ptr p (db->load (o3.id)); + assert (p->o4[0]->id == o3.o4[0]->id); + assert (p->o4[1]->id == o3.o4[1]->id); + + t.commit (); + } + + { + typedef odb::query query; + + transaction t (db->begin ()); + + unique_ptr p (db->query_one (query::id == o3.id)); + assert (p->o4[0]->id == o3.o4[0]->id); + assert (p->o4[1]->id == o3.o4[1]->id); + + t.commit (); + } + } + } + + // Test inverse with nested data members. + // + { + using namespace test4; + + { + obj1 o1; + o1.o2 = new obj2; + + { + transaction t (db->begin ()); + + o1.o2->id.i = db->persist (o1); + o1.o2->id.j = 123; + db->persist (o1.o2); + + t.commit (); + } + + { + transaction t (db->begin ()); + + unique_ptr p (db->load (o1.id)); + assert (p->o2->id.i == o1.o2->id.i && p->o2->id.j == o1.o2->id.j); + + t.commit (); + } + + { + typedef odb::query query; + + transaction t (db->begin ()); + + unique_ptr p (db->query_one ( + query::o2->id.i == o1.o2->id.i && + query::o2->id.j == o1.o2->id.j)); + assert (p->o2->id.i == o1.o2->id.i && p->o2->id.j == o1.o2->id.j); + + t.commit (); + } + } + + { + obj3 o3; + o3.o4.push_back (new obj4); + o3.o4.push_back (new obj4); + + { + transaction t (db->begin ()); + + o3.o4[0]->id.i = o3.o4[1]->id.i = db->persist (o3); + o3.o4[0]->id.j = 123; + o3.o4[1]->id.j = 234; + db->persist (o3.o4[0]); + db->persist (o3.o4[1]); + + t.commit (); + } + + { + transaction t (db->begin ()); + + unique_ptr p (db->load (o3.id)); + assert (p->o4[0]->id.i == o3.o4[0]->id.i && + p->o4[0]->id.j == o3.o4[0]->id.j); + + assert (p->o4[1]->id.i == o3.o4[1]->id.i && + p->o4[1]->id.j == o3.o4[1]->id.j); + + t.commit (); + } + + { + typedef odb::query query; + + transaction t (db->begin ()); + + unique_ptr p (db->query_one (query::id == o3.id)); + + assert (p->o4[0]->id.i == o3.o4[0]->id.i && + p->o4[0]->id.j == o3.o4[0]->id.j); + + assert (p->o4[1]->id.i == o3.o4[1]->id.i && + p->o4[1]->id.j == o3.o4[1]->id.j); + + t.commit (); + } + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/inverse/test.hxx b/odb-tests/common/inverse/test.hxx new file mode 100644 index 0000000..a7b8678 --- /dev/null +++ b/odb-tests/common/inverse/test.hxx @@ -0,0 +1,391 @@ +// file : common/inverse/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include +#include + +#include + +// Test raw pointers. +// +#pragma db namespace table("t1_") +namespace test1 +{ + struct obj1; + struct obj2; + struct obj3; + struct obj4; + struct obj5; + + typedef obj1* obj1_ptr; + typedef obj2* obj2_ptr; + typedef obj3* obj3_ptr; + typedef obj4* obj4_ptr; + typedef obj5* obj5_ptr; + + typedef std::set obj1_ptr_set; + typedef std::set obj3_ptr_set; + typedef std::set obj5_ptr_set; + + #pragma db object + struct obj1 + { + obj1 (): o2 (0), o4 (0) {} + ~obj1 (); + + #pragma db id + std::string id; + + obj2_ptr o2; + + #pragma db id_column("obj1_id") value_column("obj3_id") + obj3_ptr_set o3; + + obj4_ptr o4; + + obj5_ptr_set o5; + }; + + #pragma db object + struct obj2 + { + #pragma db id auto + int id; + + // one-to-one + // + #pragma db inverse(o2) + obj1_ptr o1; + + std::string str; + }; + + #pragma db object + struct obj3 + { + std::string str; + + // one(i)-to-many + // + #pragma db inverse (o3) + obj1_ptr o1; + + #pragma db id auto + int id; + }; + + #pragma db object + struct obj4 + { + #pragma db id auto + int id; + + std::string str; + + // many(i)-to-one + // + #pragma db inverse (o4) + obj1_ptr_set o1; + }; + + #pragma db object + struct obj5 + { + #pragma db id auto + int id; + + std::string str; + + // many(i)-to-many + // + #pragma db inverse (o5) + obj1_ptr_set o1; + }; + + inline obj1:: + ~obj1 () + { + delete o2; + for (obj3_ptr_set::iterator i (o3.begin ()); i != o3.end (); ++i) + delete *i; + delete o4; + for (obj5_ptr_set::iterator i (o5.begin ()); i != o5.end (); ++i) + delete *i; + } +} + +// Test shared_ptr/weak_ptr. +// +#pragma db namespace table("t2_") +namespace test2 +{ + using std::shared_ptr; + using std::weak_ptr; + + struct obj1; + struct obj2; + struct obj3; + struct obj4; + struct obj5; + + typedef shared_ptr obj1_ptr; + typedef shared_ptr obj2_ptr; + typedef shared_ptr obj3_ptr; + typedef shared_ptr obj4_ptr; + typedef shared_ptr obj5_ptr; + + typedef weak_ptr obj1_wptr; + + typedef std::vector obj1_wptr_vec; + typedef std::vector obj3_ptr_vec; + typedef std::vector obj5_ptr_vec; + + #pragma db object pointer(obj1_ptr) + struct obj1 + { + #pragma db id + std::string id; + + obj2_ptr o2; + + #pragma db id_column("obj1_id") value_column("obj3_id") + obj3_ptr_vec o3; + + obj4_ptr o4; + obj5_ptr_vec o5; + }; + + #pragma db object pointer(obj2_ptr) + struct obj2 + { + #pragma db id auto + int id; + + std::string str; + + // one(i)-to-one + // + #pragma db inverse(o2) + obj1_wptr o1; + }; + + #pragma db object pointer(obj3_ptr) + struct obj3 + { + #pragma db id auto + int id; + + std::string str; + + // one(i)-to-many + // + #pragma db inverse (o3) + obj1_wptr o1; + }; + + #pragma db object pointer(obj4_ptr) + struct obj4 + { + #pragma db id auto + int id; + + std::string str; + + // many(i)-to-one + // + #pragma db inverse (o4) + obj1_wptr_vec o1; + }; + + #pragma db object pointer(obj5_ptr) + struct obj5 + { + #pragma db id auto + int id; + + std::string str; + + // many(i)-to-many + // + #pragma db inverse (o5) + obj1_wptr_vec o1; + }; +} + +// Test inverse based on points_to. +// +#pragma db namespace table("t3_") +namespace test3 +{ + // Inverse pointer. + // + #pragma db value + struct comp + { + int i; + int j; + }; + + inline bool + operator< (comp x, comp y) {return x.i < y.i || (x.i == y.i && x.j < y.j);} + + struct obj2; + + #pragma db object + struct obj1 + { + #pragma db id + comp id; + + #pragma db inverse(o1) + obj2* o2; + + obj1 (int i = 0, int j = 0): o2 (0) {id.i = i; id.j = j;} + ~obj1 (); + }; + + #pragma db object + struct obj2 + { + #pragma db id auto + int id; + + #pragma db points_to(obj1) + comp o1; + +#ifndef ODB_DATABASE_MYSQL + #pragma db member(o1) on_delete(cascade) +#endif + }; + + inline obj1:: + ~obj1 () {delete o2;} + + // Inverse container of pointers. + // + struct obj4; + + #pragma db object + struct obj3 + { + #pragma db id auto + int id; + + #pragma db inverse(o3) + std::vector o4; + + ~obj3 (); + }; + + #pragma db object + struct obj4 + { + #pragma db id auto + int id; + + #pragma db points_to(obj3) + int o3; + }; + + inline obj3:: + ~obj3 () + { + for (std::vector::iterator i (o4.begin ()); i != o4.end (); ++i) + delete *i; + } +}; + +// Test inverse with nested data members. +// +#pragma db namespace table("t4_") +namespace test4 +{ + // Inverse pointer. + // + struct obj1; + struct obj2; + + #pragma db value + struct obj2_id + { + #pragma db points_to(obj1) + int i; + int j; + }; + + inline bool + operator< (obj2_id x, obj2_id y) + {return x.i < y.i || (x.i == y.i && x.j < y.j);} + + #pragma db object + struct obj1 + { + #pragma db id auto + int id; + + #pragma db inverse(id.i) + obj2* o2; + + obj1 (): o2 (0) {} + ~obj1 (); + }; + + #pragma db object + struct obj2 + { + #pragma db id + obj2_id id; + }; + + inline obj1:: + ~obj1 () {delete o2;} + + // Inverse container of pointers. + // + struct obj3; + struct obj4; + + #pragma db value + struct obj4_id + { + #pragma db points_to(obj3) + int i; + int j; + }; + + inline bool + operator< (obj4_id x, obj4_id y) + {return x.i < y.i || (x.i == y.i && x.j < y.j);} + + #pragma db object + struct obj3 + { + #pragma db id auto + int id; + + #pragma db inverse(id.i) + std::vector o4; + + ~obj3 (); + }; + + #pragma db object + struct obj4 + { + #pragma db id + obj4_id id; + }; + + inline obj3:: + ~obj3 () + { + for (std::vector::iterator i (o4.begin ()); i != o4.end (); ++i) + delete *i; + } +}; +#endif // TEST_HXX diff --git a/odb-tests/common/inverse/testscript b/odb-tests/common/inverse/testscript new file mode 100644 index 0000000..c2a4e3e --- /dev/null +++ b/odb-tests/common/inverse/testscript @@ -0,0 +1,33 @@ +# file : common/inverse/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/lazy-ptr/buildfile b/odb-tests/common/lazy-ptr/buildfile new file mode 100644 index 0000000..d495d2f --- /dev/null +++ b/odb-tests/common/lazy-ptr/buildfile @@ -0,0 +1,41 @@ +# file : common/lazy-ptr/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix lazy_ptr_ \ + --generate-schema \ + --generate-session + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/lazy-ptr/driver.cxx b/odb-tests/common/lazy-ptr/driver.cxx new file mode 100644 index 0000000..9a3b324 --- /dev/null +++ b/odb-tests/common/lazy-ptr/driver.cxx @@ -0,0 +1,360 @@ +// file : common/lazy-ptr/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test lazy object pointers. +// + +#include // std::unique_ptr +#include // std::move +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +namespace test2 +{ + cont::cont (unsigned long i) + : id (i) + { + } + + obj_ptr + create (unsigned int id) + { + obj_ptr r (new obj (id)); + return r; + } + + lazy_obj_ptr + create (database& db, unsigned int id) + { + lazy_obj_ptr r (db, id); + return r; + } +} + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Raw. + // + { + using namespace test1; + + // persist + // + obj* o1 (new obj (1)); + + { + transaction t (db->begin ()); + db->persist (o1); + t.commit (); + } + + unique_ptr c1 (new cont (1)); + unique_ptr c2 (new cont (2)); + + lazy_ptr lo1 (*db, 1); + obj* o2 (new obj (2)); + + obj* o3 (new obj (3)); + obj* o4 (new obj (4)); + + c1->o.push_back (lo1); + c1->o.push_back (o2); + c2->o.push_back (o3); + c2->o.push_back (o4); + + // Test pointer comparison. + // + assert (lazy_ptr () == lazy_ptr ()); + assert (lazy_ptr (o1) != lazy_ptr ()); + assert (lo1 != lazy_ptr ()); + assert (lazy_ptr (o1) == lazy_ptr (o1)); + assert (lo1 == lazy_ptr (*db, o1)); + assert (lo1 != lazy_ptr (*db, o2)); + + delete o1; + + { + transaction t (db->begin ()); + + db->persist (o2); + db->persist (o3); + db->persist (o4); + + db->persist (*c1); + db->persist (*c2); + + t.commit (); + } + + // load + // + { + session s; + transaction t (db->begin ()); + unique_ptr c (db->load (1)); + obj* o (db->load (1)); + + // Not loaded. + // + assert (c->o.size () == 2); + assert (!c->o[0].loaded ()); + assert (!c->o[1].loaded ()); + + assert (!o->c.loaded ()); + + // Correct object ids. + // + assert (c->o[0].object_id () == o->id); + assert (o->c.object_id () == c->id); + + // Load. + // + cont* cl (o->c.load ()); + obj* ol (c->o[0].load ()); + + assert (cl == c.get ()); + assert (ol == o); + + // Test unload/reload. + // + o->c.unload (); + assert (!o->c.loaded ()); + o->c.load (); + assert (o->c.loaded ()); + + t.commit (); + } + } + + // std::unique_ptr + // + { + using namespace test2; + + // persist + // + { + obj_ptr o1 (new obj (1)); + transaction t (db->begin ()); + db->persist (*o1); + t.commit (); + } + + cont_ptr c1 (new cont (1)); + cont_ptr c2 (new cont (2)); + + lazy_obj_ptr lo1 = create (*db, 1); + lo1 = create (*db, 1); + + c1->o = std::move (lo1); + c2->o = create (2); + + { + transaction t (db->begin ()); + + db->persist (*c2->o); + + db->persist (*c1); + db->persist (*c2); + + t.commit (); + } + + // load + // + { + session s; + transaction t (db->begin ()); + cont_ptr c (db->load (1)); + obj* o (db->load (1)); + + // Not loaded. + // + assert (!c->o.loaded ()); + assert (!o->c.loaded ()); + + // Correct object ids. + // + assert (c->o.object_id () == o->id); + assert (o->c.object_id () == c->id); + + // Load. + // + cont* cl (o->c.load ()); + const obj_ptr& ol (c->o.load ()); + + assert (cl == c.get ()); + assert (ol.get () == o); + + t.commit (); + } + + // unload/reload + // + { + // No session. + transaction t (db->begin ()); + cont_ptr c (db->load (1)); + + assert (!c->o.loaded ()); + c->o.load (); + assert (c->o.loaded ()); + c->o.unload (); + assert (!c->o.loaded ()); + c->o.load (); + assert (c->o.loaded ()); + + t.commit (); + } + } + + // Shared pointer from C++11 or TR1. + // + { + using namespace test3; + + // persist + // + shared_ptr c1 (new cont (1)); + + { + transaction t (db->begin ()); + db->persist (c1); + t.commit (); + } + + lazy_shared_ptr lc1 (*db, 1); + shared_ptr c2 (new cont (2)); + + shared_ptr o1 (new obj (1)); + shared_ptr o2 (new obj (2)); + + shared_ptr o3 (new obj (3)); + shared_ptr o4 (new obj (4)); + + o1->c = lc1; + o2->c = lc1; + o3->c = c2; + o4->c = c2; + + // Test pointer comparison. + // + assert (lazy_shared_ptr () == lazy_shared_ptr ()); + assert (lazy_shared_ptr (c1) != lazy_shared_ptr ()); + assert (lc1 != lazy_shared_ptr ()); + assert (lazy_shared_ptr (c1) == lazy_shared_ptr (c1)); + assert (lc1 == lazy_shared_ptr (*db, c1)); + assert (lc1 != lazy_shared_ptr (*db, c2)); + + // Test move constructors. + // + { + lazy_shared_ptr tmp (*db, 1); + lazy_shared_ptr l (std::move (tmp)); + assert (lc1 == l); + } + + { + shared_ptr tmp (c1); + lazy_shared_ptr l (*db, std::move (tmp)); + assert (lc1 == l); + } + + { + transaction t (db->begin ()); + + db->persist (o1); + db->persist (o2); + db->persist (o3); + db->persist (o4); + + db->persist (c2); + + t.commit (); + } + + // load + // + { + session s; + transaction t (db->begin ()); + shared_ptr c (db->load (1)); + shared_ptr o (db->load (1)); + + // Not loaded. + // + assert (c->o.size () == 2); + assert (!c->o[0].loaded ()); + assert (!c->o[1].loaded ()); + + assert (!o->c.loaded ()); + + // Correct object ids. + // + assert (c->o[0].object_id () == o->id); + assert (o->c.object_id () == c->id); + + // Load. + // + shared_ptr cl (o->c.load ()); + shared_ptr ol (c->o[0].load ()); + + assert (cl == c); + assert (ol == o); + + t.commit (); + } + + // Test lazy weak locking and reloading. + // + { + // No session. + transaction t (db->begin ()); + shared_ptr c (db->load (1)); + + // Lock. + // + assert (!c->o[1].loaded ()); + lazy_shared_ptr l (c->o[1].lock ()); + assert (!l.loaded ()); + assert (l.object_id () == c->o[1].object_id ()); + + // Reload. + // + assert (!c->o[1].loaded ()); + shared_ptr ol (c->o[1].load ()); + assert (c->o[1].loaded ()); + ol.reset (); + assert (!c->o[1].loaded ()); + ol = c->o[1].load (); + assert (c->o[1].loaded ()); + + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/lazy-ptr/test.hxx b/odb-tests/common/lazy-ptr/test.hxx new file mode 100644 index 0000000..f946029 --- /dev/null +++ b/odb-tests/common/lazy-ptr/test.hxx @@ -0,0 +1,147 @@ +// file : common/lazy-ptr/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include + +#include +#include + +// Raw pointer. +// +#pragma db namespace table("t1_") +namespace test1 +{ + using odb::lazy_ptr; + class obj; + + #pragma db object + class cont + { + public: + cont () {} + cont (unsigned long i): id (i) {} + ~cont (); + + #pragma db id + unsigned long id; + + typedef std::vector > obj_list; + + #pragma db value_not_null + obj_list o; + }; + + #pragma db object + class obj + { + public: + obj () {} + obj (unsigned long i): id (i) {} + + #pragma db id + unsigned long id; + + #pragma db inverse(o) not_null + lazy_ptr c; // weak + }; + + inline cont:: + ~cont () + { + for (obj_list::iterator i (o.begin ()); i != o.end (); ++i) + if (obj* p = i->get ()) + delete p; + } +} + +// std::auto_ptr/std::unique_ptr +// +#pragma db namespace table("t2_") +namespace test2 +{ + using odb::lazy_ptr; + + class obj; + class cont; + + typedef std::unique_ptr obj_ptr; + typedef std::unique_ptr cont_ptr; + typedef odb::lazy_unique_ptr lazy_obj_ptr; + + #pragma db object + class cont + { + public: + cont () = default; + cont (unsigned long id); + + #pragma db id + unsigned long id; + + #pragma db not_null + lazy_obj_ptr o; + }; + + #pragma db object + class obj + { + public: + obj () = default; + obj (unsigned long i): id (i) {} + + #pragma db id + unsigned long id; + + #pragma db inverse(o) not_null + lazy_ptr c; // weak + }; +} + +// shared_ptr +// +#pragma db namespace table("t3_") +namespace test3 +{ + using std::shared_ptr; + using odb::lazy_shared_ptr; + using odb::lazy_weak_ptr; + + class obj; + + #pragma db object pointer(shared_ptr) + class cont + { + public: + cont () {} + cont (unsigned long i): id (i) {} + + #pragma db id + unsigned long id; + + typedef std::vector > obj_list; + + #pragma db inverse(c) value_not_null + obj_list o; + }; + + #pragma db object pointer(shared_ptr) + class obj + { + public: + obj () {} + obj (unsigned long i): id (i) {} + + #pragma db id + unsigned long id; + + #pragma db not_null + lazy_shared_ptr c; + }; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/lazy-ptr/testscript b/odb-tests/common/lazy-ptr/testscript new file mode 100644 index 0000000..736fa4c --- /dev/null +++ b/odb-tests/common/lazy-ptr/testscript @@ -0,0 +1,33 @@ +# file : common/lazy-ptr/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/lifecycle/buildfile b/odb-tests/common/lifecycle/buildfile new file mode 100644 index 0000000..b5b2b00 --- /dev/null +++ b/odb-tests/common/lifecycle/buildfile @@ -0,0 +1,40 @@ +# file : common/lifecycle/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix lifecycle_ \ + --generate-schema + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/lifecycle/driver.cxx b/odb-tests/common/lifecycle/driver.cxx new file mode 100644 index 0000000..a01d5bd --- /dev/null +++ b/odb-tests/common/lifecycle/driver.cxx @@ -0,0 +1,248 @@ +// file : common/lifecycle/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test object state transistions. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Database operation out of transaction. + // + try + { + object o (1); + db->persist (o); + assert (false); + } + catch (const not_in_transaction&) + { + } + + // Transient. + // + try + { + transaction t (db->begin ()); + unique_ptr o (db->load (1)); + assert (false); + t.commit (); + } + catch (const object_not_persistent&) + { + } + + // Persistent. + // + { + object o (1); + o.str_ = "value 1"; + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + try + { + transaction t (db->begin ()); + db->persist (o); + assert (false); + t.commit (); + } + catch (const object_already_persistent&) + { + } + } + + // Find. + // + { + transaction t (db->begin ()); + + unique_ptr o1 (db->find (1)); + assert (o1.get () != 0 && o1->str_ == "value 1"); + + unique_ptr o2 (db->find (2)); + assert (o2.get () == 0); + + t.commit (); + } + + // Find (into existing). + // + { + object o; + + transaction t (db->begin ()); + + assert (db->find (1, o)); + assert (o.str_ == "value 1"); + + assert (!db->find (2, o)); + + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + unique_ptr o (db->load (1)); + assert (o->str_ == "value 1"); + t.commit (); + + try + { + transaction t (db->begin ()); + unique_ptr o (db->load (2)); + assert (false); + t.commit (); + } + catch (const object_not_persistent&) + { + } + } + + // Load (into existing). + // + { + object o; + + transaction t (db->begin ()); + db->load (1, o); + assert (o.str_ == "value 1"); + t.commit (); + + try + { + transaction t (db->begin ()); + db->load (2, o); + assert (false); + t.commit (); + } + catch (const object_not_persistent&) + { + } + } + + // Reload. + // + { + object o; + + transaction t (db->begin ()); + db->load (1, o); + o.str_ = "junk"; + db->reload (o); + assert (o.str_ == "value 1"); + t.commit (); + + try + { + transaction t (db->begin ()); + o.id_ = 2; + db->reload (o); + assert (false); + t.commit (); + } + catch (const object_not_persistent&) + { + } + } + + // Modified. + // + { + transaction t (db->begin ()); + unique_ptr o (db->load (1)); + o->str_ = "value 2"; + db->update (*o); + t.commit (); + + try + { + transaction t (db->begin ()); + o->id_ = 2; + db->update (*o); + assert (false); + t.commit (); + } + catch (const object_not_persistent&) + { + } + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (1)); + assert (o->str_ == "value 2"); + t.commit (); + } + + // Update of unmodified object. + // + { + transaction t (db->begin ()); + unique_ptr o (db->load (1)); + db->update (*o); + t.commit (); + } + + // Transient. + // + { + transaction t (db->begin ()); + unique_ptr o (db->load (1)); + db->erase (*o); + t.commit (); + + try + { + transaction t (db->begin ()); + db->erase (1); + assert (false); + t.commit (); + } + catch (const object_not_persistent&) + { + } + } + + try + { + transaction t (db->begin ()); + unique_ptr o (db->load (1)); + assert (false); + t.commit (); + } + catch (const object_not_persistent&) + { + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/lifecycle/test.hxx b/odb-tests/common/lifecycle/test.hxx new file mode 100644 index 0000000..8d260d2 --- /dev/null +++ b/odb-tests/common/lifecycle/test.hxx @@ -0,0 +1,27 @@ +// file : common/lifecycle/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; + std::string str_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/lifecycle/testscript b/odb-tests/common/lifecycle/testscript new file mode 100644 index 0000000..0337bba --- /dev/null +++ b/odb-tests/common/lifecycle/testscript @@ -0,0 +1,33 @@ +# file : common/lifecycle/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/no-id/buildfile b/odb-tests/common/no-id/buildfile new file mode 100644 index 0000000..1a64401 --- /dev/null +++ b/odb-tests/common/no-id/buildfile @@ -0,0 +1,41 @@ +# file : common/no-id/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix no_id_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/no-id/driver.cxx b/odb-tests/common/no-id/driver.cxx new file mode 100644 index 0000000..eee69a5 --- /dev/null +++ b/odb-tests/common/no-id/driver.cxx @@ -0,0 +1,102 @@ +// file : common/no-id/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test persistent classes without id. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + object o1 (1, "aaa"); + object o2 (2, "bbb"); + object o3 (3, "ccc"); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o2); // Ok, since there is no id. + db->persist (o3); + t.commit (); + } + + // Compile errors. + // + { + //db->load (1); + //db->find (1); + //db->update (o1); + //db->erase (1); + } + + typedef odb::query query; + typedef odb::result result; + + // Query. + // + { + transaction t (db->begin ()); + + { + result r (db->query ()); + assert (size (r) == 4); + } + + { + result r (db->query (query::str == "aaa")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->num == 1 && i->str == "aaa"); + object o; + i.load (o); + //i.id (); // Compile-time error. + assert (o.num == 1 && o.str == "aaa"); + assert (++i == r.end ()); + } + + { + result r (db->query (query::num < 3)); + assert (size (r) == 3); + } + + t.commit (); + } + + // Erase (query). + // + { + transaction t (db->begin ()); + assert (db->erase_query (query::num == 2) == 2); + assert (db->erase_query () == 2); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/no-id/test.hxx b/odb-tests/common/no-id/test.hxx new file mode 100644 index 0000000..c5b5c65 --- /dev/null +++ b/odb-tests/common/no-id/test.hxx @@ -0,0 +1,21 @@ +// file : common/no-id/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object no_id +struct object +{ + object () {} + object (unsigned long n, const std::string& s): num (n), str (s) {} + + unsigned long num; + std::string str; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/no-id/testscript b/odb-tests/common/no-id/testscript new file mode 100644 index 0000000..5ec57ee --- /dev/null +++ b/odb-tests/common/no-id/testscript @@ -0,0 +1,33 @@ +# file : common/no-id/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/object/buildfile b/odb-tests/common/object/buildfile new file mode 100644 index 0000000..cb56aee --- /dev/null +++ b/odb-tests/common/object/buildfile @@ -0,0 +1,41 @@ +# file : common/object/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix object_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/object/driver.cxx b/odb-tests/common/object/driver.cxx new file mode 100644 index 0000000..1c29417 --- /dev/null +++ b/odb-tests/common/object/driver.cxx @@ -0,0 +1,84 @@ +// file : common/object/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test persistent classes. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test persistent class template instantiation. + // + { + using namespace test1; + + pair_object po; + po.second = "abc"; + + derived d; + d.x = "abc"; + d.n = 123; + + // persist + // + { + transaction t (db->begin ()); + db->persist (po); + db->persist (d); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + unique_ptr po1 (db->load (po.first)); + unique_ptr d1 (db->load (d.id)); + t.commit (); + + assert (po == *po1); + + assert (d.x == d1->x); + assert (d.n == d1->n); + } + + // Test the API confusion. + // + { + transaction t (db->begin ()); + db->update (po); + db->reload (po); + db->erase (po); + + db->query (); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/object/test.hxx b/odb-tests/common/object/test.hxx new file mode 100644 index 0000000..87bac91 --- /dev/null +++ b/odb-tests/common/object/test.hxx @@ -0,0 +1,49 @@ +// file : common/object/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include // std::pair + +#include + +// Test persistent class template instantiation. +// +#pragma db namespace table("t1_") +namespace test1 +{ + typedef std::pair pair_object; + #pragma db object(pair_object) + #pragma db member(pair_object::first) id auto + + #pragma db object abstract + struct base_data + { + #pragma db id auto + unsigned long id; + }; + + template + struct base: base_data + { + T x; + }; + + typedef base base_derived; + #pragma db object(base_derived) abstract + + #pragma db object + struct derived: base_derived + { + int n; + }; + + // Test instantiation in order to "see" id, etc. + // + typedef base int_base; + #pragma db object(int_base) +} + +#endif // TEST_HXX diff --git a/odb-tests/common/object/testscript b/odb-tests/common/object/testscript new file mode 100644 index 0000000..6982409 --- /dev/null +++ b/odb-tests/common/object/testscript @@ -0,0 +1,33 @@ +# file : common/object/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/optimistic/buildfile b/odb-tests/common/optimistic/buildfile new file mode 100644 index 0000000..06af705 --- /dev/null +++ b/odb-tests/common/optimistic/buildfile @@ -0,0 +1,41 @@ +# file : common/optimistic/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_optimistic_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/optimistic/driver.cxx b/odb-tests/common/optimistic/driver.cxx new file mode 100644 index 0000000..6dfec6e --- /dev/null +++ b/odb-tests/common/optimistic/driver.cxx @@ -0,0 +1,300 @@ +// file : common/optimistic/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test optimistic concurrency support. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +unsigned long +version (const unique_ptr& db, unsigned long id) +{ + typedef odb::query query; + typedef odb::result result; + + result r (db->query (query::id == id)); + return r.empty () ? 0 : r.begin ()->ver; +} + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + object o (1); + o.num = 123; + o.str = "abc"; + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Verify initial version in the instance and database. + // + assert (o.ver == 1); + { + transaction t (db->begin ()); + assert (version (db, 1) == 1); + t.commit (); + } + + object c (o); + o.num++; + o.str += 'd'; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + // Verify updated version in the instance and database. + // + assert (o.ver == 2); + { + transaction t (db->begin ()); + assert (version (db, 1) == 2); + t.commit (); + } + + // Verify the data has been updated. + // + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o1->ver == 2 && o1->num == 124 && o1->str == "abcd"); + } + + // Try to update using outdated object. + // + c.num--; + c.str += 'z'; + + { + transaction t (db->begin ()); + + try + { + db->update (c); + assert (false); + } + catch (const object_changed&) {} + + // Verify the data hasn't changed. + // + unique_ptr o1 (db->load (1)); + assert (o1->ver == 2 && o1->num == 124 && o1->str == "abcd"); + + // Reload the object. + // + db->reload (c); + assert (c.ver == 2 && c.num == 124); + + // Check that we don't reload an object that is up-to-date. + // + c.num--; + db->reload (c); + assert (c.ver == 2 && c.num == 123); + + t.commit (); + } + + // Try to delete using an outdated object. + // + { + transaction t (db->begin ()); + + try + { + db->update (o); + db->erase (c); + assert (false); + } + catch (const object_changed&) {} + + t.commit (); + } + + // Try to delete using an up-to-date object. + // + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + + // Try to update deleted object. + // + { + transaction t (db->begin ()); + + try + { + db->update (o); + assert (false); + } + catch (const object_not_persistent&) + { + assert (false); + } + catch (const object_changed&) {} + + t.commit (); + } + + // Optimistic delete of objects with container requires + // extra logic. Test it here. + // + { + container o ("abc"); + o.nums.push_back (1); + o.nums.push_back (2); + o.nums.push_back (3); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + container c (o); + o.nums.pop_back (); + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + // Try to delete using an outdated object. + // + { + transaction t (db->begin ()); + + try + { + db->erase (c); + assert (false); + } + catch (const object_changed&) {} + + // Verify the container data hasn't changed. + // + unique_ptr o1 (db->load ("abc")); + assert (o1->nums.size () == 2 && o1->nums[0] == 1 && o1->nums[1] == 2); + + t.commit (); + } + + // Try to delete using an up-to-date object. + // + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test optimistic class inheritance. This is a shortened version + // of the object test. + // + { + derived o; + o.num = 123; + o.str = "abc"; + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + derived c (o); + o.num++; + o.str += 'd'; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + // Try to update using outdated object. + // + c.num--; + c.str += 'z'; + + { + transaction t (db->begin ()); + + try + { + db->update (c); + assert (false); + } + catch (const object_changed&) {} + + // Reload the object. + // + db->reload (c); + assert (c.ver == 2 && c.num == 124); + + t.commit (); + } + + // Try to delete using an outdated object. + // + { + transaction t (db->begin ()); + + try + { + db->update (o); + db->erase (c); + assert (false); + } + catch (const object_changed&) {} + + t.commit (); + } + + // Try to delete using an up-to-date object. + // + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/optimistic/test.hxx b/odb-tests/common/optimistic/test.hxx new file mode 100644 index 0000000..fcefa3d --- /dev/null +++ b/odb-tests/common/optimistic/test.hxx @@ -0,0 +1,76 @@ +// file : common/optimistic/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +#pragma db object optimistic +struct object +{ + object (): ver (123) {} + object (unsigned long id): id_ (id), ver (123) {} + + #pragma db id + unsigned long id_; + + #pragma db version + unsigned long ver; + + unsigned int num; + std::string str; +}; + +#pragma db view object(object) +struct object_version +{ + unsigned long ver; +}; + +// Optimistic class with a container. +// +#pragma db object optimistic +struct container +{ + container (): ver (123) {} + container (const std::string& id): id_ (id), ver (123) {} + + #pragma db id + std::string id_; + + #pragma db version + unsigned long ver; + + std::vector nums; +}; + +// Optimistic class inheritance. +// +#pragma db object abstract optimistic +struct base +{ + base (): ver (123) {} + + #pragma db id auto + unsigned long id_; + + #pragma db version + const unsigned long ver; + + std::string str; + + #pragma db readonly + std::string ro; +}; + +#pragma db object +struct derived: base +{ + unsigned int num; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/optimistic/testscript b/odb-tests/common/optimistic/testscript new file mode 100644 index 0000000..9ebafb2 --- /dev/null +++ b/odb-tests/common/optimistic/testscript @@ -0,0 +1,33 @@ +# file : common/optimistic/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/pragma/buildfile b/odb-tests/common/pragma/buildfile new file mode 100644 index 0000000..a2eeaa0 --- /dev/null +++ b/odb-tests/common/pragma/buildfile @@ -0,0 +1,39 @@ +# file : common/pragma/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix pragma_ + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/pragma/driver.cxx b/odb-tests/common/pragma/driver.cxx new file mode 100644 index 0000000..a9cc6e0 --- /dev/null +++ b/odb-tests/common/pragma/driver.cxx @@ -0,0 +1,27 @@ +// file : common/pragma/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test #pragma db parsing. +// + +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main () +{ +} diff --git a/odb-tests/common/pragma/test.hxx b/odb-tests/common/pragma/test.hxx new file mode 100644 index 0000000..6877e73 --- /dev/null +++ b/odb-tests/common/pragma/test.hxx @@ -0,0 +1,40 @@ +// file : common/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db value(bool) type ("INTEGER") + +struct x {int i;}; +#pragma db value (x) + +namespace N +{ + #pragma db object + struct object1 + { + object1 () {} + + #pragma db id + unsigned long id_; + + #pragma db member type ("INTEGER") + bool b_; + }; + + struct object2 + { + object2 () {} + + unsigned long id_; + }; + + #pragma db object (object2) +} + +PRAGMA_DB (member (N::object2::id_) id auto); + +#endif // TEST_HXX diff --git a/odb-tests/common/pragma/testscript b/odb-tests/common/pragma/testscript new file mode 100644 index 0000000..089f7a1 --- /dev/null +++ b/odb-tests/common/pragma/testscript @@ -0,0 +1,31 @@ +# file : common/include/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* &!odb-test.db +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $* +} diff --git a/odb-tests/common/prepared/buildfile b/odb-tests/common/prepared/buildfile new file mode 100644 index 0000000..4006a4f --- /dev/null +++ b/odb-tests/common/prepared/buildfile @@ -0,0 +1,43 @@ +# file : common/prepared/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix prepared_ \ + --generate-schema \ + --generate-query \ + --generate-prepared \ + --omit-unprepared + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/prepared/driver.cxx b/odb-tests/common/prepared/driver.cxx new file mode 100644 index 0000000..44df651 --- /dev/null +++ b/odb-tests/common/prepared/driver.cxx @@ -0,0 +1,444 @@ +// file : common/prepared/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test prepared query functionality. +// + +#include // std::unique_ptr +#include // std::move +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +struct params +{ + unsigned short age; + std::string name; +}; + +static void +query_factory (const char* name, connection& c) +{ + typedef odb::query query; + + unique_ptr p (new params); + prepared_query pq ( + c.prepare_query ( + name, + query::age > query::_ref (p->age) && + query::name != query::_ref (p->name))); + c.cache_query (pq, move (p)); +} + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + { + person p1 ("John First", 91); + person p2 ("John Second", 81); + person p3 ("John Third", 71); + person p4 ("John Fourth", 61); + person p5 ("John Fifth", 51); + + transaction t (db->begin ()); + db->persist (p1); + db->persist (p2); + db->persist (p3); + db->persist (p4); + db->persist (p5); + t.commit (); + } + + typedef odb::query query; + typedef odb::prepared_query prep_query; + typedef odb::result result; + + // Uncached query in the same transaction. + // + { + transaction t (db->begin ()); + + unsigned short age (90); + prep_query pq ( + db->prepare_query ( + "person-age-query", + query::age > query::_ref (age))); + + for (unsigned short i (1); i < 6; ++i, age -= 10) + { + result r (pq.execute ()); + assert (size (r) == i); + } + + age = 90; + result r (pq.execute ()); + result::iterator i (r.begin ()); + assert (i != r.end () && i->name_ == "John First" && i->age_ == 91); + assert (++i == r.end ()); + + t.commit (); + } + + // Uncached query in multiple transaction. + // + { + connection_ptr c (db->connection ()); + + unsigned short age (90); + prep_query pq ( + c->prepare_query ( + "person-age-query", + query::age > query::_ref (age))); + + for (unsigned short i (1); i < 6; ++i, age -= 10) + { + transaction t (c->begin ()); + + result r (pq.execute ()); + assert (size (r) == i); + + t.commit (); + } + + transaction t (c->begin ()); + + age = 90; + result r (pq.execute ()); + result::iterator i (r.begin ()); + assert (i != r.end () && i->name_ == "John First" && i->age_ == 91); + assert (++i == r.end ()); + + t.commit (); + } + + // Cached query without parameters. + // + { + for (unsigned short i (1); i < 6; ++i) + { + transaction t (db->begin ()); + + prep_query pq (db->lookup_query ("person-val-age-query")); + + if (!pq) + { + assert (i == 1); + pq = db->prepare_query ( + "person-val-age-query", + query::age > 90); + db->cache_query (pq); + } + else if (i == 2) + { + try + { + db->cache_query (pq); + assert (false); + } + catch (const odb::prepared_already_cached&) + { + } + } + + result r (pq.execute ()); + assert (size (r) == 1); + + t.commit (); + } + } + + // Cached query with parameters. + // + { + for (unsigned short i (1); i < 6; ++i) + { + transaction t (db->begin ()); + + unsigned short* age; + prep_query pq (db->lookup_query ("person-ref-age-query", age)); + + if (!pq) + { + assert (i == 1); + + unique_ptr p (new unsigned short); + age = p.get (); + pq = db->prepare_query ( + "person-ref-age-query", + query::age > query::_ref (*age)); + + db->cache_query (pq, move (p)); + } + else if (i == 2) + { + // Object type mismatch. + // + try + { + db->lookup_query ("person-ref-age-query", age); + assert (false); + } + catch (const odb::prepared_type_mismatch&) + { + } + + // Parameters type mismatch. + // + try + { + int* age; + db->lookup_query ("person-ref-age-query", age); + assert (false); + } + catch (const odb::prepared_type_mismatch&) + { + } + } + + *age = 100 - i * 10; + result r (pq.execute ()); + assert (size (r) == i); + + t.commit (); + } + } + + // Cached query with factory. + // + { + db->query_factory ("person-params-query", &query_factory); + + for (unsigned int i (1); i < 6; ++i) + { + transaction t (db->begin ()); + + params* p; + prep_query pq (db->lookup_query ("person-params-query", p)); + assert (pq); + + p->age = 100 - i * 10; + p->name = "John First"; + result r (pq.execute ()); + assert (size (r) == i - 1); + + t.commit (); + } + + db->query_factory ("person-params-query", + database::query_factory_ptr ()); + } + + // Cached query with wildcard factory. + // + { + db->query_factory ("", &query_factory); + + for (unsigned int i (1); i < 6; ++i) + { + transaction t (db->begin ()); + + params* p; + prep_query pq (db->lookup_query ("person-params-query-1", p)); + assert (pq); + + p->age = 100 - i * 10; + p->name = "John First"; + result r (pq.execute ()); + assert (size (r) == i - 1); + + t.commit (); + } + + db->query_factory ("", database::query_factory_ptr ()); + } + + // Cached query with lambda factory. + // + { + db->query_factory ( + "person-params-query-2", + [] (const char* name, connection& c) + { + typedef odb::query query; + + unique_ptr p (new params); + prepared_query pq ( + c.prepare_query ( + name, + query::age > query::_ref (p->age) && + query::name != query::_ref (p->name))); + c.cache_query (pq, move (p)); + }); + + for (unsigned int i (1); i < 6; ++i) + { + transaction t (db->begin ()); + + params* p; + prep_query pq (db->lookup_query ("person-params-query-2", p)); + assert (pq); + + p->age = 100 - i * 10; + p->name = "John First"; + result r (pq.execute ()); + assert (size (r) == i - 1); + + t.commit (); + } + + db->query_factory ("person-params-query-2", + database::query_factory_ptr ()); + } + + // Cached query with lambda factory using closure. Forces nonoptimized + // representation of std::function. + // + { + const std::string person_name ("John First"); + + db->query_factory ( + "person-params-query-3", + [person_name] (const char* name, connection& c) + { + typedef odb::query query; + + prepared_query pq ( + c.prepare_query ( + name, + query::age > 50 && query::name != person_name)); + c.cache_query (pq); + }); + + { + transaction t (db->begin ()); + + prep_query pq (db->lookup_query ("person-params-query-3")); + assert (pq); + + result r (pq.execute ()); + assert (size (r) == 4); + + t.commit (); + } + + db->query_factory ("person-params-query-3", nullptr); + } + + // View prepared query. + // + { + typedef odb::query query; + typedef odb::prepared_query prep_query; + typedef odb::result result; + + transaction t (db->begin ()); + + unsigned short age (90); + prep_query pq ( + db->prepare_query ( + "person-view-age-query", + query::age > query::_ref (age))); + + for (unsigned short i (1); i < 6; ++i, age -= 10) + { + result r (pq.execute ()); + assert (size (r) == i); + } + + age = 90; + result r (pq.execute ()); + result::iterator i (r.begin ()); + assert (i != r.end () && i->name == "John First" && i->age == 91); + assert (++i == r.end ()); + + t.commit (); + } + + // By-ref parameter image growth. + // + { + transaction t (db->begin ()); + + string name; + prep_query pq ( + db->prepare_query ( + "person-name-query", + query::name != query::_ref (name))); + + { + name = "John First"; + result r (pq.execute ()); + assert (size (r) == 4); + } + + { + name.assign (2048, 'x'); + result r (pq.execute ()); + assert (size (r) == 5); + } + + t.commit (); + } + + // Test execute_one() and execute_value(). + // + { + transaction t (db->begin ()); + + person p ("John Doe", 23); + db->persist (p); + + prep_query pq1 ( + db->prepare_query ("query-1", query::id == p.id_)); + prep_query pq0 ( + db->prepare_query ("query-0", query::id == p.id_ + 1)); + + { + unique_ptr p (pq1.execute_one ()); + assert (p.get () != 0 && p->name_ == "John Doe"); + } + + { + unique_ptr p (pq0.execute_one ()); + assert (p.get () == 0); + } + + { + person p; + assert (pq1.execute_one (p) && p.name_ == "John Doe"); + } + + { + person p ("", 0); + assert (!pq0.execute_one (p) && + p.id_ == 0 && p.name_.empty () && p.age_ == 0); + } + + { + person p (pq1.execute_value ()); + assert (p.name_ == "John Doe"); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/prepared/test.hxx b/odb-tests/common/prepared/test.hxx new file mode 100644 index 0000000..db16e67 --- /dev/null +++ b/odb-tests/common/prepared/test.hxx @@ -0,0 +1,32 @@ +// file : common/prepared/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object +struct person +{ + person (): id_ (0) {} + person (const std::string& name, unsigned short age) + : id_ (0), name_ (name), age_ (age) {} + + #pragma db id auto + unsigned long id_; + + std::string name_; + unsigned short age_; +}; + +#pragma db view object(person) +struct person_view +{ + std::string name; + unsigned short age; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/prepared/testscript b/odb-tests/common/prepared/testscript new file mode 100644 index 0000000..3530c5b --- /dev/null +++ b/odb-tests/common/prepared/testscript @@ -0,0 +1,33 @@ +# file : common/prepared/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/query/array/buildfile b/odb-tests/common/query/array/buildfile new file mode 100644 index 0000000..3beb6d0 --- /dev/null +++ b/odb-tests/common/query/array/buildfile @@ -0,0 +1,43 @@ +# file : common/query/array/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_query_array_ \ + --generate-schema \ + --generate-query \ + --generate-prepared \ + --sql-name-case oracle:upper + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/query/array/driver.cxx b/odb-tests/common/query/array/driver.cxx new file mode 100644 index 0000000..9327751 --- /dev/null +++ b/odb-tests/common/query/array/driver.cxx @@ -0,0 +1,220 @@ +// file : common/query/array/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test query support for C arrays. +// + +#include +#include // std::unique_ptr +#include // std::memcpy +#include + +#include +#include + +#include // DATABASE_* +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +#ifndef MULTI_DATABASE +# if defined(DATABASE_MYSQL) +const odb::mysql::database_type_id bt = odb::mysql::id_blob; +# elif defined(DATABASE_SQLITE) +const odb::sqlite::database_type_id bt = odb::sqlite::id_blob; +# elif defined(DATABASE_PGSQL) +const odb::pgsql::database_type_id bt = odb::pgsql::id_bytea; +# elif defined(DATABASE_ORACLE) +const odb::oracle::database_type_id bt = odb::oracle::id_raw; +# elif defined(DATABASE_MSSQL) +const odb::mssql::database_type_id bt = odb::mssql::id_binary; +# else +# error unknown database +# endif +#endif + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + typedef odb::query query; + + const char buf[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6}; + + // + // + { + object o1 (1, "abc", buf); + object o2 (2, "bcd", buf); + object o3 (3, "cde", buf); + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + } + + { + transaction t (db->begin ()); + + // string + // +#ifndef MULTI_DATABASE + assert (size (db->query (query::s == "abc")) == 1); + assert (size (db->query (query::s == query::_val ("bcd"))) == 1); + assert (size (db->query ("s = " + query::_val ("bcd"))) == 1); + assert (size (db->query ("s = " + query::_ref ("bcd"))) == 1); +#endif + + { + char a[] = "bcd"; + char* ra = a; +#ifndef MULTI_DATABASE + assert (size (db->query (query::s == a)) == 1); + assert (size (db->query (query::s == query::_val (a))) == 1); +#endif + assert (size (db->query (query::s == query::_ref (ra))) == 1); +#ifndef MULTI_DATABASE + assert (size (db->query ("s = " + query::_val (a))) == 1); + assert (size (db->query ("s = " + query::_ref (a))) == 1); +#endif + } + + { + const char a[] = "bcd"; + const char* ra = a; +#ifndef MULTI_DATABASE + assert (size (db->query (query::s == a)) == 1); + assert (size (db->query (query::s == query::_val (a))) == 1); +#endif + assert (size (db->query (query::s == query::_ref (ra))) == 1); +#ifndef MULTI_DATABASE + assert (size (db->query ("s = " + query::_val (a))) == 1); + assert (size (db->query ("s = " + query::_ref (a))) == 1); +#endif + } + + { + const char* p = "cde"; +#ifndef MULTI_DATABASE + assert (size (db->query (query::s == p)) == 1); + assert (size (db->query (query::s == query::_val (p))) == 1); +#endif + assert (size (db->query (query::s == query::_ref (p))) == 1); +#ifndef MULTI_DATABASE + assert (size (db->query ("s = " + query::_val (p))) == 1); + assert (size (db->query ("s = " + query::_ref (p))) == 1); +#endif + } + + { + char a[] = "cde"; + char* p = a; +#ifndef MULTI_DATABASE + assert (size (db->query (query::s == p)) == 1); + assert (size (db->query (query::s == query::_val (p))) == 1); +#endif + assert (size (db->query (query::s == query::_ref (p))) == 1); +#ifndef MULTI_DATABASE + assert (size (db->query ("s = " + query::_val (p))) == 1); + assert (size (db->query ("s = " + query::_ref (p))) == 1); +#endif + } + +#ifndef MULTI_DATABASE + string s ("abc"); + //assert (size (db->query (query::s == s)) == 1); + assert (size (db->query (query::s == s.c_str ())) == 1); + //assert (size (db->query (query::s == query::_val (s))) == 1); + assert (size (db->query (query::s == query::_val (s.c_str ()))) == 1); + + assert (size (db->query ("s = " + query::_val (s))) == 1); + assert (size (db->query ("s = " + query::_ref (s))) == 1); +#endif + + // @@ BUILD2 Ends up with the following warning, but strangely only in the + // multi-database mode: + // + // In file included from odb/odb-tests/common/query/array/test-odb.hxx:31, + // from odb/odb-tests/common/query/array/driver.cxx:20: + // odb/libodb/odb/query-dynamic.hxx: In instantiation of ‘odb::query_base odb::query_column::operator==(const odb::query_column&) const [with T2 = char [17]; T = char [17]]’: + // odb/odb-tests/common/query/array/driver.cxx:144:7: required from here + // odb/libodb/odb/query-dynamic.hxx:895:43: error: comparison between two arrays is deprecated in C++20 [-Werror=array-compare] + // 895 | (void) (sizeof (type_instance () == type_instance ())); + // | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ + // odb/libodb/odb/query-dynamic.hxx:895:43: note: use unary ‘+’ which decays operands to pointers or ‘&‘indirect_ref’ not supported by dump_decl[0] == &‘indirect_ref’ not supported by dump_decl[0]’ to compare the addresses + // + // Looks like compile-time assertion. Doesn't make much sense for + // arrays since compares pointers to objects rather than objects. + // Should we somehow suppress the assertion for arrays or similar? + // + // Note: temporarily ifndef-ed. + // +#ifndef MULTI_DATABASE + assert (size (db->query (query::s == query::s1)) == 3); +#endif + + // std::array + // + array a; + memcpy (a.data (), "abc", 4); // VC++ strcpy deprecation. + +#ifndef MULTI_DATABASE + assert (size (db->query (query::a == a)) == 1); + assert (size (db->query (query::a == query::_val (a))) == 1); +#endif + assert (size (db->query (query::a == query::_ref (a))) == 1); +#ifndef MULTI_DATABASE + assert (size (db->query ("a = " + query::_val (a))) == 1); + assert (size (db->query ("a = " + query::_ref (a))) == 1); +#endif + + // char + // + assert (size (db->query (query::c == 'a')) == 1); + + char c ('b'); + assert (size (db->query (query::c == query::_val (c))) == 1); + assert (size (db->query (query::c == query::_ref (c))) == 1); + +#ifndef MULTI_DATABASE + assert (size (db->query ("c = " + query::_val ('c'))) == 1); + assert (size (db->query ("c = " + query::_ref (c))) == 1); +#endif + + assert (size (db->query (query::c == query::c1)) == 3); + + // buffer + // +#ifndef MULTI_DATABASE + assert (size (db->query (query::b == buf)) == 3); + assert (size (db->query (query::b == query::_val (buf))) == 3); +#endif + + assert (size (db->query (query::b == query::_ref (buf))) == 3); + +#ifndef MULTI_DATABASE + assert (size (db->query ("b = " + query::_val (buf))) == 3); + assert (size (db->query ("b = " + query::_ref (buf))) == 3); +#endif + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/query/array/test.hxx b/odb-tests/common/query/array/test.hxx new file mode 100644 index 0000000..f0d5f3b --- /dev/null +++ b/odb-tests/common/query/array/test.hxx @@ -0,0 +1,70 @@ +// file : common/query/array/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include // std::memcpy, std::strlen + +#include + +#pragma db object +struct object +{ + object () {} + object (unsigned long id, const char* s, const char* b) + : id_ (id) + { + std::memcpy (s_, s, std::strlen (s) + 1); // VC++ strncpy deprecation. + std::memcpy (s1_, s, std::strlen (s) + 1); + std::memcpy (a_.data (), s, std::strlen (s) + 1); + c_ = c1_ = *s; + std::memcpy (b_, b, sizeof (b_)); + } + + #pragma db id + unsigned long id_; + + char s_[17]; + char s1_[17]; + +#ifdef ODB_COMPILER +# if defined(ODB_DATABASE_MYSQL) || \ + defined(ODB_DATABASE_PGSQL) || \ + defined(ODB_DATABASE_ORACLE) || \ + defined(ODB_DATABASE_MSSQL) +# pragma db type("VARCHAR(16)") +# elif defined(ODB_DATABASE_SQLITE) +# pragma db type("TEXT") +# elif defined(ODB_DATABASE_COMMON) +# pragma db type("DYMMU") // Necessary to make it a value. +# else +# error unknown database +# endif +#endif + std::array a_; + + char c_; + char c1_; + +#ifdef ODB_COMPILER +# if defined(ODB_DATABASE_MYSQL) +# pragma db type("BINARY(16)") +# elif defined(ODB_DATABASE_SQLITE) +# pragma db type("BLOB") +# elif defined(ODB_DATABASE_PGSQL) +# pragma db type("BYTEA") +# elif defined(ODB_DATABASE_ORACLE) +# pragma db type("RAW(16)") +# elif defined(ODB_DATABASE_MSSQL) +# pragma db type("BINARY(16)") +# elif defined(ODB_DATABASE_COMMON) +# else +# error unknown database +# endif +#endif + char b_[16]; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/query/array/testscript b/odb-tests/common/query/array/testscript new file mode 100644 index 0000000..631ae24 --- /dev/null +++ b/odb-tests/common/query/array/testscript @@ -0,0 +1,33 @@ +# file : common/query/array/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/query/basics/buildfile b/odb-tests/common/query/basics/buildfile new file mode 100644 index 0000000..e38e6fe --- /dev/null +++ b/odb-tests/common/query/basics/buildfile @@ -0,0 +1,42 @@ +# file : common/query/basics/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_query_basics_ \ + --generate-schema \ + --generate-query \ + --generate-prepared + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/query/basics/driver.cxx b/odb-tests/common/query/basics/driver.cxx new file mode 100644 index 0000000..73b81d2 --- /dev/null +++ b/odb-tests/common/query/basics/driver.cxx @@ -0,0 +1,668 @@ +// file : common/query/basics/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test basic query support. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include // DATABASE_XXX +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +void +print (result& r) +{ + for (result::iterator i (r.begin ()); i != r.end (); ++i) + { + unique_ptr o (i.load ()); + cout << *o << endl; + } + cout << endl; +} + +const char* names[] = { "John", "Jane", "Joe" }; +const char** names_end = names + sizeof (names)/sizeof (names[0]); + +const char* key_data[] = { "\x23\x03\x15", "\x13\x13\x54", "\x08\x62\x35" }; + +int +main (int argc, char* argv[]) +{ + buffer + key1 (key_data[0], key_data[0] + 3), + key2 (key_data[1], key_data[1] + 3), + key3 (key_data[2], key_data[2] + 3); + + try + { + unique_ptr db (create_database (argc, argv)); + odb::database_id db_id (db->id ()); + + typedef odb::query query; + typedef odb::result result; + + // + // + { + person p1 (1, "John", "Doe", 30, true, key1); + person p2 (2, "Jane", "Doe", 29, true, key2); + person p3 (3, "Joe", "Dirt", 31, false, key3); + p3.middle_name_.reset (new string ("Squeaky")); + person p4 (4, "Johansen", "Johansen", 32, false); + p4.middle_name_.reset (new string ("J")); + + transaction t (db->begin ()); + db->persist (p1); + db->persist (p2); + db->persist (p3); + db->persist (p4); + t.commit (); + } + + // + // Native queries. + // + + // Compilation tests. + // +#ifndef MULTI_DATABASE + if (false) + { + string name; + unsigned short age; + + db->query ("age = " + query::_ref (age)); + db->query ("age = " + query::_val (age)); + + query age_q (query::_ref (age) + " = age"); + query name_q ("first = " + query::_val (name)); + query q (age_q + "AND" + name_q); + + db->query (q); + db->query (age_q + "OR" + + name_q + "OR" + + "age < " + query::_ref (age)); + + query q1 (query::_val (name)); + q1 += " = first"; + } +#endif + + // Select-all query. + // + cout << "test 001" << endl; + { + transaction t (db->begin ()); + result r (db->query ()); + + for (result::iterator i (r.begin ()); i != r.end (); ++i) + { + person p; + i.load (p); + cout << p << endl; + } + + t.commit (); + } + + // Select-all query with order by. + // + cout << "test 002" << endl; + { + transaction t (db->begin ()); + result r (db->query ("ORDER BY" + query::age)); + + for (result::iterator i (r.begin ()); i != r.end (); ++i) + { + person& p (*i); + + cout << p.first_name_; + + if (i->middle_name_.get () != 0) + cout << ' ' << *i->middle_name_; + + cout << ' ' << i->last_name_ << ' ' << i->age_ << + (i->married_ ? " married" : " single") << endl; + } + cout << endl; + + t.commit (); + } + + // String query. + // + cout << "test 003" << endl; + { + transaction t (db->begin ()); + + result r; + if (db_id != odb::id_oracle) + r = db->query ("age >= 30 AND last = 'Doe'"); + else + r = db->query ("\"age\" >= 30 AND \"last\" = 'Doe'"); + + print (r); + t.commit (); + } + + // Value binding. + // + cout << "test 004" << endl; + { + transaction t (db->begin ()); + + const char* name = "Doe"; + +#if defined(MULTI_DATABASE) + result r ( + db->query ( + query::age >= query::_val (30) && + query::last_name == query::_val (name))); + +#elif defined(DATABASE_ORACLE) + result r ( + db->query ( + "\"age\" >= " + query::_val (30) + "AND" + + "\"last\" = " + query::_val (name))); +#else + result r ( + db->query ( + "age >= " + query::_val (30) + "AND" + + "last = " + query::_val (name))); +#endif + + print (r); + t.commit (); + } + + // Reference binding. + // + cout << "test 005" << endl; + { + transaction t (db->begin ()); + + string name; + unsigned short age; + +#if defined(MULTI_DATABASE) + query q (query::age >= query::_ref (age) && + query::last_name == query::_ref (name)); +#elif defined(DATABASE_ORACLE) + query q ("\"age\" >= " + query::_ref (age) + "AND" + + "\"last\" = " + query::_ref (name)); +#else + query q ("age >= " + query::_ref (age) + "AND" + + "last = " + query::_ref (name)); +#endif + + name = "Doe"; + age = 30; + result r (db->query (q)); + print (r); + + name = "Dirt"; + age = 31; + r = db->query (q); + print (r); + + t.commit (); + } + + // + // Language-embedded queries. + // + + // Compilation tests. + // + if (false) + { + string name; + unsigned short age; + + // Column operators. + // + query q1 (query::married); + db->query (query::married); + db->query (query::married == true); + + //db->query (query::age); + + db->query (query::age == 30); + db->query (query::age == age); + db->query (query::age == query::_val (30)); + db->query (query::age == query::_val (age)); + db->query (query::age == query::_ref (age)); + //db->query (query::age == "123"); + //db->query ("123" == query::age); + //db->query (query::age == query::_val ("123")); + //db->query (query::age == query::_ref (name)); + db->query (query::last_name == "Doe"); + db->query (query::last_name == name); +#ifndef MULTI_DATABASE + db->query (query::last_name == query::_val ("Doe")); +#endif + db->query (query::last_name == query::_val (name)); + db->query (query::last_name == query::_ref (name)); + //db->query (query::last_name == 30); + //db->query (query::last_name == query::_val (30)); + //db->query (query::last_name == query::_ref (age)); + + db->query (query::last_name.is_null ()); + db->query (query::last_name.is_not_null ()); + + db->query (query::first_name == query::last_name); + + db->query (query::first_name.in ("John", "Jane")); + db->query (query::first_name.in_range (names, names_end)); + + db->query (query::first_name.like ("J%")); + db->query (query::first_name.like ("J%!%", "!")); + + // Query operators. + // + db->query (query::age == 30 && query::last_name == "Doe"); + db->query (query::age == 30 || query::last_name == "Doe"); + db->query (!(query::age == 30 || query::last_name == "Doe")); + db->query ((query::last_name == "Doe") + "ORDER BY age"); + } + + // Test is_null/is_not_null. + // + cout << "test 006" << endl; + { + transaction t (db->begin ()); + result r (db->query (query::middle_name.is_null ())); + print (r); + r = db->query (query::middle_name.is_not_null ()); + print (r); + t.commit (); + } + + // Test boolean columns. + // + cout << "test 007" << endl; + { + transaction t (db->begin ()); + result r (db->query (query::married)); + print (r); + r = db->query (!query::married); + print (r); + t.commit (); + } + + // Test implicit by-value, explicit by-value, and by-reference. + // + cout << "test 008" << endl; + { + string name ("Dirt"); + + transaction t (db->begin ()); + result r (db->query (query::last_name == "Doe")); + print (r); + r = db->query (query::last_name == query::_val (name)); + print (r); + query q (query::last_name == query::_ref (name)); + name = "Doe"; + r = db->query (q); + print (r); + t.commit (); + } + + // Test column operators (==, !=, <, >, <=, >=). + // + cout << "test 009" << endl; + { + transaction t (db->begin ()); + + // == + // + result r (db->query (query::last_name == "Doe")); + print (r); + + // != + // + r = db->query (query::last_name != "Doe"); + print (r); + + // < + // + r = db->query (query::age < 31); + print (r); + + // > + // + r = db->query (query::age > 30); + print (r); + + // <= + // + r = db->query (query::age <= 30); + print (r); + + // >= + // + r = db->query (query::age >= 31); + print (r); + + t.commit (); + } + + // Test query operators (&&, ||, (), !, +). + // + cout << "test 010" << endl; + { + transaction t (db->begin ()); + + // && + // + result r (db->query ( + query::last_name == "Doe" && query::age == 29)); + print (r); + + // || + // + r = db->query (query::last_name == "Doe" || query::age == 31); + print (r); + + // () + // + r = db->query ( + (query::last_name != "Doe" || query::age == 29) && query::married); + print (r); + + // != + // + r = db->query (!(query::last_name == "Doe")); + print (r); + + // + + // + r = db->query ((query::last_name == "Doe") + + "ORDER BY" + query::age); + print (r); + + t.commit (); + } + + // Test in/in_range. + // + cout << "test 011" << endl; + { + transaction t (db->begin ()); + + result r (db->query (query::first_name.in ("John", "Jane"))); + print (r); + + r = db->query (query::first_name.in_range (names, names_end)); + print (r); + + // Empty range. + // + r = db->query (query::last_name == "Doe" && + query::first_name.in_range (names, names)); + assert (r.empty ()); + + t.commit (); + } + + // Test column-to-column comparison. + // + cout << "test 012" << endl; + { + transaction t (db->begin ()); + result r (db->query (query::first_name == query::last_name)); + print (r); + t.commit (); + } + + // Test value_traits::value_type != value_traits::query_type. + // + cout << "test 013" << endl; + { + transaction t (db->begin ()); + result r (db->query (query::middle_name == "Squeaky")); + print (r); + t.commit (); + } + + // Test that loading of the same object type during iteration does + // not invalidate the result. + // + cout << "test 014" << endl; + { + transaction t (db->begin ()); + result r (db->query (query::last_name == "Doe")); + + result::iterator i (r.begin ()); + assert (i != r.end ()); + ++i; + assert (i != r.end ()); + + { + unique_ptr joe (db->load (3)); + } + + { + person p (5, "Peter", "Peterson", 70, false, key3); + db->persist (p); + db->erase (p); + } + + // SQL Server does not support re-loading of an object with long data + // from a query result. + // + if (db_id != odb::id_mssql) + assert (i->last_name_ == "Doe"); // Actual load. + + // Overwrite object image again. + // + unique_ptr joe (db->load (3)); + person p; + i.load (p); + assert (p.last_name_ == "Doe"); + + t.commit (); + } + + // Test uncached result. + // + cout << "test 015" << endl; + { + transaction t (db->begin ()); + result r (db->query (query::last_name == "Doe", false)); + print (r); + t.commit (); + } + + // Test BLOB column operations. + // + cout << "test 016" << endl; + { + transaction t (db->begin ()); + + result r; + result::iterator i; + + // == + // + + // Oracle does not support LOB comparisons. + // +#if defined(MULTI_DATABASE) || !defined(DATABASE_ORACLE) + if (db_id != odb::id_oracle) + { + r = db->query (query::public_key == key2); + + i = r.begin (); + assert (i != r.end ()); + + assert (*i->public_key_ == key2); + assert (++i == r.end ()); + } +#endif + + // is_null + // + r = db->query (query::public_key.is_null ()); + + i = r.begin (); + assert (i != r.end ()); + + assert (i->first_name_ == "Johansen" && i->last_name_ == "Johansen"); + assert (++i == r.end ()); + + // is_not_null + // + r = db->query (query::public_key.is_not_null ()); + + i = r.begin (); + assert (i != r.end ()); + + assert (i->first_name_ == "John" && i->last_name_ == "Doe"); + assert (++i != r.end ()); + + assert (i->first_name_ == "Jane" && i->last_name_ == "Doe"); + assert (++i != r.end ()); + + assert (i->first_name_ == "Joe" && i->last_name_ == "Dirt"); + assert (++i == r.end ()); + + t.commit (); + } + + // Test iterator::id(). + // + cout << "test 017" << endl; + { + transaction t (db->begin ()); + result r (db->query (query::last_name == "Dirt")); + + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i.id () == 3); + + t.commit (); + } + + // Test empty result set. + // + cout << "test 018" << endl; + { + { + transaction t (db->begin ()); + result r (db->query (query::last_name == "None")); + assert (r.empty ()); + t.commit (); + } + + { + transaction t (db->begin ()); + result r (db->query (query::last_name == "None")); + assert (r.begin () == r.end ()); + t.commit (); + } + } + + // Test size() validity at the beginning/middle/end of result set. + // + cout << "test 019" << endl; + if (db_id != odb::id_sqlite && + db_id != odb::id_oracle && + db_id != odb::id_mssql) + { + { + transaction t (db->begin ()); + result r (db->query ()); + assert (r.size () == 4); + result::iterator i (r.begin ()); + assert (r.size () == 4); + ++i; + ++i; + ++i; + assert (r.size () == 4); + ++i; + assert (r.size () == 4); + } + + { + transaction t (db->begin ()); + result r (db->query (false)); + result::iterator i (r.begin ()); + ++i; + ++i; + r.cache (); // Cache in the middle. + assert (r.size () == 4); + ++i; + assert (r.size () == 4); + ++i; + assert (r.size () == 4); + } + + { + transaction t (db->begin ()); + result r (db->query (false)); + result::iterator i (r.begin ()); + ++i; + ++i; + ++i; + r.cache (); // Cache at the end. + assert (r.size () == 4); + } + + { + transaction t (db->begin ()); + result r (db->query (query::last_name == "None")); + assert (r.size () == 0); + for (result::iterator i (r.begin ()); i != r.end (); ++i) ; + assert (r.size () == 0); + } + } + + // Test like. + // + cout << "test 020" << endl; + { + transaction t (db->begin ()); + + result r (db->query (query::first_name.like ("Jo%"))); + print (r); + + r = db->query (!query::first_name.like ("Jo%")); + print (r); + + r = db->query (query::first_name.like ("Jo!%", "!")); + print (r); + + // In Oracle one can only escape special characters (% and _). + // + string v; + if (db_id != odb::id_oracle) + v = "!Ja%"; + else + v = "Ja%"; + + r = db->query (query::first_name.like (query::_ref (v), "!")); + print (r); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/query/basics/test.hxx b/odb-tests/common/query/basics/test.hxx new file mode 100644 index 0000000..239f6d6 --- /dev/null +++ b/odb-tests/common/query/basics/test.hxx @@ -0,0 +1,117 @@ +// file : common/query/basics/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include +#include + +#include +#include + +#ifdef ODB_COMPILER +# if defined(ODB_DATABASE_PGSQL) +# define BLOB_TYPE "BYTEA" +# elif defined(ODB_DATABASE_MSSQL) +# define BLOB_TYPE "VARBINARY(max)" +# else +# define BLOB_TYPE "BLOB" +# endif +#endif + +typedef std::vector buffer; +typedef odb::nullable nullable_buffer; + +#pragma db object +struct person +{ + person (unsigned long id, + const std::string& fn, + const std::string& ln, + unsigned short age, + bool married, + const nullable_buffer& public_key = nullable_buffer ()) + : id_ (id), + first_name_ (fn), + last_name_ (ln), + age_ (age), + married_ (married), + public_key_ (public_key) + { + } + + person () + { + } + + #pragma db id + unsigned long id_; + + #pragma db column ("first") + std::string first_name_; + + #pragma db column ("middle") null + std::unique_ptr middle_name_; + + #pragma db column ("last") + std::string last_name_; + + unsigned short age_; + bool married_; + + #pragma db column ("key") type(BLOB_TYPE) null + nullable_buffer public_key_; +}; + +inline std::ostream& +operator<< (std::ostream& os, const person& p) +{ + os << p.first_name_; + + if (p.middle_name_.get () != 0) + os << ' ' << *p.middle_name_; + + os << ' ' << p.last_name_ << ' ' << p.age_ << + (p.married_ ? " married" : " single"); + + return os; +} + +// Test member name conflicts (compilation-only test). +// +#pragma db namespace table("t2_") +namespace test2 +{ + #pragma db object + struct object + { + #pragma db id + int id; + }; + + #pragma db value + struct value + { + object* m_object; + }; + + #pragma db value + struct bar + { + value m_value; + }; + + #pragma db object + struct foo + { + #pragma db id + int id; + + bar m_value; + }; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/query/basics/testscript b/odb-tests/common/query/basics/testscript new file mode 100644 index 0000000..9086b66 --- /dev/null +++ b/odb-tests/common/query/basics/testscript @@ -0,0 +1,150 @@ +# file : common/query/basics/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + ++cat <=output + test 001 + John Doe 30 married + Jane Doe 29 married + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + test 002 + Jane Doe 29 married + John Doe 30 married + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + test 003 + John Doe 30 married + + test 004 + John Doe 30 married + + test 005 + John Doe 30 married + + Joe Squeaky Dirt 31 single + + test 006 + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + test 007 + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + test 008 + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + + John Doe 30 married + Jane Doe 29 married + + test 009 + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + test 010 + Jane Doe 29 married + + John Doe 30 married + Jane Doe 29 married + Joe Squeaky Dirt 31 single + + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + Jane Doe 29 married + John Doe 30 married + + test 011 + John Doe 30 married + Jane Doe 29 married + + John Doe 30 married + Jane Doe 29 married + Joe Squeaky Dirt 31 single + + test 012 + Johansen J Johansen 32 single + + test 013 + Joe Squeaky Dirt 31 single + + test 014 + test 015 + John Doe 30 married + Jane Doe 29 married + + test 016 + test 017 + test 018 + test 019 + test 020 + John Doe 30 married + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + Jane Doe 29 married + + + Jane Doe 29 married + + EOI + +test.redirects += >>>../output + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/query/one/buildfile b/odb-tests/common/query/one/buildfile new file mode 100644 index 0000000..76a36b0 --- /dev/null +++ b/odb-tests/common/query/one/buildfile @@ -0,0 +1,42 @@ +# file : common/query/one/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_query_one_ \ + --generate-schema \ + --generate-query \ + --generate-prepared + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/query/one/driver.cxx b/odb-tests/common/query/one/driver.cxx new file mode 100644 index 0000000..4c3dcdc --- /dev/null +++ b/odb-tests/common/query/one/driver.cxx @@ -0,0 +1,205 @@ +// file : common/query/one/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test query one support. +// +// We assume that other tests in common/query/ exercise a variety of +// different kinds of queries. Here we are concerned with what is +// specific to query_one() and query_value(). +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + odb::database_id db_id (db->id ()); + + transaction t (db->begin ()); + + // query_one() + // + { + unique_ptr o (db->query_one ()); + assert (o.get () == 0); + } + + { + object o (4); + assert (!db->query_one (o) && o.id_ == 4 && o.str_.empty ()); + } + + /* + { + object o (db->query_value ()); + assert (false); + } + */ + + object o (1); + o.str_ = "value 1"; + db->persist (o); + + { + unique_ptr o (db->query_one ()); + assert (o.get () != 0 && o->str_ == "value 1"); + } + + { + object o; + assert (db->query_one (o) && o.str_ == "value 1"); + } + + { + object o (db->query_value ()); + assert (o.str_ == "value 1"); + } + + // query_one(const char*) + // + const char* q1_c (db_id == odb::id_oracle ? "\"id\" = 1" : "id = 1"); + const char* q0_c (db_id == odb::id_oracle ? "\"id\" = 2" : "id = 2"); + + { + unique_ptr o (db->query_one (q1_c)); + assert (o.get () != 0 && o->str_ == "value 1"); + } + + { + unique_ptr o (db->query_one (q0_c)); + assert (o.get () == 0); + } + + { + object o; + assert (db->query_one (q1_c, o) && o.str_ == "value 1"); + } + + { + object o (4); + assert (!db->query_one (q0_c, o) && + o.id_ == 4 && o.str_.empty ()); + } + + { + object o (db->query_value (q1_c)); + assert (o.str_ == "value 1"); + } + + // query_one(std::string) + // + string q1_s (q1_c); + string q0_s (q0_c); + + { + unique_ptr o (db->query_one (q1_s)); + assert (o.get () != 0 && o->str_ == "value 1"); + } + + { + unique_ptr o (db->query_one (q0_s)); + assert (o.get () == 0); + } + + { + object o; + assert (db->query_one (q1_s, o) && o.str_ == "value 1"); + } + + { + object o (4); + assert (!db->query_one (q0_s, o) && + o.id_ == 4 && o.str_.empty ()); + } + + { + object o (db->query_value (q1_s)); + assert (o.str_ == "value 1"); + } + + // query_one(odb::query) + // + typedef odb::query query; + + query q1 (query::id == 1); + query q0 (query::id == 2); + + { + unique_ptr o (db->query_one (q1)); + assert (o.get () != 0 && o->str_ == "value 1"); + } + + { + unique_ptr o (db->query_one (q0)); + assert (o.get () == 0); + } + + { + object o; + assert (db->query_one (q1, o) && o.str_ == "value 1"); + } + + { + object o (4); + assert (!db->query_one (q0, o) && o.id_ == 4 && o.str_.empty ()); + } + + { + object o (db->query_value (q1)); + assert (o.str_ == "value 1"); + } + + // Assertion on more than one element. + // + { + object o (2); + o.str_ = "value 2"; + db->persist (o); + } + + /* + { + unique_ptr o (db->query_one ()); + assert (false); + } + */ + + /* + { + object o; + db->query_one (o); + assert (false); + } + */ + + /* + { + object o (db->query_value ()); + assert (false); + } + */ + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/query/one/test.hxx b/odb-tests/common/query/one/test.hxx new file mode 100644 index 0000000..3008063 --- /dev/null +++ b/odb-tests/common/query/one/test.hxx @@ -0,0 +1,26 @@ +// file : common/query/one/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; + std::string str_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/query/one/testscript b/odb-tests/common/query/one/testscript new file mode 100644 index 0000000..963a206 --- /dev/null +++ b/odb-tests/common/query/one/testscript @@ -0,0 +1,33 @@ +# file : common/query/one/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/readonly/buildfile b/odb-tests/common/readonly/buildfile new file mode 100644 index 0000000..2d83cf1 --- /dev/null +++ b/odb-tests/common/readonly/buildfile @@ -0,0 +1,40 @@ +# file : common/readonly/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix readonly_ \ + --generate-schema + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/readonly/driver.cxx b/odb-tests/common/readonly/driver.cxx new file mode 100644 index 0000000..b207627 --- /dev/null +++ b/odb-tests/common/readonly/driver.cxx @@ -0,0 +1,324 @@ +// file : common/readonly/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test readonly members/objects. Also test that const members are +// treated as readonly. For other const member tests, see the const- +// member test. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include // DATABASE_* +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Simple. + // + { + simple o (1, 1); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + o.ro++; + const_cast (o.co)++; + o.rw++; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + db->load (1, o); + t.commit (); + } + + assert (o.ro == 1 && o.co == 1 && o.rw == 2); + } + + // Pointer. + // + { + pointer p (1, new pointer (2)); + unique_ptr p1 (new pointer (3)); + + { + transaction t (db->begin ()); + db->persist (p); + db->persist (p.ro); + db->persist (*p1); + t.commit (); + } + + delete p.ro; + p.ro = p1.release (); + const_cast (p.co) = p.ro; + p.rw = p.ro; + + { + transaction t (db->begin ()); + db->update (p); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (1)); + t.commit (); + + assert (p->ro->id == 2 && p->co->id == 2 && p->rw->id == 3); + } + } + + // Composite. + // + { + composite o (1, 1); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + o.ro.v++; + o.ro.ro++; + const_cast (o.ro.co)++; + o.ro.rw++; + + value& co (const_cast (o.co)); + co.v++; + co.ro++; + const_cast (co.co)++; + co.rw++; + + o.rw.v++; + o.rw.ro++; + const_cast (o.rw.co)++; + o.rw.rw++; + + o.v.v++; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + db->load (1, o); + t.commit (); + } + + assert (o.ro.v == 1 && + o.ro.ro == 1 && + o.ro.co == 1 && + o.ro.rw == 1 && + + o.co.v == 1 && + o.co.ro == 1 && + o.co.co == 1 && + o.co.rw == 1 && + + o.rw.v == 1 && + o.rw.ro == 1 && + o.rw.co == 1 && + o.rw.rw == 2 && + + o.v.v == 1); + } + + // Container. + // + { + typedef vector ulongs; + + container o (1); + + o.ro.push_back (1); + o.ro.push_back (2); + + ulongs& co (const_cast (o.co)); + co.push_back (1); + co.push_back (2); + + o.rw.push_back (1); + o.rw.push_back (2); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + o.ro[0]++; + o.ro.pop_back (); + + co[0]++; + co.pop_back (); + + o.rw[0]++; + o.rw.pop_back (); + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + db->load (1, o); + t.commit (); + } + + assert (o.ro.size () == 2 && o.ro[0] == 1 && o.ro[1] == 2 && + o.co.size () == 2 && o.co[0] == 1 && o.co[1] == 2 && + o.rw.size () == 1 && o.rw[0] == 2); + } + + // Readonly object. + // + { +#ifndef MULTI_DATABASE + typedef odb::object_traits_impl so_traits; + typedef odb::object_traits_impl ro_traits; + typedef odb::object_traits_impl rw_traits; + + assert (so_traits::column_count == + so_traits::id_column_count + so_traits::readonly_column_count); + + assert (ro_traits::column_count == + ro_traits::id_column_count + ro_traits::readonly_column_count); + + assert (rw_traits::column_count != + rw_traits::id_column_count + rw_traits::readonly_column_count); +#endif + + simple_object so (1, 1); + ro_object ro_o (1, 1); + rw_object rw_o (1, 1); + + ro_o.cr.push_back (1); + ro_o.cr.push_back (2); + + rw_o.cr.push_back (1); + rw_o.cr.push_back (2); + + { + transaction t (db->begin ()); + db->persist (so); + db->persist (ro_o); + db->persist (rw_o); + t.commit (); + } + + rw_o.sv++; + rw_o.rw_sv++; + + { + transaction t (db->begin ()); + //db->update (so); // Compile error. + //db->update (ro_o); // Compile error. + db->update (rw_o); + t.commit (); + } + + { + transaction t (db->begin ()); + db->load (1, so); + db->load (1, ro_o); + db->load (1, rw_o); + t.commit (); + } + + assert (rw_o.sv == 1 && rw_o.rw_sv == 2); + } + + // Readonly object. + // + { + wrapper o (1, 1); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + *o.pl = 2; + *o.cpl = 2; + o.pcl.reset (new unsigned long (2)); + const_cast (*o.cpcl) = 2; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + db->load (1, o); + t.commit (); + } + + assert (*o.pl == 2 && *o.cpl == 2 && *o.pcl == 2 && *o.cpcl == 1); + } + + // Readonly object with auto id. + // + { + ro_auto o1 (1); + ro_auto o2 (2); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (p1->num == o1.num); + assert (p2->num == o2.num); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/readonly/test.hxx b/odb-tests/common/readonly/test.hxx new file mode 100644 index 0000000..45797b6 --- /dev/null +++ b/odb-tests/common/readonly/test.hxx @@ -0,0 +1,225 @@ +// file : common/readonly/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include // std::unique_ptr + +#include + +// Simple readonly object. +// +#pragma db object +struct simple +{ + simple (unsigned long i, unsigned long x) + : id (i), ro (x), co (x), rw (x) + { + } + + simple (): co (0) {} + + #pragma db id + unsigned long id; + + #pragma db readonly + unsigned long ro; + + const unsigned long co; + + unsigned long rw; +}; + +// Readonly pointer. +// +#pragma db object +struct pointer +{ + pointer (unsigned long i, pointer* p = 0): id (i), ro (p), co (p), rw (p) {} + pointer (): ro (0), co (0), rw (0) {} + + ~pointer () + { + delete ro; + + if (co != ro) + delete co; + + if (rw != ro && rw != co) + delete rw; + } + + #pragma db id + unsigned long id; + + #pragma db readonly + pointer* ro; + + pointer* const co; + + pointer* rw; +}; + +// Composite readonly value as well as simple readonly value inside +// a composite. +// +#pragma db value readonly +struct ro_value +{ + ro_value () {} + ro_value (unsigned long x): v (x) {} + + unsigned long v; +}; + +#pragma db value +struct value: ro_value +{ + value (): co (0) {} + value (unsigned long x): ro_value (x), ro (x), co (x), rw (x) {} + + #pragma db readonly + unsigned long ro; + + const unsigned long co; + + unsigned long rw; +}; + +#pragma db object +struct composite +{ + composite (unsigned long i, unsigned long x) + : id (i), ro (x), co (x), rw (x), v (x) + { + } + + composite () {} + + #pragma db id + unsigned long id; + + #pragma db readonly + value ro; + + const value co; + + value rw; + ro_value v; +}; + +// Readonly container. +// +#pragma db object +struct container +{ + container (unsigned long i): id (i) {} + container () {} + + #pragma db id + unsigned long id; + + #pragma db readonly + std::vector ro; + + const std::vector co; + + std::vector rw; +}; + +// Readonly object. +// +#pragma db object readonly +struct simple_object +{ + simple_object (unsigned long i, unsigned long x): id (i), sv (x) {} + simple_object () {} + + #pragma db id + unsigned long id; + + unsigned long sv; +}; + +#pragma db object +struct object +{ + object (unsigned long i, unsigned long x): id (i), sv (x) {} + object () {} + + #pragma db id + unsigned long id; + + unsigned long sv; +}; + +#pragma db object readonly +struct ro_object: object +{ + ro_object (unsigned long i, unsigned long x) + : object (i, x), cv (x) + { + } + + ro_object () {} + + value cv; + std::vector cr; +}; + +#pragma db object +struct rw_object: ro_object +{ + rw_object (unsigned long i, unsigned long x) + : ro_object (i, x), rw_sv (x) + { + } + + rw_object () {} + + unsigned long rw_sv; +}; + +// Readonly wrappers. Here we make sure that only const wrappers with +// const wrapped types are automatically treated as readonly. +// +#pragma db object +struct wrapper +{ + wrapper (unsigned long i, unsigned long x) + : id (i), + pl (new unsigned long (x)), + cpl (new unsigned long (x)), + pcl (new unsigned long (x)), + cpcl (new unsigned long (x)) + { + } + + wrapper () {} + + #pragma db id + unsigned long id; + + std::unique_ptr pl; + const std::unique_ptr cpl; + std::unique_ptr pcl; + const std::unique_ptr cpcl; +}; + +// Readonly object with auto id. +// +#pragma db object readonly +struct ro_auto +{ + ro_auto (unsigned long n): num (n) {} + ro_auto () {} + + #pragma db id auto + unsigned long id; + + unsigned long num; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/readonly/testscript b/odb-tests/common/readonly/testscript new file mode 100644 index 0000000..c798201 --- /dev/null +++ b/odb-tests/common/readonly/testscript @@ -0,0 +1,33 @@ +# file : common/readonly/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/relationship/basics/buildfile b/odb-tests/common/relationship/basics/buildfile new file mode 100644 index 0000000..d7bbb7e --- /dev/null +++ b/odb-tests/common/relationship/basics/buildfile @@ -0,0 +1,41 @@ +# file : common/relationship/basics/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_rel_basics_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/relationship/basics/driver.cxx b/odb-tests/common/relationship/basics/driver.cxx new file mode 100644 index 0000000..e27c127 --- /dev/null +++ b/odb-tests/common/relationship/basics/driver.cxx @@ -0,0 +1,150 @@ +// file : common/relationship/basics/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test object relationships. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + aggr a ("aggr"); + a.o1 = new obj1 ("o1", "obj1"); + a.o2.reset (new obj2 ("obj2")); + + a.v2.push_back (obj2_ptr (new obj2 ("v1 obj2 1"))); + a.v2.push_back (0); + a.v2.push_back (obj2_ptr (new obj2 ("v1 obj2 2"))); + + a.o3.reset (new obj3 ("obj3")); + + a.c.num = 123; + a.c.o3.reset (new obj3 ("c")); + + a.cv.push_back (comp (234, obj3_ptr (new obj3 ("cv 0")))); + a.cv.push_back (comp (235, obj3_ptr ())); + a.cv.push_back (comp (236, obj3_ptr (new obj3 ("cv 2")))); + + a.v1.push_back (new obj1 ("v1 0", "v1 0")); + a.v1.push_back (0); + a.v1.push_back (new obj1 ("v1 2", "v1 2")); + + // Set cannot contain NULL pointers. + // + a.s1.insert (new obj1 ("s1 0", "s1 0")); + a.s1.insert (new obj1 ("s1 2", "s1 2")); + + a.m1[0] = new obj1 ("m1 0", "m1 0"); + a.m1[1] = 0; + a.m1[2] = new obj1 ("m1 2", "m1 2"); + + // persist + // + { + transaction t (db->begin ()); + db->persist (a.o1); + db->persist (a.o2); + + for (obj2_vec::iterator i (a.v2.begin ()); i != a.v2.end (); ++i) + if (*i) + db->persist (*i); + + db->persist (a.o3); + + db->persist (a.c.o3); + + for (comp_vec::iterator i (a.cv.begin ()); i != a.cv.end (); ++i) + if (i->o3) + db->persist (i->o3); + + for (obj1_vec::iterator i (a.v1.begin ()); i != a.v1.end (); ++i) + if (*i) + db->persist (*i); + + for (obj1_set::iterator i (a.s1.begin ()); i != a.s1.end (); ++i) + if (*i) + db->persist (*i); + + for (obj1_map::iterator i (a.m1.begin ()); i != a.m1.end (); ++i) + if (i->second) + db->persist (i->second); + + db->persist (a); + t.commit (); + } + + // load & compare + // + { + transaction t (db->begin ()); + unique_ptr a1 (db->load (a.id)); + t.commit (); + + assert (*a1 == a); + } + + // query + // + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + result r (db->query (query::o1->str == "obj1")); + assert (!r.empty ()); + assert (r.begin ()->o1->id == a.o1->id); + assert (size (r) == 1); + + t.commit (); + } + + // Test NULL pointer. + // + delete a.o1; + a.o1 = 0; + a.o2.reset (); + a.o3.reset (); + + { + transaction t (db->begin ()); + db->update (a); + t.commit (); + } + + // load & compare + // + { + transaction t (db->begin ()); + unique_ptr a1 (db->load (a.id)); + t.commit (); + + assert (*a1 == a); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/relationship/basics/test.hxx b/odb-tests/common/relationship/basics/test.hxx new file mode 100644 index 0000000..8a2742e --- /dev/null +++ b/odb-tests/common/relationship/basics/test.hxx @@ -0,0 +1,260 @@ +// file : common/relationship/basics/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include +#include +#include + +#include + +// Raw pointer. +// +#pragma db object pointer(obj1*) +struct obj1 +{ + obj1 () {} + obj1 (const std::string& i, const std::string& s): id (i), str (s) {} + + #pragma db id + std::string id; + std::string str; +}; + +inline bool +operator== (const obj1& x, const obj1& y) +{ + return x.id == y.id && x.str == y.str; +} + +// vector +// +typedef std::vector obj1_vec; + +inline bool +operator== (const obj1_vec& x, const obj1_vec& y) +{ + if (x.size () != y.size ()) + return false; + + for (obj1_vec::size_type i (0); i < x.size (); ++i) + if (!(x[i] ? (y[i] && *x[i] == *y[i]) : !y[i])) + return false; + + return true; +} + +// set +// +struct obj1_cmp +{ + bool + operator() (obj1* x, obj1* y) const + { + return (!x || !y) ? x < y : x->id < y->id; + } +}; + +typedef std::set obj1_set; + +inline bool +operator== (const obj1_set& x, const obj1_set& y) +{ + if (x.size () != y.size ()) + return false; + + for (obj1_set::const_iterator i (x.begin ()); i != x.end (); ++i) + { + obj1_set::const_iterator j (y.find (*i)); + + if (j == y.end ()) + return false; + + obj1* x (*i); + obj1* y (*j); + + if (!(x ? (y && *x == *y) : !y)) + return false; + } + + return true; +} + +// map +// +typedef std::map obj1_map; + +inline bool +operator== (const obj1_map& x, const obj1_map& y) +{ + if (x.size () != y.size ()) + return false; + + for (obj1_map::const_iterator i (x.begin ()); i != x.end (); ++i) + { + obj1_map::const_iterator j (y.find (i->first)); + + if (j == y.end ()) + return false; + + obj1* x (i->second); + obj1* y (j->second); + + if (!(x ? (y && *x == *y) : !y)) + return false; + } + + return true; +} + +// auto_ptr/unique_ptr +// +struct obj2; + +typedef std::unique_ptr obj2_ptr; + +#pragma db object pointer(obj2_ptr) +struct obj2 +{ + obj2 () {} + obj2 (const std::string& s): str (s) {} + + #pragma db id auto + unsigned long id; + + std::string str; +}; + +inline bool +operator== (const obj2& x, const obj2& y) +{ + return x.id == y.id && x.str == y.str; +} + +typedef std::vector obj2_vec; + +inline bool +operator== (const obj2_vec& x, const obj2_vec& y) +{ + if (x.size () != y.size ()) + return false; + + for (obj2_vec::size_type i (0); i < x.size (); ++i) + if (!(x[i] ? (y[i] && *x[i] == *y[i]) : !y[i])) + return false; + + return true; +} + +// shared_ptr +// +struct obj3; + +typedef std::shared_ptr obj3_ptr; + +#pragma db object pointer(obj3_ptr) +struct obj3 +{ + obj3 () {} + obj3 (const std::string& s): str (s) {} + + #pragma db id auto + unsigned long id; + + std::string str; +}; + +inline bool +operator== (const obj3& x, const obj3& y) +{ + return x.id == y.id && x.str == y.str; +} + +// composite +// +#pragma db value +struct comp +{ + comp () {} + comp (int n, obj3_ptr o): num (n), o3 (o) {} + + int num; + obj3_ptr o3; +}; + +inline bool +operator== (const comp& x, const comp& y) +{ + return x.num == y.num && + (x.o3 ? (y.o3 && *x.o3 == *y.o3) : !y.o3); +} + +typedef std::vector comp_vec; + +// +// +#pragma db object +struct aggr +{ + aggr (): o1 (0) {} + aggr (const std::string& s): o1 (0), str (s) {} + + ~aggr () + { + delete o1; + + for (obj1_vec::iterator i (v1.begin ()); i != v1.end (); ++i) + delete *i; + + for (obj1_set::iterator i (s1.begin ()); i != s1.end (); ++i) + delete *i; + + for (obj1_map::iterator i (m1.begin ()); i != m1.end (); ++i) + delete i->second; + } + + #pragma db id auto + unsigned long id; + + obj1* o1; + + obj2_ptr o2; // std::auto_ptr or std::unique_ptr + obj2_vec v2; + + obj3_ptr o3; + comp c; + comp_vec cv; + + obj1_vec v1; + obj1_set s1; + obj1_map m1; + + std::string str; + +private: + aggr (const aggr&); + aggr& operator= (const aggr&); +}; + +inline bool +operator== (const aggr& x, const aggr& y) +{ + return + x.id == y.id && + (x.o1 ? (y.o1 && *x.o1 == *y.o1) : !y.o1) && + (x.o2.get () ? (y.o2.get () && *x.o2 == *y.o2) : !y.o2.get ()) && + x.v2 == y.v2 && + (x.o3.get () ? (y.o3.get () && *x.o3 == *y.o3) : !y.o3.get ()) && + x.c == y.c && + x.cv == y.cv && + x.v1 == y.v1 && + x.s1 == y.s1 && + x.m1 == y.m1 && + x.str == y.str; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/relationship/basics/testscript b/odb-tests/common/relationship/basics/testscript new file mode 100644 index 0000000..b498bfa --- /dev/null +++ b/odb-tests/common/relationship/basics/testscript @@ -0,0 +1,33 @@ +# file : common/relationship/basics/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/relationship/on-delete/buildfile b/odb-tests/common/relationship/on-delete/buildfile new file mode 100644 index 0000000..965a2eb --- /dev/null +++ b/odb-tests/common/relationship/on-delete/buildfile @@ -0,0 +1,43 @@ +# file : common/relationship/on-delete/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_rel_on_d_ \ + --generate-schema \ + --fkeys-deferrable-mode mysql:not_deferrable \ + --fkeys-deferrable-mode mssql:not_deferrable + + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/relationship/on-delete/driver.cxx b/odb-tests/common/relationship/on-delete/driver.cxx new file mode 100644 index 0000000..eec57cf --- /dev/null +++ b/odb-tests/common/relationship/on-delete/driver.cxx @@ -0,0 +1,82 @@ +// file : common/relationship/on-delete/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test ON DELETE functionality. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + object o; + + cascade c; + c.p = &o; + + cascade_cont cc; + cc.p.push_back (&o); + + set_null n; + n.p = &o; + + set_null_cont nc; + nc.p.push_back (&o); + + { + transaction t (db->begin ()); + db->persist (o); + db->persist (c); + db->persist (cc); + db->persist (n); + db->persist (nc); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + + { + transaction t (db->begin ()); + assert (db->find (c.id) == 0); + + unique_ptr pcc (db->load (cc.id)); + assert (pcc->p.empty ()); + + unique_ptr pn (db->load (n.id)); + assert (pn->p == 0); + + unique_ptr pnc (db->load (nc.id)); + assert (pnc->p.size () == 1 && pnc->p[0] == 0); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/relationship/on-delete/test.hxx b/odb-tests/common/relationship/on-delete/test.hxx new file mode 100644 index 0000000..841acd9 --- /dev/null +++ b/odb-tests/common/relationship/on-delete/test.hxx @@ -0,0 +1,58 @@ +// file : common/relationship/on-delete/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object +struct object +{ + #pragma db id auto + unsigned long id; +}; + +#pragma db object +struct cascade +{ + #pragma db id auto + unsigned long id; + + #pragma db on_delete(cascade) + object* p; +}; + +#pragma db object +struct cascade_cont +{ + #pragma db id auto + unsigned long id; + + #pragma db on_delete(cascade) + std::vector p; +}; + +#pragma db object +struct set_null +{ + #pragma db id auto + unsigned long id; + + #pragma db on_delete(set_null) + object* p; +}; + +#pragma db object +struct set_null_cont +{ + #pragma db id auto + unsigned long id; + + #pragma db on_delete(set_null) + std::vector p; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/relationship/on-delete/testscript b/odb-tests/common/relationship/on-delete/testscript new file mode 100644 index 0000000..8288ebc --- /dev/null +++ b/odb-tests/common/relationship/on-delete/testscript @@ -0,0 +1,33 @@ +# file : common/relationship/on-delete/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/relationship/query/buildfile b/odb-tests/common/relationship/query/buildfile new file mode 100644 index 0000000..b70edc4 --- /dev/null +++ b/odb-tests/common/relationship/query/buildfile @@ -0,0 +1,42 @@ +# file : common/relationship/query/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_rel_query_ \ + --generate-schema \ + --generate-query \ + --generate-session + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/relationship/query/driver.cxx b/odb-tests/common/relationship/query/driver.cxx new file mode 100644 index 0000000..20d5370 --- /dev/null +++ b/odb-tests/common/relationship/query/driver.cxx @@ -0,0 +1,168 @@ +// file : common/relationship-query/query/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test relationship queries. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // + // + { + shared_ptr ca (new country ("CA", "Canada")); + shared_ptr za (new country ("ZA", "South Africa")); + shared_ptr us (new country ("US", "United States")); + shared_ptr se (new country ("SE", "Sweden")); + + shared_ptr st (new employer ("Simple Tech, Inc", ca)); + shared_ptr ct (new employer ("Complex Tech, Inc", us)); + + // person + // + shared_ptr p1 ( + new person (1, "John", "Doe", 30, ca, true, za)); + + shared_ptr p2 ( + new person (2, "Jane", "Doe", 29, za, false, us)); + p2->husband = p1; + + shared_ptr p3 ( + new person (3, "Joe", "Dirt", 31, us, true, us)); + + shared_ptr p4 ( + new person (4, "Johan", "Johansen", 32, se, false, ca)); + + // employee + // + shared_ptr e1 ( + new employee (1, "John", "Doe", 30, ca, true, za, st)); + + shared_ptr e2 ( + new employee (2, "Jane", "Doe", 29, za, false, us, ct)); + e2->husband = p1; + + shared_ptr e3 ( + new employee (3, "Joe", "Dirt", 31, us, true, us, st)); + + shared_ptr e4 ( + new employee (4, "Johan", "Johansen", 32, se, false, ca, ct)); + + transaction t (db->begin ()); + db->persist (ca); + db->persist (za); + db->persist (us); + db->persist (se); + + db->persist (st); + db->persist (ct); + + db->persist (p1); + db->persist (p2); + db->persist (p3); + db->persist (p4); + + db->persist (e1); + db->persist (e2); + db->persist (e3); + db->persist (e4); + t.commit (); + } + + typedef odb::query p_query; + typedef odb::result p_result; + + typedef odb::query e_query; + typedef odb::result e_result; + + // Make sure we have an independent JOIN for each relationship. + // + { + session s; + transaction t (db->begin ()); + + p_result pr (db->query ( + p_query::residence.location->code == "ZA")); + assert (size (pr) == 1); + + e_result er (db->query ( + e_query::residence.location->code == "ZA")); + assert (size (er) == 1); + + t.commit (); + } + + // Test Self-JOIN. + // + { + session s; + transaction t (db->begin ()); + + p_result pr (db->query (p_query::husband->last_name == "Doe")); + assert (size (pr) == 1); + + e_result er (db->query (e_query::husband->last_name == "Doe")); + assert (size (er) == 1); + + t.commit (); + } + + // Test query conditions from both base and derived. + // + { + session s; + transaction t (db->begin ()); + + e_result r ( + db->query ( + e_query::employed_by->name == "Simple Tech, Inc" && + e_query::nationality->code == "US")); + + assert (size (r) == 1); + + t.commit (); + } + + // Test second-level pointers. + // + { + session s; + transaction t (db->begin ()); + + p_result r ( + db->query ( + p_query::husband->residence.location == "CA")); + + assert (size (r) == 1); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/relationship/query/test.hxx b/odb-tests/common/relationship/query/test.hxx new file mode 100644 index 0000000..c6e2d6d --- /dev/null +++ b/odb-tests/common/relationship/query/test.hxx @@ -0,0 +1,140 @@ +// file : common/relationship-query/query/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +using std::shared_ptr; + +struct country; + +#pragma db value +struct residence_info +{ + residence_info (bool p, shared_ptr l) + : permanent (p), location (l) + { + } + + residence_info () + { + } + + bool permanent; + + #pragma db not_null + shared_ptr location; +}; + +#pragma db object pointer(shared_ptr) +struct person +{ + person (unsigned long i, + const std::string& fn, + const std::string& ln, + unsigned short a, + shared_ptr r, + bool p, + shared_ptr n) + : id (i), + first_name (fn), + last_name (ln), + age (a), + residence (p, r), + nationality (n) + { + } + + person () + { + } + + #pragma db id + unsigned long id; + + #pragma db column ("first") + std::string first_name; + + #pragma db column ("last") + std::string last_name; + + unsigned short age; + + residence_info residence; + + #pragma db not_null + shared_ptr nationality; + + shared_ptr husband; // Self-join. +}; + +struct employer; + +#pragma db object pointer(shared_ptr) +struct employee: person +{ + employee (unsigned long i, + const std::string& fn, + const std::string& ln, + unsigned short a, + shared_ptr r, + bool p, + shared_ptr n, + shared_ptr e) + : person (i, fn, ln, a, r, p, n), + employed_by (e) + { + } + + employee () + { + } + + shared_ptr employed_by; +}; + +#pragma db object pointer(shared_ptr) +struct employer +{ + employer (const std::string& n, shared_ptr nat) + : name (n), nationality (nat) + { + } + + employer () + { + } + + #pragma db id + std::string name; + + // The same member name and type as in person (test JOIN alias). + // + #pragma db not_null + shared_ptr nationality; +}; + +#pragma db object pointer(shared_ptr) +struct country +{ + country (const std::string& c, const std::string& n) + : code (c), name (n) + { + } + + country () + { + } + + #pragma db id + std::string code; // ISO 2-letter country code. + + std::string name; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/relationship/query/testscript b/odb-tests/common/relationship/query/testscript new file mode 100644 index 0000000..d5ad419 --- /dev/null +++ b/odb-tests/common/relationship/query/testscript @@ -0,0 +1,33 @@ +# file : common/relationship/query/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/schema/embedded/basics/buildfile b/odb-tests/common/schema/embedded/basics/buildfile new file mode 100644 index 0000000..0cfe85e --- /dev/null +++ b/odb-tests/common/schema/embedded/basics/buildfile @@ -0,0 +1,42 @@ +# file : common/schema/embedded/basics/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix schema_embd_bscs_ \ + --generate-schema \ + --schema-format embedded \ + --schema-name test + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/schema/embedded/basics/driver.cxx b/odb-tests/common/schema/embedded/basics/driver.cxx new file mode 100644 index 0000000..7ba2bce --- /dev/null +++ b/odb-tests/common/schema/embedded/basics/driver.cxx @@ -0,0 +1,59 @@ +// file : common/schema/embedded/basics/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test basic embedded schema functionality. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv, false)); + + // Create the database schema. + // + { + connection_ptr c (db->connection ()); + + // Temporarily disable foreign key constraints for SQLite. + // + if (db->id () == odb::id_sqlite) + c->execute ("PRAGMA foreign_keys=OFF"); + + assert (schema_catalog::exists (*db, "test")); + assert (!schema_catalog::exists (*db, "test1")); + assert (!schema_catalog::exists (*db, "")); + + transaction t (c->begin ()); + schema_catalog::create_schema (*db, "test"); + t.commit (); + + if (db->id () == odb::id_sqlite) + c->execute ("PRAGMA foreign_keys=ON"); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/schema/embedded/basics/test.hxx b/odb-tests/common/schema/embedded/basics/test.hxx new file mode 100644 index 0000000..43331f9 --- /dev/null +++ b/odb-tests/common/schema/embedded/basics/test.hxx @@ -0,0 +1,23 @@ +// file : common/schema/embedded/basics/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +#pragma db object +struct object +{ + #pragma db auto id + unsigned long id; + + std::string str; + + std::vector nums; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/schema/embedded/basics/testscript b/odb-tests/common/schema/embedded/basics/testscript new file mode 100644 index 0000000..24448c0 --- /dev/null +++ b/odb-tests/common/schema/embedded/basics/testscript @@ -0,0 +1,31 @@ +# file : common/schema/embedded/basics/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../../mysql.testscript + + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../../pgsql.testscript + + $* +} diff --git a/odb-tests/common/schema/embedded/order/.gitignore b/odb-tests/common/schema/embedded/order/.gitignore new file mode 100644 index 0000000..5d39d39 --- /dev/null +++ b/odb-tests/common/schema/embedded/order/.gitignore @@ -0,0 +1,6 @@ +# ODB-generated files. +# +test1-odb.?xx +test1-odb-*.?xx +test2-odb.?xx +test2-odb-*.?xx diff --git a/odb-tests/common/schema/embedded/order/buildfile b/odb-tests/common/schema/embedded/order/buildfile new file mode 100644 index 0000000..57ad7dd --- /dev/null +++ b/odb-tests/common/schema/embedded/order/buildfile @@ -0,0 +1,48 @@ +# file : common/schema/embedded/order/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +hs = test1 test2 + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +for h: $hs +{ + exe{driver}: {hxx ixx cxx}{$h-odb} + + <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} + + for db: $databases + { + exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi + <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} + } +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix schema_embd_ordr_ \ + --generate-schema \ + --schema-format embedded + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/schema/embedded/order/driver.cxx b/odb-tests/common/schema/embedded/order/driver.cxx new file mode 100644 index 0000000..fde5e96 --- /dev/null +++ b/odb-tests/common/schema/embedded/order/driver.cxx @@ -0,0 +1,65 @@ +// file : common/schema/embedded/order/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test statement execution order in embedded schemas. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test1.hxx" +#include "test2.hxx" + +#include "test1-odb.hxx" +#include "test2-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv, false)); + odb::database_id db_id (db->id ()); + + // Create the database schema. + // + { + connection_ptr c (db->connection ()); + + // Temporarily disable foreign key constraints for MySQL and SQLite. + // For MySQL we can actually create the tables in any order. It is + // dropping them that's the problem (there is no IF EXISTS). + // + if (db_id == odb::id_mysql) + c->execute ("SET FOREIGN_KEY_CHECKS=0"); + else if (db_id == odb::id_sqlite) + c->execute ("PRAGMA foreign_keys=OFF"); + + transaction t (c->begin ()); + schema_catalog::create_schema (*db); + t.commit (); + + if (db_id == odb::id_mysql) + c->execute ("SET FOREIGN_KEY_CHECKS=1"); + else if (db_id == odb::id_sqlite) + c->execute ("PRAGMA foreign_keys=ON"); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/schema/embedded/order/test1.hxx b/odb-tests/common/schema/embedded/order/test1.hxx new file mode 100644 index 0000000..b35074b --- /dev/null +++ b/odb-tests/common/schema/embedded/order/test1.hxx @@ -0,0 +1,23 @@ +// file : common/schema/embedded/order/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#include + +#include + +#pragma db object polymorphic +struct base +{ + virtual + ~base () {} + + #pragma db auto id + unsigned long id; + + std::string str; +}; + +#endif // TEST1_HXX diff --git a/odb-tests/common/schema/embedded/order/test2.hxx b/odb-tests/common/schema/embedded/order/test2.hxx new file mode 100644 index 0000000..b4e6d20 --- /dev/null +++ b/odb-tests/common/schema/embedded/order/test2.hxx @@ -0,0 +1,17 @@ +// file : common/schema/embedded/order/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#include + +#include "test1.hxx" + +#pragma db object +struct derived: base +{ + int num; +}; + +#endif // TEST2_HXX diff --git a/odb-tests/common/schema/embedded/order/testscript b/odb-tests/common/schema/embedded/order/testscript new file mode 100644 index 0000000..6dfe58c --- /dev/null +++ b/odb-tests/common/schema/embedded/order/testscript @@ -0,0 +1,31 @@ +# file : common/schema/embedded/order/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../../mysql.testscript + + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../../pgsql.testscript + + $* +} diff --git a/odb-tests/common/schema/namespace/buildfile b/odb-tests/common/schema/namespace/buildfile new file mode 100644 index 0000000..fa496d7 --- /dev/null +++ b/odb-tests/common/schema/namespace/buildfile @@ -0,0 +1,41 @@ +# file : common/schema/namespace/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix schema_ns_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/schema/namespace/driver.cxx b/odb-tests/common/schema/namespace/driver.cxx new file mode 100644 index 0000000..25515f2 --- /dev/null +++ b/odb-tests/common/schema/namespace/driver.cxx @@ -0,0 +1,113 @@ +// file : common/schema/namespace/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test database schemas (aka database namespaces). +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test database schema (aka database namespace). + // + using ns::object2; + + object2 o2; + o2.id = "aaa"; + o2.nums.push_back (1); + o2.nums.push_back (2); + o2.nums.push_back (3); + o2.obj1 = new object1; + o2.obj1->str = "aaa"; + + { + transaction t (db->begin ()); + db->persist (o2.obj1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p2 (db->load ("aaa")); + t.commit (); + + assert (o2 == *p2); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + { + result r (db->query (query::id == "aaa")); + assert (size (r) == 1); + } + + { + result r (db->query (query::obj1->str == "aaa")); + assert (size (r) == 1); + } + + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query (query::object2::id == "aaa")); + + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->id2 == "aaa" && i->str == "aaa"); + assert (++i == r.end ()); + + t.commit (); + } + + { + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query ()); + + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->str == "aaa"); + assert (++i == r.end ()); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/schema/namespace/test.hxx b/odb-tests/common/schema/namespace/test.hxx new file mode 100644 index 0000000..0b1844a --- /dev/null +++ b/odb-tests/common/schema/namespace/test.hxx @@ -0,0 +1,158 @@ +// file : common/schema/namespace/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +// Table names. +// +#pragma db object table("TABLE_EXPLICIT") +struct table_explicit +{ + #pragma db id + unsigned long id_; +}; + +#pragma db object +struct table_implicit +{ + #pragma db id + unsigned long id_; +}; + +// Column names. +// +#pragma db object +struct column +{ + #pragma db id + int m1; + + #pragma db column("foo") + int m2; + + int m_m3; + int _m4; + int m5_; + int m_; + int m__; +}; + +// Column types. +// +#pragma db object +struct type +{ + #pragma db id + std::string id; + + // Test default C++ to DB type mapping. + // + bool b; + char c; + signed char sc; + unsigned char uc; + short s; + unsigned short us; + int i; + unsigned int ui; + long l; + unsigned long ul; + long long ll; + unsigned long long ull; + float f; + double d; + std::string str; + + #pragma db type("INTEGER") + bool m1; + + #pragma db transient + char* m2; +}; + +// Test database schema (aka database namespace). +// +#ifdef ODB_COMPILER +#if defined (ODB_DATABASE_MYSQL) +//# define DB_SCHEMA "odb_test" +# define DB_SCHEMA "" +#elif defined (ODB_DATABASE_SQLITE) +# define DB_SCHEMA "main" +#elif defined (ODB_DATABASE_PGSQL) +# define DB_SCHEMA "public" +#elif defined (ODB_DATABASE_ORACLE) +//# define DB_SCHEMA "ODB_TEST" +# define DB_SCHEMA "" +#elif defined(ODB_DATABASE_MSSQL) +# define DB_SCHEMA "dbo" +#elif defined(ODB_DATABASE_COMMON) +# define DB_SCHEMA "dummy" +#else +# error unknown database +#endif +#endif + +namespace ns {typedef int my_int;} // Original. + +#pragma db object table(DB_SCHEMA."object_1") +struct object1 +{ + #pragma db id auto + unsigned long id; + + #pragma db column("str") + std::string str; +}; + +inline bool +operator== (const object1& x, const object1& y) +{ + return x.id == y.id && x.str == y.str; +} + +#pragma db namespace schema(DB_SCHEMA) +namespace ns // Extension. +{ + #pragma db object + struct object2 + { + object2 (): obj1 (0) {} + ~object2 () {delete obj1;} + + #pragma db id + std::string id; + + std::vector nums; + object1* obj1; + }; + + inline bool + operator== (const object2& x, const object2& y) + { + return x.id == y.id && x.nums == y.nums && *x.obj1 == *y.obj1; + } +} + +#pragma db view object(object1) object(ns::object2) +struct object_view +{ + #pragma db column(ns::object2::id) + std::string id2; + + std::string str; +}; + +#pragma db view table(DB_SCHEMA."schema_ns_object_1") +struct table_view +{ + #pragma db column(DB_SCHEMA."schema_ns_object_1"."str") + std::string str; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/schema/namespace/testscript b/odb-tests/common/schema/namespace/testscript new file mode 100644 index 0000000..0fabe6e --- /dev/null +++ b/odb-tests/common/schema/namespace/testscript @@ -0,0 +1,33 @@ +# file : common/schema/namespace/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/section/basics/buildfile b/odb-tests/common/section/basics/buildfile new file mode 100644 index 0000000..5ccdd6b --- /dev/null +++ b/odb-tests/common/section/basics/buildfile @@ -0,0 +1,41 @@ +# file : common/section/basics/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_section_b_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/section/basics/driver.cxx b/odb-tests/common/section/basics/driver.cxx new file mode 100644 index 0000000..53783a3 --- /dev/null +++ b/odb-tests/common/section/basics/driver.cxx @@ -0,0 +1,1735 @@ +// file : common/section/basics/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test object section basics. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +struct failed {}; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test lazy-loaded, always updating section. + // + { + using namespace test1; + + object o (123, "abc"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s.loaded ()); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); + + db->load (*p, p->s); + + assert (p->s.loaded ()); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + + t.commit (); + } + + // Update. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + + // We can also update just the section. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o, o.s); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n != o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + + // Test updating unloaded section. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + o.s.unload (); + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); + t.commit (); + } + + // Test reloading of loaded/unloaded sections. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + o.s.unload (); + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + db->reload (o); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); + db->load (o, o.s); + t.commit (); + } + + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + db->reload (o); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + + typedef odb::query query; + typedef odb::result result; + + // Make sure we can access section members in queries. + // + { + transaction t (db->begin ()); + + result r (db->query (query::ss == o.ss)); + result::iterator i (r.begin ()); + + assert (i != r.end () && !i->s.loaded ()); + + db->load (*i, i->s); + assert (i->n == o.n && + i->sn == o.sn && i->ss == o.ss && i->sv == o.sv); + + assert (++i == r.end ()); + + t.commit (); + } + + // Make sure we can load/update sections without messing up the + // loaded object's image. + // + { + transaction t (db->begin ()); + + result r (db->query (query::ss == o.ss)); + result::iterator i (r.begin ()); + + assert (i != r.end ()); + + object o1; + i.load (o1); + db->load (o1, o1.s); + assert (o1.n == o.n && + o1.sn == o.sn && o1.ss == o.ss && o1.sv == o.sv); + + o.sn++; + o.ss += 'd'; + o.sv[0]++; + db->update (o, o.s); + + object o2; + i.load (o2); + db->load (o2, o2.s); + assert (o2.n == o1.n && + o2.sn == o.sn && o2.ss == o.ss && o2.sv == o.sv); + + assert (++i == r.end ()); + + t.commit (); + } + } + + // Test lazy-loaded, change-updated section. + // + { + using namespace test2; + + object o (123, "abc"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s.loaded ()); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); + + db->load (*p, p->s); + + assert (p->s.loaded ()); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + + t.commit (); + } + + // Update but don't mark as changed. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); + t.commit (); + } + + // Mark as changed. + // + o.s.change (); + + { + transaction t (db->begin ()); + db->update (o); + assert (!o.s.changed ()); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + + // We can also update just the section manually. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (o, o.s); + assert (!o.s.changed ()); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n != o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + } + + // Test lazy-loaded, manually-updated section. + // + { + using namespace test3; + + object o (123, "abc"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s.loaded ()); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); + + db->load (*p, p->s); + + assert (p->s.loaded ()); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + + t.commit (); + } + + // Update the object only. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); + t.commit (); + } + + // Update both the object and section. + // + o.n++; + + { + transaction t (db->begin ()); + db->update (o); + db->update (o, o.s); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + + // We can also update just the section. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o, o.s); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n != o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + + // Test detection of unloaded section update. + // + try + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->update (*p, p->s); + assert (false); + } + catch (const section_not_loaded&) + { + } + } + + // Test eager-loaded, change-updated section. + // + { + using namespace test4; + + object o (123, "abc"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (p->s.loaded ()); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + + t.commit (); + } + + // Update but don't mark as changed. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); + t.commit (); + } + + // Mark as changed. + // + o.s.change (); + + { + transaction t (db->begin ()); + db->update (o); + assert (!o.s.changed ()); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + } + + // Test eager-loaded, manually-updated section. + // + { + using namespace test5; + + object o (123, "abc"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (p->s.loaded ()); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + + t.commit (); + } + + // Update the object only. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); + t.commit (); + } + + // Update both the object and section. + // + o.n++; + + { + transaction t (db->begin ()); + db->update (o); + db->update (o, o.s); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + + // We can also update just the section. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o, o.s); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + assert (p->n != o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + } + + // Test value-only and container-only section. Also multiple sections + // in an object. + // + { + using namespace test6; + + object o (123, "abc"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s1.loaded ()); + assert (o.s2.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s1.loaded ()); + assert (!p->s2.loaded ()); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); + + db->load (*p, p->s1); + assert (p->s1.loaded ()); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv != o.sv); + + db->load (*p, p->s2); + assert (p->s2.loaded ()); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + + t.commit (); + } + + // Update. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s1); + db->load (*p, p->s2); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + + // We can also update just the section. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o, o.s1); + db->update (o, o.s2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s1); + db->load (*p, p->s2); + assert (p->n != o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + t.commit (); + } + } + + // Test value-only and container-only section. Also multiple sections + // in an object. + // + { + using namespace test7; + + object o (123, "abc", true); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s1.loaded ()); + assert (o.s2.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s1.loaded ()); + assert (!p->s2.loaded ()); + assert (p->sn1 != o.sn1 && p->ss1 != o.ss1 && + p->sn2 != o.sn2 && p->ss2 != o.ss2 && p->sb2 != o.sb2); + + db->load (*p, p->s1); + db->load (*p, p->s2); + assert (p->s1.loaded ()); + assert (p->s2.loaded ()); + assert (p->sn1 == o.sn1 && p->ss1 == o.ss1 && + p->sn2 == o.sn2 && p->ss2 == o.ss2 && p->sb2 == o.sb2); + + + t.commit (); + } + + // Update. + // + o.sn1++; + o.sn2++; + o.ss1 += 'd'; + o.ss2 += 'd'; + o.sb2 = !o.sb2; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s1); + db->load (*p, p->s2); + assert (p->sn1 == o.sn1 && p->ss1 == o.ss1 && + p->sn2 == o.sn2 && p->ss2 == o.ss2 && p->sb2 == o.sb2); + t.commit (); + } + + // Manual update of just the section. + // + o.sn1++; + o.sn2++; + o.ss1 += 'd'; + o.ss2 += 'd'; + o.sb2 = !o.sb2; + + { + transaction t (db->begin ()); + db->update (o, o.s2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s1); + db->load (*p, p->s2); + assert (p->sn1 != o.sn1 && p->ss1 != o.ss1 && + p->sn2 == o.sn2 && p->ss2 == o.ss2 && p->sb2 == o.sb2); + t.commit (); + } + } + + // Test readonly and inverse section members. + // + { + using namespace test8; + + object1 o1 (new object (123, "abc")); + object& o (*o1.p); + o.sp = &o1; + + { + transaction t (db->begin ()); + db->persist (o); + db->persist (o1); + t.commit (); + + assert (o.s.loaded ()); + } + + { + session s; + + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + object* p (p1->p); + + assert (!p->s.loaded ()); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sp == 0); + + db->load (*p, p->s); + + assert (p->s.loaded ()); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sp->id == o.sp->id); + + t.commit (); + } + + // Update. + // + o.n++; + o.sn++; + o.ss += 'd'; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + session s; + + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + object* p (p1->p); + + db->load (*p, p->s); + assert (p->n == o.n && + p->sn != o.sn && p->ss == o.ss && p->sp->id == o.sp->id); + + t.commit (); + } + } + + // Test object without any columns to load or update. + // + { + using namespace test9; + + object o (123, "abc"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s.loaded ()); + assert (o.id == o.id && + p->sn != o.sn && p->ss != o.ss); + + db->load (*p, p->s); + + assert (p->s.loaded ()); + assert (o.id == o.id && + p->sn == o.sn && p->ss == o.ss); + + t.commit (); + } + + // Update object. + // + o.sn++; + o.ss += 'd'; + + { + transaction t (db->begin ()); + db->update (o); // No-op. + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (o.id == o.id && + p->sn != o.sn && p->ss != o.ss); + t.commit (); + } + + // Update section. + // + { + transaction t (db->begin ()); + db->update (o, o.s); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (o.id == o.id && + p->sn == o.sn && p->ss == o.ss); + t.commit (); + } + } + + // Test section without any columns or containers to update. + // + { + using namespace test10; + + object o (123); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s.loaded ()); + assert (p->n == o.n && p->sn != o.sn); + + db->load (*p, p->s); + + assert (p->s.loaded ()); + assert (p->n == o.n && p->sn == o.sn); + + t.commit (); + } + + // Update. + // + o.n++; + o.sn++; + + { + transaction t (db->begin ()); + db->update (o); + //db->update (o, o.s); // Error. + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n == o.n && p->sn != o.sn); + t.commit (); + } + } + + // Test section with composite member. + // + { + using namespace test11; + + object o (123, "abc"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s.loaded ()); + assert (p->n == o.n && + p->sn != o.sn && p->sc.s != o.sc.s && p->sc.v != o.sc.v); + + db->load (*p, p->s); + + assert (p->s.loaded ()); + assert (p->n == o.n && + p->sn == o.sn && p->sc.s == o.sc.s && p->sc.v == o.sc.v); + + t.commit (); + } + + // Update. + // + o.n++; + o.sn++; + o.sc.s += 'd'; + o.sc.v[0]++; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n == o.n && + p->sn == o.sn && p->sc.s == o.sc.s && p->sc.v == o.sc.v); + t.commit (); + } + } + + // Test change state restoration on transaction rollback. + // + { + using namespace test12; + + object o (123, "abc"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + // Update. + // + o.n++; + o.sn++; + o.ss += 'd'; + o.s.change (); + + try + { + transaction t (db->begin ()); + db->update (o); + assert (!o.s.changed ()); + throw failed (); + } + catch (const failed&) + { + assert (o.s.changed ()); + } + + // Retry. Also test the object destruction before transaction + // termination case. + // + { + transaction t (db->begin ()); + { + object c (o); + db->update (c); + assert (!c.s.changed ()); + } + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n == o.n && p->sn == o.sn && p->ss == o.ss); + t.commit (); + } + } + + // Test section accessor/modifier. + // + { + using namespace test13; + + object o (123, "abc"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s ().loaded ()); + } + + // Load. + // + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s ().loaded ()); + assert (p->n == o.n && p->sn != o.sn && p->ss != o.ss); + + db->load (*p, p->rw_s ()); + + assert (p->s ().loaded ()); + assert (p->n == o.n && p->sn == o.sn && p->ss == o.ss); + + t.commit (); + } + + // Update. + // + o.n++; + o.sn++; + o.ss += 'd'; + + { + transaction t (db->begin ()); + db->update (o); + db->update (o, o.s ()); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->rw_s ()); + assert (p->n == o.n && p->sn == o.sn && p->ss == o.ss); + t.commit (); + } + + // Test detection of section copy. + // + try + { + transaction t (db->begin ()); + section c (o.s ()); + db->update (o, c); + assert (false); + } + catch (const section_not_in_object&) + { + } + } + + // Test LOB in section streaming, column re-ordering. + // + { + using namespace test14; + + object o (1, 123, "\x01\x02\x03\x04\x05"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s.loaded ()); + assert (p->n == o.n && p->sn != o.sn && p->sb != o.sb); + + db->load (*p, p->s); + + assert (p->s.loaded ()); + assert (p->n == o.n && p->sn == o.sn && p->sb == o.sb); + + t.commit (); + } + + // Update. + // + o.n++; + o.sn++; + o.sb.push_back ('\x06'); + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n == o.n && p->sn == o.sn && p->sb == o.sb); + t.commit (); + } + + // We can also update just the section. + // + o.n++; + o.sn++; + o.sb.push_back ('\x07'); + + { + transaction t (db->begin ()); + db->update (o, o.s); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->n != o.n && p->sn == o.sn && p->sb == o.sb); + t.commit (); + } + } + + // Test sections and optimistic concurrency. + // + { + using namespace test15; + + object o (123, "abc"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s.loaded ()); + assert (p->n == o.n && + p->sn != o.sn && p->ss != o.ss && p->sv != o.sv); + + db->load (*p, p->s); + + assert (p->s.loaded ()); + assert (p->n == o.n && + p->sn == o.sn && p->ss == o.ss && p->sv == o.sv); + + t.commit (); + } + + // Update object. + // + object o1 (o); + o1.n++; + o1.sn++; + o1.ss += 'd'; + o1.sv[0]++; + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + db->update (o1); + assert (o.v != o1.v); + + try + { + db->load (*p, p->s); + assert (false); + } + catch (const object_changed&) + { + db->reload (*p); + assert (!p->s.loaded ()); + db->load (*p, p->s); + + assert (p->n == o1.n && + p->sn == o1.sn && p->ss == o1.ss && p->sv == o1.sv); + } + + db->reload (o); + assert (o.v == o1.v); + assert (o.n == o1.n && + o.sn == o1.sn && o.ss == o1.ss && o.sv == o1.sv); + t.commit (); + } + + // Update section. + // + o1.sn++; + o1.ss += 'd'; + o1.sv[0]++; + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + db->update (o1, o1.s); + assert (o.v != o1.v); + + // Double-check object version was updated. + // + { + unique_ptr p1 (db->load (o.id)); + assert (o1.v == p1->v); + } + + try + { + db->load (*p, p->s); + assert (false); + } + catch (const object_changed&) + { + db->reload (*p); + assert (!p->s.loaded ()); + db->load (*p, p->s); + + assert (p->n == o1.n && + p->sn == o1.sn && p->ss == o1.ss && p->sv == o1.sv); + } + + db->reload (o); + assert (o.v == o1.v); + assert (o.n == o1.n && + o.sn == o1.sn && o.ss == o1.ss && o.sv == o1.sv); + t.commit (); + } + + // Update changed section. + // + o1.sn++; + o1.ss += 'd'; + o1.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o1, o1.s); + + try + { + db->update (o, o.s); + assert (false); + } + catch (const object_changed&) + { + db->reload (o); + db->update (o, o.s); + } + + t.commit (); + } + } + + // Test container-only sections and optimistic concurrency. + // + { + using namespace test16; + + object o (123); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s.loaded ()); + assert (p->sv != o.sv); + + db->load (*p, p->s); + + assert (p->s.loaded ()); + assert (p->sv == o.sv); + + t.commit (); + } + + // Update object. + // + object o1 (o); + o1.sv[0]++; + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + db->update (o1); + assert (o.v != o1.v); + + try + { + db->load (*p, p->s); + assert (false); + } + catch (const object_changed&) + { + db->reload (*p); + assert (!p->s.loaded ()); + db->load (*p, p->s); + + assert (p->sv == o1.sv); + } + + db->reload (o); + assert (o.v == o1.v); + assert (o.sv == o1.sv); + t.commit (); + } + + // Update section. + // + o1.sv[0]++; + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + db->update (o1, o1.s); + assert (o.v != o1.v); + + // Double-check object version was updated. + // + { + unique_ptr p1 (db->load (o.id)); + assert (o1.v == p1->v); + } + + try + { + db->load (*p, p->s); + assert (false); + } + catch (const object_changed&) + { + db->reload (*p); + assert (!p->s.loaded ()); + db->load (*p, p->s); + + assert (p->sv == o1.sv); + } + + db->reload (o); + assert (o.v == o1.v); + assert (o.sv == o1.sv); + t.commit (); + } + + // Update changed section. + // + o1.sv[0]++; + + { + transaction t (db->begin ()); + db->update (o1, o1.s); + + try + { + db->update (o, o.s); + assert (false); + } + catch (const object_changed&) + { + db->reload (o); + db->update (o, o.s); + } + + t.commit (); + } + } + + // Test reuse-inheritance, sections, and optimistic concurrency. + // + { + using namespace test17; + + object o (123); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s1.loaded ()); + assert (o.s2.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s1.loaded ()); + assert (!p->s2.loaded ()); + assert (p->s1n != o.s1n && p->s2v != o.s2v); + + db->load (*p, p->s1); + db->load (*p, p->s2); + + assert (p->s1.loaded ()); + assert (p->s2.loaded ()); + assert (p->s1n == o.s1n && p->s2v == o.s2v); + + t.commit (); + } + + object o1 (o); + + // Update object. + // + for (unsigned short s (1); s < 3; ++s) + { + o1.s1n++; + o1.s2v[0]++; + + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + db->update (o1); + assert (o.v != o1.v); + + try + { + switch (s) + { + case 1: db->load (*p, p->s1); break; + case 2: db->load (*p, p->s2); break; + default: break; + } + assert (false); + } + catch (const object_changed&) + { + db->reload (*p); + + assert (!p->s1.loaded ()); + assert (!p->s2.loaded ()); + + db->load (*p, p->s1); + db->load (*p, p->s2); + + assert (p->s1n == o1.s1n && p->s2v == o1.s2v); + } + + db->reload (o); + assert (o.v == o1.v); + assert (o.s1n == o1.s1n && o.s2v == o1.s2v); + t.commit (); + } + + // Update section. + // + for (unsigned short s (1); s < 3; ++s) + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + switch (s) + { + case 1: + o1.s1n++; + db->update (o1, o1.s1); + assert (o.v != o1.v); + break; + case 2: + o1.s2v[0]++; + db->update (o1, o1.s2); + assert (o.v != o1.v); + break; + default: break; + } + + try + { + switch (s) + { + case 1: db->load (*p, p->s1); break; + case 2: db->load (*p, p->s2); break; + default: break; + } + assert (false); + } + catch (const object_changed&) + { + db->reload (*p); + + assert (!p->s1.loaded ()); + assert (!p->s2.loaded ()); + + db->load (*p, p->s1); + db->load (*p, p->s2); + + assert (p->s1n == o1.s1n && p->s2v == o1.s2v); + } + + db->reload (o); + assert (o.v == o1.v); + assert (o.s1n == o1.s1n && o.s2v == o1.s2v); + t.commit (); + } + + // Update changed section. + // + for (unsigned short s (1); s < 3; ++s) + { + transaction t (db->begin ()); + + switch (s) + { + case 1: + o1.s1n++; + db->update (o1, o1.s1); + break; + case 2: + o1.s2v[0]++; + db->update (o1, o1.s2); + break; + default: break; + } + + try + { + switch (s) + { + case 1: db->update (o, o.s1); break; + case 2: db->update (o, o.s2); break; + default: break; + } + assert (false); + } + catch (const object_changed&) + { + db->reload (o); + + switch (s) + { + case 1: db->update (o, o.s1); break; + case 2: db->update (o, o.s2); break; + default: break; + } + } + + db->reload (o1); + + t.commit (); + } + } + + // Test change-updated section and change-tracking container. + // + { + using namespace test18; + + object o (123); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + + assert (o.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + assert (!p->s.loaded ()); + assert (p->sn != o.sn && p->sv != o.sv); + + db->load (*p, p->s); + + assert (p->s.loaded ()); + assert (p->sn == o.sn && p->sv == o.sv); + + t.commit (); + } + + // Update but don't mark as changed. + // + o.sn++; + o.sv.modify (0)++; + + { + transaction t (db->begin ()); + db->update (o); // Automatically marked as changed. + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->sn == o.sn && p->sv == o.sv); + t.commit (); + } + + // Test updating just the section manually. + // + o.sn++; + o.sv.modify (0)++; + + { + transaction t (db->begin ()); + db->update (o, o.s); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + db->load (*p, p->s); + assert (p->sn == o.sn && p->sv == o.sv); + t.commit (); + } + } + + // Regression: BLOB in a value type used as a map value that is in a + // section. + // + { + using namespace test19; + + object o; + o.m[1].b.assign (560, 'x'); // Size greater than the default image. + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + // Hold "old" connection to force a new set of statements/image + // buffers. + // + connection_ptr c (db->connection ()); + + transaction t (db->begin ()); + unique_ptr p (db->load (o.id)); + + db->load (*p, p->s); + assert (p->m[1].b == o.m[1].b); + + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/section/basics/test.hxx b/odb-tests/common/section/basics/test.hxx new file mode 100644 index 0000000..702ef8b --- /dev/null +++ b/odb-tests/common/section/basics/test.hxx @@ -0,0 +1,628 @@ +// file : common/section/basics/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include +#include +#include + +#ifdef ODB_COMPILER +# if defined(ODB_DATABASE_PGSQL) +# define BLOB_TYPE "BYTEA" +# elif defined(ODB_DATABASE_MSSQL) +# define BLOB_TYPE "VARBINARY(max)" +# else +# define BLOB_TYPE "BLOB" +# endif +#endif + +// Test lazy-loaded, always-updated section. +// +#pragma db namespace table("t1_") +namespace test1 +{ + #pragma db object + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx") + : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} + + #pragma db id auto + unsigned long id; + + #pragma db load(lazy) + odb::section s; + + #pragma db section(s) + int sn; + + int n; + + #pragma db section(s) + std::string ss; + + #pragma db section(s) + std::vector sv; + }; +} + +// Test lazy-loaded, change-updated section. +// +#pragma db namespace table("t2_") +namespace test2 +{ + #pragma db object + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx") + : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} + + #pragma db id auto + unsigned long id; + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + int sn; + + int n; + + #pragma db section(s) + std::string ss; + + #pragma db section(s) + std::vector sv; + }; +} + +// Test lazy-loaded, manually-updated section. +// +#pragma db namespace table("t3_") +namespace test3 +{ + #pragma db object + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx") + : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} + + #pragma db id auto + unsigned long id; + + #pragma db load(lazy) update(manual) + odb::section s; + + #pragma db section(s) + int sn; + + int n; + + #pragma db section(s) + std::string ss; + + #pragma db section(s) + std::vector sv; + }; +} + +// Test eager-loaded, change-updated section. +// +#pragma db namespace table("t4_") +namespace test4 +{ + #pragma db object + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx") + : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} + + #pragma db id auto + unsigned long id; + + #pragma db section(s) + int sn; + + #pragma db update(change) + odb::section s; + + int n; + + #pragma db section(s) + std::string ss; + + #pragma db section(s) + std::vector sv; + }; +} + +// Test eager-loaded, manually-updated section. +// +#pragma db namespace table("t5_") +namespace test5 +{ + #pragma db object + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx") + : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} + + #pragma db id auto + unsigned long id; + + #pragma db section(s) + int sn; + + #pragma db update(manual) + odb::section s; + + int n; + + #pragma db section(s) + std::string ss; + + #pragma db section(s) + std::vector sv; + }; +} + +// Test value-only and container-only section. Also multiple sections +// in an object. +// +#pragma db namespace table("t6_") +namespace test6 +{ + #pragma db object + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx") + : n (n_), sn (n_), ss (s_) {sv.push_back (n_);} + + #pragma db id auto + unsigned long id; + + int n; + + #pragma db load(lazy) + odb::section s1; + + #pragma db load(lazy) + odb::section s2; + + #pragma db section(s1) + int sn; + + #pragma db section(s1) + std::string ss; + + #pragma db section(s2) + std::vector sv; + }; +} + +// Test sections and reuse inheritance. +// +#pragma db namespace table("t7_") +namespace test7 +{ + #pragma db object abstract + struct base + { + #pragma db id auto + unsigned long id; + + #pragma db load(lazy) + odb::section s1; // Empty section. + + #pragma db load(lazy) + odb::section s2; + + #pragma db section(s2) + int sn2; + }; + + #pragma db object abstract + struct interm: base + { + // Section s1 is still empty. + + #pragma db section(s2) + std::string ss2; + }; + + #pragma db object + struct derived: interm + { + #pragma db section(s1) + int sn1; + }; + + #pragma db object + struct object: derived + { + object (int n = 999, const std::string& s = "xxx", bool b = false) + { + sn1 = sn2 = n; + ss1 = ss2 = s; + sb2 = b; + } + + #pragma db section(s1) + std::string ss1; + + #pragma db section(s2) + bool sb2; + }; +} + +// Test readonly and inverse section members. +// +#pragma db namespace table("t8_") +namespace test8 +{ + struct object1; + + #pragma db object session + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx", object1* p_ = 0) + : n (n_), sn (n_), ss (s_), sp (p_) {} + + #pragma db id auto + unsigned long id; + + int n; + + #pragma db load(lazy) + odb::section s; + + #pragma db section(s) readonly + int sn; + + #pragma db section(s) + std::string ss; + + #pragma db inverse(p) section(s) + object1* sp; + }; + + #pragma db object session + struct object1 + { + object1 (object* p_ = 0): p (p_) {} + ~object1 () {delete p;} + + #pragma db id auto + unsigned long id; + + object* p; + }; +} + +// Test object without any columns to load or update. +// +#pragma db namespace table("t9_") +namespace test9 +{ + #pragma db object + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx"): sn (n_), ss (s_) {} + + #pragma db id auto + unsigned long id; + + #pragma db load(lazy) update(manual) + odb::section s; + + #pragma db section(s) + int sn; + + #pragma db section(s) + std::string ss; + }; +} + +// Test section without any columns or containers to update. +// +#pragma db namespace table("t10_") +namespace test10 +{ + #pragma db object + struct object + { + object (int n_ = 999): n (n_), sn (n_) {} + + #pragma db id auto + unsigned long id; + + int n; + + #pragma db load(lazy) + odb::section s; + + #pragma db section(s) readonly + int sn; + }; +} + +// Test section with composite member. +// +#pragma db namespace table("t11_") +namespace test11 +{ + #pragma db value + struct comp + { + comp (int n_, const std::string& s_): s (s_) {v.push_back (n_);} + + std::string s; + std::vector v; + }; + + #pragma db object + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx") + : n (n_), sn (n_), sc (n_, s_) {} + + #pragma db id auto + unsigned long id; + + int n; + + #pragma db load(lazy) + odb::section s; + + #pragma db section(s) + int sn; + + #pragma db section(s) + comp sc; + }; +} + +// Test change state restoration on transaction rollback. +// +#pragma db namespace table("t12_") +namespace test12 +{ + #pragma db object + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx") + : sn (n_), n (n_), ss (s_) {} + + #pragma db id auto + unsigned long id; + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + int sn; + + int n; + + #pragma db section(s) + std::string ss; + }; +} + +// Test section accessor/modifier. +// +#pragma db namespace table("t13_") +namespace test13 +{ + #pragma db object + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx") + : n (n_), sn (n_), ss (s_) {} + + #pragma db id auto + unsigned long id; + + int n; + + #pragma db section(s_) + int sn; + + #pragma db section(s_) + std::string ss; + + public: + const odb::section& + s () const {return s_;} + + odb::section& + rw_s () {return s_;} + + private: + #pragma db load(lazy) update(manual) + odb::section s_; + }; +} + +// Test LOB in section streaming, column re-ordering. +// +#pragma db namespace table("t14_") +namespace test14 +{ + #pragma db object + struct object + { + object (unsigned long id_ = 0, int n_ = 999, const std::string& s_ = "xxx") + : id (id_), sb (s_.begin (), s_.end ()), sn (n_), n (n_) {} + + #pragma db id + unsigned long id; + + #pragma db load(lazy) + odb::section s; + + #pragma db section(s) type(BLOB_TYPE) + std::vector sb; // Comes before sn. + + #pragma db section(s) + int sn; + + int n; + }; +} + +// Test sections and optimistic concurrency. +// +#pragma db namespace table("t15_") +namespace test15 +{ + #pragma db object optimistic + struct object + { + object (int n_ = 999, const std::string& s_ = "xxx") + : sn (n_), n (n_), ss (s_) {sv.push_back (n_);} + + #pragma db id auto + unsigned long id; + + #pragma db version mssql:type("ROWVERSION") + unsigned long long v; + + #pragma db load(lazy) + odb::section s; + + #pragma db section(s) + int sn; + + int n; + + #pragma db section(s) + std::string ss; + + #pragma db section(s) + std::vector sv; + }; +} + +// Test container-only sections and optimistic concurrency. +// +#pragma db namespace table("t16_") +namespace test16 +{ + #pragma db object optimistic + struct object + { + object (int n = 999) {sv.push_back (n);} + + #pragma db id auto + unsigned long id; + + #pragma db version // mssql:type("ROWVERSION") + unsigned long long v; + + #pragma db load(lazy) + odb::section s; + + #pragma db section(s) + std::vector sv; + }; +} + +// Test reuse-inheritance, sections, and optimistic concurrency. +// +#pragma db namespace table("t17_") +namespace test17 +{ + #pragma db object optimistic sectionable abstract + struct root + { + #pragma db id auto + unsigned long id; + + #pragma db version + unsigned long long v; + }; + + #pragma db object + struct base: root + { + }; + + #pragma db object + struct object: base + { + object (int n = 999): s1n (n) {s2v.push_back (n);} + + #pragma db load(lazy) + odb::section s1; + + #pragma db section(s1) + int s1n; + + #pragma db load(lazy) + odb::section s2; + + #pragma db section(s2) + std::vector s2v; + }; +} + +// Test change-updated section and change-tracking container. +// +#pragma db namespace table("t18_") +namespace test18 +{ + #pragma db object + struct object + { + object (int n = 999): sn (n) {sv.push_back (n);} + + #pragma db id auto + unsigned long id; + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + int sn; + + #pragma db section(s) + odb::vector sv; + }; +} + +// Regression: BLOB in a value type used as a map value that is in a section. +// +#include +#include + +#pragma db namespace table("t19_") +namespace test19 +{ + #pragma db value + struct value + { + #pragma db type(BLOB_TYPE) + std::vector b; + }; + + #pragma db object + struct object + { + #pragma db id auto + unsigned long id; + + #pragma db load(lazy) update(always) + odb::section s; + + #pragma db section(s) + std::map m; + }; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/section/basics/testscript b/odb-tests/common/section/basics/testscript new file mode 100644 index 0000000..c0c6617 --- /dev/null +++ b/odb-tests/common/section/basics/testscript @@ -0,0 +1,33 @@ +# file : common/section/basics/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/section/polymorphism/buildfile b/odb-tests/common/section/polymorphism/buildfile new file mode 100644 index 0000000..b9a7514 --- /dev/null +++ b/odb-tests/common/section/polymorphism/buildfile @@ -0,0 +1,41 @@ +# file : common/section/polymorphism/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_section_p_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/section/polymorphism/driver.cxx b/odb-tests/common/section/polymorphism/driver.cxx new file mode 100644 index 0000000..c15d317 --- /dev/null +++ b/odb-tests/common/section/polymorphism/driver.cxx @@ -0,0 +1,1807 @@ +// file : common/section/polymorphism/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test sections in polymorphic objects. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +struct failed {}; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test basic polymorphic section functionality. + // + { + using namespace test1; + + base b (123, "abc"); + derived d (234, "bcd", true); + + { + transaction t (db->begin ()); + db->persist (b); + db->persist (d); + t.commit (); + + assert (b.rs1.loaded ()); + assert (b.rs2.loaded ()); + assert (b.rs3.loaded ()); + assert (b.rs4.loaded ()); + assert (b.bs1.loaded ()); + + assert (d.rs1.loaded ()); + assert (d.rs2.loaded ()); + assert (d.rs3.loaded ()); + assert (d.rs4.loaded ()); + assert (d.bs1.loaded ()); + assert (d.ds1.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + assert (!pb->rs1.loaded ()); + assert (!pb->rs2.loaded ()); + assert (!pb->rs3.loaded ()); + assert (!pb->rs4.loaded ()); + assert (!pb->bs1.loaded ()); + + assert (!pd->rs1.loaded ()); + assert (!pd->rs2.loaded ()); + assert (!pd->rs3.loaded ()); + assert (!pd->rs4.loaded ()); + assert (!pd->bs1.loaded ()); + assert (!pd->ds1.loaded ()); + + assert (pb->rs1n != b.rs1n && pb->rs1s != b.rs1s && + pb->rs2n != b.rs2n && pb->rs2v != b.rs2v && + pb->rs3v != b.rs3v && + pb->rs4n != b.rs4n && + pb->bs1n != b.bs1n); + + assert (pd->rs1n != d.rs1n && pd->rs1s != d.rs1s && + pd->rs1b != d.rs1b && pd->rs1v != d.rs1v && + pd->rs2n != d.rs2n && pd->rs2v != d.rs2v && + pd->rs3v != d.rs3v && pd->rs3n != d.rs3n && + pd->rs4n != d.rs4n && pd->rs4s != d.rs4s && + pd->bs1n != d.bs1n && pd->bs1s != d.bs1s && + pd->ds1n != d.ds1n); + + db->load (*pb, pb->rs1); + db->load (*pb, pb->rs2); + db->load (*pb, pb->rs3); + db->load (*pb, pb->rs4); + db->load (*pb, pb->bs1); + + root* pr (pd.get ()); + db->load (*pr, pr->rs1); // Via base. + db->load (*pd, pd->rs2); + db->load (*pr, pr->rs3); // Via base. + db->load (*pd, pd->rs4); + db->load (*pd, pd->bs1); + db->load (*pd, pd->ds1); + + try + { + db->load (*pr, pd->bs1); // Object-section association is static. + assert (false); + } + catch (const section_not_in_object&) {} + + assert (pb->rs1.loaded ()); + assert (pb->rs2.loaded ()); + assert (pb->rs3.loaded ()); + assert (pb->rs4.loaded ()); + assert (pb->bs1.loaded ()); + + assert (pd->rs1.loaded ()); + assert (pd->rs2.loaded ()); + assert (pd->rs3.loaded ()); + assert (pd->rs4.loaded ()); + assert (pd->bs1.loaded ()); + assert (pd->ds1.loaded ()); + + assert (pb->rs1n == b.rs1n && pb->rs1s == b.rs1s && + pb->rs2n == b.rs2n && pb->rs2v == b.rs2v && + pb->rs3v == b.rs3v && + pb->rs4n == b.rs4n && + pb->bs1n == b.bs1n); + + assert (pd->rs1n == d.rs1n && pd->rs1s == d.rs1s && + pd->rs1b == d.rs1b && pd->rs1v == d.rs1v && + pd->rs2n == d.rs2n && pd->rs2v == d.rs2v && + pd->rs3v == d.rs3v && pd->rs3n == d.rs3n && + pd->rs4n == d.rs4n && pd->rs4s == d.rs4s && + pd->bs1n == d.bs1n && pd->bs1s == d.bs1s && + pd->ds1n == d.ds1n); + t.commit (); + } + + // Update object. + // + b.rs1n++; + b.rs1s += 'd'; + b.rs1.change (); + b.rs2n++; + b.rs2v[0]++; + b.rs3v[0]++; + b.rs4n++; + b.bs1n++; + + d.rs1n++; + d.rs1s += 'e'; + d.rs1b = !d.rs1b; + d.rs1v[0]++; + d.rs1.change (); + d.rs2n++; + d.rs2v[0]++; + d.rs3v[0]++; + d.rs3n++; + d.rs4n++; + d.rs4s += 'e'; + d.bs1n++; + d.bs1s += 'e'; + d.ds1n++; + + { + transaction t (db->begin ()); + db->update (b); + db->update (d); + t.commit (); + + assert (!b.rs1.changed ()); + assert (!d.rs1.changed ()); + } + + { + transaction t (db->begin ()); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + db->load (*pb, pb->rs1); + db->load (*pb, pb->rs2); + db->load (*pb, pb->rs3); + db->load (*pb, pb->rs4); + db->load (*pb, pb->bs1); + + db->load (*pd, pd->rs1); + db->load (*pd, pd->rs2); + db->load (*pd, pd->rs3); + db->load (*pd, pd->rs4); + db->load (*pd, pd->bs1); + db->load (*pd, pd->ds1); + + assert (pb->rs1n == b.rs1n && pb->rs1s == b.rs1s && + pb->rs2n == b.rs2n && pb->rs2v == b.rs2v && + pb->rs3v == b.rs3v && + pb->rs4n == b.rs4n && + pb->bs1n == b.bs1n); + + assert (pd->rs1n == d.rs1n && pd->rs1s == d.rs1s && + pd->rs1b == d.rs1b && pd->rs1v == d.rs1v && + pd->rs2n == d.rs2n && pd->rs2v == d.rs2v && + pd->rs3v == d.rs3v && pd->rs3n == d.rs3n && + pd->rs4n == d.rs4n && pd->rs4s == d.rs4s && + pd->bs1n == d.bs1n && pd->bs1s == d.bs1s && + pd->ds1n == d.ds1n); + t.commit (); + } + + // Update section. + // + b.rs1n++; + b.rs1s += 'd'; + b.rs2n++; + b.rs2v[0]++; + b.rs3v[0]++; + b.rs4n++; + b.bs1n++; + + d.rs1n++; + d.rs1s += 'e'; + d.rs1b = !d.rs1b; + d.rs1v[0]++; + d.rs2n++; + d.rs2v[0]++; + d.rs3v[0]++; + d.rs3n++; + d.rs4n++; + d.rs4s += 'e'; + d.bs1n++; + d.bs1s += 'e'; + d.ds1n++; + + { + transaction t (db->begin ()); + db->update (b, b.rs1); + db->update (b, b.rs2); + db->update (b, b.rs3); + db->update (b, b.rs4); + db->update (b, b.bs1); + + db->update (d, d.rs1); + db->update (d, d.rs2); + db->update (d, d.rs3); + db->update (d, d.rs4); + db->update (d, d.bs1); + db->update (d, d.ds1); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + db->load (*pb, pb->rs1); + db->load (*pb, pb->rs2); + db->load (*pb, pb->rs3); + db->load (*pb, pb->rs4); + db->load (*pb, pb->bs1); + + db->load (*pd, pd->rs1); + db->load (*pd, pd->rs2); + db->load (*pd, pd->rs3); + db->load (*pd, pd->rs4); + db->load (*pd, pd->bs1); + db->load (*pd, pd->ds1); + + assert (pb->rs1n == b.rs1n && pb->rs1s == b.rs1s && + pb->rs2n == b.rs2n && pb->rs2v == b.rs2v && + pb->rs3v == b.rs3v && + pb->rs4n == b.rs4n && + pb->bs1n == b.bs1n); + + assert (pd->rs1n == d.rs1n && pd->rs1s == d.rs1s && + pd->rs1b == d.rs1b && pd->rs1v == d.rs1v && + pd->rs2n == d.rs2n && pd->rs2v == d.rs2v && + pd->rs3v == d.rs3v && pd->rs3n == d.rs3n && + pd->rs4n == d.rs4n && pd->rs4s == d.rs4s && + pd->bs1n == d.bs1n && pd->bs1s == d.bs1s && + pd->ds1n == d.ds1n); + t.commit (); + } + + // Reload. + // + b.rs1n++; + b.rs1s += 'd'; + b.rs1.change (); + b.rs2n++; + b.rs2v[0]++; + b.rs3v[0]++; + b.rs4n++; + b.bs1n++; + + d.rs1n++; + d.rs1s += 'e'; + d.rs1b = !d.rs1b; + d.rs1v[0]++; + d.rs1.change (); + d.rs2n++; + d.rs2v[0]++; + d.rs3v[0]++; + d.rs3n++; + d.rs4n++; + d.rs4s += 'e'; + d.bs1n++; + d.bs1s += 'e'; + d.ds1n++; + + { + transaction t (db->begin ()); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + db->load (*pb, pb->rs1); + db->load (*pb, pb->rs2); + db->load (*pb, pb->rs3); + db->load (*pb, pb->rs4); + db->load (*pb, pb->bs1); + + db->load (*pd, pd->rs1); + db->load (*pd, pd->rs2); + db->load (*pd, pd->rs3); + db->load (*pd, pd->rs4); + db->load (*pd, pd->bs1); + db->load (*pd, pd->ds1); + + db->update (b); + db->update (d); + + db->reload (*pb); + db->reload (*pd); + + assert (pb->rs1n == b.rs1n && pb->rs1s == b.rs1s && + pb->rs2n == b.rs2n && pb->rs2v == b.rs2v && + pb->rs3v == b.rs3v && + pb->rs4n == b.rs4n && + pb->bs1n == b.bs1n); + + assert (pd->rs1n == d.rs1n && pd->rs1s == d.rs1s && + pd->rs1b == d.rs1b && pd->rs1v == d.rs1v && + pd->rs2n == d.rs2n && pd->rs2v == d.rs2v && + pd->rs3v == d.rs3v && pd->rs3n == d.rs3n && + pd->rs4n == d.rs4n && pd->rs4s == d.rs4s && + pd->bs1n == d.bs1n && pd->bs1s == d.bs1s && + pd->ds1n == d.ds1n); + + t.commit (); + } + } + + // Test empty section and override "gap". + // + { + using namespace test2; + + derived d (234); + + { + transaction t (db->begin ()); + db->persist (d); + t.commit (); + + assert (d.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + assert (!pd->s.loaded ()); + assert (pd->sn != d.sn && pd->sv != d.sv); + + root* pr (pd.get ()); + db->load (*pr, pr->s); // Via root. + + assert (pd->s.loaded ()); + assert (pd->sn == d.sn && pd->sv == d.sv); + t.commit (); + } + + // Update object. + // + d.sn++; + d.sv[0]++; + + { + transaction t (db->begin ()); + root* pr (&d); + db->update (pr); // Via root. + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + base* pb (pd.get ()); + db->load (*pb, pb->s); // Via base. + + assert (pd->sn == d.sn && pd->sv == d.sv); + t.commit (); + } + + // Update section. + // + d.sn++; + d.sv[0]++; + + { + transaction t (db->begin ()); + root* pr (&d); + db->update (*pr, pr->s); // Via root. + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + db->load (*pd, pd->s); + + assert (pd->sn == d.sn && pd->sv == d.sv); + t.commit (); + } + + // Reload. + // + d.sn++; + d.sv[0]++; + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + db->load (*pd, pd->s); + + db->update (d); + + root* pr (pd.get ()); + db->reload (*pr); + + assert (pd->sn == d.sn && pd->sv == d.sv); + t.commit (); + } + } + + // Test value-only/container-only base/override combinations. + // + { + using namespace test3; + + root r (123); + base b (234); + derived d (345, "abc"); + + { + transaction t (db->begin ()); + db->persist (r); + db->persist (b); + db->persist (d); + t.commit (); + + assert (r.s1.loaded ()); + assert (r.s2.loaded ()); + assert (r.s3.loaded ()); + assert (r.s4.loaded ()); + + assert (b.s1.loaded ()); + assert (b.s2.loaded ()); + assert (b.s3.loaded ()); + assert (b.s4.loaded ()); + + assert (d.s1.loaded ()); + assert (d.s2.loaded ()); + assert (d.s3.loaded ()); + assert (d.s4.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr pr (db->load (r.id)); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + assert (!pr->s1.loaded ()); + assert (!pr->s2.loaded ()); + assert (!pr->s3.loaded ()); + assert (!pr->s4.loaded ()); + + assert (!pb->s1.loaded ()); + assert (!pb->s2.loaded ()); + assert (!pb->s3.loaded ()); + assert (!pb->s4.loaded ()); + + assert (!pd->s1.loaded ()); + assert (!pd->s2.loaded ()); + assert (!pd->s3.loaded ()); + assert (!pd->s4.loaded ()); + + assert (pr->s1n != r.s1n && + pr->s2n != r.s2n && + pr->s3v != r.s3v && + pr->s4nv != r.s4nv); + + assert (pb->s1n != b.s1n && + pb->s2n != b.s2n && + pb->s3v != b.s3v && + pb->s4nv != b.s4nv); + + assert (pd->s1n != d.s1n && pd->s1s != d.s1s && + pd->s2n != d.s2n && pd->s2v != d.s2v && + pd->s3v != d.s3v && pd->s3n != d.s3n && + pd->s4nv != d.s4nv && pd->s4sv != d.s4sv); + + db->load (*pr, pr->s1); + db->load (*pr, pr->s2); + db->load (*pr, pr->s3); + db->load (*pr, pr->s4); + + db->load (*pb, pb->s1); + db->load (*pb, pb->s2); + db->load (*pb, pb->s3); + db->load (*pb, pb->s4); + + root* pdr (pd.get ()); + db->load (*pdr, pdr->s1); + db->load (*pdr, pdr->s2); + db->load (*pdr, pdr->s3); + db->load (*pdr, pdr->s4); + + assert (pr->s1.loaded ()); + assert (pr->s2.loaded ()); + assert (pr->s3.loaded ()); + assert (pr->s4.loaded ()); + + assert (pb->s1.loaded ()); + assert (pb->s2.loaded ()); + assert (pb->s3.loaded ()); + assert (pb->s4.loaded ()); + + assert (pd->s1.loaded ()); + assert (pd->s2.loaded ()); + assert (pd->s3.loaded ()); + assert (pd->s4.loaded ()); + + assert (pr->s1n == r.s1n && + pr->s2n == r.s2n && + pr->s3v == r.s3v && + pr->s4nv == r.s4nv); + + assert (pb->s1n == b.s1n && + pb->s2n == b.s2n && + pb->s3v == b.s3v && + pb->s4nv == b.s4nv); + + assert (pd->s1n == d.s1n && pd->s1s == d.s1s && + pd->s2n == d.s2n && pd->s2v == d.s2v && + pd->s3v == d.s3v && pd->s3n == d.s3n && + pd->s4nv == d.s4nv && pd->s4sv == d.s4sv); + t.commit (); + } + + // Update object. + // + r.s1n++; + r.s2n++; + r.s3v[0]++; + r.s4nv[0]++; + + b.s1n++; + b.s2n++; + b.s3v[0]++; + b.s4nv[0]++; + + d.s1n++; + d.s1s += 'd'; + d.s2n++; + d.s2v[0]++; + d.s3v[0]++; + d.s3n++; + d.s4nv[0]++; + d.s4sv[0] += 'd'; + + { + transaction t (db->begin ()); + db->update (r); + db->update (b); + db->update (d); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr pr (db->load (r.id)); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + db->load (*pr, pr->s1); + db->load (*pr, pr->s2); + db->load (*pr, pr->s3); + db->load (*pr, pr->s4); + + db->load (*pb, pb->s1); + db->load (*pb, pb->s2); + db->load (*pb, pb->s3); + db->load (*pb, pb->s4); + + db->load (*pd, pd->s1); + db->load (*pd, pd->s2); + db->load (*pd, pd->s3); + db->load (*pd, pd->s4); + + assert (pr->s1n == r.s1n && + pr->s2n == r.s2n && + pr->s3v == r.s3v && + pr->s4nv == r.s4nv); + + assert (pb->s1n == b.s1n && + pb->s2n == b.s2n && + pb->s3v == b.s3v && + pb->s4nv == b.s4nv); + + assert (pd->s1n == d.s1n && pd->s1s == d.s1s && + pd->s2n == d.s2n && pd->s2v == d.s2v && + pd->s3v == d.s3v && pd->s3n == d.s3n && + pd->s4nv == d.s4nv && pd->s4sv == d.s4sv); + t.commit (); + } + + // Update section. + // + r.s1n++; + r.s2n++; + r.s3v[0]++; + r.s4nv[0]++; + + b.s1n++; + b.s2n++; + b.s3v[0]++; + b.s4nv[0]++; + + d.s1n++; + d.s1s += 'd'; + d.s2n++; + d.s2v[0]++; + d.s3v[0]++; + d.s3n++; + d.s4nv[0]++; + d.s4sv[0] += 'd'; + + { + transaction t (db->begin ()); + db->update (r, r.s1); + db->update (r, r.s2); + db->update (r, r.s3); + db->update (r, r.s4); + + db->update (b, b.s1); + db->update (b, b.s2); + db->update (b, b.s3); + db->update (b, b.s4); + + root& rr (d); + db->update (rr, rr.s1); + db->update (rr, rr.s2); + db->update (rr, rr.s3); + db->update (rr, rr.s4); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr pr (db->load (r.id)); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + db->load (*pr, pr->s1); + db->load (*pr, pr->s2); + db->load (*pr, pr->s3); + db->load (*pr, pr->s4); + + db->load (*pb, pb->s1); + db->load (*pb, pb->s2); + db->load (*pb, pb->s3); + db->load (*pb, pb->s4); + + db->load (*pd, pd->s1); + db->load (*pd, pd->s2); + db->load (*pd, pd->s3); + db->load (*pd, pd->s4); + + assert (pr->s1n == r.s1n && + pr->s2n == r.s2n && + pr->s3v == r.s3v && + pr->s4nv == r.s4nv); + + assert (pb->s1n == b.s1n && + pb->s2n == b.s2n && + pb->s3v == b.s3v && + pb->s4nv == b.s4nv); + + assert (pd->s1n == d.s1n && pd->s1s == d.s1s && + pd->s2n == d.s2n && pd->s2v == d.s2v && + pd->s3v == d.s3v && pd->s3n == d.s3n && + pd->s4nv == d.s4nv && pd->s4sv == d.s4sv); + t.commit (); + } + + // Reload. + // + r.s1n++; + r.s2n++; + r.s3v[0]++; + r.s4nv[0]++; + + b.s1n++; + b.s2n++; + b.s3v[0]++; + b.s4nv[0]++; + + d.s1n++; + d.s1s += 'd'; + d.s2n++; + d.s2v[0]++; + d.s3v[0]++; + d.s3n++; + d.s4nv[0]++; + d.s4sv[0] += 'd'; + + { + transaction t (db->begin ()); + unique_ptr pr (db->load (r.id)); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + db->load (*pr, pr->s1); + db->load (*pr, pr->s2); + db->load (*pr, pr->s3); + db->load (*pr, pr->s4); + + db->load (*pb, pb->s1); + db->load (*pb, pb->s2); + db->load (*pb, pb->s3); + db->load (*pb, pb->s4); + + db->load (*pd, pd->s1); + db->load (*pd, pd->s2); + db->load (*pd, pd->s3); + db->load (*pd, pd->s4); + + db->update (r); + db->update (b); + db->update (d); + + db->reload (*pr); + db->reload (*pb); + db->reload (*pd); + + assert (pr->s1n == r.s1n && + pr->s2n == r.s2n && + pr->s3v == r.s3v && + pr->s4nv == r.s4nv); + + assert (pb->s1n == b.s1n && + pb->s2n == b.s2n && + pb->s3v == b.s3v && + pb->s4nv == b.s4nv); + + assert (pd->s1n == d.s1n && pd->s1s == d.s1s && + pd->s2n == d.s2n && pd->s2v == d.s2v && + pd->s3v == d.s3v && pd->s3n == d.s3n && + pd->s4nv == d.s4nv && pd->s4sv == d.s4sv); + t.commit (); + } + } + + // Test basic polymorphic optimistic section functionality. + // + { + using namespace test4; + + base b (123, "abc"); + derived d (234, "bcd", true); + + { + transaction t (db->begin ()); + db->persist (b); + db->persist (d); + t.commit (); + + assert (b.rs1.loaded ()); + assert (b.rs2.loaded ()); + assert (b.rs3.loaded ()); + assert (b.rs4.loaded ()); + assert (b.bs1.loaded ()); + + assert (d.rs1.loaded ()); + assert (d.rs2.loaded ()); + assert (d.rs3.loaded ()); + assert (d.rs4.loaded ()); + assert (d.bs1.loaded ()); + assert (d.ds1.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + assert (!pb->rs1.loaded ()); + assert (!pb->rs2.loaded ()); + assert (!pb->rs3.loaded ()); + assert (!pb->rs4.loaded ()); + assert (!pb->bs1.loaded ()); + + assert (!pd->rs1.loaded ()); + assert (!pd->rs2.loaded ()); + assert (!pd->rs3.loaded ()); + assert (!pd->rs4.loaded ()); + assert (!pd->bs1.loaded ()); + assert (!pd->ds1.loaded ()); + + assert (pb->rs1n != b.rs1n && pb->rs1s != b.rs1s && + pb->rs2n != b.rs2n && + pb->rs3n != b.rs3n && + pb->rs4n != b.rs4n && pb->rs4s != b.rs4s); + + assert (pd->rs1n != d.rs1n && pd->rs1s != d.rs1s && + pd->rs1b != d.rs1b && pd->rs1v != d.rs1v && + pd->rs2n != d.rs2n && + pd->rs3n != d.rs3n && pd->rs3s != d.rs3s && + pd->rs4n != d.rs4n && pd->rs4s != d.rs4s && + pd->rs4v != d.rs4v && + pd->bs1n != d.bs1n && + pd->ds1v != d.ds1v); + + db->load (*pb, pb->rs1); + db->load (*pb, pb->rs2); + db->load (*pb, pb->rs3); + db->load (*pb, pb->rs4); + db->load (*pb, pb->bs1); // No-op. + + root* pr (pd.get ()); + db->load (*pr, pr->rs1); // Via base. + db->load (*pd, pd->rs2); + db->load (*pd, pd->rs3); + db->load (*pr, pr->rs4); // Via base. + db->load (*pd, pd->bs1); + db->load (*pd, pd->ds1); + + assert (pb->rs1.loaded ()); + assert (pb->rs2.loaded ()); + assert (pb->rs3.loaded ()); + assert (pb->rs4.loaded ()); + assert (pb->bs1.loaded ()); + + assert (pd->rs1.loaded ()); + assert (pd->rs2.loaded ()); + assert (pd->rs3.loaded ()); + assert (pd->rs4.loaded ()); + assert (pd->bs1.loaded ()); + assert (pd->ds1.loaded ()); + + assert (pb->rs1n == b.rs1n && pb->rs1s == b.rs1s && + pb->rs2n == b.rs2n && + pb->rs3n == b.rs3n && + pb->rs4n == b.rs4n && pb->rs4s == b.rs4s); + + assert (pd->rs1n == d.rs1n && pd->rs1s == d.rs1s && + pd->rs1b == d.rs1b && pd->rs1v == d.rs1v && + pd->rs2n == d.rs2n && + pd->rs3n == d.rs3n && pd->rs3s == d.rs3s && + pd->rs4n == d.rs4n && pd->rs4s == d.rs4s && + pd->rs4v == d.rs4v && + pd->bs1n == d.bs1n && + pd->ds1v == d.ds1v); + t.commit (); + } + + base b1 (b); + derived d1 (d); + + // Update object. + // + for (unsigned short s (1); s < 7; ++s) + { + b1.rs1n++; + b1.rs1s += 'd'; + b1.rs1.change (); + b1.rs4s += 'd'; + + d1.rs1n++; + d1.rs1s += 'e'; + d1.rs1b = !d.rs1b; + d1.rs1v[0]++; + d1.rs1.change (); + d1.rs4s += 'e'; + d1.rs4v[0]++; + d1.bs1n++; + d1.ds1v[0]++; + + transaction t (db->begin ()); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + db->update (b1); + db->update (d1); + + assert (!b1.rs1.changed ()); + assert (!d1.rs1.changed ()); + + assert (b.v != b1.v); + assert (d.v != d1.v); + + try + { + bool a (false); + switch (s) + { + case 1: db->load (*pb, pb->rs1); break; + case 2: db->load (*pb, pb->rs2); break; + case 3: db->load (*pb, pb->rs3); break; + case 4: db->load (*pb, pb->rs4); break; + case 5: + case 6: a = true; break; // No-op. + default: break; + } + assert (a); + } + catch (const object_changed&) + { + db->reload (*pb); + + assert (!pb->rs1.loaded ()); + assert (!pb->rs2.loaded ()); + assert (!pb->rs3.loaded ()); + assert (!pb->rs3.loaded ()); + assert (!pb->bs1.loaded ()); + + db->load (*pb, pb->rs1); + db->load (*pb, pb->rs2); + db->load (*pb, pb->rs3); + db->load (*pb, pb->rs4); + db->load (*pb, pb->bs1); // No-op. + + assert (pb->rs1n == b1.rs1n && pb->rs1s == b1.rs1s && + pb->rs2n == b1.rs2n && + pb->rs3n == b1.rs3n && + pb->rs4n == b1.rs4n && pb->rs4s == b1.rs4s); + } + + try + { + switch (s) + { + case 1: db->load (*pd, pd->rs1); break; + case 2: db->load (*pd, pd->rs2); break; + case 3: db->load (*pd, pd->rs3); break; + case 4: db->load (*pd, pd->rs4); break; + case 5: db->load (*pd, pd->bs1); break; + case 6: db->load (*pd, pd->ds1); break; + default: break; + } + assert (false); + } + catch (const object_changed&) + { + db->reload (*pd); + + assert (!pd->rs1.loaded ()); + assert (!pd->rs2.loaded ()); + assert (!pd->rs3.loaded ()); + assert (!pd->rs4.loaded ()); + assert (!pd->bs1.loaded ()); + assert (!pd->ds1.loaded ()); + + db->load (*pd, pd->rs1); + db->load (*pd, pd->rs2); + db->load (*pd, pd->rs3); + db->load (*pd, pd->rs4); + db->load (*pd, pd->bs1); + db->load (*pd, pd->ds1); + + assert (pd->rs1n == d1.rs1n && pd->rs1s == d1.rs1s && + pd->rs1b == d1.rs1b && pd->rs1v == d1.rs1v && + pd->rs2n == d1.rs2n && + pd->rs3n == d1.rs3n && pd->rs3s == d1.rs3s && + pd->rs4n == d1.rs4n && pd->rs4s == d1.rs4s && + pd->rs4v == d1.rs4v && + pd->bs1n == d1.bs1n && + pd->ds1v == d1.ds1v); + } + + db->reload (b); + db->reload (d); + + assert (b.v == b1.v); + assert (d.v == d1.v); + + assert (b.rs1n == b1.rs1n && b.rs1s == b1.rs1s && + b.rs2n == b1.rs2n && + b.rs3n == b1.rs3n && + b.rs4n == b1.rs4n && b.rs4s == b1.rs4s); + + assert (d.rs1n == d1.rs1n && d.rs1s == d1.rs1s && + d.rs1b == d1.rs1b && d.rs1v == d1.rs1v && + d.rs2n == d1.rs2n && + d.rs3n == d1.rs3n && d.rs3s == d1.rs3s && + d.rs4n == d1.rs4n && d.rs4s == d1.rs4s && + d.rs4v == d1.rs4v && + d.bs1n == d1.bs1n && + d.ds1v == d1.ds1v); + + t.commit (); + } + + // Update section. + // + for (unsigned short s (1); s < 7; ++s) + { + transaction t (db->begin ()); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + switch (s) + { + case 1: + b1.rs1n++; + b1.rs1s += 'd'; + + d1.rs1n++; + d1.rs1s += 'e'; + d1.rs1b = !d.rs1b; + d1.rs1v[0]++; + + db->update (b1, b1.rs1); + db->update (d1, d1.rs1); + + assert (b.v != b1.v); + assert (d.v != d1.v); + break; + case 2: + db->update (b1, b1.rs2); // No-op. + db->update (d1, d1.rs2); // No-op. + + assert (b.v == b1.v); + assert (d.v == d1.v); + continue; // Object hasn't changed. + case 3: + db->update (b1, b1.rs3); // No-op. + db->update (d1, d1.rs3); // No-op. + + assert (b.v == b1.v); + assert (d.v == d1.v); + continue; // Object hasn't changed. + case 4: + b1.rs4s += 'd'; + + d1.rs4s += 'e'; + d1.rs4v[0]++; + + db->update (b1, b1.rs4); + db->update (d1, d1.rs4); + + assert (b.v != b1.v); + assert (d.v != d1.v); + break; + case 5: + d1.bs1n++; + + db->update (b1, b1.bs1); // No-op. + db->update (d1, d1.bs1); + + assert (b.v == b1.v); + assert (d.v != d1.v); + break; + case 6: + d1.ds1v[0]++; + + db->update (d1, d1.ds1); + + assert (d.v != d1.v); + break; + default: break; + } + + try + { + bool a (false); + switch (s) + { + case 1: db->load (*pb, pb->rs1); break; + case 4: db->load (*pb, pb->rs4); break; + case 5: + case 6: a = true; break; // No-op. + default: break; + } + assert (a); + } + catch (const object_changed&) + { + db->reload (*pb); + + assert (!pb->rs1.loaded ()); + assert (!pb->rs2.loaded ()); + assert (!pb->rs3.loaded ()); + assert (!pb->rs4.loaded ()); + assert (!pb->bs1.loaded ()); + + db->load (*pb, pb->rs1); + db->load (*pb, pb->rs2); + db->load (*pb, pb->rs3); + db->load (*pb, pb->rs4); + db->load (*pb, pb->bs1); // No-op. + + assert (pb->rs1n == b1.rs1n && pb->rs1s == b1.rs1s && + pb->rs2n == b1.rs2n && + pb->rs3n == b1.rs3n && + pb->rs4n == b1.rs4n && pb->rs4s == b1.rs4s); + } + + try + { + switch (s) + { + case 1: db->load (*pd, pd->rs1); break; + case 4: db->load (*pd, pd->rs4); break; + case 5: db->load (*pd, pd->bs1); break; + case 6: db->load (*pd, pd->ds1); break; + default: break; + } + assert (false); + } + catch (const object_changed&) + { + db->reload (*pd); + + assert (!pd->rs1.loaded ()); + assert (!pd->rs2.loaded ()); + assert (!pd->rs3.loaded ()); + assert (!pd->rs4.loaded ()); + assert (!pd->bs1.loaded ()); + assert (!pd->ds1.loaded ()); + + db->load (*pd, pd->rs1); + db->load (*pd, pd->rs2); + db->load (*pd, pd->rs3); + db->load (*pd, pd->rs4); + db->load (*pd, pd->bs1); + db->load (*pd, pd->ds1); + + assert (pd->rs1n == d1.rs1n && pd->rs1s == d1.rs1s && + pd->rs1b == d1.rs1b && pd->rs1v == d1.rs1v && + pd->rs2n == d1.rs2n && + pd->rs3n == d1.rs3n && pd->rs3s == d1.rs3s && + pd->rs4n == d1.rs4n && pd->rs4s == d1.rs4s && + pd->rs4v == d1.rs4v && + pd->bs1n == d1.bs1n && + pd->ds1v == d1.ds1v); + } + + db->reload (b); + db->reload (d); + + assert (b.v == b1.v); + assert (d.v == d1.v); + + assert (b.rs1n == b1.rs1n && b.rs1s == b1.rs1s && + b.rs2n == b1.rs2n && + b.rs3n == b1.rs3n && + b.rs4n == b1.rs4n && b.rs4s == b1.rs4s); + + assert (d.rs1n == d1.rs1n && d.rs1s == d1.rs1s && + d.rs1b == d1.rs1b && d.rs1v == d1.rs1v && + d.rs2n == d1.rs2n && + d.rs3n == d1.rs3n && d.rs3s == d1.rs3s && + d.rs4n == d1.rs4n && d.rs4s == d1.rs4s && + d.rs4v == d1.rs4v && + d.bs1n == d1.bs1n && + d.ds1v == d1.ds1v); + + t.commit (); + } + + // Update changed section. + // + for (unsigned short s (1); s < 7; ++s) + { + if (s == 2 || s == 3) // Readonly sections. + continue; + + transaction t (db->begin ()); + + switch (s) + { + case 1: + b1.rs1n++; + b1.rs1s += 'd'; + + d1.rs1n++; + d1.rs1s += 'e'; + d1.rs1b = !d.rs1b; + d1.rs1v[0]++; + + db->update (b1, b1.rs1); + db->update (d1, d1.rs1); + break; + case 4: + b1.rs4s += 'd'; + + d1.rs4s += 'e'; + d1.rs4v[0]++; + + db->update (b1, b1.rs4); + db->update (d1, d1.rs4); + break; + case 5: + d1.bs1n++; + + db->update (b1, b1.bs1); // No-op. + db->update (d1, d1.bs1); + break; + case 6: + d1.ds1v[0]++; + + db->update (d1, d1.bs1); + break; + default: break; + } + + try + { + bool a (false); + switch (s) + { + case 1: db->update (b, b.rs1); break; + case 4: db->update (b, b.rs4); break; + case 5: + case 6: a = true; break; // No-op. + default: break; + } + assert (a); + } + catch (const object_changed&) + { + db->reload (b); + + switch (s) + { + case 1: db->update (b, b.rs1); break; + case 4: db->update (b, b.rs4); break; + default: break; + } + } + + try + { + switch (s) + { + case 1: db->update (d, d.rs1); break; + case 4: db->update (d, d.rs4); break; + case 5: db->update (d, d.bs1); break; + case 6: db->update (d, d.ds1); break; + default: break; + } + assert (false); + } + catch (const object_changed&) + { + db->reload (d); + + switch (s) + { + case 1: db->update (d, d.rs1); break; + case 4: db->update (d, d.rs4); break; + case 5: db->update (d, d.bs1); break; + case 6: db->update (d, d.ds1); break; + default: break; + } + } + + db->reload (b1); + db->reload (d1); + + t.commit (); + } + } + + // Test polymorphic optimistic readonly/empty to readwrite section + // override. + // + { + using namespace test5; + + base b; + derived d (123); + + { + transaction t (db->begin ()); + db->persist (b); + db->persist (d); + t.commit (); + + assert (b.s.loaded ()); + assert (d.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + assert (!pb->s.loaded ()); + assert (!pd->s.loaded ()); + assert (pd->sn != d.sn); + + db->load (*pb, pb->s); // No-op. + db->load (*pd, pd->s); + + assert (pb->s.loaded ()); + assert (pd->s.loaded ()); + + assert (pd->sn == d.sn); + + t.commit (); + } + + // Update object. + // + base b1 (b); + derived d1 (d); + d1.sn++; + d1.s.change (); + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + db->update (d1); + + assert (!d1.s.changed ()); + assert (d.v != d1.v); + + try + { + db->load (*pd, pd->s); + assert (false); + } + catch (const object_changed&) + { + db->reload (*pd); + assert (!pd->s.loaded ()); + db->load (*pd, pd->s); + assert (pd->sn == d1.sn); + } + + db->reload (d); + assert (d.v == d1.v); + assert (d.sn == d1.sn); + t.commit (); + } + + // Update section. + // + d1.sn++; + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + db->update (b1, b1.s); // No-op. + db->update (d1, d1.s); + + assert (b.v == b1.v); + assert (d.v != d1.v); + + try + { + db->load (*pd, pd->s); + assert (false); + } + catch (const object_changed&) + { + db->reload (*pd); + assert (!pd->s.loaded ()); + db->load (*pd, pd->s); + + assert (pd->sn == d1.sn); + } + + db->reload (d); + assert (d.v == d1.v); + assert (d.sn == d1.sn); + t.commit (); + } + + // Update changed section. + // + d1.sn++; + + { + transaction t (db->begin ()); + db->update (d1, d1.s); + + try + { + db->update (d, d.s); + assert (false); + } + catch (const object_changed&) + { + db->reload (d); + db->update (d, d.s); + } + + t.commit (); + } + } + + // Test polymorphic optimistic readonly/empty to readwrite section + // override, eager-loaded case. + // + { + using namespace test6; + + derived d (123); + + { + transaction t (db->begin ()); + db->persist (d); + t.commit (); + + assert (d.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + assert (pd->s.loaded ()); + assert (pd->sn == d.sn); + + t.commit (); + } + + // Update object. + // + derived d1 (d); + d1.sn++; + d1.s.change (); + + { + transaction t (db->begin ()); + + db->update (d1); + + assert (!d1.s.changed ()); + assert (d.v != d1.v); + + db->reload (d); + assert (d.v == d1.v); + assert (d.sn == d1.sn); + t.commit (); + } + + // Update section. + // + d1.sn++; + + { + transaction t (db->begin ()); + + db->update (d1, d1.s); + assert (d.v != d1.v); + + db->reload (d); + assert (d.v == d1.v); + assert (d.sn == d1.sn); + t.commit (); + } + + // Update changed section. + // + d1.sn++; + + { + transaction t (db->begin ()); + db->update (d1, d1.s); + + try + { + db->update (d, d.s); + assert (false); + } + catch (const object_changed&) + { + db->reload (d); + db->update (d, d.s); + } + + t.commit (); + } + } + + // Test polymorphic optimistic section added in derived. + // + { + using namespace test7; + + base b; + derived d (123); + + { + transaction t (db->begin ()); + db->persist (b); + db->persist (d); + t.commit (); + + assert (b.s.loaded ()); + assert (d.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); + + assert (!pb->s.loaded ()); + assert (!pd->s.loaded ()); + assert (pd->sn != d.sn); + + db->load (*pb, pb->s); // No-op. + db->load (*pd, pd->s); + + assert (pb->s.loaded ()); + assert (pd->s.loaded ()); + + assert (pd->sn == d.sn); + + t.commit (); + } + + // Update object. + // + base b1 (b); + derived d1 (d); + d1.sn++; + d1.s.change (); + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + db->update (d1); + + assert (!d1.s.changed ()); + assert (d.v != d1.v); + + try + { + db->load (*pd, pd->s); + assert (false); + } + catch (const object_changed&) + { + db->reload (*pd); + assert (!pd->s.loaded ()); + db->load (*pd, pd->s); + assert (pd->sn == d1.sn); + } + + db->reload (d); + assert (d.v == d1.v); + assert (d.sn == d1.sn); + t.commit (); + } + + // Update section. + // + d1.sn++; + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + db->update (b1, b1.s); // No-op. + db->update (d1, d1.s); + + assert (b.v == b1.v); + assert (d.v != d1.v); + + try + { + db->load (*pd, pd->s); + assert (false); + } + catch (const object_changed&) + { + db->reload (*pd); + assert (!pd->s.loaded ()); + db->load (*pd, pd->s); + + assert (pd->sn == d1.sn); + } + + db->reload (d); + assert (d.v == d1.v); + assert (d.sn == d1.sn); + t.commit (); + } + + // Update changed section. + // + d1.sn++; + + { + transaction t (db->begin ()); + db->update (d1, d1.s); + + try + { + db->update (d, d.s); + assert (false); + } + catch (const object_changed&) + { + db->reload (d); + db->update (d, d.s); + } + + t.commit (); + } + } + + // Test reuse/polymorphic inheritance and optimistic mix. + // + { + using namespace test8; + + derived d (123); + + { + transaction t (db->begin ()); + db->persist (d); + t.commit (); + + assert (d.s.loaded ()); + } + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + assert (!pd->s.loaded ()); + assert (pd->sn != d.sn); + + db->load (*pd, pd->s); + + assert (pd->s.loaded ()); + assert (pd->sn == d.sn); + + t.commit (); + } + + // Update object. + // + derived d1 (d); + d1.sn++; + d1.s.change (); + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + db->update (d1); + + assert (!d1.s.changed ()); + assert (d.v != d1.v); + + try + { + db->load (*pd, pd->s); + assert (false); + } + catch (const object_changed&) + { + db->reload (*pd); + assert (!pd->s.loaded ()); + db->load (*pd, pd->s); + assert (pd->sn == d1.sn); + } + + db->reload (d); + assert (d.v == d1.v); + assert (d.sn == d1.sn); + t.commit (); + } + + // Update section. + // + d1.sn++; + + { + transaction t (db->begin ()); + unique_ptr pd (db->load (d.id)); + + db->update (d1, d1.s); + assert (d.v != d1.v); + + try + { + db->load (*pd, pd->s); + assert (false); + } + catch (const object_changed&) + { + db->reload (*pd); + assert (!pd->s.loaded ()); + db->load (*pd, pd->s); + + assert (pd->sn == d1.sn); + } + + db->reload (d); + assert (d.v == d1.v); + assert (d.sn == d1.sn); + t.commit (); + } + + // Update changed section. + // + d1.sn++; + + { + transaction t (db->begin ()); + db->update (d1, d1.s); + + try + { + db->update (d, d.s); + assert (false); + } + catch (const object_changed&) + { + db->reload (d); + db->update (d, d.s); + } + + t.commit (); + } + } + + // Test reuse/polymorphic inheritance and optimistic mix. + // + { + using namespace test9; + using std::shared_ptr; + + unsigned long long id; + + { + container c (123); + + c.e1.push_back (shared_ptr (new element (11))); + c.e1.push_back (shared_ptr (new element (12))); + + c.e2.push_back (shared_ptr (new element (21))); + c.e2.push_back (shared_ptr (new element (22))); + + transaction t (db->begin ()); + + db->persist (c.e1[0]); + db->persist (c.e1[1]); + db->persist (c.e2[0]); + db->persist (c.e2[1]); + + id = db->persist (c); + + t.commit (); + } + + { + transaction t (db->begin ()); + + shared_ptr c (db->load (id)); + + assert (c->n == 123); + db->load (*c, c->s); + assert (c->e1.size () == 2 && c->e1[0]->n == 11 && c->e1[1]->n == 12); + assert (c->e2.size () == 2 && c->e2[0]->n == 21 && c->e2[1]->n == 22); + + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/section/polymorphism/test.hxx b/odb-tests/common/section/polymorphism/test.hxx new file mode 100644 index 0000000..6d524bd --- /dev/null +++ b/odb-tests/common/section/polymorphism/test.hxx @@ -0,0 +1,542 @@ +// file : common/section/polymorphism/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include + +#include +#include + +// Test basic polymorphic section functionality. +// +#pragma db namespace table("t1_") +namespace test1 +{ + #pragma db object polymorphic abstract + struct root + { + root (int n): rs1n (n), rs2n (n), rs4n (n) {rs2v.push_back (n);} + virtual ~root () {} + + #pragma db id auto + unsigned long id; + + // rs1: override in base and derived + // + #pragma db load(lazy) update(change) + odb::section rs1; + + #pragma db section(rs1) + int rs1n; + + // rs2: no override + // + #pragma db load(lazy) + odb::section rs2; + + #pragma db section(rs2) + int rs2n; + + #pragma db section(rs2) + std::vector rs2v; + + // rs3: empty + // + #pragma db load(lazy) + odb::section rs3; + + // rs4: override "gap" + // + #pragma db load(lazy) + odb::section rs4; + + #pragma db section(rs4) + int rs4n; + }; + + #pragma db object + struct base: root + { + base (int n = 999, const std::string& s = "xxx") + : root (n), rs1s (s), bs1n (n) {rs3v.push_back (n);} + + // rs1 + // + #pragma db section(rs1) + std::string rs1s; + + // rs3 + // + #pragma db section(rs3) + std::vector rs3v; + + // bs1: override in derived + // + #pragma db load(lazy) + odb::section bs1; + + #pragma db section(bs1) + int bs1n; + }; + + #pragma db object + struct derived: base + { + derived (int n = 999, const std::string& s = "xxx", bool b = false) + : base (n, s), rs1b (b), rs3n (n), rs4s (s), bs1s (s), ds1n (n) + {rs1v.push_back (n);} + + // rs1 + // + #pragma db section(rs1) + bool rs1b; + + #pragma db section(rs1) + std::vector rs1v; + + // rs3 + // + #pragma db section(rs3) + int rs3n; + + // rs4 + // + #pragma db section(rs4) + std::string rs4s; + + // bs1 + // + #pragma db section(bs1) + std::string bs1s; + + // ds1: no override + // + #pragma db load(lazy) + odb::section ds1; + + #pragma db section(ds1) + int ds1n; + }; +} + +// Test empty section and override "gap". +// +#pragma db namespace table("t2_") +namespace test2 +{ + #pragma db object polymorphic abstract + struct root + { + virtual ~root () {} + + #pragma db id auto + unsigned long id; + + #pragma db load(lazy) + odb::section s; + }; + + #pragma db object abstract + struct base: root + { + // The "gap". + }; + + #pragma db object + struct derived: base + { + derived (int n = 999): sn (n) {sv.push_back (n);} + + #pragma db section(s) + int sn; + + #pragma db section(s) + std::vector sv; + }; +} + +// Test value-only/container-only base/override combinations. +// +#pragma db namespace table("t3_") +namespace test3 +{ + #pragma db object polymorphic + struct root + { + root (int n = 999) + : s1n (n), s2n (n) {s3v.push_back (n); s4nv.push_back (n);} + virtual ~root () {} + + #pragma db id auto + unsigned long id; + + // value/value + // + #pragma db load(lazy) + odb::section s1; + + #pragma db section(s1) + int s1n; + + // value/container + // + #pragma db load(lazy) + odb::section s2; + + #pragma db section(s2) + int s2n; + + // container/value + // + #pragma db load(lazy) + odb::section s3; + + #pragma db section(s3) + std::vector s3v; + + // container/container + // + #pragma db load(lazy) + odb::section s4; + + #pragma db section(s4) + std::vector s4nv; + }; + + #pragma db object + struct base: root + { + base (int n = 999): root (n) {} + + // The "gap". + }; + + #pragma db object + struct derived: base + { + derived (int n = 999, const std::string& s = "xxx") + : base (n), s1s (s), s3n (n) {s2v.push_back (n); s4sv.push_back (s);} + + #pragma db section(s1) + std::string s1s; + + #pragma db section(s2) + std::vector s2v; + + #pragma db section(s3) + int s3n; + + #pragma db section(s4) + std::vector s4sv; + }; +} + +// Test basic polymorphic optimistic section functionality. +// +#pragma db namespace table("t4_") +namespace test4 +{ + #pragma db object polymorphic optimistic abstract sectionable + struct root + { + root (int n): rs1n (n), rs2n (n), rs3n (n), rs4n (n) {} + virtual ~root () {} + + #pragma db id auto + unsigned long id; + + #pragma db version + unsigned long long v; + + // rs1: readwrite, override + // + #pragma db load(lazy) update(change) + odb::section rs1; + + #pragma db section(rs1) + int rs1n; + + // rs2: readonly, no override + // + #pragma db load(lazy) + odb::section rs2; + + #pragma db section(rs2) + const int rs2n; + + // rs3: readonly, readonly override + // + #pragma db load(lazy) + odb::section rs3; + + #pragma db section(rs3) + const int rs3n; + + // rs4: readonly, readwrite override + // + #pragma db load(lazy) + odb::section rs4; + + #pragma db section(rs4) + const int rs4n; + }; + + #pragma db object + struct base: root + { + base (int n = 999, const std::string& s = "xxx") + : root (n), rs1s (s), rs4s (s) {} + + // rs1 + // + #pragma db section(rs1) + std::string rs1s; + + // rs4 + // + #pragma db section(rs4) + std::string rs4s; + + // bs2: empty, readwrite override + // + #pragma db load(lazy) + odb::section bs1; + }; + + #pragma db object + struct derived: base + { + derived (int n = 999, const std::string& s = "xxx", bool b = false) + : base (n, s), rs1b (b), rs3s (s), bs1n (n) + { + rs1v.push_back (n); + rs4v.push_back (n); + ds1v.push_back (n); + } + + // rs1 + // + #pragma db section(rs1) + bool rs1b; + + #pragma db section(rs1) + std::vector rs1v; + + // rs3 + // + #pragma db section(rs3) + const std::string rs3s; + + // rs4 + // + #pragma db section(rs4) + std::vector rs4v; + + // bs1 + // + #pragma db section(bs1) + int bs1n; + + // ds1: readwrite + // + #pragma db load(lazy) + odb::section ds1; + + #pragma db section(ds1) + std::vector ds1v; + }; +} + +// Test polymorphic optimistic readonly/empty to readwrite section override. +// +#pragma db namespace table("t5_") +namespace test5 +{ + #pragma db object polymorphic optimistic abstract + struct root + { + virtual ~root () {} + + #pragma db id auto + unsigned long id; + + #pragma db version + unsigned long long v; + + #pragma db load(lazy) update(change) + odb::section s; + }; + + #pragma db object + struct base: root + { + // The "gap". + }; + + #pragma db object + struct derived: base + { + derived (int n = 999): sn (n) {} + + #pragma db section(s) + int sn; + }; +} + +// Test polymorphic optimistic readonly/empty to readwrite section override, +// eager-loaded case. +// +#pragma db namespace table("t6_") +namespace test6 +{ + #pragma db object polymorphic optimistic abstract + struct root + { + virtual ~root () {} + + #pragma db id auto + unsigned long id; + + #pragma db version + unsigned long long v; + + #pragma db update(change) + odb::section s; + }; + + #pragma db object abstract + struct base: root + { + // The "gap". + }; + + #pragma db object + struct derived: base + { + derived (int n = 999): sn (n) {} + + #pragma db section(s) + int sn; + }; +} + +// Test polymorphic optimistic section added in derived. +// +#pragma db namespace table("t7_") +namespace test7 +{ + #pragma db object polymorphic optimistic sectionable + struct root + { + virtual ~root () {} + + #pragma db id auto + unsigned long id; + + #pragma db version + unsigned long long v; + }; + + #pragma db object + struct base: root + { + #pragma db load(lazy) update(change) + odb::section s; + }; + + #pragma db object + struct derived: base + { + derived (int n = 999): sn (n) {} + + #pragma db section(s) + int sn; + }; +} + +// Test reuse/polymorphic inheritance and optimistic mix. +// +#pragma db namespace table("t8_") +namespace test8 +{ + #pragma db object optimistic sectionable abstract + struct root + { + #pragma db id auto + unsigned long id; + + #pragma db version + unsigned long long v; + }; + + #pragma db object polymorphic sectionable + struct base: root + { + virtual ~base () {} + }; + + #pragma db object + struct derived: base + { + derived (int n = 999): sn (n) {} + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + int sn; + }; +} + +// Test id overwrite regression. +// +// The key here is the setup: the object that contains the containers in a +// section and the pointers to objects stored in those containers. And these +// objects derive polymorphically from the same base (and thus shared the id +// bindind). +// +#pragma db namespace table("t9_") +namespace test9 +{ + #pragma db object polymorphic pointer(std::shared_ptr) + struct base + { + virtual ~base () {} + + #pragma db id auto + unsigned long id; + }; + + #pragma db object + struct element: base + { + element (int n_ = 0): n (n_) {} + + int n; + }; + + typedef std::vector> elements; + + #pragma db object + struct container: base + { + container (int n_ = 0): n (n_) {} + + int n; + + #pragma db load(lazy) update(always) + odb::section s; + + #pragma db section(s) + elements e1; + + #pragma db section(s) + elements e2; + }; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/section/polymorphism/testscript b/odb-tests/common/section/polymorphism/testscript new file mode 100644 index 0000000..f2cd536 --- /dev/null +++ b/odb-tests/common/section/polymorphism/testscript @@ -0,0 +1,33 @@ +# file : common/section/polymorphism/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/session/cache/buildfile b/odb-tests/common/session/cache/buildfile new file mode 100644 index 0000000..6d5b0bc --- /dev/null +++ b/odb-tests/common/session/cache/buildfile @@ -0,0 +1,41 @@ +# file : common/session/cache/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix session_cache_ \ + --generate-schema \ + --generate-session + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/session/cache/driver.cxx b/odb-tests/common/session/cache/driver.cxx new file mode 100644 index 0000000..4b4ea12 --- /dev/null +++ b/odb-tests/common/session/cache/driver.cxx @@ -0,0 +1,83 @@ +// file : common/session/cache/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test session object cache. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test the session_required exception. + // + { + using namespace test1; + + shared_ptr o1a (new obj1 (1)); + shared_ptr o1b (new obj1 (2)); + shared_ptr o2 (new obj2 (1)); + + o1a->o2 = o2; + o1b->o2 = o2; + + o2->o1.push_back (o1a); + o2->o1.push_back (o1b); + + { + transaction t (db->begin ()); + db->persist (o1a); + db->persist (o1b); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + + try + { + shared_ptr o1 (db->load (1)); + assert (false); + } + catch (const session_required&) + { + } + + t.commit (); + } + + { + session s; + transaction t (db->begin ()); + shared_ptr o1 (db->load (1)); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/session/cache/test.hxx b/odb-tests/common/session/cache/test.hxx new file mode 100644 index 0000000..d2b1b2b --- /dev/null +++ b/odb-tests/common/session/cache/test.hxx @@ -0,0 +1,50 @@ +// file : common/session/cache/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +// Test the session_required exception. +// +#pragma db namespace table("t1_") +namespace test1 +{ + using std::shared_ptr; + using std::weak_ptr; + + #pragma db namespace(test1) pointer(shared_ptr) + + struct obj2; + + #pragma db object + struct obj1 + { + obj1 () {} + obj1 (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + shared_ptr o2; + }; + + #pragma db object + struct obj2 + { + obj2 () {} + obj2 (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db inverse (o2) + std::vector< weak_ptr > o1; + }; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/session/cache/testscript b/odb-tests/common/session/cache/testscript new file mode 100644 index 0000000..6d013eb --- /dev/null +++ b/odb-tests/common/session/cache/testscript @@ -0,0 +1,33 @@ +# file : common/session/cache/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/session/custom/buildfile b/odb-tests/common/session/custom/buildfile new file mode 100644 index 0000000..1b64de1 --- /dev/null +++ b/odb-tests/common/session/custom/buildfile @@ -0,0 +1,43 @@ +# file : common/session/custom/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx txx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix session_custom_ \ + --generate-schema \ + --generate-session \ + --session-type ::session \ + --hxx-prologue '#include "session.hxx"' + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/session/custom/driver.cxx b/odb-tests/common/session/custom/driver.cxx new file mode 100644 index 0000000..3056fd6 --- /dev/null +++ b/odb-tests/common/session/custom/driver.cxx @@ -0,0 +1,231 @@ +// file : common/session/custom/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test custom session (C++11 only). +// + +#include +#include // std::size_t +#include + +#include +#include +#include +#include +#include // ODB_CXX11_* + +#include + +#include "session.hxx" + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; + +using odb::database; +using odb::transaction; + +struct counting_tracer: odb::tracer +{ + virtual void + execute (odb::connection&, const char*) {count++;} + size_t count; +}; + +static counting_tracer tracer; + +struct failed {}; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Simple Tech Ltd. + // + { + shared_ptr er (new employer ("Simple Tech Ltd", "ST")); + + shared_ptr john (new employee ("John", "Doe", er)); + shared_ptr jane (new employee ("Jane", "Doe", er)); + + transaction t (db->begin ()); + + db->persist (er); + db->persist (john); + db->persist (jane); + + t.commit (); + } + + // Complex Systems Inc. + // + { + shared_ptr er (new employer ("Complex Systems Inc", "CS")); + + shared_ptr john (new employee ("John", "Smith", er)); + shared_ptr jane (new employee ("Jane", "Smith", er)); + + transaction t (db->begin ()); + + db->persist (er); + db->persist (john); + db->persist (jane); + + t.commit (); + } + + { + session s; + shared_ptr st, cs; + shared_ptr ste, cse; + + { + transaction t (db->begin ()); + + st = db->load ("Simple Tech Ltd"); +#ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT + ste = db->load (st->employees ()[0].object_id ()); +#else + ste = db->load (st->employees ()[0].object_id ()); +#endif + + // Test object cache. + // + shared_ptr e (st->employees ()[0].load ()); + assert (ste->employer () == st); + assert (ste == e); + + t.commit (); + } + + { + transaction t (db->begin ()); + + cs = db->load ("Complex Systems Inc"); +#ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT + cse = db->load (cs->employees ()[0].object_id ()); +#else + cse = db->load (cs->employees ()[0].object_id ()); +#endif + cs->employees ()[0].load (); + + t.commit (); + } + + cs->symbol ("CSI"); + + // Swap employees. + // + ste->employer (cs); + cse->employer (st); + st->employees ()[0] = cse; + cs->employees ()[0] = ste; + + { + transaction t (db->begin ()); + tracer.count = 0; + t.tracer (tracer); + s.flush (*db); + assert (tracer.count == 3); + t.commit (); + } + + { + transaction t (db->begin ()); + tracer.count = 0; + t.tracer (tracer); + s.flush (*db); + assert (tracer.count == 0); + t.commit (); + } + + cs->symbol ("COMP"); + st->symbol ("SMPL"); + + { + transaction t (db->begin ()); + tracer.count = 0; + t.tracer (tracer); + s.flush (*db); + assert (tracer.count == 2); + t.commit (); + } + + { + transaction t (db->begin ()); + tracer.count = 0; + t.tracer (tracer); + s.flush (*db); + assert (tracer.count == 0); + t.commit (); + } + + // Explicit update. + // + cs->symbol ("CS"); + st->symbol ("ST"); + + { + transaction t (db->begin ()); + db->update (cs); + tracer.count = 0; + t.tracer (tracer); + s.flush (*db); + assert (tracer.count == 1); + t.commit (); + } + + // Rollback after update. + // + cs->symbol ("CSI"); + + try + { + transaction t (db->begin ()); + tracer.count = 0; + t.tracer (tracer); + s.flush (*db); + assert (tracer.count == 1); + throw failed (); + t.commit (); + } + catch (const failed&) + { + transaction t (db->begin ()); + tracer.count = 0; + t.tracer (tracer); + s.flush (*db); + assert (tracer.count == 1); + t.commit (); + } + } + + // Test session destruction before transaction is commited. + // + { + transaction t (db->begin ()); + { + session s; + shared_ptr st (db->load ("Simple Tech Ltd")); + st->symbol ("STL"); + tracer.count = 0; + t.tracer (tracer); + s.flush (*db); + assert (tracer.count == 1); + } + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/session/custom/session.cxx b/odb-tests/common/session/custom/session.cxx new file mode 100644 index 0000000..1a08c79 --- /dev/null +++ b/odb-tests/common/session/custom/session.cxx @@ -0,0 +1,57 @@ +// file : common/session/custom/session.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +#include "session.hxx" + +session* session::current; + +session:: +session () + : tran_ (0) +{ + assert (current == 0); + current = this; +} + +session:: +~session () +{ + // Unregister from transaction. + // + if (tran_ != 0) + tran_->callback_unregister (this); + + assert (current == this); + current = 0; +} + +void session:: +flush (odb::database& db) +{ + bool flushed (false); + + for (type_map::iterator i (map_.begin ()), e (map_.end ()); i != e; ++i) + { + bool r (i->second->flush (db)); + flushed = flushed || r; + } + + // If we flushed anything, then register the post-commit/rollback callback. + // + if (flushed) + { + tran_ = &odb::transaction::current (); + tran_->callback_register ( + &mark, this, odb::transaction::event_all, 0, &tran_); + } +} + +void session:: +mark (unsigned short event, void* key, unsigned long long) +{ + session& s (*static_cast (key)); + for (type_map::iterator i (s.map_.begin ()), e (s.map_.end ()); i != e; ++i) + i->second->mark (event); +} diff --git a/odb-tests/common/session/custom/session.hxx b/odb-tests/common/session/custom/session.hxx new file mode 100644 index 0000000..2d2f597 --- /dev/null +++ b/odb-tests/common/session/custom/session.hxx @@ -0,0 +1,191 @@ +// file : common/session/custom/session.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef SESSION_HXX +#define SESSION_HXX + +#include +#include +#include + +#include +#include + +#include // odb::object_traits +#include // odb::details::type_info_comparator + +// This custom session implementation assumes we are working with +// one database at a time. +// +class session +{ +public: + session (); + ~session (); + +private: + session (const session&); + session& operator= (const session&); + + // Session for the current thread. This can be implemented in pretty + // much any way that makes sense to the application. It can be a global + // session as we have here. In multi-threaded applications we could use + // TLS instead. + // +public: + static session* current; + + // Change tracking interface. + // +public: + // Call flush() within a transaction to apply the changes to the + // database. + // + void + flush (odb::database&); + +private: + struct object_map_base + { + virtual + ~object_map_base () {} + + // Return true if we flushed anything. + // + virtual bool + flush (odb::database&) = 0; + + virtual void + mark (unsigned short event) = 0; + }; + + enum object_state + { + tracking, // Tracking any modifications by storing the original copy. + changed, // Known to be changed. + flushed // Flushed but not yet committed/rolled back. + }; + + template + struct object_data + { + typedef typename odb::object_traits::pointer_type pointer_type; + + explicit + object_data (pointer_type o): obj (o), state (tracking) {} + + pointer_type obj; + pointer_type orig; + object_state state; + }; + + template + struct object_map: object_map_base, + std::map::id_type, + object_data > + { + virtual bool + flush (odb::database&); + + virtual void + mark (unsigned short event); + }; + + // Object cache interface. + // +public: + static bool + _has_cache () {return current != 0;} + + template + struct cache_position + { + typedef object_map map; + typedef typename map::iterator iterator; + + cache_position (): map_ (0) {} + cache_position (map& m, const iterator& p): map_ (&m), pos_ (p) {} + + cache_position (const cache_position& p) + : map_ (p.map_) + { + // It might not be ok to use an uninitialized iterator. + // + if (p.map_ != 0) + pos_ = p.pos_; + } + + cache_position& + operator= (const cache_position& p) + { + // It might not be ok to use an uninitialized iterator on the rhs. + // + if (p.map_ != 0) + pos_ = p.pos_; + map_ = p.map_; + return *this; + } + + map* map_; + iterator pos_; + }; + + // Cache management. + // + template + static cache_position + _cache_insert (odb::database&, + const typename odb::object_traits::id_type&, + const typename odb::object_traits::pointer_type&); + + template + static typename odb::object_traits::pointer_type + _cache_find (odb::database&, const typename odb::object_traits::id_type&); + + template + static void + _cache_erase (const cache_position& p) + { + if (p.map_ != 0) + p.map_->erase (p.pos_); + } + + // Notifications. + // + template + static void + _cache_persist (const cache_position& p) + { + _cache_load (p); + } + + template + static void + _cache_load (const cache_position&); + + template + static void + _cache_update (odb::database&, const T&); + + template + static void + _cache_erase (odb::database&, + const typename odb::object_traits::id_type&); + +private: + // Post-commit/rollback callback. + // + static void + mark (unsigned short event, void* key, unsigned long long); + +private: + typedef std::map, + odb::details::type_info_comparator> type_map; + type_map map_; + odb::transaction* tran_; +}; + +#include "session.txx" + +#endif // SESSION_HXX diff --git a/odb-tests/common/session/custom/session.txx b/odb-tests/common/session/custom/session.txx new file mode 100644 index 0000000..65ab933 --- /dev/null +++ b/odb-tests/common/session/custom/session.txx @@ -0,0 +1,159 @@ +// file : common/session/custom/session.txx +// license : GNU GPL v2; see accompanying LICENSE file + +#include + +template +typename session::cache_position session:: +_cache_insert (odb::database&, + const typename odb::object_traits::id_type& id, + const typename odb::object_traits::pointer_type& obj) +{ + if (current == 0) + return cache_position (); // No session, return empty position. + + std::shared_ptr& pm (current->map_[&typeid (T)]); + + if (!pm) + pm.reset (new object_map); + + object_map& m (static_cast&> (*pm)); + + typename object_map::value_type vt (id, object_data (obj)); + std::pair::iterator, bool> r (m.insert (vt)); + + // We shall never try to re-insert the same object into the cache. + // + assert (r.second); + + return cache_position (m, r.first); +} + +template +typename odb::object_traits::pointer_type session:: +_cache_find (odb::database&, const typename odb::object_traits::id_type& id) +{ + typedef typename odb::object_traits::pointer_type pointer_type; + + if (current == 0) + return pointer_type (); // No session, return NULL pointer. + + type_map::const_iterator ti (current->map_.find (&typeid (T))); + + if (ti == current->map_.end ()) + return pointer_type (); + + const object_map& m (static_cast&> (*ti->second)); + typename object_map::const_iterator oi (m.find (id)); + + if (oi == m.end ()) + return pointer_type (); + + return oi->second.obj; +} + +template +void session:: +_cache_load (const cache_position& p) +{ + typedef typename odb::object_traits::pointer_type pointer_type; + + if (p.map_ == 0) + return; // Empty position. + + // Make a copy for change tracking. If our object model had a + // polymorphic hierarchy, then we would have had to use a + // virtual function-based mechanism (e.g., clone()) instead of + // the copy constructor since for a polymorphic hierarchy all + // the derived objects are stored as pointers to the root object. + // + p.pos_->second.orig = pointer_type (new T (*p.pos_->second.obj)); +} + +template +void session:: +_cache_update (odb::database&, const T& obj) +{ + typedef odb::object_traits object_traits; + typedef typename object_traits::pointer_type pointer_type; + + if (current == 0) + return; // No session. + + // User explicitly updated the object by calling database::update(). + // Change the state to flushed and reset the original copy (we are + // still tracking changes after the update). + // + type_map::iterator ti (current->map_.find (&typeid (T))); + + if (ti == current->map_.end ()) + return; // This object is not in the session. + + object_map& m (static_cast&> (*ti->second)); + typename object_map::iterator oi (m.find (object_traits::id (obj))); + + if (oi == m.end ()) + return; // This object is not in the session. + + object_data& d (oi->second); + d.orig = pointer_type (new T (*d.obj)); + d.state = flushed; +} + +template +void session:: +_cache_erase (odb::database&, + const typename odb::object_traits::id_type& id) +{ + if (current == 0) + return; // No session. + + type_map::iterator ti (current->map_.find (&typeid (T))); + + if (ti == current->map_.end ()) + return; + + object_map& m (static_cast&> (*ti->second)); + typename object_map::iterator oi (m.find (id)); + + if (oi == m.end ()) + return; + + m.erase (oi); + + if (m.empty ()) + current->map_.erase (ti); +} + +template +bool session::object_map:: +flush (odb::database& db) +{ + bool r (false); + for (typename object_map::iterator i (this->begin ()), e (this->end ()); + i != e; ++i) + { + object_data& d (i->second); + + if (d.state == changed || d.obj->changed (*d.orig)) + db.update (d.obj); // State changed by the update() notification. + + r = r || d.state == flushed; + } + + return r; +} + +template +void session::object_map:: +mark (unsigned short event) +{ + for (typename object_map::iterator i (this->begin ()), e (this->end ()); + i != e; ++i) + { + object_data& d (i->second); + + if (d.state == flushed) + d.state = event == odb::transaction::event_commit ? tracking : changed; + } +} diff --git a/odb-tests/common/session/custom/test.hxx b/odb-tests/common/session/custom/test.hxx new file mode 100644 index 0000000..3f2703f --- /dev/null +++ b/odb-tests/common/session/custom/test.hxx @@ -0,0 +1,118 @@ +// file : common/session/custom/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include + +#include +#include + +class employee; + +#pragma db object pointer(std::shared_ptr) session +class employer +{ +public: + employer (const std::string& name, const std::string& symbol) + : name_ (name), symbol_ (symbol) {} + + const std::string& + name () const {return name_;} + + const std::string& + symbol () const {return symbol_;} + + void + symbol (const std::string& symbol) {symbol_ = symbol;} + + // Employees of this employer. + // + typedef std::vector> employees_type; + + const employees_type& + employees () const {return employees_;} + + employees_type& + employees () {return employees_;} + + // Change tracking. + // +public: + bool + changed (const employer& orig) const + { + // Note that we don't need to track object ids, inverse pointers, nor + // readonly/const data members. + // + return symbol_ != orig.symbol_; + } + +private: + friend class odb::access; + employer () {} + + #pragma db id + std::string name_; + + std::string symbol_; + + #pragma db value_not_null inverse(employer_) + employees_type employees_; +}; + +#pragma db object pointer(std::shared_ptr) session +class employee +{ +public: + typedef ::employer employer_type; + + employee (const std::string& first, + const std::string& last, + std::shared_ptr employer) + : first_ (first), last_ (last), employer_ (employer) {} + + // Name. + // + const std::string& + first () const {return first_;} + + const std::string& + last () const {return last_;} + + // Employer. + // + std::shared_ptr + employer () const {return employer_;} + + void + employer (std::shared_ptr e) {employer_ = e;} + + // Change tracking. + // +public: + bool + changed (const employee& orig) const + { + return first_ != orig.first_ || last_ != orig.last_ || + employer_ != orig.employer_; + } + +private: + friend class odb::access; + employee () {} + + #pragma db id auto + unsigned long id_; + + std::string first_; + std::string last_; + + #pragma db not_null + std::shared_ptr employer_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/session/custom/testscript b/odb-tests/common/session/custom/testscript new file mode 100644 index 0000000..39c281d --- /dev/null +++ b/odb-tests/common/session/custom/testscript @@ -0,0 +1,33 @@ +# file : common/session/custom/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/statement/processing/buildfile b/odb-tests/common/statement/processing/buildfile new file mode 100644 index 0000000..97124e8 --- /dev/null +++ b/odb-tests/common/statement/processing/buildfile @@ -0,0 +1,8 @@ +# file : common/statement/processing/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libs = libodb%lib{odb} + +exe{driver}: {hxx cxx}{*} $libs testscript + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/common/statement/processing/driver.cxx b/odb-tests/common/statement/processing/driver.cxx new file mode 100644 index 0000000..2d00107 --- /dev/null +++ b/odb-tests/common/statement/processing/driver.cxx @@ -0,0 +1,619 @@ +// file : common/statement/processing/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test internal statement processing machinery. +// + +#include +#include + +#include + +#undef NDEBUG +#include + +using namespace std; + +static bool +insert (const char* stmt, + const char* expected, + const void* const* bind, + size_t bind_size) +{ + string r; + odb::statement::process_insert ( + r, stmt, bind, bind_size, sizeof (void*), '$'); + return r == expected; +} + +static bool +update (const char* stmt, + const char* expected, + const void* const* bind, + size_t bind_size) +{ + string r; + odb::statement::process_update ( + r, stmt, bind, bind_size, sizeof (void*), '$'); + return r == expected; +} + +static bool +select (const char* stmt, + const char* expected, + const void* const* bind, + size_t bind_size) +{ + string r; + odb::statement::process_select ( + r, stmt, bind, bind_size, sizeof (void*), '[', ']', true); + return r == expected; +} + +int +main (int, char* argv[]) +{ + // + // INSERT + // + + // Fast path. + // + { + void* b[] = {argv, argv}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b])\n" + "VALUES\n" + "(DEFAULT,\n$1)", + "INSERT INTO [foo] ([a], [b]) VALUES (DEFAULT, $1)", + b, 2)); + } + + // Empty via statement. + // + /* LIBODB_DEBUG_STATEMENT_PROCESSING + { + assert (insert ("INSERT INTO [foo]\n" + "DEFAULT VALUES", + "INSERT INTO [foo] DEFAULT VALUES", + 0, 0)); + } + */ + + // Empty via bind. + // + { + void* b[] = {0}; + assert (insert ("INSERT INTO [foo]\n" + "([a])\n" + "VALUES\n" + "($1)", + "INSERT INTO [foo] DEFAULT VALUES", + b, 1)); + } + + // Empty with OUTPUT. + // + { + void* b[] = {0, 0}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b])\n" + "OUTPUT INSERTED.[id]\n" + "VALUES\n" + "($1,\n$2)", + "INSERT INTO [foo] OUTPUT INSERTED.[id] DEFAULT VALUES", + b, 2)); + } + + // Empty with RETURNING. + // + { + void* b[] = {0, 0, 0}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b],\n[c])\n" + "VALUES\n" + "($1,\n$1,\n$2)\n" + "RETURNING [id]", + "INSERT INTO [foo] DEFAULT VALUES RETURNING [id]", + b, 3)); + } + + // Empty via bind, but not values. + // + { + void* b[] = {0}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b])\n" + "VALUES\n" + "(1,\n$1)", + "INSERT INTO [foo] ([a]) VALUES (1)", + b, 1)); + } + + // Empty via bind, but not values. + // + { + void* b[] = {0}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b],\n[c])\n" + "VALUES\n" + "(1,\n$1,\nDEFAULT)", + "INSERT INTO [foo] ([a], [c]) VALUES (1, DEFAULT)", + b, 1)); + } + + // First not present. + // + { + void* b[] = {0, argv, argv}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b],\n[c])\n" + "VALUES\n" + "($1,\n$2,\n$3)", + "INSERT INTO [foo] ([b], [c]) VALUES ($2, $3)", + b, 3)); + } + + // Last not present. + // + { + void* b[] = {argv, argv, 0}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b],\n[c])\n" + "VALUES\n" + "($1,\n$2,\n$3)", + "INSERT INTO [foo] ([a], [b]) VALUES ($1, $2)", + b, 3)); + } + + // Middle not present. + // + { + void* b[] = {argv, 0, argv}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b],\n[c])\n" + "VALUES\n" + "($1,\n$2,\n$3)", + "INSERT INTO [foo] ([a], [c]) VALUES ($1, $3)", + b, 3)); + } + + // Multiple not present. + // + { + void* b[] = {0, argv, 0, argv, 0}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b],\n[c],\n[d],\n[e])\n" + "VALUES\n" + "($1,\n$2,\n$3,\n$4,\n$5)", + "INSERT INTO [foo] ([b], [d]) VALUES ($2, $4)", + b, 5)); + } + + // Not present and OUTPUT. + // + { + void* b[] = {argv, 0, argv}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b],\n[c])\n" + "OUTPUT INSERTED.[id]\n" + "VALUES\n" + "($1,\n$2,\n$3)", + "INSERT INTO [foo] ([a], [c]) OUTPUT INSERTED.[id] " + "VALUES ($1, $3)", + b, 3)); + } + + // Not present and RETURNING. + // + { + void* b[] = {argv, 0, argv}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b],\n[c])\n" + "VALUES\n" + "($1,\n$2,\n$3)\n" + "RETURNING [id]", + "INSERT INTO [foo] ([a], [c]) VALUES ($1, $3) " + "RETURNING [id]", + b, 3)); + } + + // Value expressions. + // + { + void* b[] = {argv, argv, argv}; + assert (insert ("INSERT INTO [foo]\n" + "([a],\n[b],\n[c])\n" + "VALUES\n" + "($1,\nCAST($2, TEXT),\n$3)", + "INSERT INTO [foo] ([a], [b], [c]) " + "VALUES ($1, CAST($2, TEXT), $3)", + b, 3)); + } + + // + // UPDATE + // + + // Fast path. + // + { + void* b[] = {argv, argv}; + assert (update ("UPDATE [foo]\n" + "SET\n" + "ver=ver+1,\n[a]=$1\n" + "WHERE [id]=$2", + "UPDATE [foo] SET ver=ver+1, [a]=$1 WHERE [id]=$2", + b, 2)); + } + + // Empty via bind. + // + { + void* b[] = {0, argv}; + assert (update ("UPDATE [foo]\n" + "SET\n" + "[a]=$1\n" + "WHERE [id]=$2", + "", + b, 2)); + } + + // Empty via bind, but not values. + // + { + void* b[] = {0, argv}; + assert (update ("UPDATE [foo]\n" + "SET\n" + "ver=ver+1,\n[a]=$1\n" + "WHERE [id]=$2", + "UPDATE [foo] SET ver=ver+1 WHERE [id]=$2", + b, 2)); + } + + // First not present. + // + { + void* b[] = {0, argv, argv, argv}; + assert (update ("UPDATE [foo]\n" + "SET\n" + "[a]=$1,\n" + "[b]=$2,\n" + "[c]=$3\n" + "WHERE [id]=$4", + "UPDATE [foo] SET [b]=$2, [c]=$3 WHERE [id]=$4", + b, 4)); + } + + // Last not present. + // + { + void* b[] = {argv, argv, 0, argv}; + assert (update ("UPDATE [foo]\n" + "SET\n" + "[a]=$1,\n" + "[b]=$2,\n" + "[c]=$3\n" + "WHERE [id]=$4", + "UPDATE [foo] SET [a]=$1, [b]=$2 WHERE [id]=$4", + b, 4)); + } + + // Middle not present. + // + { + void* b[] = {argv, 0, argv, argv}; + assert (update ("UPDATE [foo]\n" + "SET\n" + "[a]=$1,\n" + "[b]=$2,\n" + "[c]=$3\n" + "WHERE [id]=$4", + "UPDATE [foo] SET [a]=$1, [c]=$3 WHERE [id]=$4", + b, 4)); + } + + // Multiple not present. + // + { + void* b[] = {0, argv, 0, argv, argv}; + assert (update ("UPDATE [foo]\n" + "SET\n" + "[a]=$1,\n" + "[b]=$2,\n" + "[c]=$3,\n" + "[d]=$4\n" + "WHERE [id]=$5", + "UPDATE [foo] SET [b]=$2, [d]=$4 WHERE [id]=$5", + b, 5)); + } + + // Not present and OUTPUT. + // + { + void* b[] = {argv, 0, argv, argv}; + assert (update ("UPDATE [foo]\n" + "SET\n" + "[a]=$1,\n" + "[b]=$2,\n" + "[c]=$3\n" + "OUTPUT INSERTED.[ver] " + "WHERE [id]=$4", + "UPDATE [foo] SET [a]=$1, [c]=$3 OUTPUT INSERTED.[ver] " + "WHERE [id]=$4", + b, 4)); + } + + // Value expressions. + // + { + void* b[] = {argv, argv, argv, argv}; + assert (update ("UPDATE [foo]\n" + "SET\n" + "[a]=$1,\n" + "[b]=CAST($2, TEXT),\n" + "[c]=$3\n" + "WHERE [id]=$4", + "UPDATE [foo] SET [a]=$1, [b]=CAST($2, TEXT), [c]=$3 " + "WHERE [id]=$4", + b, 4)); + } + + // No OUTPUT/WHERE clause. + // + { + void* b[] = {argv, 0, argv}; + assert (update ("UPDATE [foo]\n" + "SET\n" + "[a]=$1,\n" + "[b]=$2,\n" + "[c]=$3", + "UPDATE [foo] SET [a]=$1, [c]=$3", + b, 4)); + } + + // + // SELECT + // + + // Empty. + // + { + void* b[] = {0, 0, 0}; + assert (select ("SELECT\n" + "[a].[x],\n" + "[t].[y],\n" + "[t].[z]\n" + "FROM [t]\n" + "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" + "WHERE [t].[id]=$1", + "", + b, 3)); + } + + // Fast path. + // + { + void* b[] = {argv, argv}; + assert (select ("SELECT\n" + "[s].[t].[x],\n" + "[a].[y]\n" + "FROM [s].[t]\n" + "LEFT JOIN [t1] AS [a] ON [a].[id]=[s].[t].[id]\n" + "WHERE [s].[t].[id]=$1", + "SELECT [s].[t].[x], [a].[y] FROM [s].[t] " + "LEFT JOIN [t1] AS [a] ON [a].[id]=[s].[t].[id] " + "WHERE [s].[t].[id]=$1", + b, 2)); + } + + // First not present. + // + { + void* b[] = {0, argv, argv}; + assert (select ("SELECT\n" + "[a].[x],\n" + "[t].[y],\n" + "[t].[z]\n" + "FROM [t]\n" + "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" + "WHERE [t].[id]=$1", + "SELECT [t].[y], [t].[z] FROM [t] WHERE [t].[id]=$1", + b, 3)); + } + + // Last not present. + // + { + void* b[] = {argv, argv, 0}; + assert (select ("SELECT\n" + "[t].[x],\n" + "[t].[y],\n" + "[a].[z]\n" + "FROM [t]\n" + "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" + "WHERE [t].[id]=$1", + "SELECT [t].[x], [t].[y] FROM [t] WHERE [t].[id]=$1", + b, 3)); + } + + // Middle not present. + // + { + void* b[] = {argv, 0, argv}; + assert (select ("SELECT\n" + "[t].[x],\n" + "[a].[y],\n" + "[t].[z]\n" + "FROM [t]\n" + "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" + "WHERE [t].[id]=$1", + "SELECT [t].[x], [t].[z] FROM [t] WHERE [t].[id]=$1", + b, 3)); + } + + // Multiple not present. + // + { + void* b[] = {0, argv, 0, argv}; + assert (select ("SELECT\n" + "[a1].[w],\n" + "[t].[x],\n" + "[a2].[y],\n" + "[a3].[z]\n" + "FROM [t]\n" + "LEFT JOIN [t1] AS [a1] ON [a1].[id]=[t].[id]\n" + "LEFT JOIN [t2] AS [a2] ON [a2].[id]=[t].[id]\n" + "LEFT JOIN [t3] AS [a3] ON [a3].[id]=[t].[id]\n" + "WHERE [t].[id]=$1", + "SELECT [t].[x], [a3].[z] FROM [t] " + "LEFT JOIN [t3] AS [a3] ON [a3].[id]=[t].[id] " + "WHERE [t].[id]=$1", + b, 4)); + } + + // Column expression. + // + { + void* b[] = {argv, argv, 0}; + assert (select ("SELECT\n" + "[t].[x],\n" + "CAST([a].[y], TEXT),\n" + "[t].[z]\n" + "FROM [t]\n" + "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" + "WHERE [t].[id]=$1", + "SELECT [t].[x], CAST([a].[y], TEXT) FROM [t] " + "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id] " + "WHERE [t].[id]=$1", + b, 3)); + } + + // No WHERE. + // + { + void* b[] = {argv, 0, argv}; + assert (select ("SELECT\n" + "[t].[x],\n" + "[t].[y],\n" + "[t].[z]\n" + "FROM [t]", + "SELECT [t].[x], [t].[z] FROM [t]", + b, 3)); + } + + // JOIN without WHERE. + // + { + void* b[] = {argv, 0, argv}; + assert (select ("SELECT\n" + "[t].[x],\n" + "[a].[y],\n" + "[t].[z]\n" + "FROM [t]\n" + "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]", + "SELECT [t].[x], [t].[z] FROM [t]", + b, 3)); + } + + // JOIN presence because of WHERE. + // + { + void* b[] = {argv, 0, argv}; + assert (select ("SELECT\n" + "[t].[x],\n" + "[a].[y],\n" + "[t].[z]\n" + "FROM [t]\n" + "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" + "WHERE [t].[id]=$1 AND [a].[id]=$2", + "SELECT [t].[x], [t].[z] FROM [t] " + "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id] " + "WHERE [t].[id]=$1 AND [a].[id]=$2", + b, 3)); + } + + + // JOIN presence because of dependent JOIN. + // + { + void* b[] = {argv, argv, argv}; + assert (select ("SELECT\n" + "[t].[x],\n" + "[a_b].[y],\n" + "[t].[z]\n" + "FROM [t]\n" + "LEFT JOIN [d] AS [a_d] ON [a_d].[id]=[t].[id]\n" + "LEFT JOIN [b] AS [a_b] ON [a_b].[id]=[a_d].[id]\n" + "WHERE [t].[id]=$1", + "SELECT [t].[x], [a_b].[y], [t].[z] FROM [t] " + "LEFT JOIN [d] AS [a_d] ON [a_d].[id]=[t].[id] " + "LEFT JOIN [b] AS [a_b] ON [a_b].[id]=[a_d].[id] " + "WHERE [t].[id]=$1", + b, 3)); + } + + // JOIN without alias and with schema. + // + { + void* b[] = {argv, argv, argv}; + assert (select ("SELECT\n" + "[t].[x],\n" + "[s].[t1].[y],\n" + "[t2].[z]\n" + "FROM [t]\n" + "LEFT JOIN [s].[t1] ON [s].[t1].[id]=[t].[id]\n" + "LEFT JOIN [t2] ON [t2].[id]=[t].[id]\n" + "WHERE [t].[id]=$1", + "SELECT [t].[x], [s].[t1].[y], [t2].[z] FROM [t] " + "LEFT JOIN [s].[t1] ON [s].[t1].[id]=[t].[id] " + "LEFT JOIN [t2] ON [t2].[id]=[t].[id] " + "WHERE [t].[id]=$1", + b, 3)); + } + + // JOIN alias top-level qualifer test. + // + { + void* b[] = {argv, 0}; + assert (select ("SELECT\n" + "[s].[a].[x],\n" + "[a].[y]\n" + "FROM [s].[a]\n" + "LEFT JOIN [t1] AS [a] ON [a].[id]=[s].[a].[id]\n" + "WHERE [s].[a].[id]=$1", + "SELECT [s].[a].[x] FROM [s].[a] WHERE [s].[a].[id]=$1", + b, 2)); + } + + // JOIN alias bottom-level qualifer test (FROM case). + // + { + void* b[] = {argv, 0}; + assert (select ("SELECT\n" + "[a].[t].[x],\n" + "[a].[y]\n" + "FROM [a].[t]\n" + "LEFT JOIN [t1] AS [a] ON [a].[id]=[a].[t].[id]\n" + "WHERE [a].[t].[id]=$1", + "SELECT [a].[t].[x] FROM [a].[t] WHERE [a].[t].[id]=$1", + b, 2)); + } + + // JOIN alias bottom-level qualifer test (LEFT JOIN case). + // + { + void* b[] = {0, argv}; + assert (select ("SELECT\n" + "[a].[y],\n" + "[a].[t2].[x]\n" + "FROM [t]\n" + "LEFT JOIN [t1] AS [a] ON [a].[id]=[t].[id]\n" + "LEFT JOIN [a].[t2] ON [a].[t2].[id]=[t].[id]\n" + "WHERE [t].[id]=$1", + "SELECT [a].[t2].[x] FROM [t] " + "LEFT JOIN [a].[t2] ON [a].[t2].[id]=[t].[id] " + "WHERE [t].[id]=$1", + b, 2)); + } +} diff --git a/odb-tests/common/statement/processing/testscript b/odb-tests/common/statement/processing/testscript new file mode 100644 index 0000000..2460dc6 --- /dev/null +++ b/odb-tests/common/statement/processing/testscript @@ -0,0 +1,6 @@ +# file : common/statement/processing/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +: basics +: +$* diff --git a/odb-tests/common/threads/buildfile b/odb-tests/common/threads/buildfile new file mode 100644 index 0000000..53b98ec --- /dev/null +++ b/odb-tests/common/threads/buildfile @@ -0,0 +1,49 @@ +# file : common/threads/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix threads_ \ + --generate-schema \ + --generate-query \ + --generate-prepared + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# While we don't call any pthread_*() functions, this appears to be needed for +# some std::thread implementations (like libstdc++). Note that +# odb::details::thread inlines some std::thread API calls. +# +if ($cxx.target.class != 'windows') + cxx.libs += -pthread + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/threads/driver.cxx b/odb-tests/common/threads/driver.cxx new file mode 100644 index 0000000..1add011 --- /dev/null +++ b/odb-tests/common/threads/driver.cxx @@ -0,0 +1,236 @@ +// file : common/threads/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test operations in a multi-threaded environment. +// + +#include +#include // std::unique_ptr +#include // std::size_t +#include + +#include +#include + +#include +#include + +#include // DATABASE_* +#include + +#if defined(DATABASE_SQLITE) +# include +#endif + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; +namespace details = odb::details; + +const unsigned long thread_count = 24; +const unsigned long iteration_count = 30; +const unsigned long sub_iteration_count = 40; + +struct task +{ + task (database& db, unsigned long n) + : db_ (db), n_ (n) + { + } + + void* + execute () + { + try + { + for (unsigned long i (0); i < iteration_count; ++i) + { + unsigned long id ((n_ * iteration_count + i) * 3); + + object o1 (id, "first object"); + object o2 (id + 1, "second object"); + object o3 (id + 2, "third object"); + + // The following transactions may lead to deadlocks. + // + while (true) + { + try + { + transaction t (db_.begin ()); + + db_.persist (o1); + db_.persist (o2); + db_.persist (o3); + t.commit (); + break; + } + catch (const deadlock&) {} + } + + while (true) + { + try + { +#if !defined(DATABASE_SQLITE) + transaction t (db_.begin ()); +#else + // SQLite has a peculiar table locking mode (shared cache) + // which can lead to any of the transactions in this test + // deadlocking even though they shouldn't from the user's + // perspective. One way to work around this problem is to + // start a "write" transaction as such right away. + // + transaction t; + + if (db_.id () != odb::id_sqlite) + t.reset (db_.begin ()); + else + { + t.reset ( + static_cast (db_).begin_immediate ()); + } +#endif + unique_ptr o (db_.load (id)); + assert (o->str_ == "first object"); + o->str_ = "another value"; + db_.update (*o); + t.commit (); + break; + } + catch (const deadlock&) {} + } + + for (unsigned long j (0); j < sub_iteration_count; ++j) + { + typedef odb::query query; + typedef odb::prepared_query prep_query; + typedef odb::result result; + + while (true) + { + try + { + transaction t (db_.begin ()); + + prep_query pq (db_.lookup_query ("object-query")); + + if (!pq) + { + pq = db_.prepare_query ( + "object-query", query::str == "another value"); + db_.cache_query (pq); + } + + result r (pq.execute (false)); + + bool found (false); + for (result::iterator i (r.begin ()); i != r.end (); ++i) + { + if (i->id_ == id) + { + found = true; + break; + } + } + assert (found); + t.commit (); + break; + } + catch (const deadlock&) {} + } + } + + while (true) + { + try + { + transaction t (db_.begin ()); + db_.erase (id); + t.commit (); + break; + } + catch (const deadlock&) {} + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return reinterpret_cast (1); + } + + return 0; + } + + static void* + execute (void* arg) + { + return static_cast (arg)->execute (); + } + + database& db_; + unsigned long n_; +}; + +bool +test (int argc, char* argv[], size_t max_connections) +{ + unique_ptr db (create_database (argc, argv, true, max_connections)); + + vector > threads; + vector > tasks; + + for (unsigned long i (0); i < thread_count; ++i) + { + details::shared_ptr t (new (details::shared) task (*db, i)); + tasks.push_back (t); + + threads.push_back ( + details::shared_ptr ( + new (details::shared) details::thread (&task::execute, t.get ()))); + } + + bool r (true); + + for (unsigned long i (0); i < thread_count; ++i) + if (threads[i]->join () != 0) + r = false; + + { + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query ()); + + for (result::iterator i (r.begin ()); i != r.end (); ++i) + db->erase (i->id_); + + t.commit (); + } + + return r; +} + +int +main (int argc, char* argv[]) +{ + try + { + if (!(test (argc, argv, 0) && + test (argc, argv, thread_count - 1) && + test (argc, argv, thread_count / 2) && + test (argc, argv, thread_count / 4))) + return 1; + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/threads/test.hxx b/odb-tests/common/threads/test.hxx new file mode 100644 index 0000000..2ed6e67 --- /dev/null +++ b/odb-tests/common/threads/test.hxx @@ -0,0 +1,29 @@ +// file : common/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object +struct object +{ + object (unsigned long id, const std::string& str) + : id_ (id), str_ (str) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; + + std::string str_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/threads/testscript b/odb-tests/common/threads/testscript new file mode 100644 index 0000000..87e03e0 --- /dev/null +++ b/odb-tests/common/threads/testscript @@ -0,0 +1,50 @@ +# file : common/threads/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + # Note: this is quite slow: + # + # $ time ./driver --database ~/odb-test.db + # real 3m5.593s + # user 1m1.244s + # sys 0m26.793s + # + # $ time ./driver --database /tmp/odb-test.db + # real 0m13.909s + # user 0m16.724s + # sys 0m4.874s + # + # $ time ./driver --database "file::memory:" + # real 0m12.406s + # user 0m15.694s + # sys 0m4.207s + # + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/transaction/basics/buildfile b/odb-tests/common/transaction/basics/buildfile new file mode 100644 index 0000000..f412235 --- /dev/null +++ b/odb-tests/common/transaction/basics/buildfile @@ -0,0 +1,13 @@ +# file : common/transaction/basics/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libs = libodb%lib{odb} +import libs += lib{common} + +exe{driver}: {hxx cxx}{*} $libs testscript + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/transaction/basics/driver.cxx b/odb-tests/common/transaction/basics/driver.cxx new file mode 100644 index 0000000..1833555 --- /dev/null +++ b/odb-tests/common/transaction/basics/driver.cxx @@ -0,0 +1,151 @@ +// file : common/transaction/basics/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test basic transaction operations. +// + +#include +#include // std::unique_ptr +#include + +#include +#include +#include +#include +#include + +#include +#include + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +struct transaction_tracer: odb::tracer +{ + virtual void + execute (connection&, const char* s) + { + string str (s); + + if (str == "BEGIN") + cout << "begin transaction" << endl; + else if (str == "COMMIT") + cout << "commit transaction" << endl; + else if (str == "ROLLBACK") + cout << "rollback transaction" << endl; + } + + // Override the other version to get rid of a Sun CC warning. + // + virtual void + execute (connection& c, const statement& s) + { + execute (c, s.text ()); + } +}; + +int +main (int argc, char* argv[]) +{ + { + transaction_tracer tracer; + unique_ptr db (create_database (argc, argv, false)); + db->tracer (tracer); + + assert (!transaction::has_current ()); + + // Current and db accessors. + // + cout << "test 001" << endl; + { + transaction t (db->begin ()); + assert (&t.database () == db.get ()); + assert (transaction::has_current ()); + assert (&transaction::current () == &t); + + transaction::reset_current (); + assert (!transaction::has_current ()); + + transaction t2 (db->begin (), false); + assert (!transaction::has_current ()); + + transaction::current (t2); + assert (&transaction::current () == &t2); + } + + // Commit. + // + cout << "test 002" << endl; + { + transaction t (db->begin ()); + t.commit (); + } + + // Rollback. + // + cout << "test 003" << endl; + { + transaction t (db->begin ()); + t.rollback (); + } + + // Auto rollback. + // + cout << "test 004" << endl; + { + transaction t (db->begin ()); + } + + // Nested transaction. + // + cout << "test 005" << endl; + { + transaction t (db->begin ()); + + try + { + transaction n (db->begin ()); + } + catch (const already_in_transaction&) + { + cout << "already_in_transaction" << endl; + } + } + + // Concrete transaction type. + // + cout << "test 006" << endl; + { + assert (sizeof (odb_db::transaction) == sizeof (transaction)); + + odb_db::transaction t (static_cast (*db).begin ()); + odb_db::transaction& r (odb_db::transaction::current ()); + assert (&t == &r); + } + + // Transaction restart. + // + cout << "test 007" << endl; + { + transaction t (db->begin ()); + t.commit (); + t.reset (db->begin ()); + t.commit (); + } + } + + // Test early connection release. + // + { + unique_ptr db (create_database (argc, argv, false, 1)); + transaction t1 (db->begin ()); + t1.commit (); + transaction t2 (db->begin ()); + t2.rollback (); + transaction t3 (db->begin ()); + t3.commit (); + } +} diff --git a/odb-tests/common/transaction/basics/testscript b/odb-tests/common/transaction/basics/testscript new file mode 100644 index 0000000..94c58b6 --- /dev/null +++ b/odb-tests/common/transaction/basics/testscript @@ -0,0 +1,62 @@ +# file : common/transaction/basics/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + ++cat <=output + test 001 + begin transaction + begin transaction + rollback transaction + rollback transaction + test 002 + begin transaction + commit transaction + test 003 + begin transaction + rollback transaction + test 004 + begin transaction + rollback transaction + test 005 + begin transaction + already_in_transaction + rollback transaction + test 006 + begin transaction + rollback transaction + test 007 + begin transaction + commit transaction + begin transaction + commit transaction + EOI + +test.redirects += >>>../output + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $* +} diff --git a/odb-tests/common/transaction/callback/buildfile b/odb-tests/common/transaction/callback/buildfile new file mode 100644 index 0000000..78b1b03 --- /dev/null +++ b/odb-tests/common/transaction/callback/buildfile @@ -0,0 +1,13 @@ +# file : common/transaction/callback/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libs = libodb%lib{odb} +import libs += lib{common} + +exe{driver}: {hxx cxx}{*} $libs testscript + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/transaction/callback/driver.cxx b/odb-tests/common/transaction/callback/driver.cxx new file mode 100644 index 0000000..d0af993 --- /dev/null +++ b/odb-tests/common/transaction/callback/driver.cxx @@ -0,0 +1,231 @@ +// file : common/transaction/callback/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test transaction callbacks. +// + +#include // std::unique_ptr +#include // std::size_t +#include + +#include +#include + +#include + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +struct callback +{ + callback (unsigned short v): v_ (v), t_ (0) {} + callback (unsigned short v, transaction& t): v_ (v), t_ (0) {register_ (t);} + ~callback () {if (t_ != 0) unregister ();} + + void + register_ (transaction& t) + { + t_ = &t; + t.callback_register (&func, this, transaction::event_all, v_, &t_); + } + + void + unregister () + { + cout << " unregister callback " << v_ << endl; + t_->callback_unregister (this); + t_ = 0; + } + + void + update (unsigned short v) + { + v_ = v; + t_->callback_update (this, transaction::event_all, v_, &t_); + } + +private: + static void + func (unsigned short event, void* key, unsigned long long data) + { + callback& c (*static_cast (key)); + + const char* en; + switch (event) + { + case transaction::event_commit: + en = "commit"; + break; + case transaction::event_rollback: + en = "rollback"; + break; + default: + en = "unknown"; + } + + cout << " callback " << c.v_ << " " << en << endl; + + assert (data == c.v_); + assert (c.t_ == 0); + } + + unsigned short v_; + transaction* t_; +}; + +struct failed {}; + +static void +throw_func (unsigned short, void*, unsigned long long) +{ + throw failed (); +} + +static void +dummy_func (unsigned short, void* key, unsigned long long data) +{ + assert (reinterpret_cast (key) == data); +} + +static void +fill (transaction& t) +{ + // 20 is from odb/transaction.hxx. + // + for (size_t i (0); i < 20; ++i) + t.callback_register (&dummy_func, + reinterpret_cast (i), + transaction::event_all, + i); +} + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv, false)); + + // We want to test both stack and dynamic slots. + // + for (unsigned short i (1); i < 3; ++i) + { + // Test basic logic. + // + cout << "test " << i << "/001" << endl; + + // Commit callback. + // + { + transaction t (db->begin ()); + if (i == 2) fill (t); + callback c1 (1, t); + t.commit (); + } + + // Rollback callback. + // + { + transaction t (db->begin ()); + if (i == 2) fill (t); + callback c1 (1, t); + t.rollback (); + } + + // Rollback via exception callback. + // + { + callback c1 (1); + + try + { + transaction t (db->begin ()); + if (i == 2) fill (t); + c1.register_ (t); + throw failed (); + } + catch (const failed&) + { + } + } + + // Unregister callback at the end. + // + { + transaction t (db->begin ()); + if (i == 2) fill (t); + callback c1 (1, t); + c1.unregister (); + t.callback_unregister (&c1); // Test unregistering non-registered key. + t.commit (); + } + + { + transaction t (db->begin ()); + if (i == 2) fill (t); + callback c1 (1, t); + c1.unregister (); + callback c2 (2, t); + t.commit (); + } + + // Unregister callback in the middle. + // + cout << "test " << i << "/002" << endl; + { + transaction t (db->begin ()); + if (i == 2) fill (t); + callback c1 (1, t); + callback c2 (2, t); + callback c3 (3, t); + c2.unregister (); + t.commit (); + } + + { + transaction t (db->begin ()); + if (i == 2) fill (t); + callback c1 (1, t); + callback c2 (2, t); + callback c3 (3, t); + c2.unregister (); + callback c4 (4, t); // Using the free slot. + t.commit (); + } + + // Test a callback in the middle that throws. + // + cout << "test " << i << "/003" << endl; + try + { + transaction t (db->begin ()); + if (i == 2) fill (t); + callback c1 (1, t); + t.callback_register (&throw_func, 0); + callback c2 (2, t); + t.commit (); + } + catch (const failed&) + { + } + + // Test callback_update(). + // + { + transaction t (db->begin ()); + if (i == 2) fill (t); + callback c (1, t); + c.update (2); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/transaction/callback/testscript b/odb-tests/common/transaction/callback/testscript new file mode 100644 index 0000000..7229ecd --- /dev/null +++ b/odb-tests/common/transaction/callback/testscript @@ -0,0 +1,72 @@ +# file : common/transaction/callback/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + ++cat <=output + test 1/001 + callback 1 commit + callback 1 rollback + callback 1 rollback + unregister callback 1 + unregister callback 1 + callback 2 commit + test 1/002 + unregister callback 2 + callback 1 commit + callback 3 commit + unregister callback 2 + callback 1 commit + callback 4 commit + callback 3 commit + test 1/003 + callback 1 commit + callback 2 commit + test 2/001 + callback 1 commit + callback 1 rollback + callback 1 rollback + unregister callback 1 + unregister callback 1 + callback 2 commit + test 2/002 + unregister callback 2 + callback 1 commit + callback 3 commit + unregister callback 2 + callback 1 commit + callback 4 commit + callback 3 commit + test 2/003 + callback 1 commit + callback 2 commit + EOI + +test.redirects += >>>../output + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $* +} diff --git a/odb-tests/common/types/buildfile b/odb-tests/common/types/buildfile new file mode 100644 index 0000000..95fe5b6 --- /dev/null +++ b/odb-tests/common/types/buildfile @@ -0,0 +1,39 @@ +# file : common/types/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix types_ + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/types/driver.cxx b/odb-tests/common/types/driver.cxx new file mode 100644 index 0000000..bdc66b8 --- /dev/null +++ b/odb-tests/common/types/driver.cxx @@ -0,0 +1,37 @@ +// file : common/types/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test C++ type handling (anonymous types, aliasing). +// + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +template +struct same_p +{ + static const bool result = false; +}; + +template +struct same_p +{ + static const bool result = true; +}; + +int +main () +{ + assert ((same_p::id_type, int>::result)); +} diff --git a/odb-tests/common/types/test.hxx b/odb-tests/common/types/test.hxx new file mode 100644 index 0000000..a99b499 --- /dev/null +++ b/odb-tests/common/types/test.hxx @@ -0,0 +1,55 @@ +// file : common/types/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#ifdef ODB_COMPILER +typedef int int_t; +typedef short num_t; +#else +typedef int num_t; +#endif + +typedef num_t num_type; + +#pragma db object +struct object1 +{ + typedef int int_type; + + #pragma db id + int_type id_; +}; + +#pragma db object +struct object2 +{ + #pragma db id + num_type num_; +}; + +// Template-id with "inner" name (compilation test). +// +template +struct num_wrap +{ +#ifdef ODB_COMPILER + typedef num_wrap this_type; // Name that we should not use. +#endif + + num_wrap () {} + num_wrap (X v): v_ (v) {} + operator X () const {return v_;} + + X v_; +}; + +#pragma db object +struct object3 +{ + #pragma db id type("INTEGER") + num_wrap num_; // Use long long to avoid warnings. +}; + +#endif // TEST_HXX diff --git a/odb-tests/common/types/testscript b/odb-tests/common/types/testscript new file mode 100644 index 0000000..159972b --- /dev/null +++ b/odb-tests/common/types/testscript @@ -0,0 +1,6 @@ +# file : common/types/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +: basic +: +$* diff --git a/odb-tests/common/view/basics/buildfile b/odb-tests/common/view/basics/buildfile new file mode 100644 index 0000000..d9738a4 --- /dev/null +++ b/odb-tests/common/view/basics/buildfile @@ -0,0 +1,42 @@ +# file : common/view/basics/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_view_b_ \ + --generate-schema \ + --generate-query \ + --generate-prepared + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/view/basics/driver.cxx b/odb-tests/common/view/basics/driver.cxx new file mode 100644 index 0000000..e2f611a --- /dev/null +++ b/odb-tests/common/view/basics/driver.cxx @@ -0,0 +1,846 @@ +// file : common/view/basics/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test view basics. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include +#include // DATABASE_XXX + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +template +void +view1_check (odb::result& r) +{ + typedef odb::result result; + + typename result::iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->first == "Jane" && i->last == "Doe" && i->age == 29); + + assert (++i != r.end ()); + V v; + i.load (v); + assert (v.first == "John" && v.last == "Doe" && v.age == 30); + + assert (++i == r.end ()); +} + +template +void +view2_test (const unique_ptr& db) +{ + typedef odb::query query; + typedef odb::result result; + typedef typename result::iterator iterator; + + transaction t (db->begin ()); + + { + result r (db->query ()); + iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->count == 4); + } + + { + result r; + if (db->id () != odb::id_oracle) + r = db->query ("age < 31"); + else + r = db->query ("\"age\" < 31"); + + iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->count == 2); + } + + { + result r (db->query (query::age < 31)); + iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->count == 2); + } + + { + unique_ptr v (db->query_one ()); + assert (v->count == 4); + } + + { + unique_ptr v; + if (db->id () != odb::id_oracle) + v.reset (db->query_one ("age < 31")); + else + v.reset (db->query_one ("\"age\" < 31")); + assert (v->count == 2); + } + + { + unique_ptr v (db->query_one (query::age < 31)); + assert (v->count == 2); + } + + t.commit (); +} + +template +void +view4_test (const unique_ptr& db) +{ + typedef odb::query query; + typedef odb::result result; + typedef typename result::iterator iterator; + + transaction t (db->begin ()); + + { + result r; + if (db->id () != odb::id_oracle) + r = db->query ((query::person::age > 30) + "ORDER BY age"); + else + r = db->query ((query::person::age > 30) + "ORDER BY \"age\""); + + iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->first_name == "Joe" && i->last_name == "Dirt" && + i->name == "United States"); + + assert (++i != r.end ()); + assert (i->first_name == "Johan" && i->last_name == "Johansen" && + i->name == "Sweden"); + + assert (++i == r.end ()); + } + + { + result r (db->query ( + (query::person::age > 30) + + "ORDER BY " + query::person::age)); + + iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->first_name == "Joe" && i->last_name == "Dirt" && + i->name == "United States"); + + assert (++i != r.end ()); + assert (i->first_name == "Johan" && i->last_name == "Johansen" && + i->name == "Sweden"); + + assert (++i == r.end ()); + } + + { + result r (db->query (query::residence::code == "US")); + + iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->first_name == "Joe" && i->last_name == "Dirt" && + i->name == "United States"); + + assert (++i == r.end ()); + } + + t.commit (); +} + +template +void +view6_test (const unique_ptr& db, const odb::query& q) +{ + typedef odb::result result; + typedef typename result::iterator iterator; + + transaction t (db->begin ()); + + { + result r (db->query (q)); + + iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->first_name == "John" && i->last_name == "Doe" && + i->employer == "Simple Tech, Inc"); + + assert (++i != r.end ()); + assert (i->first_name == "Joe" && i->last_name == "Dirt" && + i->employer == "Simple Tech, Inc"); + + assert (++i == r.end ()); + } + + t.commit (); +} + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // + // + { + country ca ("CA", "Canada"); + country za ("ZA", "South Africa"); + country us ("US", "United States"); + country se ("SE", "Sweden"); + + person p1 (1, "John", "Doe", 30, male, measures (60, 160), &ca, &ca); + person p2 (2, "Jane", "Doe", 29, female, measures (70, 170), &za, &us); + person p3 (3, "Joe", "Dirt", 31, male, measures (80, 180), &us, &za); + person p4 (4, "Johan", "Johansen", 32, male, measures (90, 190), &se, + &se); + + p2.husband = &p1; + + employer st ("Simple Tech, Inc"); + employer ct ("Complex Tech, Inc"); + + p2.previous_employer = st.name; + p3.previous_employer = ct.name; + + st.employees.push_back (&p1); + st.employees.push_back (&p3); + st.head_count = 2; + + ct.employees.push_back (&p2); + ct.employees.push_back (&p4); + ct.head_count = 2; + + transaction t (db->begin ()); + db->persist (ca); + db->persist (za); + db->persist (us); + db->persist (se); + + db->persist (p1); + db->persist (p2); + db->persist (p3); + db->persist (p4); + + db->persist (st); + db->persist (ct); + t.commit (); + } + + // view1 + // + { + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r (db->query ()); + assert (size (r) == 4); + } + + { + result r; + if (db->id () != odb::id_oracle) + r = db->query ("ORDER BY age"); + else + r = db->query ("ORDER BY \"age\""); + + assert (size (r) == 4); + } + + { + result r; + if (db->id () != odb::id_oracle) + r = db->query ("age < 31 ORDER BY age"); + else + r = db->query ("\"age\" < 31 ORDER BY \"age\""); + + view1_check (r); + } + + t.commit (); + } + } + + // view1a + // + { + typedef odb::result result; + + { + transaction t (db->begin ()); + + result r (db->query ()); + view1_check (r); + + t.commit (); + } + } + + // view1b + // + { + typedef odb::result result; + + { + transaction t (db->begin ()); + + result r (db->query ()); + view1_check (r); + + t.commit (); + } + + // No native parameter support in dynamic multi-database mode. + // +#ifndef MULTI_DATABASE + { + typedef odb::query query; + + transaction t (db->begin ()); + +#ifndef DATABASE_ORACLE + result r (db->query ("first = " + query::_val ("Jane"))); +#else + result r (db->query ("\"first\" = " + query::_val ("Jane"))); +#endif + + result::iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->first == "Jane" && i->last == "Doe"); + assert (++i == r.end ()); + + t.commit (); + } +#endif + } + + // view1c + // + { + typedef odb::result result; + + { + transaction t (db->begin ()); + + result r; + if (db->id () != odb::id_oracle) + r = db->query ("SELECT first, last, age " + "FROM t_view_b_person " + "WHERE age < 31 ORDER BY age"); + else + r = db->query ("SELECT \"first\", \"last\", \"age\" " + "FROM \"t_view_b_person\" " + "WHERE \"age\" < 31 ORDER BY \"age\""); + view1_check (r); + + t.commit (); + } + } + + // view1d + // + { + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r; + if (db->id () != odb::id_oracle) + r = db->query ("age < 31 ORDER BY age"); + else + r = db->query ("\"age\" < 31 ORDER BY \"age\""); + + view1_check (r); + } + + t.commit (); + } + } + + // view2 + // + view2_test (db); + view2_test (db); + view2_test (db); + view2_test (db); + + // view3 + // + { + typedef odb::result result; // Test const result. + + { + transaction t (db->begin ()); + + { + result r (db->query ()); + + size_t count (0); + for (result::iterator i (r.begin ()); i != r.end (); ++i) + { + if (i->last_name == "Doe") + assert (i->count == 2); + else if (i->last_name == "Dirt" || + i->last_name == "Johansen") + assert (i->count == 1); + else + assert (false); + + count++; + } + + assert (count == 3); + } + + t.commit (); + } + } + + // view3a + // + { + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r (db->query (query::last_name == "Doe")); + result::iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->last_name == "Doe" && i->count == 2); + assert (++i == r.end ()); + } + + t.commit (); + } + } + + // view4 + // + view4_test (db); + view4_test (db); + + // view5 + // + { + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r ( + db->query ( + query::residence::name == query::nationality::name)); + + result::iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->first_name == "John" && i->last_name == "Doe" && + i->rname == "Canada" && i->rname == "Canada"); + + assert (++i != r.end ()); + assert (i->first_name == "Johan" && i->last_name == "Johansen" && + i->rname == "Sweden" && i->rname == "Sweden"); + + assert (++i == r.end ()); + } + + t.commit (); + } + } + + // view6 + // + view6_test ( + db, odb::query::employer::name == "Simple Tech, Inc"); + + view6_test ( + db, odb::query::employer::name == "Simple Tech, Inc"); + + view6_test ( + db, odb::query::employer::name == "Simple Tech, Inc"); + + // No native parameter support in dynamic multi-database mode. + // +#ifndef MULTI_DATABASE + view6_test ( +#ifndef DATABASE_ORACLE + db, "e.name = " + odb::query::_val ("Simple Tech, Inc")); +#else + db, "\"e\".\"name\" = " + odb::query::_val ("Simple Tech, Inc")); +#endif +#endif + + // view7 + // + { + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r (db->query (query::person::last_name == "Doe")); + + result::iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->first_name == "Jane" && i->last_name == "Doe" && + !i->head_count.null () && *i->head_count == 2); + + assert (++i != r.end ()); + assert (i->first_name == "John" && i->last_name == "Doe" && + i->head_count.null ()); + + assert (++i == r.end ()); + } + + t.commit (); + } + } + + // view8 + // + { + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r (db->query ()); + + result::iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->wife_name == "Jane" && i->husb_name == "John"); + assert (++i == r.end ()); + } + + t.commit (); + } + } + + // view9 + // + { + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + // Test case-insensitive clause prefix detection. + // + result r (db->query ("where" + (query::gender == female))); + + result::iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->first_name == "Jane" && i->last_name == "Doe" && + i->gender == female); + assert (++i == r.end ()); + } + + t.commit (); + } + } + + // view10 + // + { + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r (db->query ( + query::measures.weight > 60 && + query::measures.hight < 190)); + + result::iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->last_name == "Doe" && + i->measures.weight == 70 && i->measures.hight == 170); + + assert (++i != r.end ()); + assert (i->last_name == "Dirt" && + i->measures.weight == 80 && i->measures.hight == 180); + + assert (++i == r.end ()); + } + + t.commit (); + } + } + + // view11 + // + { + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r (db->query ()); + + result::iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->last_name == "Doe" && i->hight == 170); + + assert (++i != r.end ()); + assert (i->last_name == "Dirt" && i->hight == 180); + + assert (++i == r.end ()); + } + + t.commit (); + } + } + + // view12 + // + { + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r (db->query (query::last_name == "Dirt")); + + result::iterator i (r.begin ()); + + assert (i != r.end ()); + assert (i->residence == "US"); + assert (++i == r.end ()); + } + + t.commit (); + } + } + + // view13 + // + { + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + { + result r (db->query ( + (query::person::age < 32) + + "ORDER BY" + query::employer::name)); + + assert (size (r) == 2); + } + + t.commit (); + } + } + + // view14 + // + { + transaction t (db->begin ()); + assert (size (db->query ()) == 2); + t.commit (); + } + + // Test join types. + // + { + using namespace test2; + + { + obj1 o11 (1, 1); + obj1 o12 (2, 2); + + obj2 o21 (1, 1); + obj2 o22 (2, 1); + obj2 o23 (3, 3); + + transaction t (db->begin ()); + db->persist (o11); + db->persist (o12); + db->persist (o21); + db->persist (o22); + db->persist (o23); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query ( + "ORDER BY" + query::o1::id1 + "," + query::o2::id2)); + result::iterator i (r.begin ()); + assert ( i != r.end () && i->id1 == 1 && *i->id2 == 1); + assert (++i != r.end () && i->id1 == 1 && *i->id2 == 2); + assert (++i != r.end () && i->id1 == 2 && i->id2.null ()); + assert (++i == r.end ()); + t.commit (); + } + + // @@ BUILD2 Also disable for DATABASE_MYSQL and DATABASE_PGSQL (see + // vright definition for details). + // +#if !defined(DATABASE_MYSQL) && \ + !defined(DATABASE_SQLITE) && \ + !defined(DATABASE_PGSQL) + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query ( + "ORDER BY" + query::o1::id1 + "," + query::o2::id2)); + result::iterator i (r.begin ()); + assert ( i != r.end () && i->id1 == 1 && *i->id2 == 1); + assert (++i != r.end () && i->id1 == 1 && *i->id2 == 2); + assert (++i != r.end () && i->id1 == 2 && i->id2.null ()); + assert (++i == r.end ()); + t.commit (); + } +#endif + + // @@ BUILD2 Also disable for DATABASE_PGSQL (see vfull definition for + // details). + // +#if !defined(DATABASE_MYSQL) && \ + !defined(DATABASE_SQLITE) && \ + !defined(DATABASE_PGSQL) + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query ( + "ORDER BY" + query::o1::id1 + "," + query::o2::id2)); + result::iterator i (r.begin ()); + + // SQL Server orders NULL values first. Got to be different. + // +#ifdef DATABASE_MSSQL + assert ( i != r.end () && i->id1.null () && *i->id2 == 3); + assert (++i != r.end () && *i->id1 == 1 && *i->id2 == 1); + assert (++i != r.end () && *i->id1 == 1 && *i->id2 == 2); + assert (++i != r.end () && *i->id1 == 2 && i->id2.null ()); +#else + assert ( i != r.end () && *i->id1 == 1 && *i->id2 == 1); + assert (++i != r.end () && *i->id1 == 1 && *i->id2 == 2); + assert (++i != r.end () && *i->id1 == 2 && i->id2.null ()); + assert (++i != r.end () && i->id1.null () && *i->id2 == 3); +#endif + assert (++i == r.end ()); + t.commit (); + } +#endif + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query ( + "ORDER BY" + query::o1::id1 + "," + query::o2::id2)); + result::iterator i (r.begin ()); + assert ( i != r.end () && i->id1 == 1 && i->id2 == 1); + assert (++i != r.end () && i->id1 == 1 && i->id2 == 2); + assert (++i == r.end ()); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query ( + "ORDER BY" + query::o1::id1 + "," + query::o2::id2)); + result::iterator i (r.begin ()); + assert ( i != r.end () && i->id1 == 1 && i->id2 == 1); + assert (++i != r.end () && i->id1 == 1 && i->id2 == 2); + assert (++i != r.end () && i->id1 == 1 && i->id2 == 3); + assert (++i != r.end () && i->id1 == 2 && i->id2 == 1); + assert (++i != r.end () && i->id1 == 2 && i->id2 == 2); + assert (++i != r.end () && i->id1 == 2 && i->id2 == 3); + assert (++i == r.end ()); + t.commit (); + } + + // Inner JOIN via relationship/container. + // + { + obj3 o31 (1, 1); + obj3 o32 (2, 2); + + obj4 o41 (1, 1); + obj4 o42 (2, 2); + o42.o3.push_back (&o32); + + transaction t (db->begin ()); + db->persist (o31); + db->persist (o32); + db->persist (o41); + db->persist (o42); + t.commit (); + } + + { + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query ()); + result::iterator i (r.begin ()); + assert ( i != r.end () && i->id4 == 2); + assert (++i == r.end ()); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/view/basics/test.hxx b/odb-tests/common/view/basics/test.hxx new file mode 100644 index 0000000..130bcd4 --- /dev/null +++ b/odb-tests/common/view/basics/test.hxx @@ -0,0 +1,640 @@ +// file : common/view/basics/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include // std::size_t + +#include +#include + +struct employer; + +#pragma db object +struct country +{ + country (const std::string& c, const std::string& n) + : code (c), name (n) + { + } + + country () + { + } + + #pragma db id + std::string code; // ISO 2-letter country code. + + std::string name; +}; + +enum gender_type {male, female}; + +#pragma db value +struct measures +{ + measures (unsigned short w, unsigned short h) : weight (w), hight (h) {} + measures () {} + + unsigned short weight; + unsigned short hight; +}; + +#pragma db object +struct person +{ + typedef ::measures measures_type; + + person (unsigned long i, + const std::string& fn, + const std::string& ln, + unsigned short a, + gender_type g, + const measures_type m, + country* r, + country* n) + : id (i), + first_name_ (fn), + last_name_ (ln), + age (a), + gender (g), + measures (m), + residence (r), + nationality (n), + husband (0) + { + } + + person () + { + } + + #pragma db id + unsigned long id; + + #pragma db column("first") + std::string first_name_; + + #pragma db column("last") + std::string last_name_; + + unsigned short age; + + // #pragma db type("INT") - in MySQL test type pragma copying + gender_type gender; + + measures_type measures; + + #pragma db not_null + country* residence; + + #pragma db not_null + country* nationality; + + #pragma db inverse(employees) + employer* employed_by; + + // A non-pointer relationship. + // + odb::nullable previous_employer; + + person* husband; // Self-reference. +}; + +#pragma db object +struct employer +{ + employer (const std::string& n) + : name (n) + { + } + + employer () + { + } + + #pragma db id + std::string name; + unsigned int head_count; + std::vector employees; +}; + +// +// General view with no associated objects. +// + +// Complete suffix query template. +// +#ifndef ODB_DATABASE_ORACLE +# pragma db view query("SELECT first, last, age FROM t_view_b_person") +#else +# pragma db view query("SELECT \"first\", \"last\", \"age\" " \ + "FROM \"t_view_b_person\"") +#endif +struct view1 +{ + std::string first; + std::string last; + unsigned short age; +}; + +// Complete query. +// +#ifndef ODB_DATABASE_ORACLE +# pragma db view query("SELECT first, last, age " \ + "FROM t_view_b_person " \ + "WHERE age < 31 ORDER BY age") +#else +# pragma db view query("SELECT \"first\", \"last\", \"age\" " \ + "FROM \"t_view_b_person\" " \ + "WHERE \"age\" < 31 ORDER BY \"age\"") +#endif +struct view1a +{ + std::string first; + std::string last; + unsigned short age; +}; + +// Complete placeholder query template. +// +#ifndef ODB_DATABASE_ORACLE +# pragma db view query("SELECT first, last, age " \ + "FROM t_view_b_person " \ + "WHERE age < 31 AND (?) ORDER BY age") +#else +# pragma db view query("SELECT \"first\", \"last\", \"age\" " \ + "FROM \"t_view_b_person\" " \ + "WHERE \"age\" < 31 AND (?) ORDER BY \"age\"") +#endif +struct view1b +{ + std::string first; + std::string last; + unsigned short age; +}; + +// Runtime query. +// +#pragma db view //query() +struct view1c +{ + std::string first; + std::string last; + unsigned short age; +}; + +// Assembled SELECT and FROM-lists. +// +#pragma db view table("t_view_b_person") +struct view1d +{ + #pragma db column("first") + std::string first; + + #pragma db column("last") + std::string last; + + #pragma db column("age") + unsigned short age; +}; + +// +// Count view plus associated object. +// + +// Complete suffix query. +// +#ifndef ODB_DATABASE_ORACLE +# pragma db view object(person) \ + query("SELECT count(id) FROM t_view_b_person") +#else +# pragma db view object(person) \ + query("SELECT count(\"id\") FROM \"t_view_b_person\"") +#endif +struct view2 +{ + std::size_t count; +}; + +// Generated query, literal column. +// +#pragma db view object(person) +struct view2a +{ +#ifndef ODB_DATABASE_ORACLE + #pragma db column("count(id)") +#else + #pragma db column("count(\"id\")") +#endif + std::size_t count; +}; + +// Generated query, qualified literal column. +// +#pragma db view object(person) +struct view2b +{ +#ifndef ODB_DATABASE_ORACLE + #pragma db column("count(t_view_b_person.id)") +#else + #pragma db column("count(\"t_view_b_person\".\"id\")") +#endif + std::size_t count; +}; + +// Generated query, expression column. +// +#pragma db view object(person) +struct view2c +{ + #pragma db column("count(" + person::id + ")") + std::size_t count; +}; + +// +// Aggregate view plus associated object with a custom alias. +// + +// Complete suffix query. +// +#ifndef ODB_DATABASE_ORACLE +# pragma db view object(person = test) \ + query("SELECT last, count(last) " \ + "FROM t_view_b_person " \ + "GROUP BY last") +#else +# pragma db view object(person = test) \ + query("SELECT \"last\", count(\"last\") " \ + "FROM \"t_view_b_person\" " \ + "GROUP BY \"last\"") +#endif +struct view3 +{ + std::string last_name; + std::size_t count; +}; + +// Generated query with integrated query condition and placeholder. +// +#pragma db view object(person = test) \ + query((?) + "GROUP BY" + test::last_name_) +struct view3a +{ + // Automatically resolved to test::last_name_. + // + std::string last_name; + + #pragma db column("count(" + test::last_name_ + ")") + std::size_t count; +}; + +// +// JOIN view plus associated objects, some with custom aliases. +// + +// Complete suffix query. +// +#ifndef ODB_DATABASE_ORACLE +# pragma db view object(person) object(country = residence) \ + query("SELECT first, last, residence.name " \ + "FROM t_view_b_person " \ + "LEFT JOIN t_view_b_country AS residence " \ + "ON t_view_b_person.residence = residence.code") +#else +# pragma db view object(person) object(country = residence) \ + query("SELECT \"first\", \"last\", \"residence\".\"name\" " \ + "FROM \"t_view_b_person\" " \ + "LEFT JOIN \"t_view_b_country\" \"residence\" " \ + "ON \"t_view_b_person\".\"residence\" = \"residence\".\"code\"") +#endif +struct view4 +{ + std::string first_name; + std::string last_name; + std::string name; +}; + +// Generated query. +// +#pragma db view object(person) \ + object(country = residence: person::residence) +struct view4a +{ + std::string first_name; + std::string last_name; + std::string name; +}; + +// +// JOIN the same object twice. +// +#pragma db view object(person) \ + object(country = residence: person::residence) \ + object(country = nationality: person::nationality) \ + query((?) + "ORDER BY" + person::age) +struct view5 +{ + std::string first_name; + std::string last_name; + + #pragma db column(residence::name) + std::string rname; + + #pragma db column(nationality::name) + std::string nname; +}; + +// +// JOIN via one(i)-to-many relationship. +// + +// Automatic relationship discovery. +// +#pragma db view object(person) object(employer) +struct view6 +{ + std::string first_name; + std::string last_name; + + #pragma db column(::employer::name) + std::string employer; +}; + +// Manual relationship specification, left side. +// +#pragma db view object(person) object(employer: person::employed_by) +struct view6a +{ + std::string first_name; + std::string last_name; + + #pragma db column(::employer::name) + std::string employer; +}; + +// Manual relationship specification, right side. +// +#pragma db view object(person) object(employer: employer::employees) +struct view6b +{ + std::string first_name; + std::string last_name; + + #pragma db column(::employer::name) + std::string employer; +}; + +// The same using tables. +// +#if defined(ODB_DATABASE_ORACLE) +#pragma db view table("t_view_b_person" = "p") \ + table("t_view_b_employer_employees" = "ee": "\"ee\".\"value\" = \"p\".\"id\"")\ + table("t_view_b_employer" = "e": "\"ee\".\"object_id\" = \"e\".\"name\"") +#elif defined(ODB_DATABASE_MSSQL) +#pragma db view table("t_view_b_person" = "p") \ + table("t_view_b_employer_employees" = "ee": "ee.value = p.id") \ + table("t_view_b_employer" = "e": "[ee].[object_id] = e.name") +#elif defined(ODB_DATABASE_MYSQL) +#pragma db view table("t_view_b_person" = "p") \ + table("t_view_b_employer_employees" = "ee": "ee.value = p.id") \ + table("t_view_b_employer" = "e": "`ee`.`object_id` = e.name") +#else +#pragma db view table("t_view_b_person" = "p") \ + table("t_view_b_employer_employees" = "ee": "ee.value = p.id") \ + table("t_view_b_employer" = "e": "\"ee\".\"object_id\" = e.name") +#endif +struct view6c +{ + #pragma db column("p.first") + std::string first_name; + + #pragma db column("p.last") + std::string last_name; + + #pragma db column("e"."name") + std::string employer; +}; + +// +// JOIN via a custom condition. +// +#pragma db view object(person) \ + object(employer: person::previous_employer == employer::name)\ + query((?) + "ORDER BY" + person::age) +struct view7 +{ + std::string first_name; + std::string last_name; + + odb::nullable head_count; +}; + +// +// Self-JOIN. +// +#pragma db view object(person = wife) object(person = husb) \ + query (wife::husband.is_not_null ()) +struct view8 +{ + #pragma db column(wife::first_name_) + std::string wife_name; + + #pragma db column(husb::first_name_) + std::string husb_name; +}; + +// +// Enum mapping. +// +#pragma db view object(person) +struct view9 +{ + std::string first_name; + std::string last_name; + gender_type gender; +}; + +// +// Composite in view. +// +#pragma db view object(person) query((?) + "ORDER BY" + person::age) +struct view10 +{ + std::string last_name; + ::measures measures; +}; + +// +// Composite in object. +// +#pragma db view object(person) \ + query((person::measures.weight > 60 && person::measures.hight < 190 && (?)) \ + + "ORDER BY" + person::age) +struct view11 +{ + std::string last_name; + + #pragma db column(person::measures.hight) + unsigned short hight; +}; + +// +// Extract object pointer as object id. +// +#pragma db view object(person) +struct view12 +{ + std::string residence; +}; + +// +// Test 'distinct' result modifier. +// +#pragma db view object(employer) object(person) query(distinct) +struct view13 +{ + std::string name; +}; + +// +// Test 'for_update' result modifier. +// +#pragma db view object(employer) query((?), for_update) +struct view14 +{ + std::string name; +}; + +// Test join types. +// +#pragma db namespace table("t2_") +namespace test2 +{ + #pragma db object + struct obj1 + { + obj1 (int id = 0, int n_ = 0): id1 (id), n (n_) {} + + #pragma db id + int id1; + + int n; + }; + + #pragma db object no_id + struct obj2 + { + obj2 (int id = 0, int n_ = 0): id2 (id), n (n_) {} + + #pragma db id + int id2; + + int n; + }; + + #pragma db view object(obj1 = o1) object(obj2 = o2 left: o1::n == o2::n) + struct vleft + { + int id1; + odb::nullable id2; + }; + + // @@ BUILD2 Also disable for ODB_DATABASE_MYSQL and ODB_DATABASE_PGSQL, + // otherwise we end up with the following error: + // + // test-odb-mysql.hxx:3202:20: error: invalid use of incomplete type ‘class odb::access::view_traits’ + // 3202 | public access::view_traits< ::test2::vright > + // | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // +//#if !defined(ODB_DATABASE_SQLITE) && !defined(ODB_DATABASE_COMMON) +#if !defined(ODB_DATABASE_MYSQL) && \ + !defined(ODB_DATABASE_SQLITE) && \ + !defined(ODB_DATABASE_PGSQL) && \ + !defined(ODB_DATABASE_COMMON) + + #pragma db view object(obj2 = o2) object(obj1 = o1 right: o2::n == o1::n) + struct vright + { + int id1; + odb::nullable id2; + }; + +#endif + + // @@ BUILD2 Also disable for ODB_DATABASE_PGSQL, otherwise we end up with the + // following error: + // + // test-odb-pgsql.hxx:3325:20: error: invalid use of incomplete type ‘class odb::access::view_traits’ + // 3325 | public access::view_traits< ::test2::vfull > + // | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // +/* +#if !defined(ODB_DATABASE_MYSQL) && \ + !defined(ODB_DATABASE_SQLITE) && \ + !defined(ODB_DATABASE_COMMON) +*/ +#if !defined(ODB_DATABASE_MYSQL) && \ + !defined(ODB_DATABASE_SQLITE) && \ + !defined(ODB_DATABASE_PGSQL) && \ + !defined(ODB_DATABASE_COMMON) + + #pragma db view object(obj1 = o1) object(obj2 = o2 full: o1::n == o2::n) + struct vfull + { + odb::nullable id1; + odb::nullable id2; + }; + +#endif + + #pragma db view object(obj1 = o1) object(obj2 = o2 inner: o1::n == o2::n) + struct vinner + { + int id1; + int id2; + }; + + #pragma db view object(obj1 = o1) object(obj2 = o2 cross) + struct vcross + { + int id1; + int id2; + }; + + // Inner JOIN via relationship/container. + // + #pragma db object + struct obj3 + { + obj3 (int id = 0, int n_ = 0): id3 (id), n (n_) {} + + #pragma db id + int id3; + + int n; + }; + + #pragma db object no_id + struct obj4 + { + obj4 (int id = 0, int n_ = 0): id4 (id), n (n_) {} + + #pragma db id + int id4; + + int n; + std::vector o3; + }; + + #pragma db view object(obj4) object(obj3 inner) + struct vrel + { + int id4; + }; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/view/basics/testscript b/odb-tests/common/view/basics/testscript new file mode 100644 index 0000000..faa8408 --- /dev/null +++ b/odb-tests/common/view/basics/testscript @@ -0,0 +1,33 @@ +# file : common/view/basics/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/view/olv/.gitignore b/odb-tests/common/view/olv/.gitignore new file mode 100644 index 0000000..2b95165 --- /dev/null +++ b/odb-tests/common/view/olv/.gitignore @@ -0,0 +1,46 @@ +# ODB-generated files. +# +test1-odb.?xx +test1-odb-*.?xx +test1.sql +test1-*.sql + +test2-odb.?xx +test2-odb-*.?xx +test2.sql +test2-*.sql + +test3-odb.?xx +test3-odb-*.?xx +test3.sql +test3-*.sql + +test4-odb.?xx +test4-odb-*.?xx +test4.sql +test4-*.sql + +test5-odb.?xx +test5-odb-*.?xx +test5.sql +test5-*.sql + +test6-odb.?xx +test6-odb-*.?xx +test6.sql +test6-*.sql + +test7-odb.?xx +test7-odb-*.?xx +test7.sql +test7-*.sql + +test8-odb.?xx +test8-odb-*.?xx +test8.sql +test8-*.sql + +test9-odb.?xx +test9-odb-*.?xx +test9.sql +test9-*.sql diff --git a/odb-tests/common/view/olv/buildfile b/odb-tests/common/view/olv/buildfile new file mode 100644 index 0000000..89ecbcf --- /dev/null +++ b/odb-tests/common/view/olv/buildfile @@ -0,0 +1,50 @@ +# file : common/view/olv/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +hs = test1 test2 test3 test4 test5 test6 test7 test8 test9 + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +for h: $hs +{ + exe{driver}: {hxx ixx cxx}{$h-odb} + + <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} + + for db: $databases + { + exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi + <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} + } +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_view_olv_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc + +testscript@./: schemas = $hs diff --git a/odb-tests/common/view/olv/driver.cxx b/odb-tests/common/view/olv/driver.cxx new file mode 100644 index 0000000..c08015e --- /dev/null +++ b/odb-tests/common/view/olv/driver.cxx @@ -0,0 +1,654 @@ +// file : common/view/olv/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test object loading views. +// + +#include // std::unique_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test1.hxx" +#include "test2.hxx" +#include "test3.hxx" +#include "test4.hxx" +#include "test5.hxx" +#include "test6.hxx" +#include "test7.hxx" +#include "test8.hxx" +#include "test9.hxx" + +#include "test1-odb.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" +#include "test4-odb.hxx" +#include "test5-odb.hxx" +#include "test6-odb.hxx" +#include "test7-odb.hxx" +#include "test8-odb.hxx" +#include "test9-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test basic object loading functionality. + // + { + using namespace test1; + + { + object1 o1a (1, 123); + object2 o2 (1, "abc"); + + transaction t (db->begin ()); + db->persist (o1a); + db->persist (o2); + t.commit (); + } + + { + typedef odb::query query; + + transaction t (db->begin ()); + view1 v (db->query_value (query::object1::n == 123)); + assert (v.o2->s == "abc"); + t.commit (); + } + + { + transaction t (db->begin ()); + view2 v (db->query_value ()); + assert (v.o1->n == 123 && v.o2->s == "abc"); + t.commit (); + } + + { + transaction t (db->begin ()); + view3 v (db->query_value ()); + assert (v.o1->n == 123 && v.o2->s == "abc"); + t.commit (); + } + + { + transaction t (db->begin ()); + view4 v (db->query_value ()); + assert (v.s == "abc" && v.o2->s == "abc" && v.id == 1 && + v.o1->n == 123 && v.n == 123); + t.commit (); + } + + { + transaction t (db->begin ()); + view4 v (db->query_value ()); + assert (v.s == "abc" && v.o2->s == "abc" && v.id == 1 && + v.o1->n == 123 && v.n == 123); + t.commit (); + } + + { + typedef odb::query query; + + object1 o1b (123, 1); + + transaction t (db->begin ()); + db->persist (o1b); + view5 v (db->query_value (query::o1b::n == 1)); + assert (v.o1a->n == 123 && v.o2->s == "abc" && v.o1b->n == 1); + t.commit (); + } + } + + // Test loading of object pointers inside objects. + // + { + using namespace test2; + + shared_ptr o1 (new object1 (123)); + shared_ptr o2 (new object2 ("abc", o1)); + + { + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + view1 v (db->query_value ()); + assert (v.o2->s == "abc" && v.o2->o1->n == 123); + t.commit (); + } + + { + // Check session interaction. + // + transaction t (db->begin ()); + session s; + shared_ptr o2a (db->load (o2->id)); + view1 v (db->query_value ()); + assert (v.o2 == o2a); + t.commit (); + } + + { + transaction t (db->begin ()); + session s; + view2 v (db->query_value ()); + assert (v.o1->n == 123 && v.o2->s == "abc" && v.o2->o1 == v.o1); + t.commit (); + } + + shared_ptr o3 (new object3 (o2)); + + { + transaction t (db->begin ()); + db->persist (o3); + t.commit (); + } + + { + transaction t (db->begin ()); + session s; + view3 v (db->query_value ()); + assert (v.o1->n == 123 && v.o3->o2->s == "abc" && + v.o3->o2->o1 == v.o1); + t.commit (); + } + + shared_ptr o1b (new object1 (234)); + shared_ptr o2b (new object2 ("bcd", o1b)); + shared_ptr o4 (new object4); + o4->o2.push_back (o2); + o4->o2.push_back (o2b); + + { + transaction t (db->begin ()); + db->persist (o1b); + db->persist (o2b); + db->persist (o4); + t.commit (); + } + + { + transaction t (db->begin ()); + view4 v (db->query_value ()); + assert (v.o4->o2[0]->s == "abc" && v.o4->o2[0]->o1->n == 123 && + v.o4->o2[1]->s == "bcd" && v.o4->o2[1]->o1->n == 234); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + session s; + result r (db->query ("ORDER BY" + query::object1::id)); + result::iterator i (r.begin ()); + + assert (i != r.end ()); + { + const view5& v (*i); + + assert (v.o4->o2[0]->s == "abc" && v.o4->o2[0]->o1->n == 123 && + v.o4->o2[1]->s == "bcd" && v.o4->o2[1]->o1->n == 234 && + v.o4->o2[0]->o1 == v.o1); + } + assert (++i != r.end ()); + { + const view5& v (*i); + + assert (v.o4->o2[0]->s == "abc" && v.o4->o2[0]->o1->n == 123 && + v.o4->o2[1]->s == "bcd" && v.o4->o2[1]->o1->n == 234 && + v.o4->o2[1]->o1 == v.o1); + } + assert (++i == r.end ()); + t.commit (); + } + + shared_ptr o5 (new object5 (o1b, o2)); + + { + transaction t (db->begin ()); + db->persist (o5); + t.commit (); + } + + { + transaction t (db->begin ()); + view6 v (db->query_value ()); + assert (v.o1a->n == 123 && v.o1b->n == 234); + t.commit (); + } + } + + // Test JOINs for pointed-to objects, existing and automatically added. + // + { + using namespace test3; + + shared_ptr o1 (new object1 (123)); + shared_ptr o2 (new object2 ("abc")); + + o1->o2 = o2; + o2->o1 = o1; + + { + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + view1a v (db->query_value ()); + // VC11 + assert (v.o1->n == 123 && v.o1->o2.object_id () == o2->id); + t.commit (); + } + + { + transaction t (db->begin ()); + view1b v (db->query_value ()); + // VC11 + assert (v.o1->n == 123 && v.o1->o2.object_id () == o2->id); + t.commit (); + } + + // Container case. + // + + shared_ptr o3 (new object3 (123)); + shared_ptr o4 (new object4 ("abc")); + + o3->o4 = o4; + o4->o3.push_back (o3); + + { + + transaction t (db->begin ()); + db->persist (o3); + db->persist (o4); + t.commit (); + } + + { + transaction t (db->begin ()); + view2a v (db->query_value ()); + // VC11 + assert (v.o3->n == 123 && v.o3->o4.object_id () == o4->id); + t.commit (); + } + + { + transaction t (db->begin ()); + view2b v (db->query_value ()); + // VC11 + assert (v.o3->n == 123 && v.o3->o4.object_id () == o4->id); + t.commit (); + } + } + + // Test by-value load. + // + { + using namespace test4; + + { + object1 o1 (1, 123); + object2 o2 (1, "abc", &o1); + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + view1 v (db->query_value ()); + assert (v.o1.n == 123); + t.commit (); + } + + { + transaction t (db->begin ()); + view1a v (db->query_value ()); + assert (!v.o1_null && v.o1.n == 123); + t.commit (); + } + + { + transaction t (db->begin ()); + view1b v (db->query_value ()); + assert (/*v.o1_p == &v.o1 && */ v.o1.n == 123); // Copy ctor. + t.commit (); + } + + { + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query ()); + result::iterator i (r.begin ()); + assert (i != r.end ()); + + object1 o1; + view1c v (o1); + i.load (v); + + assert (v.o1_p == &o1 && o1.n == 123); + + assert (++i == r.end ()); + t.commit (); + } + + { + transaction t (db->begin ()); + session s; + view2 v (db->query_value ()); + + // @@ BUILD2 As of cl 19.29.30136 (VS 2019 16.11.5) v.o2.o1 points to + // the address of o1 member of the object being returned by + // query_value() which v is a copy of, and thus the + // original assertion fails. Note that changing `view2 v` to + // `const view2& v` doesn't help. + // + //assert (v.o1.n == 123 && v.o2.s == "abc" && v.o2.o1 == &v.o1); + assert (v.o1.n == 123 && v.o2.s == "abc"); + t.commit (); + } + + object1 o1b (2, 234); + + { + transaction t (db->begin ()); + db->persist (o1b); + t.commit (); + } + + { + typedef odb::query query; + + transaction t (db->begin ()); + session s; + view2a v (db->query_value (query::object1::id == 2)); + assert (v.o1.n == 234 && v.o2_null); + t.commit (); + } + + shared_ptr o3 (new object3 (1, 123)); + + { + transaction t (db->begin ()); + db->persist (o3); + t.commit (); + } + + { + transaction t (db->begin ()); + { + view3 v (db->query_value ()); + assert (v.o3_p == &v.o3 && v.o3.n == 123); // Load into value. + } + session s; // Load into cache. + shared_ptr o3a (db->load (o3->id)); + { + view3 v (db->query_value ()); + assert (v.o3_p == o3a.get ()); // Load from cache. + } + t.commit (); + } + } + + // Test NULL object pointers. + // + { + using namespace test5; + + shared_ptr o1a (new object1 (123)); + shared_ptr o1b (new object1 (234)); + shared_ptr o2 (new object2 ("abc", o1a)); + + { + transaction t (db->begin ()); + db->persist (o1a); + db->persist (o1b); + db->persist (o2); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + session s; + result r (db->query ("ORDER BY" + query::object1::id)); + result::iterator i (r.begin ()); + + assert (i != r.end ()); + { + const view1& v (*i); + assert (v.o1->n == 123 && v.o2->s == "abc" && v.o2->o1 == v.o1); + } + assert (++i != r.end ()); + { + const view1& v (*i); + assert (v.o1->n == 234 && !v.o2); + } + assert (++i == r.end ()); + t.commit (); + } + + shared_ptr o3a (new object3 (make_pair (1, 1), 123)); + shared_ptr o3b (new object3 (make_pair (2, 2), 234)); + shared_ptr o4 (new object4 ("abc", o3a)); + + { + transaction t (db->begin ()); + db->persist (o3a); + db->persist (o3b); + db->persist (o4); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + session s; + result r (db->query ("ORDER BY" + query::object3::n)); + result::iterator i (r.begin ()); + + assert (i != r.end ()); + { + const view2& v (*i); + assert (v.o3->n == 123 && v.o4->s == "abc" && v.o4->o3 == v.o3); + } + assert (++i != r.end ()); + { + const view2& v (*i); + assert (v.o3->n == 234 && !v.o4); + } + assert (++i == r.end ()); + t.commit (); + } + } + + // Test interaction with sections. + // + { + using namespace test6; + + shared_ptr o1 (new object1 (123)); + shared_ptr o2 (new object2 ("abc", o1)); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + view1 v (db->query_value ()); + + assert (v.o1->n == 123 && v.o2->s == "abc" && + !v.o2->r.loaded () && !v.o2->o1); + + db->load (*v.o2, v.o2->r); + assert (v.o2->r.loaded () && v.o2->o1 && v.o2->o1->n == 123); + + t.commit (); + } + } + + // Test explicit conversion to smart pointer member. + // + { + using namespace test7; + + object1 o1 (123); + object2 o2 ("abc", &o1); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + session s; + view1 v (db->query_value ()); + assert (v.o1->n == 123 && v.o2->s == "abc" && v.o2->o1 == v.o1.get ()); + t.commit (); + } + } + + // Test loading objects without id. + // + { + using namespace test8; + + object1 o1 (123); + object2 o2 ("abc", &o1); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + session s; + view1 v (db->query_value ()); + assert (v.o1->n == 123 && v.o2->s == "abc" && v.o2->o1 == v.o1.get ()); + t.commit (); + } + } + + // Test loading polymorphic objects. + // + { + using namespace test9; + + root r (1); + base b (2, "a"); + derived d (3, "b", true); + + { + transaction t (db->begin ()); + db->persist (r); + db->persist (b); + db->persist (d); + t.commit (); + } + + { + transaction t (db->begin ()); + + // Load via root. + // + { + view1r r (db->query_value (query::n == 1)); + auto& o (*r.o); + assert (r.n == 1 && r.o->n == 1 && typeid (o) == typeid (root)); + } + + { + view1r r (db->query_value (query::n == 2)); + auto& o (*r.o); + assert (r.n == 2 && r.o->n == 2 && typeid (o) == typeid (base)); + base& b (dynamic_cast (*r.o)); + assert (b.s == "a"); + } + + { + view1r r (db->query_value (query::n == 3)); + auto& o (*r.o); + assert (r.n == 3 && r.o->n == 3 && typeid (o) == typeid (derived)); + derived& d (dynamic_cast (o)); + assert (d.s == "b" && d.b); + } + + // Load via base. + // + { + view1b r (db->query_value (query::n == 2)); + assert (r.s == "a" && r.n == 2 && r.o->n == 2 && b.s == "a"); + } + + { + view1b r (db->query_value (query::n == 3)); + auto& o (*r.o); + assert (r.s == "b" && r.n == 3 && r.o->n == 3 && + typeid (o) == typeid (derived)); + derived& d (dynamic_cast (o)); + assert (d.s == "b" && d.b); + } + + // Load via derived. + // + { + view1d r (db->query_value ()); + assert (r.s == "b" && r.n == 3 && + r.o->n == 3 && r.o->s == "b" && r.o->b); + } + + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/view/olv/test1.hxx b/odb-tests/common/view/olv/test1.hxx new file mode 100644 index 0000000..0de9483 --- /dev/null +++ b/odb-tests/common/view/olv/test1.hxx @@ -0,0 +1,116 @@ +// file : common/view/olv/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#include +#include // unique_ptr +#include // std::move + +#include + +// Test basic object loading functionality. +// +#pragma db namespace table("t1_") pointer(std::unique_ptr) +namespace test1 +{ + #pragma db object + struct object1 + { + object1 (int id_ = 0, int n_ = 0): id (id_), n (n_) {} + + #pragma db id + int id; + + int n; + }; + + #pragma db object + struct object2 + { + object2 (int id_ = 0, const char* s_ = ""): id (id_), s (s_) {} + + #pragma db id + int id; + + std::string s; + }; + + #pragma db view object(object1) object(object2: object1::id == object2::id) + struct view1 + { + // VC12 workaround (no default move constructor generation). + // + view1 () {} + view1 (view1&& x): o2 (std::move (x.o2)) {} + + std::unique_ptr o2; + }; + + #pragma db view object(object1) object(object2: object1::id == object2::id) + struct view2 + { + // VC12 workaround (no default move constructor generation). + // + view2 () {} + view2 (view2&& x): o2 (std::move (x.o2)), o1 (std::move (x.o1)) {} + + std::unique_ptr o2; + std::unique_ptr o1; + }; + + #pragma db view object(object1 = o1) object(object2 = o2: o1::id == o2::id) + struct view3 + { + // VC12 workaround (no default move constructor generation). + // + view3 () {} + view3 (view3&& x): o1 (std::move (x.o1)), o2 (std::move (x.o2)) {} + + std::unique_ptr o1; + std::unique_ptr o2; + }; + + #pragma db view object(object1 = o1) object(object2 = o2: o1::id == o2::id) + struct view4 + { + // VC12 workaround (no default move constructor generation). + // + view4 () {} + view4 (view4&& x): s (std::move (x.s)), + o2 (std::move (x.o2)), + id (x.id), + o1 (std::move (x.o1)), + n (x.n) {} + + std::string s; + std::unique_ptr o2; + + #pragma db column(o1::id) + int id; + + std::unique_ptr o1; + int n; + }; + + #pragma db view \ + object(object1) \ + object(object2: object1::id == object2::id) \ + object(object1 = o1b: object1::id == o1b::n) + struct view5 + { + // VC12 workaround (no default move constructor generation). + // + view5 () {} + view5 (view5&& x): o1a (std::move (x.o1a)), + o2 (std::move (x.o2)), + o1b (std::move (x.o1b)) {} + + std::unique_ptr o1a; + std::unique_ptr o2; + std::unique_ptr o1b; + }; +} + +#endif // TEST1_HXX diff --git a/odb-tests/common/view/olv/test2.hxx b/odb-tests/common/view/olv/test2.hxx new file mode 100644 index 0000000..a769daa --- /dev/null +++ b/odb-tests/common/view/olv/test2.hxx @@ -0,0 +1,122 @@ +// file : common/view/olv/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#include +#include +#include // shared_ptr + +#include + +// Test loading of object pointers inside objects. +// +#pragma db namespace table("t2_") pointer(std::shared_ptr) session +namespace test2 +{ + using std::shared_ptr; + + #pragma db object + struct object1 + { + object1 (int n_ = 0): n (n_) {} + + #pragma db id auto + int id; + + int n; + }; + + #pragma db object + struct object2 + { + object2 () {} + object2 (const char* s_, shared_ptr o1_): s (s_), o1 (o1_) {} + + #pragma db id auto + int id; + + std::string s; + shared_ptr o1; + }; + + #pragma db view object(object1) object(object2) + struct view1 + { + shared_ptr o2; + }; + + #pragma db view object(object1) object(object2) + struct view2 + { + shared_ptr o2; // "Unfortunate" order. + shared_ptr o1; + }; + + #pragma db object + struct object3 + { + object3 () {} + object3 (shared_ptr o2_): o2 (o2_) {} + + #pragma db id auto + int id; + + shared_ptr o2; + }; + + #pragma db view object(object1) object(object2) object(object3) + struct view3 + { + shared_ptr o3; // "Unfortunate" order. + shared_ptr o1; + }; + + #pragma db object + struct object4 + { + #pragma db id auto + int id; + + std::vector> o2; + }; + + #pragma db view object(object4) + struct view4 + { + shared_ptr o4; + }; + + #pragma db view object(object4) object (object2) object(object1) + struct view5 + { + shared_ptr o4; // "Unfortunate" order. + shared_ptr o1; + }; + + #pragma db object + struct object5 + { + object5 () {} + object5 (shared_ptr o1_, shared_ptr o2_) + : o1 (o1_), o2 (o2_) {} + + #pragma db id auto + int id; + + shared_ptr o1; + shared_ptr o2; + }; + + #pragma db view object(object5) object (object2) \ + object(object1 = o1a: object2::o1) \ + object(object1 = o1b: object5::o1) + struct view6 + { + shared_ptr o1a; + shared_ptr o1b; + }; +} + +#endif // TEST2_HXX diff --git a/odb-tests/common/view/olv/test3.hxx b/odb-tests/common/view/olv/test3.hxx new file mode 100644 index 0000000..8cf4344 --- /dev/null +++ b/odb-tests/common/view/olv/test3.hxx @@ -0,0 +1,106 @@ +// file : common/view/olv/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#include +#include +#include // shared_ptr + +#include +#include + +// Test JOINs for pointed-to objects, existing and automatically added. +// +#pragma db namespace table("t3_") pointer(std::shared_ptr) session +namespace test3 +{ + using std::shared_ptr; + + struct object2; + + #pragma db object + struct object1 + { + object1 (int n_ = 0): n (n_) {} + + #pragma db id auto + int id; + + int n; + + #pragma db inverse(o1) + odb::lazy_weak_ptr o2; + }; + + #pragma db object + struct object2 + { + object2 (const char* s_ = ""): s (s_) {} + + #pragma db id auto + int id; + + std::string s; + + shared_ptr o1; + }; + + #pragma db view object(object1) object(object2) + struct view1a // Existing JOIN. + { + shared_ptr o1; + }; + + #pragma db view object(object1) + struct view1b // Automatic JOIN. + { + shared_ptr o1; + }; + + // Container case. + // + struct object4; + + #pragma db object + struct object3 + { + object3 (int n_ = 0): n (n_) {} + + #pragma db id auto + int id; + + int n; + + #pragma db inverse(o3) + odb::lazy_weak_ptr o4; + }; + + #pragma db object + struct object4 + { + object4 (const char* s_ = ""): s (s_) {} + + #pragma db id auto + int id; + + std::string s; + + std::vector> o3; + }; + + #pragma db view object(object3) object(object4 = o4) + struct view2a // Existing JOIN. + { + shared_ptr o3; + }; + + #pragma db view object(object3) + struct view2b // Automatic JOIN. + { + shared_ptr o3; + }; +} + +#endif // TEST3_HXX diff --git a/odb-tests/common/view/olv/test4.hxx b/odb-tests/common/view/olv/test4.hxx new file mode 100644 index 0000000..f2af5fd --- /dev/null +++ b/odb-tests/common/view/olv/test4.hxx @@ -0,0 +1,151 @@ +// file : common/view/olv/test4.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST4_HXX +#define TEST4_HXX + +#include +#include // shared_ptr + +#include + +// Test by-value load. +// +#pragma db namespace table("t4_") session +namespace test4 +{ + #pragma db object + struct object1 + { + object1 (int id_ = 0, int n_ = 0): id (id_), n (n_) {} + + #pragma db id + int id; + + int n; + }; + + #pragma db object + struct object2 + { + object2 (int id_ = 0, const char* s_ = "", object1* o1_ = 0) + : id (id_), s (s_), o1 (o1_) {} + + #pragma db id + int id; + + std::string s; + object1* o1; // Shallow copy. + }; + + typedef object1* object1_ptr; + typedef object2* object2_ptr; + + #pragma db view object(object1) + struct view1 + { + #pragma db member(o1_) virtual(object1_ptr) get(&this.o1) set() + + #pragma db transient + object1 o1; + }; + + #pragma db view object(object1) transient + struct view1a + { + view1a (): o1_null (true) {} + + #pragma db member(o1_) virtual(object1_ptr) get(&this.o1) \ + set(this.o1_null = !(?)) + + object1 o1; + bool o1_null; + }; + + #pragma db view object(object1) + struct view1b + { + view1b (): o1_p (0) {} + + #pragma db transient + object1 o1; + + #pragma db get(&this.o1) set(o1_p = (?)) + object1* o1_p; + }; + + #pragma db view object(object1) + struct view1c + { + view1c (object1& o1): o1_p (&o1) {} + + object1* o1_p; + }; + + #pragma db view object(object1) object(object2) transient + struct view2 + { + #pragma db member(o2_) virtual(object2_ptr) get(&this.o2) set() + #pragma db member(o1_) virtual(object1_ptr) get(&this.o1) set() + + object1 o1; + object2 o2; + }; + + #pragma db view object(object1) object(object2) transient + struct view2a + { + #pragma db member(o2_) virtual(object2_ptr) get(&this.o2) \ + set(o2_null = !(?)) + #pragma db member(o1_) virtual(object1_ptr) get(&this.o1) set() + + object1 o1; + object2 o2; + bool o2_null; + }; + + // Test loading into raw pointer with non-raw object pointer. + // + using std::shared_ptr; + + #pragma db object pointer(shared_ptr) + struct object3 + { + object3 (int id_ = 0, int n_ = 0): id (id_), n (n_) {} + + #pragma db id + int id; + + int n; + }; + + #pragma db view object(object3) + struct view3 + { + // This view implements the following slightly twisted logic: if the + // object is already in the cache, then set o3_p to that. Otherwise, + // load it into the by-value instance. We can also check whether o3_p + // points to o3 to distinguish between the two outcomes. + // + + // Since we may be getting the pointer as both smart and raw, we + // need to create a bit of support code to use in the modifier + // expression. + // + void set_o3 (object3* p) {o3_p = p;} // &o3 or NULL. + void set_o3 (shared_ptr p) {o3_p = p.get ();} // From cache. + + #pragma db get(&this.o3) set(set_o3(?)) + object3* o3_p; + + #pragma db transient + object3 o3; + + // Return-by-value support (query_value()). + // + view3 (): o3_p (0) {} + view3 (const view3& x): o3_p (x.o3_p == &x.o3 ? &o3 : x.o3_p), o3 (x.o3) {} + }; +} + +#endif // TEST4_HXX diff --git a/odb-tests/common/view/olv/test5.hxx b/odb-tests/common/view/olv/test5.hxx new file mode 100644 index 0000000..e3a671b --- /dev/null +++ b/odb-tests/common/view/olv/test5.hxx @@ -0,0 +1,86 @@ +// file : common/view/olv/test5.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST5_HXX +#define TEST5_HXX + +#include +#include // shared_ptr +#include // pair + +#include + +// Test NULL object pointers. +// +#pragma db namespace table("t5_") pointer(std::shared_ptr) session +namespace test5 +{ + using std::shared_ptr; + + #pragma db object + struct object1 + { + object1 (int n_ = 0): n (n_) {} + + #pragma db id auto + int id; + + int n; + }; + + #pragma db object + struct object2 + { + object2 () {} + object2 (const char* s_, shared_ptr o1_): s (s_), o1 (o1_) {} + + #pragma db id auto + int id; + + std::string s; + shared_ptr o1; + }; + + #pragma db view object(object1) object(object2) + struct view1 + { + shared_ptr o1; + shared_ptr o2; + }; + + typedef std::pair comp_id; + #pragma db value(comp_id) + + #pragma db object + struct object3 + { + object3 (comp_id id_ = comp_id (), int n_ = 0): id (id_), n (n_) {} + + #pragma db id + comp_id id; + + int n; + }; + + #pragma db object + struct object4 + { + object4 () {} + object4 (const char* s_, shared_ptr o3_): s (s_), o3 (o3_) {} + + #pragma db id auto + int id; + + std::string s; + shared_ptr o3; + }; + + #pragma db view object(object3) object(object4) + struct view2 + { + shared_ptr o4; + shared_ptr o3; + }; +} + +#endif // TEST5_HXX diff --git a/odb-tests/common/view/olv/test6.hxx b/odb-tests/common/view/olv/test6.hxx new file mode 100644 index 0000000..5336fa6 --- /dev/null +++ b/odb-tests/common/view/olv/test6.hxx @@ -0,0 +1,57 @@ +// file : common/view/olv/test6.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST6_HXX +#define TEST6_HXX + +#include +#include // shared_ptr + +#include +#include + +// Test interaction with sections. +// +#pragma db namespace table("t6_") pointer(std::shared_ptr) +namespace test6 +{ + using std::shared_ptr; + + #pragma db object + struct object1 + { + object1 (int n_ = 0): n (n_) {} + + #pragma db id auto + int id; + + int n; + }; + + #pragma db object + struct object2 + { + object2 () {} + object2 (const char* s_, shared_ptr o1_): s (s_), o1 (o1_) {} + + #pragma db id auto + int id; + + std::string s; + + #pragma db load(lazy) + odb::section r; + + #pragma db section(r) + shared_ptr o1; + }; + + #pragma db view object(object1) object(object2) + struct view1 + { + shared_ptr o1; + shared_ptr o2; + }; +} + +#endif // TEST6_HXX diff --git a/odb-tests/common/view/olv/test7.hxx b/odb-tests/common/view/olv/test7.hxx new file mode 100644 index 0000000..dbdc663 --- /dev/null +++ b/odb-tests/common/view/olv/test7.hxx @@ -0,0 +1,57 @@ +// file : common/view/olv/test7.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST7_HXX +#define TEST7_HXX + +#include +#include // unique_ptr +#include // std::move + +#include + +// Test explicit conversion to smart pointer member. +// +#pragma db namespace table("t7_") pointer(*) session +namespace test7 +{ + using std::unique_ptr; + + #pragma db object + struct object1 + { + object1 (int n_ = 0): n (n_) {} + + #pragma db id auto + int id; + + int n; + }; + + #pragma db object + struct object2 + { + object2 () {} + object2 (const char* s_, object1* o1_): s (s_), o1 (o1_) {} + + #pragma db id auto + int id; + + std::string s; + object1* o1; // Shallow. + }; + + #pragma db view object(object1) object(object2) + struct view1 + { + // VC12 workaround (no default move constructor generation). + // + view1 () {} + view1 (view1&& x): o2 (std::move (x.o2)), o1 (std::move (x.o1)) {} + + unique_ptr o2; + unique_ptr o1; + }; +} + +#endif // TEST7_HXX diff --git a/odb-tests/common/view/olv/test8.hxx b/odb-tests/common/view/olv/test8.hxx new file mode 100644 index 0000000..607d222 --- /dev/null +++ b/odb-tests/common/view/olv/test8.hxx @@ -0,0 +1,54 @@ +// file : common/view/olv/test8.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST8_HXX +#define TEST8_HXX + +#include +#include // unique_ptr +#include // std::move + +#include + +// Test loading objects without id. +// +#pragma db namespace table("t8_") pointer(*) session +namespace test8 +{ + using std::unique_ptr; + + #pragma db object + struct object1 + { + object1 (int n_ = 0): n (n_) {} + + #pragma db id auto + int id; + + int n; + }; + + #pragma db object no_id + struct object2 + { + object2 () {} + object2 (const char* s_, object1* o1_): s (s_), o1 (o1_) {} + + std::string s; + object1* o1; // Shallow. + }; + + #pragma db view object(object1) object(object2) + struct view1 + { + // VC12 workaround (no default move constructor generation). + // + view1 () {} + view1 (view1&& x): o2 (std::move (x.o2)), o1 (std::move (x.o1)) {} + + unique_ptr o2; + unique_ptr o1; + }; +} + +#endif // TEST8_HXX diff --git a/odb-tests/common/view/olv/test9.hxx b/odb-tests/common/view/olv/test9.hxx new file mode 100644 index 0000000..b109de3 --- /dev/null +++ b/odb-tests/common/view/olv/test9.hxx @@ -0,0 +1,78 @@ +// file : common/view/olv/test9.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST9_HXX +#define TEST9_HXX + +#include +#include // shared_ptr + +#include + +// Test loading polymorphic objects. +// +#pragma db namespace table("t9_") session +namespace test9 +{ + using std::shared_ptr; + + #pragma db object polymorphic pointer(shared_ptr) + struct root + { + virtual ~root () {} + root (int n_ = 0): n (n_) {} + + #pragma db id auto + int id; + + int n; + }; + + #pragma db object + struct base: root + { + base (int n_ = 0, const char* s_ = ""): root (n_), s (s_) {} + + std::string s; + }; + + #pragma db object + struct derived: base + { + derived (int n_ = 0, const char* s_ = "", bool b_ = false) + : base (n_, s_), b (b_) {} + + bool b; + }; + + // Load via root. + // + #pragma db view object(root) + struct view1r + { + shared_ptr o; + int n; + }; + + // Load via base. + // + #pragma db view object(base) + struct view1b + { + std::string s; + shared_ptr o; + int n; + }; + + // Load via derived. + // + #pragma db view object(derived) + struct view1d + { + std::string s; + shared_ptr o; + int n; + }; +} + +#endif // TEST9_HXX diff --git a/odb-tests/common/view/olv/testscript b/odb-tests/common/view/olv/testscript new file mode 100644 index 0000000..160426d --- /dev/null +++ b/odb-tests/common/view/olv/testscript @@ -0,0 +1,39 @@ +# file : common/view/olv/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql-schema.testscript + + for s: $schemas + cat $out_base/"$s"($multi ? '-mysql' : '').sql | $create_schema_cmd + end; + + $* ($multi ? 'mysql' : ) $mysql_options +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql-schema.testscript + + for s: $schemas + $create_schema_cmd -f $out_base/"$s"($multi ? '-pgsql' : '').sql + end; + + $* ($multi ? 'pgsql' : ) $pgsql_options +} diff --git a/odb-tests/common/virtual/buildfile b/odb-tests/common/virtual/buildfile new file mode 100644 index 0000000..96d062e --- /dev/null +++ b/odb-tests/common/virtual/buildfile @@ -0,0 +1,42 @@ +# file : common/virtual/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix virtual_ \ + --generate-schema \ + --generate-query \ + --generate-session + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/virtual/driver.cxx b/odb-tests/common/virtual/driver.cxx new file mode 100644 index 0000000..f96f543 --- /dev/null +++ b/odb-tests/common/virtual/driver.cxx @@ -0,0 +1,154 @@ +// file : common/virtual/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test virtual data members. +// + +#include // std::auto_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test basic virtual data member functionality. + // + { + using namespace test1; + + object o; + o.i (123); + o.c1.i = 123; + o.c1.s = "abc"; + o.v1.push_back ("abc"); + o.v1.push_back ("abd"); + o.v1.push_back ("abe"); + o.p1 = new object; + + { + transaction t (db->begin ()); + db->persist (*o.p1); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (o.id1.v)); + t.commit (); + + assert (o == *p); + } + } + + // Test pragma resolution to virtual data member. + // + { + using namespace test2; + + object1 o1 (1); + o1.o2 = new object2 (1); + o1.o2->o1 = &o1; + + { + transaction t (db->begin ()); + db->persist (*o1.o2); + o1.n1 = o1.o2->id; + db->persist (o1); + t.commit (); + } + + { + session s; + transaction t (db->begin ()); + unique_ptr p (db->load (o1.id)); + t.commit (); + + assert (p->o2->id == o1.o2->id); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::object2::id == o1.o2->id)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->i == o1.n1); + assert (++i == r.end ()); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::o2::id == o1.o2->id)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->i == o1.n1); + assert (++i == r.end ()); + t.commit (); + } + + { + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query ()); + result::iterator i (r.begin ()); + assert (i != r.end () && i->i == o1.n1); + assert (++i == r.end ()); + t.commit (); + } + } + + // Use virtual data members to implement multi-member composite object id. + // + { + using namespace test3; + + person o; + o.first_ = "John"; + o.last_ = "Doe"; + + name id; + { + transaction t (db->begin ()); + id = db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p (db->load (id)); + t.commit (); + + assert (o.first_ == p->first_ && o.last_ == p->last_); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/virtual/test.hxx b/odb-tests/common/virtual/test.hxx new file mode 100644 index 0000000..2654d09 --- /dev/null +++ b/odb-tests/common/virtual/test.hxx @@ -0,0 +1,171 @@ +// file : common/virtual/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +// Test basic virtual data member functionality. +// +#pragma db namespace table("t1_") +namespace test1 +{ + #pragma db value + struct comp + { + int i; + + #pragma db transient + std::string s; + #pragma db member(s_) virtual(std::string) access(s) + + bool operator== (const comp& v) const + { + return i == v.i && s == v.s; + } + }; + + #pragma db object transient + struct object + { + object (): p1 (0) {} + ~object () {delete p1;} + + struct {unsigned long v;} id1; + + #pragma db id + #pragma db member(id) get(id1.v) virtual(unsigned long) set(id1.v) + #pragma db member(id) auto + + int i () const {return i1;} + void i (int i) {i1 = i;} + int i1; + + comp c1; + #pragma db member(c) virtual(comp) access(c1) + + typedef std::vector strings; + strings v1; + #pragma db member(v) virtual(strings) access(v1) + + typedef object* object_ptr; + object_ptr p1; + #pragma db member(p) virtual(object_ptr) access(p1) + + bool operator== (const object& o) const + { + return id1.v == o.id1.v && + i1 == o.i1 && + c1 == o.c1 && + v1 == o.v1 && + (p1 != 0 ? o.p1 != 0 && *p1 == *o.p1 : o.p1 == 0); + } + }; + + #pragma db member(object::i) virtual(int) +} + +#pragma db member(test1::object::id) column("oid") + +// Test pragma resolution to virtual data member. +// +#pragma db namespace table("t2_") +namespace test2 +{ + struct object1; + struct object2; + + typedef object1* object1_ptr; + typedef object2* object2_ptr; + + #pragma db object + struct object2 + { + object2 (unsigned long i = 0): id (i) {} + + #pragma db id + unsigned long id; + + #pragma db inverse(o) + object1_ptr o1; + }; + + #pragma db object + struct object1 + { + object1 (unsigned long i = 0): id (i), o2 (0) {} + ~object1 () {delete o2;} + + #pragma db id + unsigned long id; + + #pragma db transient + object2_ptr o2; + #pragma db member(o) virtual(object2_ptr) access(o2) + + #pragma db transient + unsigned long n1; + #pragma db member(n) virtual(unsigned long) access(n1) + #pragma db index member(n) + }; + + #pragma db view object(object1) object(object2) + struct view1 + { + #pragma db column(object1::n) + unsigned long i; + }; + + #pragma db view object(object1 = o1) object(object2 = o2: o1::n == o2::id) + struct view2 + { + #pragma db column(o1::n) + unsigned long i; + }; + + #pragma db view object(object1: object1::n != 0) + struct view3 + { + #pragma db column(test2::object1::n) + unsigned long i; + }; +} + +// Use virtual data members to implement multi-member composite object id. +// +#pragma db namespace table("t3_") +namespace test3 +{ + #pragma db value + struct name + { + name () {} + name (const std::string& f, const std::string& l) + : first (f), last(l) {} + + std::string first; + std::string last; + + bool operator< (const name& x) const + { + return first < x.first || (first == x.first && last < x.last); + } + }; + + #pragma db object transient + struct person + { + std::string first_; + std::string last_; + + #pragma db member(name) virtual(name) id \ + get(::test3::name (this.first_, this.last_)) \ + set(this.first_ = (?).first; this.last_ = (?).last) + }; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/virtual/testscript b/odb-tests/common/virtual/testscript new file mode 100644 index 0000000..769c7f9 --- /dev/null +++ b/odb-tests/common/virtual/testscript @@ -0,0 +1,33 @@ +# file : common/virtual/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/common/wrapper/buildfile b/odb-tests/common/wrapper/buildfile new file mode 100644 index 0000000..57f43f2 --- /dev/null +++ b/odb-tests/common/wrapper/buildfile @@ -0,0 +1,40 @@ +# file : common/wrapper/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix wrapper_ \ + --generate-schema + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{database-client}: include = adhoc diff --git a/odb-tests/common/wrapper/driver.cxx b/odb-tests/common/wrapper/driver.cxx new file mode 100644 index 0000000..9c352fc --- /dev/null +++ b/odb-tests/common/wrapper/driver.cxx @@ -0,0 +1,216 @@ +// file : common/wrapper/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test wrapper machinery. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_database (argc, argv)); + + // Test 1: simple values. + // + { + using namespace test1; + + unsigned long id1, id2; + { + object1 o1; + object2 o2; + + o1.num.reset (new int (123)); + o1.nstrs.push_back (nullable_string ()); + o1.nstrs.push_back (nullable_string ("123")); + + o2.sstrs.push_back (str_sptr ()); + o2.sstrs.push_back (str_sptr (new string ("123"))); + + transaction t (db->begin ()); + id1 = db->persist (o1); + id2 = db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (id1)); + unique_ptr o2 (db->load (id2)); + t.commit (); + + assert (*o1->num == 123); + assert (o1->str.get () == 0); + assert (o1->nstr.null ()); + assert (o1->nstrs[0].null ()); + assert (o1->nstrs[1].get () == "123"); + + assert (!o2->sstr); + assert (!o2->sstrs[0]); + assert (*o2->sstrs[1] == "123"); + } + } + + // + // Composite values. + // + unsigned long id; + { + comp_object co; + + co.c1.reset (new comp1 ("123", 123)); + co.vc1.push_back (comp1 ("1", 1)); + co.vc1.push_back (comp1 ("2", 2)); + co.vc1.push_back (comp1 ("3", 3)); + + co.c2.reset (new comp2 ("123", 123)); + co.c2->strs.push_back ("1"); + co.c2->strs.push_back ("2"); + co.c2->strs.push_back ("3"); + + { + transaction t (db->begin ()); + id = db->persist (co); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (id)); + t.commit (); + + assert (*o->c1 == *co.c1); + assert (o->vc1 == co.vc1); + assert (*o->c2 == *co.c2); + } + } + + // + // Containers. + // + { + cont_object co; + + co.nums.reset (new vector); + co.nums->push_back (1); + co.nums->push_back (2); + co.nums->push_back (3); + + co.c.num = 123; + co.c.strs.reset (new vector); + co.c.strs->push_back ("1"); + co.c.strs->push_back ("2"); + co.c.strs->push_back ("3"); + + { + transaction t (db->begin ()); + id = db->persist (co); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (id)); + t.commit (); + + assert (*o->nums == *co.nums); + assert (o->c == co.c); + } + } + + // Test 5: composite NULL values. + // + { + using namespace test5; + + object o1, o2; + + o1.v.push_back (nullable ()); + + o2.p.reset (new comp (1, "a")); + o2.n = comp (2, "b"); + o2.v.push_back (comp (3, "c")); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (p1->p.get () == 0); + assert (!p1->n); + assert (!p1->v[0]); + + assert (p2->p.get () != 0 && *p2->p == *o2.p); + assert (p2->n && *p2->n == *o2.n); + assert (p2->v[0] && *p2->v[0] == *o2.v[0]); + } + + // Update. + // + { + o1.p.reset (new comp (1, "a")); + o1.n = comp (2, "b"); + o1.v[0] = comp (3, "c"); + + o2.p.reset (); + o2.n.reset (); + o2.v[0].reset (); + + transaction t (db->begin ()); + db->update (o1); + db->update (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (o1.id)); + unique_ptr p2 (db->load (o2.id)); + t.commit (); + + assert (p1->p.get () != 0 && *p1->p == *o1.p); + assert (p1->n && *p1->n == *o1.n); + assert (p1->v[0] && *p1->v[0] == *o1.v[0]); + + assert (p2->p.get () == 0); + assert (!p2->n); + assert (!p2->v[0]); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/common/wrapper/test.hxx b/odb-tests/common/wrapper/test.hxx new file mode 100644 index 0000000..3ae4151 --- /dev/null +++ b/odb-tests/common/wrapper/test.hxx @@ -0,0 +1,214 @@ +// file : common/wrapper/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include // std::unique_ptr +#include + +#include +#include + +using odb::nullable; + +// Test 1: simple values. +// +#pragma db namespace table("t1_") +namespace test1 +{ + typedef nullable nullable_string; + + typedef std::unique_ptr num_uptr; + typedef std::unique_ptr str_uptr; + typedef std::shared_ptr str_sptr; + + #pragma db object table("obj1") + struct object1 + { + #pragma db id auto + unsigned long id_; + + num_uptr num; + + #pragma db null + str_uptr str; + + nullable_string nstr; + std::vector nstrs; + }; + + #pragma db object + struct object2 + { + #pragma db id auto + unsigned long id_; + + #pragma db null + str_sptr sstr; + + #pragma db value_null + std::vector sstrs; + }; +} + +// +// Composite values. +// + +#pragma db value +struct comp1 +{ + comp1 () {} + comp1 (const std::string& s, int n): str (s), num (n) {} + + std::string str; + int num; +}; + +inline bool +operator== (const comp1& x, const comp1& y) +{ + return x.str == y.str && x.num == y.num; +} + + +#pragma db value +struct comp2 +{ + comp2 () {} + comp2 (const std::string& s, int n): str (s), num (n) {} + + std::string str; + int num; + + std::vector strs; +}; + +inline bool +operator== (const comp2& x, const comp2& y) +{ + return x.str == y.str && x.num == y.num && x.strs == y.strs; +} + +struct comp3; + +typedef std::unique_ptr comp1_uptr; +typedef std::unique_ptr comp2_uptr; +typedef std::unique_ptr comp3_uptr; + +#pragma db object +struct comp_object +{ + #pragma db id auto + unsigned long id_; + + comp1_uptr c1; // Wrapped comp value. + std::vector > vc1; // Container of wrapped comp values. + comp2_uptr c2; // Container inside wrapped comp value. +}; + +// This one is just a compilation test to cover more convolute cases. +// +#pragma db value +struct comp3: comp2 +{ + comp1_uptr c1; + std::vector > vc1; +}; + +#pragma db object +struct comp_object2 +{ + #pragma db id auto + unsigned long id_; + + comp3_uptr c3; +}; + +// +// Containers. +// + +typedef std::unique_ptr> nums_uptr; +typedef std::unique_ptr> strs_uptr; + +#pragma db value +struct cont_comp +{ + int num; + strs_uptr strs; +}; + +inline bool +operator== (const cont_comp& x, const cont_comp& y) +{ + return x.num == y.num && *x.strs == *y.strs; +} + +#pragma db object +struct cont_object +{ + #pragma db id auto + unsigned long id_; + + nums_uptr nums; // Wrapped container. + cont_comp c; // Wrapped container in comp value. +}; + +// Test composite NULL values. +// +#pragma db namespace table("t5_") +namespace test5 +{ + #pragma db value + struct base + { + base () {} + base (int n): num (n) {} + + int num = 0; + }; + + inline bool + operator== (const base& x, const base& y) + { + return x.num == y.num; + } + + #pragma db value + struct comp: base + { + comp () {} + comp (int n, const std::string s): base (n), str (s), extra (n + 1) {} + + std::string str; + base extra; + + odb::nullable always_null; + }; + + inline bool + operator== (const comp& x, const comp& y) + { + return static_cast (x) == y && + x.str == y.str && x.extra == y.extra; + } + + #pragma db object + struct object + { + #pragma db id auto + unsigned long id; + + #pragma db null + std::unique_ptr p; + + odb::nullable n; + + std::vector< odb::nullable > v; + }; +} + +#endif // TEST_HXX diff --git a/odb-tests/common/wrapper/testscript b/odb-tests/common/wrapper/testscript new file mode 100644 index 0000000..6630813 --- /dev/null +++ b/odb-tests/common/wrapper/testscript @@ -0,0 +1,33 @@ +# file : common/wrapper/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../pgsql.testscript + + $create_schema; + $* +} diff --git a/odb-tests/database-options.testscript b/odb-tests/database-options.testscript new file mode 100644 index 0000000..2c0ee82 --- /dev/null +++ b/odb-tests/database-options.testscript @@ -0,0 +1,75 @@ +# file : database-options.testscript +# license : GNU GPL v2; see accompanying LICENSE file + +# For the enabled databases create the test driver option lists (*_options) +# for subsequent use in the tests. Also create the database-specific client +# option lists (*_client_options) and command lines (*_client_cmd) which can +# be used as a base for the data manipulation commands. +# ++if $mysql + mysql_options = --user $config.odb_tests.pgsql.user \ + --database $config.odb_tests.pgsql.database + + mysql_client_options = --user $config.odb_tests.pgsql.user \ + --database $config.odb_tests.pgsql.database + + if $defined(config.odb_tests.mysql.passwd) + mysql_options += --password $config.odb_tests.mysql.passwd + mysql_client_options += --password=$config.odb_tests.mysql.passwd + end + + if $defined(config.odb_tests.mysql.host) + mysql_options += --host $config.odb_tests.mysql.host + mysql_client_options += --host $config.odb_tests.mysql.host + end + + if $defined(config.odb_tests.mysql.port) + mysql_options += --port $config.odb_tests.mysql.port + mysql_client_options += --port $config.odb_tests.mysql.port + end + + if $defined(config.odb_tests.mysql.socket) + mysql_options += --socket $config.odb_tests.mysql.socket + mysql_client_options += --socket $config.odb_tests.mysql.socket + end + + mysql_client_cmd = $path($mysql_client) $mysql_client_options +end + ++if $sqlite + sqlite_options = --database odb-test.db + + # Note that we currently don't manipulate the data using the sqlite3 + # utility. Thus, we don't create the sqlite client option list and command + # line. + # +end + ++if $pgsql + pgsql_options = --user $config.odb_tests.pgsql.user \ + --database $config.odb_tests.pgsql.database + + pgsql_client_options = --quiet \ + --set ON_ERROR_STOP=1 \ + --username $config.odb_tests.pgsql.user \ + --dbname $config.odb_tests.pgsql.database + + if $defined(config.odb_tests.pgsql.host) + pgsql_options += --host $config.odb_tests.pgsql.host + pgsql_client_options += --host $config.odb_tests.pgsql.host + end + + if $defined(config.odb_tests.pgsql.port) + pgsql_options += --port $config.odb_tests.pgsql.port + pgsql_client_options += --port $config.odb_tests.pgsql.port + end + + pgsql_client_cmd = $path($pgsql_client) $pgsql_client_options + + export PGOPTIONS=--client-min-messages=warning +end + +# Set the default schema file name, which can be overridden by the subsequent +# tests in their own scopes. +# +schema = test diff --git a/odb-tests/evolution/add-column/driver.cxx b/odb-tests/evolution/add-column/driver.cxx new file mode 100644 index 0000000..d4eb396 --- /dev/null +++ b/odb-tests/evolution/add-column/driver.cxx @@ -0,0 +1,125 @@ +// file : evolution/add-column/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test adding a new column. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + object o (1); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + + assert (!p->str); + assert (p->num == 999); + + // Migration. + // + p->str = "abc"; + p->num = 123; + db->update (*p); + + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + + assert (p->str && *p->str == "abc"); + assert (p->num == 123); + + t.commit (); + } + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/add-column/model.hxx b/odb-tests/evolution/add-column/model.hxx new file mode 100644 index 0000000..6ac9160 --- /dev/null +++ b/odb-tests/evolution/add-column/model.hxx @@ -0,0 +1,38 @@ +// file : evolution/add-column/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#include +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + +#if MODEL_VERSION == 3 + odb::nullable str; + + #pragma db default(999) + unsigned long num; +#endif + }; +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/add-column/test1.hxx b/odb-tests/evolution/add-column/test1.hxx new file mode 100644 index 0000000..b0d7fda --- /dev/null +++ b/odb-tests/evolution/add-column/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/add-column/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/add-column/test2.hxx b/odb-tests/evolution/add-column/test2.hxx new file mode 100644 index 0000000..b62530a --- /dev/null +++ b/odb-tests/evolution/add-column/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/add-column/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/add-column/test3.hxx b/odb-tests/evolution/add-column/test3.hxx new file mode 100644 index 0000000..b24dba1 --- /dev/null +++ b/odb-tests/evolution/add-column/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/add-column/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/add-foreign-key/driver.cxx b/odb-tests/evolution/add-foreign-key/driver.cxx new file mode 100644 index 0000000..177b615 --- /dev/null +++ b/odb-tests/evolution/add-foreign-key/driver.cxx @@ -0,0 +1,173 @@ +// file : evolution/add-foreign-key/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test adding a foreign key. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include // DATABASE_XXX +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + object o (1); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + break; + } + case 2: + { + using namespace v3; + +#ifdef DATABASE_SQLITE + // In SQLite we can only add foreign keys inline in the column + // definition. + // + db->connection ()->execute ("PRAGMA foreign_keys=OFF"); +#endif + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + // Both pointers are now NULL. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + + assert (p->o1 == 0 && p->o2 == 0); + + // Migration. The foreign key constraint is not yet there. + // + p->o1 = new object1 (1); + p->o2 = new object2 (1); + db->update (*p); + + t.commit (); + } + + // Migration. Add the missing objects. + // + object1 o1 (1); + object2 o2 (1); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->o1->id_ == 1); + assert (p->o2->id_ == 1); + t.commit (); + } + + // Now the foreign key constraint is there. + // + try + { + object o (2); + o.o1 = new object1 (2); + o.o2 = new object2 (2); + + transaction t (db->begin ()); + db->persist (o); + assert (false); + } + catch (const odb::exception& ) {} + + // As well as the NOT NULL. + // +#ifndef DATABASE_SQLITE + try + { + object o (3); + o.o2 = 0; + + transaction t (db->begin ()); + db->persist (o); + assert (false); + } + catch (const odb::exception& ) {} +#endif + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/add-foreign-key/model.hxx b/odb-tests/evolution/add-foreign-key/model.hxx new file mode 100644 index 0000000..f5fe26d --- /dev/null +++ b/odb-tests/evolution/add-foreign-key/model.hxx @@ -0,0 +1,66 @@ +// file : evolution/add-foreign-key/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#include + +#include // DATABASE_XXX + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ +#if MODEL_VERSION == 3 + #pragma db object + struct object1 + { + object1 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + }; + + #pragma db object + struct object2 + { + object2 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + }; +#endif + + #pragma db object + struct object + { + #pragma db id + unsigned long id_; + +#if MODEL_VERSION == 2 + object (unsigned long id = 0): id_ (id) {} +#else + object1* o1; + + // There is no support for changing a column to NOT NULL in SQLite. + // +#ifndef ODB_DATABASE_SQLITE + #pragma db not_null +#endif + object2* o2; + + object (unsigned long id = 0): id_ (id), o1 (0), o2 (0) {} + ~object () {delete o1; delete o2;} +#endif + }; +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/add-foreign-key/test1.hxx b/odb-tests/evolution/add-foreign-key/test1.hxx new file mode 100644 index 0000000..05c78c3 --- /dev/null +++ b/odb-tests/evolution/add-foreign-key/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/add-foreign-key/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/add-foreign-key/test2.hxx b/odb-tests/evolution/add-foreign-key/test2.hxx new file mode 100644 index 0000000..c57d9a1 --- /dev/null +++ b/odb-tests/evolution/add-foreign-key/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/add-foreign-key/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/add-foreign-key/test3.hxx b/odb-tests/evolution/add-foreign-key/test3.hxx new file mode 100644 index 0000000..c844469 --- /dev/null +++ b/odb-tests/evolution/add-foreign-key/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/add-foreign-key/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/add-index/driver.cxx b/odb-tests/evolution/add-index/driver.cxx new file mode 100644 index 0000000..689504e --- /dev/null +++ b/odb-tests/evolution/add-index/driver.cxx @@ -0,0 +1,165 @@ +// file : evolution/add-index/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test adding a new index. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + object o0 (0); + o0.num = 123; + + object o1 (1); + o1.num = 234; + + object o2 (2); + o2.num = 234; + + // Duplicates are ok. + // + { + transaction t (db->begin ()); + db->persist (o0); + db->persist (o1); + db->persist (o2); + t.commit (); + } + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + object o3 (3); + o3.num = 234; + + // Duplicates are still ok but we need to remove them before the + // post migration step. + // + { + transaction t (db->begin ()); + db->persist (o3); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query ( + "ORDER BY" + query::num + "," + query::id)); + + unsigned long prev (0); + for (result::iterator i (r.begin ()); i != r.end (); ++i) + { + if (i->num == prev) + db->erase (*i); + + prev = i->num; + } + + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + { + transaction t (db->begin ()); + auto_ptr p0 (db->load (0)); + auto_ptr p1 (db->load (1)); + + assert (p0->num == 123); + assert (p1->num == 234); + + t.commit (); + } + + try + { + object o2 (2); + o2.num = 234; + + transaction t (db->begin ()); + db->persist (o2); + assert (false); + } + catch (const odb::exception& ) {} + + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/add-index/model.hxx b/odb-tests/evolution/add-index/model.hxx new file mode 100644 index 0000000..fec75cc --- /dev/null +++ b/odb-tests/evolution/add-index/model.hxx @@ -0,0 +1,33 @@ +// file : evolution/add-index/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + +#if MODEL_VERSION == 3 + #pragma db unique +#endif + unsigned long num; + }; +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/add-index/test1.hxx b/odb-tests/evolution/add-index/test1.hxx new file mode 100644 index 0000000..1be2b5b --- /dev/null +++ b/odb-tests/evolution/add-index/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/add-index/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/add-index/test2.hxx b/odb-tests/evolution/add-index/test2.hxx new file mode 100644 index 0000000..a0faca9 --- /dev/null +++ b/odb-tests/evolution/add-index/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/add-index/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/add-index/test3.hxx b/odb-tests/evolution/add-index/test3.hxx new file mode 100644 index 0000000..aab9c86 --- /dev/null +++ b/odb-tests/evolution/add-index/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/add-index/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/add-table/driver.cxx b/odb-tests/evolution/add-table/driver.cxx new file mode 100644 index 0000000..67b0f0e --- /dev/null +++ b/odb-tests/evolution/add-table/driver.cxx @@ -0,0 +1,140 @@ +// file : evolution/add-table/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test adding a new table (object, container). +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include // DATABASE_XXX +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + // SQLite has broken foreign keys when it comes to DDL. + // +#ifdef DATABASE_SQLITE + db->connection ()->execute ("PRAGMA foreign_keys=OFF"); +#endif + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + +#ifdef DATABASE_SQLITE + db->connection ()->execute ("PRAGMA foreign_keys=ON"); +#endif + } + + object o (1); + o.str = "abc"; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + object1 o1; + o1.nums.push_back (1); + o1.nums.push_back (2); + o1.nums.push_back (3); + + { + transaction t (db->begin ()); + o1.o = db->load (1); + db->persist (o1); + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + result r (db->query (query::o->str == "abc")); + result::iterator i (r.begin ()), e (r.end ()); + + assert (i != e && + i->o->id_ == 1 && + i->nums[0] == 1 && i->nums[1] == 2 && i->nums[2] == 3); + assert (++i == e); + + t.commit (); + } + + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/add-table/model.hxx b/odb-tests/evolution/add-table/model.hxx new file mode 100644 index 0000000..208a156 --- /dev/null +++ b/odb-tests/evolution/add-table/model.hxx @@ -0,0 +1,48 @@ +// file : evolution/add-table/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include +#include + +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + std::string str; + }; + +#if MODEL_VERSION == 3 + #pragma db object + struct object1 + { + object1 (): o (0) {} + ~object1 () {delete o;} + + #pragma db id auto + unsigned long id_; + + object* o; + std::vector nums; + }; +#endif +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/add-table/test1.hxx b/odb-tests/evolution/add-table/test1.hxx new file mode 100644 index 0000000..adc51a1 --- /dev/null +++ b/odb-tests/evolution/add-table/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/add-table/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/add-table/test2.hxx b/odb-tests/evolution/add-table/test2.hxx new file mode 100644 index 0000000..ca03cef --- /dev/null +++ b/odb-tests/evolution/add-table/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/add-table/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/add-table/test3.hxx b/odb-tests/evolution/add-table/test3.hxx new file mode 100644 index 0000000..39406a2 --- /dev/null +++ b/odb-tests/evolution/add-table/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/add-table/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/alter-column/driver.cxx b/odb-tests/evolution/alter-column/driver.cxx new file mode 100644 index 0000000..be63f05 --- /dev/null +++ b/odb-tests/evolution/alter-column/driver.cxx @@ -0,0 +1,160 @@ +// file : evolution/alter-column/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test altering a column. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + + // SQLite doesn't support altering of columns. + // +#ifndef DATABASE_SQLITE + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + object o (1); + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + // NULL is already in effect; NOT NULL is not yet. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + + assert (!p->str); + assert (p->num && *p->num == 123); + assert (!p->num1); + + // Migration. + // + p->str = "abc"; + p->num.reset (); + p->num1 = 123; + db->update (*p); + + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + + assert (p->str && *p->str == "abc"); + assert (!p->num); + + t.commit (); + } + + // NOT NULL is now in effect. + // + try + { + object o2 (2); + o2.num1 = 234; // str is NULL + + transaction t (db->begin ()); + db->persist (o2); + assert (false); + } + catch (const odb::exception& ) {} + + try + { + object o3 (3); + o3.str = "bcd"; // num1 is NULL + + transaction t (db->begin ()); + db->persist (o3); + assert (false); + } + catch (const odb::exception& ) {} + + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } +#endif // DATABASE_SQLITE + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/alter-column/model.hxx b/odb-tests/evolution/alter-column/model.hxx new file mode 100644 index 0000000..fc6661c --- /dev/null +++ b/odb-tests/evolution/alter-column/model.hxx @@ -0,0 +1,56 @@ +// file : evolution/alter-column/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#include +#include + +#include // DATABASE_XXX + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + // SQLite doesn't support altering of columns. + // +#ifndef DATABASE_SQLITE +#if MODEL_VERSION == 2 + odb::nullable str; + + unsigned long num; +#else + // Use nullable to be able to access during migration. + // + #pragma db not_null + odb::nullable str; + + odb::nullable num; + + // Test adding NOT NULL column. It should be added NULL in pre + // and then converted to NOT NULL in post. + // + #pragma db not_null + odb::nullable num1; +#endif +#endif + }; +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/alter-column/test1.hxx b/odb-tests/evolution/alter-column/test1.hxx new file mode 100644 index 0000000..9353558 --- /dev/null +++ b/odb-tests/evolution/alter-column/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/alter-column/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/alter-column/test2.hxx b/odb-tests/evolution/alter-column/test2.hxx new file mode 100644 index 0000000..e2dbed3 --- /dev/null +++ b/odb-tests/evolution/alter-column/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/alter-column/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/alter-column/test3.hxx b/odb-tests/evolution/alter-column/test3.hxx new file mode 100644 index 0000000..ac08e2f --- /dev/null +++ b/odb-tests/evolution/alter-column/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/alter-column/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/combined/driver.cxx b/odb-tests/evolution/combined/driver.cxx new file mode 100644 index 0000000..88453c3 --- /dev/null +++ b/odb-tests/evolution/combined/driver.cxx @@ -0,0 +1,157 @@ +// file : evolution/combined/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Combined schema evolution test. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + object o ("1"); + o.dui = 1; + o.anui = 1; + o.dnui = 1; + o.dc = 1; + o.dt.push_back (1); + o.aui = 1; + +#ifndef DATABASE_SQLITE + o.dfk = new object1 (1); + o.acn = 1; + o.acnn.reset (); + o.afk = 1; +#endif + + { + transaction t (db->begin ()); +#ifndef DATABASE_SQLITE + db->persist (o.dfk); +#endif + db->persist (o); + t.commit (); + } + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load ("1")); + + assert (p->ac1 == 999); + assert (!p->ac2); + +#ifndef DATABASE_SQLITE + assert (!p->ac3); +#endif + // Migrate. + // + p->at.push_back ("abc"); + +#ifndef DATABASE_SQLITE + p->dfk = 999; + p->ac3 = 1; + p->acn.reset (); + p->acnn = 1; +#endif + db->update (*p); + + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + { + transaction t (db->begin ()); + auto_ptr p (db->load ("1")); + + // Check post-migration. + // + assert (p->at[0] == "abc"); + +#ifndef DATABASE_SQLITE + assert (p->dfk == 999); + assert (*p->ac3 == 1); + assert (!p->acn); + assert (*p->acnn == 1); +#endif + t.commit (); + } + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/combined/model.hxx b/odb-tests/evolution/combined/model.hxx new file mode 100644 index 0000000..e924943 --- /dev/null +++ b/odb-tests/evolution/combined/model.hxx @@ -0,0 +1,174 @@ +// file : evolution/combined/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include +#include + +#include +#include + +#include // DATABASE_XXX + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ + #pragma db object + struct object1 + { + object1 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + }; + + #pragma db object + struct object + { + #pragma db id + std::string id_; + + // + // Pre pass 1. + // + + // Drop unique index. + // +#if MODEL_VERSION == 2 + #pragma db unique +#endif + unsigned long dui; + + // Alter table drop foreign key. Not supported by SQLite. + // +#ifndef DATABASE_SQLITE +#if MODEL_VERSION == 2 + object1* dfk; +#else + #pragma db null + unsigned long dfk; +#endif +#endif + + // Add table. + // +#if MODEL_VERSION == 3 + std::vector at; +#endif + + // Add column. + // +#if MODEL_VERSION == 3 + #pragma db default(999) + unsigned long ac1; + + odb::nullable ac2; + + // Initially added as NULL, converted to NOT NULL. Not supported by SQLite. + // +#ifndef DATABASE_SQLITE + #pragma db not_null + odb::nullable ac3; +#endif +#endif + + // Alter column NULL. Not supported by SQLite. + // +#ifndef DATABASE_SQLITE +#if MODEL_VERSION == 2 + unsigned long acn; +#else + odb::nullable acn; +#endif +#endif + + // + // Pre pass 2. + // + + // Add non-unique indexes. + // +#if MODEL_VERSION == 3 + #pragma db index +#endif + unsigned long anui; + + // + // Post pass 1. + // + + // Drop non-unique indexes. + // +#if MODEL_VERSION == 2 + #pragma db index +#endif + unsigned long dnui; + + // + // Post pass 2. + // + + // Drop table. + // +#if MODEL_VERSION == 2 + std::vector dt; +#endif + + // Drop column. Logical drop (set NULL) in SQLite. + // +#if MODEL_VERSION == 2 + unsigned long dc; +#endif + + // Alter column NOT NULL. Not supported by SQLite. + // +#ifndef DATABASE_SQLITE +#if MODEL_VERSION == 3 + #pragma db not_null +#endif + odb::nullable acnn; +#endif + + // Alter table add foreign key. Not supported by SQLite. + // +#ifndef DATABASE_SQLITE +#if MODEL_VERSION == 2 + #pragma db null + unsigned long afk; +#else + object1* afk; +#endif +#endif + + // Add unique index. + // +#if MODEL_VERSION == 3 + #pragma db unique +#endif + unsigned long aui; + + public: +#ifndef DATABASE_SQLITE +#if MODEL_VERSION == 2 + + object (std::string id = ""): id_ (id), dfk (0) {} + ~object () {delete dfk;} +#else + object (std::string id = ""): id_ (id), afk (0) {} + ~object () {delete afk;} +#endif +#else + object (std::string id = ""): id_ (id) {} +#endif + }; +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/combined/test1.hxx b/odb-tests/evolution/combined/test1.hxx new file mode 100644 index 0000000..1a18aff --- /dev/null +++ b/odb-tests/evolution/combined/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/combined/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/combined/test2.hxx b/odb-tests/evolution/combined/test2.hxx new file mode 100644 index 0000000..8eb7ac8 --- /dev/null +++ b/odb-tests/evolution/combined/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/combined/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/combined/test3.hxx b/odb-tests/evolution/combined/test3.hxx new file mode 100644 index 0000000..05a052f --- /dev/null +++ b/odb-tests/evolution/combined/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/combined/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/data/driver.cxx b/odb-tests/evolution/data/driver.cxx new file mode 100644 index 0000000..73cc852 --- /dev/null +++ b/odb-tests/evolution/data/driver.cxx @@ -0,0 +1,178 @@ +// file : evolution/data/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test data migration support. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include // DATABASE_XXX, HAVE_CXX11 +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +void +migrate1 (database& db) +{ + using namespace v2; + using namespace v3; + + auto_ptr o1 (db.load (1)); + object2 o2 (1); + o2.num = o1->num; + db.persist (o2); +} + +void +migrate2 (database& db) +{ + using namespace v2; + using namespace v3; + + auto_ptr o1 (db.load (2)); + object2 o2 (2); + o2.num = o1->num; + db.persist (o2); +} + +static const data_migration_entry<3, 1> migrate2_entry (&migrate2); + +int +main (int argc, char* argv[]) +{ + schema_catalog::data_migration_function<3, 1> (&migrate1); + +#ifdef HAVE_CXX11 + schema_catalog::data_migration_function<3, 1> ( + [] (database& db) + { + using namespace v2; + using namespace v3; + + auto_ptr o1 (db.load (11)); + object2 o2 (11); + o2.num = o1->num; + db.persist (o2); + }); +#endif + + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + { + transaction t (db->begin ()); + + { + object1 o1 (1); + o1.num = 123; + db->persist (o1); + } + + { + object1 o1 (2); + o1.num = 123; + db->persist (o1); + } + +#ifdef HAVE_CXX11 + { + object1 o1 (11); + o1.num = 123; + db->persist (o1); + } +#endif + t.commit (); + } + break; + } + case 2: + { + { + transaction t (db->begin ()); + + if (embedded) + schema_catalog::migrate (*db); + else + schema_catalog::migrate_data (*db); + + t.commit (); + } + + break; + } + case 3: + { + using namespace v3; + + { + transaction t (db->begin ()); + + { + auto_ptr o2 (db->load (1)); + assert (o2->num == 123); + } + + { + auto_ptr o2 (db->load (2)); + assert (o2->num == 123); + } + +#ifdef HAVE_CXX11 + { + auto_ptr o2 (db->load (11)); + assert (o2->num == 123); + } +#endif + t.commit (); + } + + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/data/model.hxx b/odb-tests/evolution/data/model.hxx new file mode 100644 index 0000000..680bc55 --- /dev/null +++ b/odb-tests/evolution/data/model.hxx @@ -0,0 +1,45 @@ +// file : evolution/data/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ +#if MODEL_VERSION == 2 + #pragma db object + struct object1 + { + object1 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + int num; + }; +#endif + +#if MODEL_VERSION == 3 + #pragma db object + struct object2 + { + object2 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + int num; + }; +#endif +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/data/test1.hxx b/odb-tests/evolution/data/test1.hxx new file mode 100644 index 0000000..976ed04 --- /dev/null +++ b/odb-tests/evolution/data/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/data/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/data/test2.hxx b/odb-tests/evolution/data/test2.hxx new file mode 100644 index 0000000..bd72940 --- /dev/null +++ b/odb-tests/evolution/data/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/data/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/data/test3.hxx b/odb-tests/evolution/data/test3.hxx new file mode 100644 index 0000000..0f47099 --- /dev/null +++ b/odb-tests/evolution/data/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/data/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/drop-column/driver.cxx b/odb-tests/evolution/drop-column/driver.cxx new file mode 100644 index 0000000..7f0c253 --- /dev/null +++ b/odb-tests/evolution/drop-column/driver.cxx @@ -0,0 +1,126 @@ +// file : evolution/drop-column/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test dropping a column. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + object o (1); + o.str = "abc"; + o.num = 123; + o.ptr = new object1 (1, 2); + + { + transaction t (db->begin ()); + db->persist (*o.ptr); + db->persist (o); + t.commit (); + } + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + // Things are still there. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + + assert (p->str == "abc"); + assert (p->num == 123); + assert (p->ptr->id.x == 1 && p->ptr->id.y == 2); + + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + // Now they are gone. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "" && p->ptr == 0); + db->erase (value (1, 2)); // SQLite logical delete test. + t.commit (); + } + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/drop-column/model.hxx b/odb-tests/evolution/drop-column/model.hxx new file mode 100644 index 0000000..09b63b9 --- /dev/null +++ b/odb-tests/evolution/drop-column/model.hxx @@ -0,0 +1,59 @@ +// file : evolution/drop-column/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#include +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ + #pragma db value + struct value + { + value (int x_ = 0, int y_ = 0): x (x_), y (y_) {} + int x; + int y; + }; + + #pragma db object + struct object1 + { + object1 (int x = 0, int y = 0): id (x, y) {} + + #pragma db id + value id; + }; + + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id), ptr (0) {} + ~object () {delete ptr;} + + #pragma db id + unsigned long id_; + + std::string str; + unsigned long num; + object1* ptr; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) deleted(3) + #pragma db member(object::num) deleted(3) + #pragma db member(object::ptr) deleted(3) +#endif +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/drop-column/test1.hxx b/odb-tests/evolution/drop-column/test1.hxx new file mode 100644 index 0000000..1efb1fa --- /dev/null +++ b/odb-tests/evolution/drop-column/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/drop-column/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/drop-column/test2.hxx b/odb-tests/evolution/drop-column/test2.hxx new file mode 100644 index 0000000..2842cd3 --- /dev/null +++ b/odb-tests/evolution/drop-column/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/drop-column/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/drop-column/test3.hxx b/odb-tests/evolution/drop-column/test3.hxx new file mode 100644 index 0000000..d1ce616 --- /dev/null +++ b/odb-tests/evolution/drop-column/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/drop-column/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/drop-foreign-key/driver.cxx b/odb-tests/evolution/drop-foreign-key/driver.cxx new file mode 100644 index 0000000..f829562 --- /dev/null +++ b/odb-tests/evolution/drop-foreign-key/driver.cxx @@ -0,0 +1,145 @@ +// file : evolution/drop-foreign-key/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test dropping a foreign key. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + + // SQLite doesn't support dropping of foreign keys. + // +#ifndef DATABASE_SQLITE + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + object o (1); + o.o1 = new object (2); + o.o2 = new object (3); + + { + transaction t (db->begin ()); + db->persist (o.o1); + db->persist (o.o2); + db->persist (o); + t.commit (); + } + + // The foreign key constraint is there. + // + try + { + object o (11); + o.o1 = new object (12); + o.o2 = new object (13); + + transaction t (db->begin ()); + db->persist (o); + assert (false); + } + catch (const odb::exception& ) {} + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + // The data is still there but the constraints are gone. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + + assert (p->o1 == 2); + assert (p->o2 == 3); + + db->erase (p->o1); + db->erase (p->o2); + + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->o1 == 2); + assert (p->o2 == 3); + t.commit (); + } + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } +#endif // DATABASE_SQLITE + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/drop-foreign-key/model.hxx b/odb-tests/evolution/drop-foreign-key/model.hxx new file mode 100644 index 0000000..eed8c46 --- /dev/null +++ b/odb-tests/evolution/drop-foreign-key/model.hxx @@ -0,0 +1,50 @@ +// file : evolution/drop-foreign-key/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#include + +#include // DATABASE_XXX + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ + #pragma db object + struct object + { + #pragma db id + unsigned long id_; + + // SQLite doesn't support dropping of foreign keys. + // +#ifndef DATABASE_SQLITE +#if MODEL_VERSION == 2 + object* o1; + object* o2; + + object (unsigned long id = 0): id_ (id), o1 (0), o2 (0) {} + ~object () {delete o1; delete o2;} +#else + #pragma db null + unsigned long o1; + + #pragma db null + unsigned long o2; + + object (unsigned long id = 0): id_ (id) {} +#endif +#endif + }; +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/drop-foreign-key/test1.hxx b/odb-tests/evolution/drop-foreign-key/test1.hxx new file mode 100644 index 0000000..5476796 --- /dev/null +++ b/odb-tests/evolution/drop-foreign-key/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/drop-foreign-key/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/drop-foreign-key/test2.hxx b/odb-tests/evolution/drop-foreign-key/test2.hxx new file mode 100644 index 0000000..f091a25 --- /dev/null +++ b/odb-tests/evolution/drop-foreign-key/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/drop-foreign-key/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/drop-foreign-key/test3.hxx b/odb-tests/evolution/drop-foreign-key/test3.hxx new file mode 100644 index 0000000..beb8c42 --- /dev/null +++ b/odb-tests/evolution/drop-foreign-key/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/drop-foreign-key/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/drop-index/driver.cxx b/odb-tests/evolution/drop-index/driver.cxx new file mode 100644 index 0000000..5ad1cd4 --- /dev/null +++ b/odb-tests/evolution/drop-index/driver.cxx @@ -0,0 +1,154 @@ +// file : evolution/drop-index/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test dropping an index. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + object o0 (0); + o0.num = 123; + + object o1 (1); + o1.num = 234; + + object o2 (2); + o2.num = 234; + + { + transaction t (db->begin ()); + db->persist (o0); + db->persist (o1); + t.commit (); + } + + // Duplicates are not ok. + // + try + { + transaction t (db->begin ()); + db->persist (o2); + assert (false); + } + catch (const odb::exception& ) {} + + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + // Duplicates are now ok. + // + object o2 (2); + o2.num = 234; + + { + transaction t (db->begin ()); + db->persist (o2); + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + { + transaction t (db->begin ()); + auto_ptr p0 (db->load (0)); + auto_ptr p1 (db->load (1)); + auto_ptr p2 (db->load (2)); + + assert (p0->num == 123); + assert (p1->num == 234); + assert (p2->num == 234); + + t.commit (); + } + + // Duplicates are still ok. + // + object o3 (3); + o3.num = 234; + + { + transaction t (db->begin ()); + db->persist (o3); + t.commit (); + } + + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/drop-index/model.hxx b/odb-tests/evolution/drop-index/model.hxx new file mode 100644 index 0000000..5e163ca --- /dev/null +++ b/odb-tests/evolution/drop-index/model.hxx @@ -0,0 +1,33 @@ +// file : evolution/drop-index/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + +#if MODEL_VERSION == 2 + #pragma db unique +#endif + unsigned long num; + }; +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/drop-index/test1.hxx b/odb-tests/evolution/drop-index/test1.hxx new file mode 100644 index 0000000..5a279bb --- /dev/null +++ b/odb-tests/evolution/drop-index/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/drop-index/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/drop-index/test2.hxx b/odb-tests/evolution/drop-index/test2.hxx new file mode 100644 index 0000000..78b89f2 --- /dev/null +++ b/odb-tests/evolution/drop-index/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/drop-index/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/drop-index/test3.hxx b/odb-tests/evolution/drop-index/test3.hxx new file mode 100644 index 0000000..17b670d --- /dev/null +++ b/odb-tests/evolution/drop-index/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/drop-index/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/drop-table/driver.cxx b/odb-tests/evolution/drop-table/driver.cxx new file mode 100644 index 0000000..81cec55 --- /dev/null +++ b/odb-tests/evolution/drop-table/driver.cxx @@ -0,0 +1,168 @@ +// file : evolution/drop-table/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test dropping a table (object, container). +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + { + using namespace v2; + + object1 o1; + o1.o = new object (1); + o1.o->str = "abc"; + o1.nums.push_back (1); + o1.nums.push_back (2); + o1.nums.push_back (3); + + { + transaction t (db->begin ()); + db->persist (o1.o); + db->persist (o1); + t.commit (); + } + } + + // Polymorphism test. + // + { + // We have to use v3 here because the discriminator includes + // the namespace. + // + using namespace v3; + + base b (123, "abc"); + derived d1 (234, "bcd"); + derived d2 (345, "cde"); + + { + transaction t (db->begin ()); + db->persist (b); + db->persist (d1); + db->persist (d2); + t.commit (); + } + } + + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + // Both object and object1 are still there so we can migrate the data. + // + typedef odb::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + result r (db->query (query::o->str == "abc")); + result::iterator i (r.begin ()), e (r.end ()); + + assert (i != e && + i->o->id_ == 1 && + i->nums[0] == 1 && i->nums[1] == 2 && i->nums[2] == 3); + assert (++i == e); + + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + + break; + } + case 3: + { + using namespace v3; + + // Only object is still there. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "abc"); + t.commit (); + } + + // Polymorphism test. + // + { + transaction t (db->begin ()); + assert (size (db->query ()) == 1); + assert (size (db->query ()) == 1); + t.commit (); + } + + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/drop-table/model.hxx b/odb-tests/evolution/drop-table/model.hxx new file mode 100644 index 0000000..2c02d09 --- /dev/null +++ b/odb-tests/evolution/drop-table/model.hxx @@ -0,0 +1,94 @@ +// file : evolution/drop-table/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include +#include + +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + std::string str; + }; + + #pragma db object + struct object1 + { + object1 (): o (0) {} + ~object1 () {delete o;} + + #pragma db id auto + unsigned long id_; + + object* o; + std::vector nums; + }; + +#if MODEL_VERSION == 3 + #pragma db object(object1) deleted(3) +#endif + + // Make sure we also clean up base tables when dropping a + // table corresponding to the polymorphic derived object. + // + #pragma db value + struct value + { + value (unsigned long n = 0, const std::string& s = ""): num (n), str (s) {} + + unsigned long num; + std::string str; + }; + + #pragma db object polymorphic + struct root + { + root (unsigned long n = 0, const std::string& s = ""): id (n, s) {} + virtual ~root () {} + + #pragma db id + value id; + }; + + #pragma db object + struct base: root + { + base (unsigned long n = 0, const std::string& s = "") + : root (n, s), num (n) {} + + unsigned long num; + }; + + #pragma db object + struct derived: base + { + derived (unsigned long n = 0, const std::string& s = "") + : base (n, s), str (s) {} + + std::string str; + }; + +#if MODEL_VERSION == 3 + #pragma db object(derived) deleted(3) +#endif +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/drop-table/test1.hxx b/odb-tests/evolution/drop-table/test1.hxx new file mode 100644 index 0000000..a9ec64c --- /dev/null +++ b/odb-tests/evolution/drop-table/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/drop-table/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/drop-table/test2.hxx b/odb-tests/evolution/drop-table/test2.hxx new file mode 100644 index 0000000..c9ec149 --- /dev/null +++ b/odb-tests/evolution/drop-table/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/drop-table/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/drop-table/test3.hxx b/odb-tests/evolution/drop-table/test3.hxx new file mode 100644 index 0000000..8d3f17b --- /dev/null +++ b/odb-tests/evolution/drop-table/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/drop-table/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/embedded/driver.cxx b/odb-tests/evolution/embedded/driver.cxx new file mode 100644 index 0000000..1816a5c --- /dev/null +++ b/odb-tests/evolution/embedded/driver.cxx @@ -0,0 +1,181 @@ +// file : evolution/embedded/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test embedded schema migration. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include // DATABASE_XXX +#include + +#ifdef DATABASE_PGSQL +# include +#endif + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + t.commit (); + } + + // PostgreSQL cannot continue a transaction after a query failed. We + // have a workaround but only for 9.4+. + // +#ifdef DATABASE_PGSQL + { + odb::connection_ptr c (db->connection ()); + int v (static_cast (*c).server_version ()); + if (v < 90400) + assert (db->schema_version () == 0); + } +#endif + + { + transaction t (db->begin ()); + assert (db->schema_version () == 0); + + schema_catalog::create_schema (*db, "", false); + + assert (db->schema_version () == 1 && !db->schema_migration ()); + + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + assert (db->schema_version () == 2 && !db->schema_migration ()); + + { + transaction t (db->begin ()); + object1 o1 (1); + o1.num = 123; + db->persist (o1); + t.commit (); + } + break; + } + case 2: + { + using namespace v2; + using namespace v3; + + // Check version information correctness. + // + assert (schema_catalog::base_version (*db) == 1); + assert (schema_catalog::current_version (*db) == 3); + assert (schema_catalog::next_version (*db, 0) == 3); + assert (schema_catalog::next_version (*db, 1) == 2); + assert (schema_catalog::next_version (*db) == 3); + assert (schema_catalog::next_version (*db, 3) == 4); + + { + assert (db->schema_version () == 2 && !db->schema_migration ()); + + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + assert (db->schema_version () == 3 && db->schema_migration ()); + + { + transaction t (db->begin ()); + auto_ptr o1 (db->load (1)); + object2 o2 (1); + o2.num = o1->num; + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + + assert (db->schema_version () == 3 && !db->schema_migration ()); + } + break; + } + case 3: + { + using namespace v3; + + // In transaction. + // + { + transaction t (db->begin ()); + assert (db->schema_version () == 3 && !db->schema_migration ()); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr o2 (db->load (1)); + assert (o2->num == 123); + t.commit (); + } + + // Test the case where there is still no version table. + // + db->schema_version_migration (0, false); + + { + transaction t (db->begin ()); + +#ifdef DATABASE_ORACLE + db->execute ("DROP TABLE \"schema_version\""); +#else + db->execute ("DROP TABLE schema_version"); +#endif + t.commit (); + } + + assert (db->schema_version () == 0); + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/embedded/model.hxx b/odb-tests/evolution/embedded/model.hxx new file mode 100644 index 0000000..f3aa7a4 --- /dev/null +++ b/odb-tests/evolution/embedded/model.hxx @@ -0,0 +1,45 @@ +// file : evolution/embedded/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ +#if MODEL_VERSION == 2 + #pragma db object + struct object1 + { + object1 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + int num; + }; +#endif + +#if MODEL_VERSION == 3 + #pragma db object + struct object2 + { + object2 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + int num; + }; +#endif +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/embedded/test1.hxx b/odb-tests/evolution/embedded/test1.hxx new file mode 100644 index 0000000..32903a1 --- /dev/null +++ b/odb-tests/evolution/embedded/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/embedded/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/embedded/test2.hxx b/odb-tests/evolution/embedded/test2.hxx new file mode 100644 index 0000000..fce8760 --- /dev/null +++ b/odb-tests/evolution/embedded/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/embedded/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/embedded/test3.hxx b/odb-tests/evolution/embedded/test3.hxx new file mode 100644 index 0000000..d49ecc5 --- /dev/null +++ b/odb-tests/evolution/embedded/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/embedded/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/soft-add/driver.cxx b/odb-tests/evolution/soft-add/driver.cxx new file mode 100644 index 0000000..c70edcb --- /dev/null +++ b/odb-tests/evolution/soft-add/driver.cxx @@ -0,0 +1,2219 @@ +// file : evolution/soft-add/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test soft-add functionality. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include // DATABASE_XXX +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v3; // NOTE: not v2. + + if (embedded) + { + // SQLite has broken foreign keys when it comes to DDL. + // +#ifdef DATABASE_SQLITE + db->connection ()->execute ("PRAGMA foreign_keys=OFF"); +#endif + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + +#ifdef DATABASE_SQLITE + db->connection ()->execute ("PRAGMA foreign_keys=ON"); +#endif + } + + // Test basic soft-added member logic. + // + { + using namespace test2; + + // None of the database operations should yet include the + // added members. + // + { + object o (1); + o.str = "abc"; + o.num = 123; + o.vec.push_back (123); + o.ptr = new object1 (1); + o.ptr->ptrs.push_back (&o); + + transaction t (db->begin ()); + db->persist (o); + db->persist (*o.ptr); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "" && p->num == 123 && + p->vec.empty () && p->ptr == 0); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && + i->str == "" && i->num == 123 && + i->vec.empty () && i->ptr == 0); + + try + { + db->query (query::str.is_null ()); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + o.ptr = new object1 (2); + o.ptr->ptrs.push_back (&o); + + { + transaction t (db->begin ()); + db->persist (o); + db->persist (*o.ptr); + auto_ptr p (db->load (2)); + assert (p->str == "" && p->num == 234 && + p->vec.empty () && p->ptr == 0); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; + delete o.ptr; + o.ptr = 0; + + { + transaction t (db->begin ()); + db->erase (2); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->str == "" && p->num == 235 && + p->vec.empty () && p->ptr == 0); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test empty statement handling (INSERT, UPDATE). + // + { + using namespace test3; + + // None of the database operations should yet include the + // added members. + // + object o; + o.str = "bcd"; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (o.id)); + assert (p->str == ""); + t.commit (); + } + + o.str += 'e'; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (o.id)); + assert (p->str == ""); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test empty statement handling (SELECT in polymorphic loader). + // + { + using namespace test4; + + // None of the database operations should yet include the + // added members. + // + object o (1); + o.str = "abc"; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (1)); + assert (static_cast (*p).str == ""); + db->erase (o); + t.commit (); + } + } + + // Test container with soft-added value member. + // + { + using namespace test5; + + // None of the database operations should yet include the + // added members. + // + { + object o (1); + o.vec.push_back (value ("abc", 123)); + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->vec[0].str == "" && p->vec[0].num == 123); + t.commit (); + } + + object o (2); + o.vec.push_back (value ("bcd", 234)); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->vec[0].str == "" && p->vec[0].num == 234); + t.commit (); + } + + o.vec.modify (0).str += 'e'; + o.vec.modify (0).num++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->vec[0].str == "" && p->vec[0].num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test view with soft-added member. + // + { + using namespace test6; + + // None of the database operations should yet include the + // added members. + // + { + object o (1); + o.str = "abc"; + o.num = 123; + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 123); + + try + { + db->query (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + } + + // Test soft-added section member. + // + { + using namespace test7; + + // None of the database operations should yet include the + // added members. + // + { + object o (1); + o.str = "abc"; + o.num = 123; + o.vec.push_back (123); + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + + try + { + db->load (*p, p->s); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test soft-added members of a section. + // + { + using namespace test8; + + // None of the database operations should yet include the + // added members. + // + { + object o (1); + o.str = "abc"; + o.num = 123; + o.vec.push_back (123); + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->str == "" && p->num == 123 && p->vec.empty ()); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + assert (i->str == "" && i->num == 123 && i->vec.empty ()); + + try + { + db->query (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "" && p->num == 234 && p->vec.empty ()); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; // No longer automatically marked as changed. + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "" && p->num == 234 && p->vec.empty ()); + t.commit (); + } + + o.s.change (); + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "" && p->num == 235 && p->vec.empty ()); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test basic soft-added member logic in polymorphic classes. + // + { + using namespace test9; + + // None of the database operations should yet include the + // added members. + // + { + object o (1); + o.bstr = "ab"; + o.dstr = "abc"; + o.num = 123; + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (static_cast (db->load (1))); + assert (p->bstr == "" && p->dstr == "" && p->num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::id == 1)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + object& o (static_cast (*i)); + assert (o.bstr == "" && o.dstr == "" && o.num == 123); + + try + { + db->query (query::bstr == "ab"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && + i->bstr == "" && i->dstr == "" && i->num); + + try + { + db->query (query::dstr == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + auto_ptr p (db->load (2)); + assert (p->bstr == "" && p->dstr == "" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + auto_ptr p (db->load (2)); + assert (p->bstr == "" && p->dstr == "" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test soft-added section member in polymorphic classes. + // + { + using namespace test10; + + // None of the database operations should yet include the + // added members. + // + { + object o (1); + o.bstr = "ab"; + o.dstr = "abc"; + o.num = 123; + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + + try + { + db->load (*p, p->s); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test soft-added members of a section in polymorphic classes. + // + { + using namespace test11; + + // None of the database operations should yet include the + // added members. + // + { + object o (1); + o.bstr = "ab"; + o.dstr = "abc"; + o.num = 123; + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + object& o (static_cast (*p)); + assert (o.bstr == "" && o.dstr == "" && o.num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::id == 1)); + result::iterator i (r.begin ()); + db->load (*i, i->s); + assert (i != r.end ()); + object& o (static_cast (*i)); + assert (o.bstr == "" && o.dstr == "" && o.num == 123); + + try + { + db->query (query::bstr == "ab"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + db->load (*i, i->s); + assert (i != r.end () && + i->bstr == "" && i->dstr == "" && i->num); + + try + { + db->query (query::dstr == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "" && p->dstr == "" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "" && p->dstr == "" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + + // Test empty statement detection in sections. + // + base b (3); + b.bstr = "bc"; + + { + transaction t (db->begin ()); + db->persist (b); + auto_ptr p (db->load (3)); + db->load (*p, p->s); + assert (p->bstr == ""); + t.commit (); + } + + b.bstr += 'd'; + b.s.change (); + + { + transaction t (db->begin ()); + db->update (b); + auto_ptr p (db->load (3)); + db->load (*p, p->s); + assert (p->bstr == ""); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (b); + t.commit (); + } + } + + // Test soft-added member and optimistic concurrency. + // + { + using namespace test12; + + // None of the database operations should yet include the + // added members. + // + { + object o (1); + o.str = "abc"; + o.num = 123; + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "" && p->num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 123); + + try + { + db->query (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->str == "" && p->num == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + + { + transaction t (db->begin ()); + unsigned long long v (o.v_); + db->update (o); + assert (o.v_ != v); + auto_ptr p (db->load (2)); + assert (p->str == "" && p->num == 235 && p->v_ == o.v_); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test soft-added member in an object without id. + // + { + using namespace test13; + + typedef odb::query query; + typedef odb::result result; + + // None of the database operations should yet include the + // added members. + // + { + object o; + o.str = "abc"; + o.num = 123; + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 123); + + try + { + db->query (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o; + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + + result r (db->query (query::num == 234)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 234); + + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase_query (query::num == 234); + t.commit (); + } + } + + // Test soft-added member in an object with auto id. + // + { + using namespace test14; + + // None of the database operations should yet include the + // added members. + // + unsigned long id; + { + object o; + o.str = "abc"; + o.num = 123; + + transaction t (db->begin ()); + db->persist (o); + id = o.id; + t.commit (); + } + { + transaction t (db->begin ()); + auto_ptr p (db->load (id)); + assert (p->str == "" && p->num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 123); + + try + { + db->query (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} + + t.commit (); + } + + object o; + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (o.id)); + assert (p->str == "" && p->num == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (o.id)); + assert (p->str == "" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o.id); + t.commit (); + } + } + + // Test soft-added container member in a non-versioned object. + // + { + using namespace test21; + + // None of the database operations should yet include the + // added members. + // + { + object o (1); + o.num = 123; + o.vec.push_back (123); + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->num == 123 && p->vec.empty ()); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->num == 123 && i->vec.empty ()); + t.commit (); + } + + object o (2); + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->num == 234 && p->vec.empty ()); + t.commit (); + } + + o.num++; + o.vec.modify (0)++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->num == 235 && p->vec.empty ()); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test soft-added container member in a non-versioned section. + // + { + using namespace test22; + + // None of the database operations should yet include the + // added members. + // + { + object o (1); + o.num = 123; + o.vec.push_back (123); + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->num == 123 && p->vec.empty ()); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + assert (i->num == 123 && i->vec.empty ()); + t.commit (); + } + + object o (2); + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->num == 234 && p->vec.empty ()); + t.commit (); + } + + o.num++; + o.vec.modify (0)++; // No longer automatically marks as changed. + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->num == 234 && p->vec.empty ()); + t.commit (); + } + + o.s.change (); + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->num == 235 && p->vec.empty ()); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + // Test basic soft-added member logic. + // + { + using namespace test2; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + p->str = "abc"; + p->vec.push_back (123); + delete p->ptr; + p->ptr = new object1 (1); + db->update (*p); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "abc" && p->num == 123 && + p->vec[0] == 123 && p->ptr->id_ == 1); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str.is_not_null () && + query::ptr->id == 1)); + result::iterator i (r.begin ()); + assert (i != r.end () && + i->str == "abc" && i->num == 123 && + i->vec[0] == 123 && i->ptr->id_ == 1); + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + o.ptr = new object1 (2); + o.ptr->ptrs.push_back (&o); + + { + transaction t (db->begin ()); + db->persist (o); + db->persist (*o.ptr); + auto_ptr p (db->load (2)); + assert (p->str == "bcd" && p->num == 234 && + p->vec[0] == 234 && p->ptr->id_ == 2); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; + delete o.ptr; + o.ptr = 0; + + { + transaction t (db->begin ()); + db->erase (2); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->str == "bcde" && p->num == 235 && + p->vec[0] == 235 && p->ptr == 0); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test container with soft-added value member. + // + { + using namespace test5; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + p->vec.modify (0).str = "abc"; + db->update (*p); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->vec[0].str == "abc" && p->vec[0].num == 123); + t.commit (); + } + + object o (2); + o.vec.push_back (value ("bcd", 234)); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->vec[0].str == "bcd" && p->vec[0].num == 234); + t.commit (); + } + + o.vec.modify (0).str += 'e'; + o.vec.modify (0).num++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->vec[0].str == "bcde" && p->vec[0].num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test view with soft-added member. + // + { + using namespace test6; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + p->str = "abc"; + db->update (*p); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + } + + // Test soft-added section member. + // + { + using namespace test7; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + p->str = "abc"; + p->vec.push_back (123); + db->update (*p, p->s); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + assert (i->str == "abc" && i->num == 123 && i->vec[0] == 123); + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "bcd" && p->num == 234 && p->vec[0] == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; // Automatically marks section as updated. + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "bcde" && p->num == 235 && p->vec[0] == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test soft-added members of a section. + // + { + using namespace test8; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + p->str = "abc"; + p->vec.push_back (123); + db->update (*p, p->s); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + assert (i->str == "abc" && i->num == 123 && i->vec[0] == 123); + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "bcd" && p->num == 234 && p->vec[0] == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; // Automatically marks section as updated. + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "bcde" && p->num == 235 && p->vec[0] == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test basic soft-added member logic in polymorphic classes. + // + { + using namespace test9; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + p->bstr = "ab"; + p->dstr = "abc"; + db->update (*p); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (static_cast (db->load (1))); + assert (p->bstr == "ab" && p->dstr == "abc" && p->num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::bstr == "ab")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + object& o (static_cast (*i)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + auto_ptr p (db->load (2)); + assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + auto_ptr p (db->load (2)); + assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (static_cast (o)); + t.commit (); + } + } + + // Test soft-added section member in polymorphic classes. + // + { + using namespace test10; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + p->bstr = "ab"; + p->dstr = "abc"; + db->update (*p, p->s); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + object& o (static_cast (*p)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::bstr == "ab")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + object& o (static_cast (*i)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (static_cast (o)); + t.commit (); + } + } + + // Test soft-added members of a section in polymorphic classes. + // + { + using namespace test11; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + p->bstr = "ab"; + p->dstr = "abc"; + db->update (*p, p->s); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + object& o (static_cast (*p)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::bstr == "ab")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + object& o (static_cast (*i)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (static_cast (o)); + t.commit (); + } + } + + // Test soft-added member and optimistic concurrency. + // + { + using namespace test12; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + p->str = "abc"; + db->update (*p); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "abc" && p->num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->str == "bcd" && p->num == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + + { + transaction t (db->begin ()); + unsigned long long v (o.v_); + db->update (o); + assert (o.v_ != v); + auto_ptr p (db->load (2)); + assert (p->str == "bcde" && p->num == 235 && p->v_ == o.v_); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test soft-added member in an object without id. + // + { + using namespace test13; + + typedef odb::query query; + typedef odb::result result; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + + object o; + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + + result r (db->query (query::str == "bcd")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "bcd" && i->num == 234); + + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase_query (query::str == "bcd"); + t.commit (); + } + } + + // Test soft-added member in an object with auto id. + // + { + using namespace test14; + + typedef odb::query query; + typedef odb::result result; + + // All the database operations should now include the added + // members. + // + unsigned long id; + { + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + i->str = "abc"; + db->update (*i); + id = i->id; + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (id)); + assert (p->str == "abc" && p->num == 123); + t.commit (); + } + + { + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + + object o; + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (o.id)); + assert (p->str == "bcd" && p->num == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (o.id)); + assert (p->str == "bcde" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test soft-added container member in a non-versioned object. + // + { + using namespace test21; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + p->vec.push_back (123); + db->update (*p); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->num == 123 && p->vec[0] == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->num == 123 && i->vec[0] == 123); + t.commit (); + } + + object o (2); + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->num == 234 && p->vec[0] == 234); + t.commit (); + } + + o.num++; + o.vec.modify (0)++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->num == 235 && p->vec[0] == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test soft-added container member in a non-versioned section. + // + { + using namespace test22; + + // All the database operations should now include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + p->vec.push_back (123); + db->update (*p, p->s); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->num == 123 && p->vec[0] == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + assert (i->num == 123 && i->vec[0] == 123); + t.commit (); + } + + object o (2); + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->num == 234 && p->vec[0] == 234); + t.commit (); + } + + o.num++; + o.vec.modify (0)++; // Automatically marks section as changed. + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->num == 235 && p->vec[0] == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + // Test basic soft-added member logic. + // + { + using namespace test2; + + // All the database operations should still include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "abc" && p->num == 123 && + p->vec[0] == 123 && p->ptr->id_ == 1); + t.commit (); + } + } + + // Test container with soft-added value member. + // + { + using namespace test5; + + // All the database operations should still include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->vec[0].str == "abc" && p->vec[0].num == 123); + t.commit (); + } + } + + // Test view with soft-added member. + // + { + using namespace test6; + + // All the database operations should still include the added + // members. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + } + + // Test soft-added section member. + // + { + using namespace test7; + + // All the database operations should still include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); + t.commit (); + } + } + + // Test soft-added members of a section. + // + { + using namespace test8; + + // All the database operations should still include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); + t.commit (); + } + } + + // Test basic soft-added member logic in polymorphic classes. + // + { + using namespace test9; + + // All the database operations should still include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (static_cast (db->load (1))); + assert (p->bstr == "ab" && p->dstr == "abc" && p->num == 123); + t.commit (); + } + } + + // Test soft-added section member in polymorphic classes. + // + { + using namespace test10; + + // All the database operations should still include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + object& o (static_cast (*p)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + } + + // Test soft-added members of a section in polymorphic classes. + // + { + using namespace test11; + + // All the database operations should still include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + object& o (static_cast (*p)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + } + + // Test soft-added member and optimistic concurrency. + // + { + using namespace test12; + + // All the database operations should still include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "abc" && p->num == 123); + t.commit (); + } + } + + // Test soft-added member in an object without id. + // + { + using namespace test13; + + typedef odb::query query; + typedef odb::result result; + + // All the database operations should still include the added + // members. + // + { + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + } + + // Test soft-added member in an object with auto id. + // + { + using namespace test14; + + // All the database operations should still include the added + // members. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + } + + // Test soft-added container member in a non-versioned object. + // + { + using namespace test21; + + // All the database operations should still include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->num == 123 && p->vec[0] == 123); + t.commit (); + } + } + + // Test soft-added container member in a non-versioned section. + // + { + using namespace test22; + + // All the database operations should still include the added + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->num == 123 && p->vec[0] == 123); + t.commit (); + } + } + + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/soft-add/model.hxx b/odb-tests/evolution/soft-add/model.hxx new file mode 100644 index 0000000..39d63c4 --- /dev/null +++ b/odb-tests/evolution/soft-add/model.hxx @@ -0,0 +1,504 @@ +// file : evolution/soft-add/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#include +#include +#include +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ + // The test numbers are made to correspond to the soft-delete ones. + // + + // Test basic soft-added member logic. + // + #pragma db namespace table("t2_") + namespace test2 + { + struct object; + + #pragma db object + struct object1 + { + object1 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + odb::vector > ptrs; + }; + + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id), ptr (0) {} + ~object () {delete ptr;} + + #pragma db id + unsigned long id_; + + std::string str; + unsigned long num; + odb::vector vec; + + #pragma db inverse(ptrs) + object1* ptr; + }; + +#if MODEL_VERSION == 3 + // Make it a LOB for Oracle and long data for SQL Server. + // + #pragma db member(object::str) added(3) \ + oracle:type("CLOB") \ + mssql:type("VARCHAR(max)") + #pragma db member(object::vec) added(3) + #pragma db member(object::ptr) added(3) +#else + #pragma db member(object::str) transient + #pragma db member(object::vec) transient + #pragma db member(object::ptr) transient +#endif + } + + // Test empty statement handling (INSERT, UPDATE). + // + #pragma db namespace table("t3_") + namespace test3 + { + #pragma db object + struct object + { + #pragma db id auto + unsigned long id; + + std::string str; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) added(3) +#else + #pragma db member(object::str) transient +#endif + } + + // Test empty statement handling (SELECT in polymorphic loader). + // + #pragma db namespace table("t4_") + namespace test4 + { + #pragma db object polymorphic + struct base + { + virtual + ~base () {} + base (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + }; + + #pragma db object + struct object: base + { + object (unsigned long id = 0): base (id) {} + + std::string str; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) added(3) +#else + #pragma db member(object::str) transient +#endif + } + + // Test container with soft-added value member. + // + #pragma db namespace table("t5_") + namespace test5 + { + #pragma db value + struct value + { + value () {} + value (const std::string& s, unsigned long n): str (s), num (n) {} + + std::string str; + unsigned long num; + }; + + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + odb::vector vec; + }; + +#if MODEL_VERSION == 3 + #pragma db member(value::str) added(3) +#else + #pragma db member(value::str) transient +#endif + } + + // Test view with soft-added member. + // + #pragma db namespace table("t6_") + namespace test6 + { + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + std::string str; + unsigned long num; + }; + + #pragma db view object(object) + struct view + { + std::string str; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) added(3) + #pragma db member(view::str) added(3) +#else + #pragma db member(object::str) transient + #pragma db member(view::str) transient +#endif + } + + // Test soft-added section member. + // + #pragma db namespace table("t7_") + namespace test7 + { + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + +#if MODEL_VERSION == 3 + #pragma db load(lazy) update(change) added(3) + odb::section s; +#endif + + #pragma db section(s) + std::string str; + + unsigned long num; + + #pragma db section(s) + odb::vector vec; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) section(s) + #pragma db member(object::vec) section(s) +#else + #pragma db member(object::str) transient + #pragma db member(object::vec) transient +#endif + } + + // Test soft-added members of a section. + // + #pragma db namespace table("t8_") + namespace test8 + { + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db load(lazy) update(change) + odb::section s; + + std::string str; + + #pragma db section(s) + unsigned long num; + + odb::vector vec; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) added(3) section(s) + #pragma db member(object::vec) added(3) section(s) +#else + #pragma db member(object::str) transient + #pragma db member(object::vec) transient +#endif + } + + // Test basic soft-added member logic in polymorphic classes. + // + #pragma db namespace table("t9_") + namespace test9 + { + #pragma db object polymorphic + struct base + { + virtual + ~base () {} + base (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + std::string bstr; + }; + + #pragma db object + struct object: base + { + object (unsigned long id = 0): base (id) {} + + std::string dstr; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(base::bstr) added(3) + #pragma db member(object::dstr) added(3) +#else + #pragma db member(base::bstr) transient + #pragma db member(object::dstr) transient +#endif + } + + // Test soft-added section member in polymorphic classes. + // + #pragma db namespace table("t10_") + namespace test10 + { + #pragma db object polymorphic + struct base + { + virtual + ~base () {} + base (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + +#if MODEL_VERSION == 3 + #pragma db load(lazy) update(change) added(3) + odb::section s; +#endif + + std::string bstr; + }; + + #pragma db object + struct object: base + { + object (unsigned long id = 0): base (id) {} + + std::string dstr; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(base::bstr) section(s) + #pragma db member(object::dstr) section(s) +#else + #pragma db member(base::bstr) transient + #pragma db member(object::dstr) transient +#endif + } + + // Test soft-added members of a section in polymorphic classes. + // + #pragma db namespace table("t11_") + namespace test11 + { + #pragma db object polymorphic + struct base + { + virtual + ~base () {} + base (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db load(lazy) update(change) + odb::section s; + + std::string bstr; + }; + + #pragma db object + struct object: base + { + object (unsigned long id = 0): base (id) {} + + std::string dstr; + + #pragma db section(s) + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(base::bstr) added(3) section(s) + #pragma db member(object::dstr) added(3) section(s) +#else + #pragma db member(base::bstr) transient + #pragma db member(object::dstr) transient +#endif + } + + // Test soft-added member and optimistic concurrency. + // + #pragma db namespace table("t12_") + namespace test12 + { + #pragma db object optimistic + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db version mssql:type("ROWVERSION") + unsigned long long v_; + + std::string str; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) added(3) +#else + #pragma db member(object::str) transient +#endif + } + + // Test soft-added member in an object without id. + // + #pragma db namespace table("t13_") + namespace test13 + { + #pragma db object no_id + struct object + { + std::string str; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) added(3) default("abc") \ + mysql:type("VARCHAR(255)") +#else + #pragma db member(object::str) transient +#endif + } + + // Test soft-added member in an object with auto id. + // + #pragma db namespace table("t14_") + namespace test14 + { + #pragma db object + struct object + { + std::string str; + unsigned long num; + + #pragma db id auto + unsigned long id; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) added(3) +#else + #pragma db member(object::str) transient +#endif + } + + // Test soft-added container member in a non-versioned object. + // + #pragma db namespace table("t21_") + namespace test21 + { + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + unsigned long num; + odb::vector vec; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::vec) added(3) +#else + #pragma db member(object::vec) transient +#endif + } + + // Test soft-added container member in a non-versioned section. + // + #pragma db namespace table("t22_") + namespace test22 + { + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + unsigned long num; + + odb::vector vec; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::vec) added(3) section(s) +#else + #pragma db member(object::vec) transient +#endif + } +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/soft-add/test1.hxx b/odb-tests/evolution/soft-add/test1.hxx new file mode 100644 index 0000000..461d663 --- /dev/null +++ b/odb-tests/evolution/soft-add/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/soft-add/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/soft-add/test2.hxx b/odb-tests/evolution/soft-add/test2.hxx new file mode 100644 index 0000000..746da4b --- /dev/null +++ b/odb-tests/evolution/soft-add/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/soft-add/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/soft-add/test3.hxx b/odb-tests/evolution/soft-add/test3.hxx new file mode 100644 index 0000000..f2990d0 --- /dev/null +++ b/odb-tests/evolution/soft-add/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/soft-add/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/soft-delete/driver.cxx b/odb-tests/evolution/soft-delete/driver.cxx new file mode 100644 index 0000000..e41a70c --- /dev/null +++ b/odb-tests/evolution/soft-delete/driver.cxx @@ -0,0 +1,2202 @@ +// file : evolution/soft-delete/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test soft-delete functionality. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include // DATABASE_XXX +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + // SQLite has broken foreign keys when it comes to DDL. + // +#ifdef DATABASE_SQLITE + db->connection ()->execute ("PRAGMA foreign_keys=OFF"); +#endif + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + +#ifdef DATABASE_SQLITE + db->connection ()->execute ("PRAGMA foreign_keys=ON"); +#endif + } + + // Test soft-deleted objects. + // + { + using namespace test1; + + object o (1); + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test basic soft-deleted member logic. + // + { + using namespace test2; + + object o (1); + o.str = "abc"; + o.num = 123; + o.vec.push_back (123); + o.ptr = new object1 (1); + o.ptr->ptrs.push_back (&o); + + { + transaction t (db->begin ()); + db->persist (o); + db->persist (*o.ptr); + t.commit (); + } + } + + // Test container with soft-deleted value member. + // + { + using namespace test5; + + object o (1); + o.vec.push_back (value ("abc", 123)); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test view with soft-deleted member. + // + { + using namespace test6; + + object o (1); + o.str = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted section member. + // + { + using namespace test7; + + object o (1); + o.str = "abc"; + o.num = 123; + o.vec.push_back (123); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted members of a section. + // + { + using namespace test8; + + object o (1); + o.str = "abc"; + o.num = 123; + o.vec.push_back (123); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test basic soft-deleted member logic in polymorphic classes. + // + { + // We have to use v3 here because the discriminator includes + // the namespace. + // + using namespace v3::test9; + + object o (1); + o.bstr = "ab"; + o.dstr = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted section member in polymorphic classes. + // + { + // We have to use v3 here because the discriminator includes + // the namespace. + // + using namespace v3::test10; + + object o (1); + o.bstr = "ab"; + o.dstr = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted members of a section in polymorphic classes. + // + { + // We have to use v3 here because the discriminator includes + // the namespace. + // + using namespace v3::test11; + + object o (1); + o.bstr = "ab"; + o.dstr = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted member and optimistic concurrency. + // + { + using namespace test12; + + object o (1); + o.str = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted member in an object without id. + // + { + using namespace test13; + + object o; + o.str = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted member in an object with auto id. + // + { + using namespace test14; + + object o; + o.str = "abc"; + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test summarily deleted composite values. + // + { + using namespace test15; + + object o (1); + o.v.reset (new value); + o.v->str = "abc"; + o.v->vec.push_back (123); + o.num = 123; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted container member in a non-versioned object. + // + { + using namespace test21; + + object o (1); + o.num = 123; + o.vec.push_back (123); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + // Test soft-deleted container member in a non-versioned section. + // + { + using namespace test22; + + object o (1); + o.num = 123; + o.vec.push_back (123); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + } + + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + // Test soft-deleted objects. + // + { + using namespace test1; + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->num == 123); + t.commit (); + } + } + + // Test basic soft-deleted member logic. + // + { + using namespace test2; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "abc" && p->num == 123 && + p->vec[0] == 123 && p->ptr->id_ == 1); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc" && + query::ptr->id == 1)); + result::iterator i (r.begin ()); + assert (i != r.end () && + i->str == "abc" && i->num == 123 && + i->vec[0] == 123 && i->ptr->id_ == 1); + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + o.ptr = new object1 (2); + o.ptr->ptrs.push_back (&o); + + { + transaction t (db->begin ()); + db->persist (o); + db->persist (*o.ptr); + auto_ptr p (db->load (2)); + assert (p->str == "bcd" && p->num == 234 && + p->vec[0] == 234 && p->ptr->id_ == 2); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; + delete o.ptr; + o.ptr = 0; + + { + transaction t (db->begin ()); + db->erase (2); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->str == "bcde" && p->num == 235 && + p->vec[0] == 235 && p->ptr == 0); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test container with soft-deleted value member. + // + { + using namespace test5; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->vec[0].str == "abc" && p->vec[0].num == 123); + t.commit (); + } + + object o (2); + o.vec.push_back (value ("bcd", 234)); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->vec[0].str == "bcd" && p->vec[0].num == 234); + t.commit (); + } + + o.vec.modify (0).str += 'e'; + o.vec.modify (0).num++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->vec[0].str == "bcde" && p->vec[0].num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test view with soft-deleted member. + // + { + using namespace test6; + + // All the database operations should still include the deleted + // members. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + } + + // Test soft-deleted section member. + // + { + using namespace test7; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + assert (i->str == "abc" && i->num == 123 && i->vec[0] == 123); + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "bcd" && p->num == 234 && p->vec[0] == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; // Automatically marks section as updated. + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "bcde" && p->num == 235 && p->vec[0] == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test soft-deleted members of a section. + // + { + using namespace test8; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->str == "abc" && p->num == 123 && p->vec[0] == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + assert (i->str == "abc" && i->num == 123 && i->vec[0] == 123); + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "bcd" && p->num == 234 && p->vec[0] == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; // Automatically marks section as updated. + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "bcde" && p->num == 235 && p->vec[0] == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test basic soft-deleted member logic in polymorphic classes. + // + { + using namespace test9; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (static_cast (db->load (1))); + assert (p->bstr == "ab" && p->dstr == "abc" && p->num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::bstr == "ab")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + object& o (static_cast (*i)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + auto_ptr p (db->load (2)); + assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + auto_ptr p (db->load (2)); + assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (static_cast (o)); + t.commit (); + } + } + + // Test soft-deleted section member in polymorphic classes. + // + { + using namespace test10; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + object& o (static_cast (*p)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::bstr == "ab")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + object& o (static_cast (*i)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (static_cast (o)); + t.commit (); + } + } + + // Test soft-deleted members of a section in polymorphic classes. + // + { + using namespace test11; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + object& o (static_cast (*p)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::bstr == "ab")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + object& o (static_cast (*i)); + assert (o.bstr == "ab" && o.dstr == "abc" && o.num == 123); + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "bc" && p->dstr == "bcd" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "bcd" && p->dstr == "bcde" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (static_cast (o)); + t.commit (); + } + } + + // Test soft-deleted member and optimistic concurrency. + // + { + using namespace test12; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "abc" && p->num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->str == "bcd" && p->num == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + + { + transaction t (db->begin ()); + unsigned long long v (o.v_); + db->update (o); + assert (o.v_ != v); + auto_ptr p (db->load (2)); + assert (p->str == "bcde" && p->num == 235 && p->v_ == o.v_); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test soft-deleted member in an object without id. + // + { + using namespace test13; + + typedef odb::query query; + typedef odb::result result; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + t.commit (); + } + + object o; + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + + result r (db->query (query::str == "bcd")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "bcd" && i->num == 234); + + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase_query (query::str == "bcd"); + t.commit (); + } + } + + // Test soft-deleted member in an object with auto id. + // + { + using namespace test14; + + // All the database operations should still include the deleted + // members. + // + unsigned long id; + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "abc" && i->num == 123); + id = i->id; + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (id)); + assert (p->str == "abc" && p->num == 123); + t.commit (); + } + + object o; + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (o.id)); + assert (p->str == "bcd" && p->num == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (o.id)); + assert (p->str == "bcde" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test summarily deleted composite values. + // + { + using namespace test15; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->v->str == "abc" && p->num == 123 && + p->v->vec[0] == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::v.str == "abc")); + result::iterator i (r.begin ()); + assert (i != r.end () && + i->v->str == "abc" && i->num == 123 && + i->v->vec[0] == 123); + t.commit (); + } + + object o (2); + o.v.reset (new value); + o.v->str = "bcd"; + o.num = 234; + o.v->vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->v->str == "bcd" && p->num == 234 && + p->v->vec[0] == 234); + t.commit (); + } + + o.v->str += 'e'; + o.num++; + o.v->vec.modify (0)++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->v->str == "bcde" && p->num == 235 && + p->v->vec[0] == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test soft-deleted container member in a non-versioned object. + // + { + using namespace test21; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->num == 123 && p->vec[0] == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->num == 123 && i->vec[0] == 123); + t.commit (); + } + + object o (2); + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->num == 234 && p->vec[0] == 234); + t.commit (); + } + + o.num++; + o.vec.modify (0)++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->num == 235 && p->vec[0] == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + // Test soft-deleted container member in a non-versioned section. + // + { + using namespace test22; + + // All the database operations should still include the deleted + // members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->num == 123 && p->vec[0] == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + assert (i->num == 123 && i->vec[0] == 123); + t.commit (); + } + + object o (2); + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->num == 234 && p->vec[0] == 234); + t.commit (); + } + + o.num++; + o.vec.modify (0)++; // Automatically marks section as changed. + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->num == 235 && p->vec[0] == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + // Test soft-deleted objects. + // + { + using namespace test1; + + try + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); // No such table. + assert (false); + } + catch (const odb::exception&) {} + } + + // Test basic soft-deleted member logic. + // + { + using namespace test2; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "" && p->num == 123 && + p->vec.empty () && p->ptr == 0); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && + i->str == "" && i->num == 123 && + i->vec.empty () && i->ptr == 0); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->query (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#else + assert (size (db->query (query::str.is_null ())) == 1); +#endif + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + o.ptr = new object1 (2); + o.ptr->ptrs.push_back (&o); + + { + transaction t (db->begin ()); + db->persist (o); + db->persist (*o.ptr); + auto_ptr p (db->load (2)); + assert (p->str == "" && p->num == 234 && + p->vec.empty () && p->ptr == 0); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; + delete o.ptr; + o.ptr = 0; + + { + transaction t (db->begin ()); + db->erase (2); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->str == "" && p->num == 235 && + p->vec.empty () && p->ptr == 0); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test empty statement handling (INSERT, UPDATE). + // + { + using namespace test3; + + // Now none of the database operations should include the + // deleted member. + // + object o; + o.str = "bcd"; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (o.id)); + assert (p->str == ""); + t.commit (); + } + + o.str += 'e'; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (o.id)); + assert (p->str == ""); + t.commit (); + } + } + + // Test empty statement handling (SELECT in polymorphic loader). + // + { + using namespace test4; + + // Now none of the database operations should include the + // deleted member. + // + object o (1); + o.str = "abc"; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (1)); + assert (static_cast (*p).str == ""); + t.commit (); + } + } + + // Test container with soft-deleted value member. + // + { + using namespace test5; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->vec[0].str == "" && p->vec[0].num == 123); + t.commit (); + } + + object o (2); + o.vec.push_back (value ("bcd", 234)); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->vec[0].str == "" && p->vec[0].num == 234); + t.commit (); + } + + o.vec.modify (0).str += 'e'; + o.vec.modify (0).num++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->vec[0].str == "" && p->vec[0].num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test view with soft-deleted member. + // + { + using namespace test6; + + // Now none of the database operations should include the + // deleted members. + // + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 123); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->query (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#else + assert (size (db->query (query::str.is_null ())) == 1); +#endif + t.commit (); + } + } + + // Test soft-deleted section member. + // + { + using namespace test7; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->load (*p, p->s); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#endif + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test soft-deleted members of a section. + // + { + using namespace test8; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->str == "" && p->num == 123 && p->vec.empty ()); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + assert (i->str == "" && i->num == 123 && i->vec.empty ()); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->query (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#else + assert (size (db->query (query::str.is_null ())) == 1); +#endif + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "" && p->num == 234 && p->vec.empty ()); + t.commit (); + } + + o.str += 'e'; + o.num++; + o.vec.modify (0)++; // No longer automatically marked as changed. + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "" && p->num == 234 && p->vec.empty ()); + t.commit (); + } + + o.s.change (); + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->str == "" && p->num == 235 && p->vec.empty ()); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test basic soft-deleted member logic in polymorphic classes. + // + { + using namespace test9; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr p (static_cast (db->load (1))); + assert (p->bstr == "" && p->dstr == "" && p->num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::id == 1)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + object& o (static_cast (*i)); + assert (o.bstr == "" && o.dstr == "" && o.num == 123); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->query (query::bstr == "ab"); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#else + assert (size (db->query (query::bstr.is_null ())) == 1); +#endif + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && + i->bstr == "" && i->dstr == "" && i->num); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->query (query::dstr == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#else + assert (size (db->query (query::dstr.is_null ())) == 1); +#endif + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + auto_ptr p (db->load (2)); + assert (p->bstr == "" && p->dstr == "" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + auto_ptr p (db->load (2)); + assert (p->bstr == "" && p->dstr == "" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test soft-deleted section member in polymorphic classes. + // + { + using namespace test10; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->load (*p, p->s); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#endif + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test soft-deleted members of a section in polymorphic classes. + // + { + using namespace test11; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + object& o (static_cast (*p)); + assert (o.bstr == "" && o.dstr == "" && o.num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::id == 1)); + result::iterator i (r.begin ()); + db->load (*i, i->s); + assert (i != r.end ()); + object& o (static_cast (*i)); + assert (o.bstr == "" && o.dstr == "" && o.num == 123); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->query (query::bstr == "ab"); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#else + assert (size (db->query (query::bstr.is_null ())) == 1); +#endif + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + db->load (*i, i->s); + assert (i != r.end () && + i->bstr == "" && i->dstr == "" && i->num); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->query (query::dstr == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#else + assert (size (db->query (query::dstr.is_null ())) == 1); +#endif + t.commit (); + } + + object o (2); + o.bstr = "bc"; + o.dstr = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "" && p->dstr == "" && p->num == 234); + t.commit (); + } + + o.bstr += 'd'; + o.dstr += 'e'; + o.num++; + o.s.change (); + + { + transaction t (db->begin ()); + db->update (static_cast (o)); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->bstr == "" && p->dstr == "" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + + // Test empty statement detection in sections. + // + base b (3); + b.bstr = "bc"; + + { + transaction t (db->begin ()); + db->persist (b); + auto_ptr p (db->load (3)); + db->load (*p, p->s); + assert (p->bstr == ""); + t.commit (); + } + + b.bstr += 'd'; + b.s.change (); + + { + transaction t (db->begin ()); + db->update (b); + auto_ptr p (db->load (3)); + db->load (*p, p->s); + assert (p->bstr == ""); + t.commit (); + } + } + + // Test soft-deleted member and optimistic concurrency. + // + { + using namespace test12; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->str == "" && p->num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 123); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->query (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#else + assert (size (db->query (query::str.is_null ())) == 1); +#endif + t.commit (); + } + + object o (2); + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->str == "" && p->num == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + + { + transaction t (db->begin ()); + unsigned long long v (o.v_); + db->update (o); + assert (o.v_ != v); + auto_ptr p (db->load (2)); + assert (p->str == "" && p->num == 235 && p->v_ == o.v_); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test soft-deleted member in an object without id. + // + { + using namespace test13; + + typedef odb::query query; + typedef odb::result result; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 123); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->query (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#else + assert (size (db->query (query::str.is_null ())) == 1); +#endif + t.commit (); + } + + object o; + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + + result r (db->query (query::num == 234)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 234); + + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase_query (query::num == 234); + t.commit (); + } + } + + // Test soft-deleted member in an object with auto id. + // + { + using namespace test14; + + // Now none of the database operations should include the + // deleted members. + // + unsigned long id; + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->str == "" && i->num == 123); + id = i->id; + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->query (query::str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#else + assert (size (db->query (query::str.is_null ())) == 1); +#endif + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (id)); + assert (p->str == "" && p->num == 123); + t.commit (); + } + + object o; + o.str = "bcd"; + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (o.id)); + assert (p->str == "" && p->num == 234); + t.commit (); + } + + o.str += 'e'; + o.num++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (o.id)); + assert (p->str == "" && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (o.id); + t.commit (); + } + } + + // Test summarily deleted composite values. + // + { + using namespace test15; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->v.get () == 0 && p->num == 123); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->v.get () == 0 && i->num == 123); + + // Logical delete in SQLite. + // +#ifndef DATABASE_SQLITE + try + { + db->query (query::v.str == "abc"); // No such column. + assert (false); + } + catch (const odb::exception&) {} +#else + assert (size (db->query (query::v.str.is_null ())) == 1); +#endif + t.commit (); + } + + object o (2); + o.num = 234; + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->v.get () == 0 && p->num == 234); + t.commit (); + } + + o.num++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->v.get () == 0 && p->num == 235); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test soft-deleted container member in a non-versioned object. + // + { + using namespace test21; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + assert (p->num == 123 && p->vec.empty ()); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->num == 123 && i->vec.empty ()); + t.commit (); + } + + object o (2); + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + assert (p->num == 234 && p->vec.empty ()); + t.commit (); + } + + o.num++; + o.vec.modify (0)++; + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + assert (p->num == 235 && p->vec.empty ()); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + // Test soft-deleted container member in a non-versioned section. + // + { + using namespace test22; + + // Now none of the database operations should include the + // deleted members. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + db->load (*p, p->s); + assert (p->num == 123 && p->vec.empty ()); + t.commit (); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::num == 123)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + db->load (*i, i->s); + assert (i->num == 123 && i->vec.empty ()); + t.commit (); + } + + object o (2); + o.num = 234; + o.vec.push_back (234); + + { + transaction t (db->begin ()); + db->persist (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->num == 234 && p->vec.empty ()); + t.commit (); + } + + o.num++; + o.vec.modify (0)++; // No longer automatically marks as changed. + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->num == 234 && p->vec.empty ()); + t.commit (); + } + + o.s.change (); + + { + transaction t (db->begin ()); + db->update (o); + auto_ptr p (db->load (2)); + db->load (*p, p->s); + assert (p->num == 235 && p->vec.empty ()); + t.commit (); + } + + { + transaction t (db->begin ()); + db->erase (2); + t.commit (); + } + } + + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/soft-delete/model.hxx b/odb-tests/evolution/soft-delete/model.hxx new file mode 100644 index 0000000..65083dd --- /dev/null +++ b/odb-tests/evolution/soft-delete/model.hxx @@ -0,0 +1,518 @@ +// file : evolution/soft-delete/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include // HAVE_CXX11 + +#include +#include // std::auto_ptr/unique_ptr + +#include +#include +#include +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ + // Test soft-deleted objects. + // + #pragma db namespace table("t1_") + namespace test1 + { + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db object(object) deleted(3) +#endif + } + + // Test basic soft-deleted member logic. + // + #pragma db namespace table("t2_") + namespace test2 + { + struct object; + + #pragma db object + struct object1 + { + object1 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + odb::vector > ptrs; + }; + + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id), ptr (0) {} + ~object () {delete ptr;} + + #pragma db id + unsigned long id_; + + std::string str; + unsigned long num; + odb::vector vec; + + #pragma db inverse(ptrs) + object1* ptr; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) deleted(3) + #pragma db member(object::vec) deleted(3) + #pragma db member(object::ptr) deleted(3) +#endif + } + + // Test empty statement handling (INSERT, UPDATE). + // + #pragma db namespace table("t3_") + namespace test3 + { + #pragma db object + struct object + { + #pragma db id auto + unsigned long id; + + std::string str; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) deleted(3) +#endif + } + + // Test empty statement handling (SELECT in polymorphic loader). + // + #pragma db namespace table("t4_") + namespace test4 + { + #pragma db object polymorphic + struct base + { + virtual + ~base () {} + base (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + }; + + #pragma db object + struct object: base + { + object (unsigned long id = 0): base (id) {} + + std::string str; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) deleted(3) +#endif + } + + // Test container with soft-deleted value member. + // + #pragma db namespace table("t5_") + namespace test5 + { + #pragma db value + struct value + { + value () {} + value (const std::string& s, unsigned long n): str (s), num (n) {} + + std::string str; + unsigned long num; + }; + + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + odb::vector vec; + }; + +#if MODEL_VERSION == 3 + #pragma db member(value::str) deleted(3) +#endif + } + + // Test view with soft-deleted member. + // + #pragma db namespace table("t6_") + namespace test6 + { + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + std::string str; + unsigned long num; + }; + + #pragma db view object(object) + struct view + { + std::string str; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) deleted(3) + #pragma db member(view::str) deleted(3) +#endif + } + + // Test soft-deleted section member. + // + #pragma db namespace table("t7_") + namespace test7 + { + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + std::string str; + + unsigned long num; + + #pragma db section(s) + odb::vector vec; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::s) deleted(3) +#endif + } + + // Test soft-deleted members of a section. + // + #pragma db namespace table("t8_") + namespace test8 + { + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + std::string str; + + #pragma db section(s) + unsigned long num; + + #pragma db section(s) + odb::vector vec; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) deleted(3) + #pragma db member(object::vec) deleted(3) +#endif + } + + // Test basic soft-deleted member logic in polymorphic classes. + // + #pragma db namespace table("t9_") + namespace test9 + { + #pragma db object polymorphic + struct base + { + virtual + ~base () {} + base (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + std::string bstr; + }; + + #pragma db object + struct object: base + { + object (unsigned long id = 0): base (id) {} + + std::string dstr; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(base::bstr) deleted(3) + #pragma db member(object::dstr) deleted(3) +#endif + } + + // Test soft-deleted section member in polymorphic classes. + // + #pragma db namespace table("t10_") + namespace test10 + { + #pragma db object polymorphic + struct base + { + virtual + ~base () {} + base (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + std::string bstr; + }; + + #pragma db object + struct object: base + { + object (unsigned long id = 0): base (id) {} + + #pragma db section(s) + std::string dstr; + + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(base::s) deleted(3) +#endif + } + + // Test soft-deleted members of a section in polymorphic classes. + // + #pragma db namespace table("t11_") + namespace test11 + { + #pragma db object polymorphic + struct base + { + virtual + ~base () {} + base (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + std::string bstr; + }; + + #pragma db object + struct object: base + { + object (unsigned long id = 0): base (id) {} + + #pragma db section(s) + std::string dstr; + + #pragma db section(s) + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(base::bstr) deleted(3) + #pragma db member(object::dstr) deleted(3) +#endif + } + + // Test soft-deleted member and optimistic concurrency. + // + #pragma db namespace table("t12_") + namespace test12 + { + #pragma db object optimistic + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db version mssql:type("ROWVERSION") + unsigned long long v_; + + std::string str; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) deleted(3) +#endif + } + + // Test soft-deleted member in an object without id. + // + #pragma db namespace table("t13_") + namespace test13 + { + #pragma db object no_id + struct object + { + std::string str; + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) deleted(3) +#endif + } + + // Test soft-deleted member in an object with auto id. + // + #pragma db namespace table("t14_") + namespace test14 + { + #pragma db object + struct object + { + std::string str; + unsigned long num; + + #pragma db id auto + unsigned long id; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::str) deleted(3) +#endif + } + + // Test summarily deleted composite values. + // + #pragma db namespace table("t15_") + namespace test15 + { + #pragma db value + struct value + { + std::string str; + odb::vector vec; + }; + + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + +#ifdef HAVE_CXX11 + std::unique_ptr v; +#else + std::auto_ptr v; +#endif + unsigned long num; + }; + +#if MODEL_VERSION == 3 + #pragma db member(value::str) deleted(3) + #pragma db member(value::vec) deleted(3) +#endif + } + + // Test soft-deleted container member in a non-versioned object. + // + #pragma db namespace table("t21_") + namespace test21 + { + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + unsigned long num; + odb::vector vec; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::vec) deleted(3) +#endif + } + + // Test soft-deleted container member in a non-versioned section. + // + #pragma db namespace table("t22_") + namespace test22 + { + #pragma db object + struct object + { + object (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db load(lazy) update(change) + odb::section s; + + #pragma db section(s) + unsigned long num; + + #pragma db section(s) + odb::vector vec; + }; + +#if MODEL_VERSION == 3 + #pragma db member(object::vec) deleted(3) +#endif + } +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/soft-delete/test1.hxx b/odb-tests/evolution/soft-delete/test1.hxx new file mode 100644 index 0000000..d4df90f --- /dev/null +++ b/odb-tests/evolution/soft-delete/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/soft-delete/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/soft-delete/test2.hxx b/odb-tests/evolution/soft-delete/test2.hxx new file mode 100644 index 0000000..3b2b5b4 --- /dev/null +++ b/odb-tests/evolution/soft-delete/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/soft-delete/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/soft-delete/test3.hxx b/odb-tests/evolution/soft-delete/test3.hxx new file mode 100644 index 0000000..5a90ab2 --- /dev/null +++ b/odb-tests/evolution/soft-delete/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/soft-delete/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/template/driver.cxx b/odb-tests/evolution/template/driver.cxx new file mode 100644 index 0000000..b278acd --- /dev/null +++ b/odb-tests/evolution/template/driver.cxx @@ -0,0 +1,124 @@ +// file : evolution/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + schema_catalog::create_schema (*db, "", false); + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + { + transaction t (db->begin ()); + dummy d (1); + db->persist (d); + t.commit (); + } + break; + } + case 2: + { + using namespace v3; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + } + break; + } + case 3: + { + using namespace v3; + + object o; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (o.id_)); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + t.commit (); + } + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/template/model.hxx b/odb-tests/evolution/template/model.hxx new file mode 100644 index 0000000..182c81f --- /dev/null +++ b/odb-tests/evolution/template/model.hxx @@ -0,0 +1,40 @@ +// file : evolution/template/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ +#if MODEL_VERSION == 3 + #pragma db object + struct object + { + #pragma db id auto + unsigned long id_; + }; +#endif + + // The presence of this object makes sure that there are no empty + // changesets and we get the complete set of migration files. + // + #pragma db object + struct dummy + { + dummy (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + }; +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/template/template-vc10.vcxproj b/odb-tests/evolution/template/template-vc10.vcxproj new file mode 100644 index 0000000..c0ebe18 --- /dev/null +++ b/odb-tests/evolution/template/template-vc10.vcxproj @@ -0,0 +1,196 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test1.hxx, +odb test1.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options1) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test1.hxx, +test1-odb.hxx;test1-odb.ixx;test1-odb.cxx;test1.sql;model.xml, +model.hxx) +__custom_build_entry__( +test2.hxx, +odb test2.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options2) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test2.hxx, +test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml, +test1-odb.hxx;model.hxx) +__custom_build_entry__( +test3.hxx, +odb test3.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options3) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test3.hxx, +test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql, +test2-odb.hxx;model.hxx) + + +__header_entry__(test1-odb.hxx) +__header_entry__(test1-odb.ixx) +__header_entry__(test2-odb.hxx) +__header_entry__(test2-odb.ixx) +__header_entry__(test3-odb.hxx) +__header_entry__(test3-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test1-odb.cxx) +__source_entry__(test2-odb.cxx) +__source_entry__(test3-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/evolution/template/template-vc10.vcxproj.filters b/odb-tests/evolution/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..d6ac66e --- /dev/null +++ b/odb-tests/evolution/template/template-vc10.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test1.hxx) +__header_filter_entry__(test1-odb.hxx) +__header_filter_entry__(test1-odb.ixx) +__header_filter_entry__(test2.hxx) +__header_filter_entry__(test2-odb.hxx) +__header_filter_entry__(test2-odb.ixx) +__header_filter_entry__(test3.hxx) +__header_filter_entry__(test3-odb.hxx) +__header_filter_entry__(test3-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test1-odb.cxx) +__source_filter_entry__(test2-odb.cxx) +__source_filter_entry__(test3-odb.cxx) +__source_filter_entries__(extra_sources) + + diff --git a/odb-tests/evolution/template/template-vc11.vcxproj b/odb-tests/evolution/template/template-vc11.vcxproj new file mode 100644 index 0000000..f51fd0c --- /dev/null +++ b/odb-tests/evolution/template/template-vc11.vcxproj @@ -0,0 +1,200 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test1.hxx, +odb test1.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options1) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test1.hxx, +test1-odb.hxx;test1-odb.ixx;test1-odb.cxx;test1.sql;model.xml, +model.hxx) +__custom_build_entry__( +test2.hxx, +odb test2.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options2) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test2.hxx, +test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml, +test1-odb.hxx;model.hxx) +__custom_build_entry__( +test3.hxx, +odb test3.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options3) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test3.hxx, +test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql, +test2-odb.hxx;model.hxx) + + +__header_entry__(test1-odb.hxx) +__header_entry__(test1-odb.ixx) +__header_entry__(test2-odb.hxx) +__header_entry__(test2-odb.ixx) +__header_entry__(test3-odb.hxx) +__header_entry__(test3-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test1-odb.cxx) +__source_entry__(test2-odb.cxx) +__source_entry__(test3-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/evolution/template/template-vc11.vcxproj.filters b/odb-tests/evolution/template/template-vc11.vcxproj.filters new file mode 100644 index 0000000..d6ac66e --- /dev/null +++ b/odb-tests/evolution/template/template-vc11.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test1.hxx) +__header_filter_entry__(test1-odb.hxx) +__header_filter_entry__(test1-odb.ixx) +__header_filter_entry__(test2.hxx) +__header_filter_entry__(test2-odb.hxx) +__header_filter_entry__(test2-odb.ixx) +__header_filter_entry__(test3.hxx) +__header_filter_entry__(test3-odb.hxx) +__header_filter_entry__(test3-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test1-odb.cxx) +__source_filter_entry__(test2-odb.cxx) +__source_filter_entry__(test3-odb.cxx) +__source_filter_entries__(extra_sources) + + diff --git a/odb-tests/evolution/template/template-vc12.vcxproj b/odb-tests/evolution/template/template-vc12.vcxproj new file mode 100644 index 0000000..9562323 --- /dev/null +++ b/odb-tests/evolution/template/template-vc12.vcxproj @@ -0,0 +1,204 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test1.hxx, +odb test1.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options1) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test1.hxx, +test1-odb.hxx;test1-odb.ixx;test1-odb.cxx;test1.sql;model.xml, +model.hxx) +__custom_build_entry__( +test2.hxx, +odb test2.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options2) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test2.hxx, +test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml, +test1-odb.hxx;model.hxx) +__custom_build_entry__( +test3.hxx, +odb test3.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options3) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test3.hxx, +test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql, +test2-odb.hxx;model.hxx) + + +__header_entry__(test1-odb.hxx) +__header_entry__(test1-odb.ixx) +__header_entry__(test2-odb.hxx) +__header_entry__(test2-odb.ixx) +__header_entry__(test3-odb.hxx) +__header_entry__(test3-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test1-odb.cxx) +__source_entry__(test2-odb.cxx) +__source_entry__(test3-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/evolution/template/template-vc12.vcxproj.filters b/odb-tests/evolution/template/template-vc12.vcxproj.filters new file mode 100644 index 0000000..d6ac66e --- /dev/null +++ b/odb-tests/evolution/template/template-vc12.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test1.hxx) +__header_filter_entry__(test1-odb.hxx) +__header_filter_entry__(test1-odb.ixx) +__header_filter_entry__(test2.hxx) +__header_filter_entry__(test2-odb.hxx) +__header_filter_entry__(test2-odb.ixx) +__header_filter_entry__(test3.hxx) +__header_filter_entry__(test3-odb.hxx) +__header_filter_entry__(test3-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test1-odb.cxx) +__source_filter_entry__(test2-odb.cxx) +__source_filter_entry__(test3-odb.cxx) +__source_filter_entries__(extra_sources) + + diff --git a/odb-tests/evolution/template/template-vc8.vcproj b/odb-tests/evolution/template/template-vc8.vcproj new file mode 100644 index 0000000..d6c5f15 --- /dev/null +++ b/odb-tests/evolution/template/template-vc8.vcproj @@ -0,0 +1,372 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__source_entry__(test1-odb.cxx) +__source_entry__(test2-odb.cxx) +__source_entry__(test3-odb.cxx) +__source_entries__(extra_sources) + + +__file_entry_custom_build__( +test1.hxx, +odb test1.hxx, +odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options1) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test1.hxx, +test1-odb.hxx;test1-odb.ixx;test1-odb.cxx;test1.sql;model.xml, +model.hxx) +__file_entry__(test1-odb.hxx) +__file_entry__(test1-odb.ixx) +__file_entry_custom_build__( +test2.hxx, +odb test2.hxx, +odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options2) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test2.hxx, +test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml, +test1-odb.hxx;model.hxx) +__file_entry__(test2-odb.hxx) +__file_entry__(test2-odb.ixx) +__file_entry_custom_build__( +test3.hxx, +odb test3.hxx, +odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options3) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test3.hxx, +test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql, +test2-odb.hxx;model.hxx) +__file_entry__(test3-odb.hxx) +__file_entry__(test3-odb.ixx) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/evolution/template/template-vc9.vcproj b/odb-tests/evolution/template/template-vc9.vcproj new file mode 100644 index 0000000..9177928 --- /dev/null +++ b/odb-tests/evolution/template/template-vc9.vcproj @@ -0,0 +1,379 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__source_entry__(test1-odb.cxx) +__source_entry__(test2-odb.cxx) +__source_entry__(test3-odb.cxx) +__source_entries__(extra_sources) + + +__file_entry_custom_build__( +test1.hxx, +odb test1.hxx, +odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options1) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test1.hxx, +test1-odb.hxx;test1-odb.ixx;test1-odb.cxx;test1.sql;model.xml, +model.hxx) +__file_entry__(test1-odb.hxx) +__file_entry__(test1-odb.ixx) +__file_entry_custom_build__( +test2.hxx, +odb test2.hxx, +odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options2) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test2.hxx, +test2-odb.hxx;test2-odb.ixx;test2-odb.cxx;test2.sql;model.xml, +test1-odb.hxx;model.hxx) +__file_entry__(test2-odb.hxx) +__file_entry__(test2-odb.ixx) +__file_entry_custom_build__( +test3.hxx, +odb test3.hxx, +odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options3) --changelog model.xml -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 __upcase__(-Ddatabase_)__upcase__(__value__(database)) -I$(SolutionDir)\..\libcommon)) test3.hxx, +test3-odb.hxx;test3-odb.ixx;test3-odb.cxx;test3.sql;test3-002-pre.sql;test3-002-post.sql;test3-003-pre.sql;test3-003-post.sql, +test2-odb.hxx;model.hxx) +__file_entry__(test3-odb.hxx) +__file_entry__(test3-odb.ixx) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/evolution/template/test1.hxx b/odb-tests/evolution/template/test1.hxx new file mode 100644 index 0000000..238b686 --- /dev/null +++ b/odb-tests/evolution/template/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/template/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/template/test2.hxx b/odb-tests/evolution/template/test2.hxx new file mode 100644 index 0000000..ec982f5 --- /dev/null +++ b/odb-tests/evolution/template/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/template/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/template/test3.hxx b/odb-tests/evolution/template/test3.hxx new file mode 100644 index 0000000..50f3882 --- /dev/null +++ b/odb-tests/evolution/template/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/template/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/evolution/version/driver.cxx b/odb-tests/evolution/version/driver.cxx new file mode 100644 index 0000000..236c9b4 --- /dev/null +++ b/odb-tests/evolution/version/driver.cxx @@ -0,0 +1,156 @@ +// file : evolution/version/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test schema version access via the database instance. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include // DATABASE_XXX +#include + +#include "test2.hxx" +#include "test3.hxx" +#include "test2-odb.hxx" +#include "test3-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv, false)); + bool embedded (schema_catalog::exists (*db)); + + // 1 - base version + // 2 - migration + // 3 - current version + // + unsigned short pass (*argv[argc - 1] - '0'); + + switch (pass) + { + case 1: + { + using namespace v2; + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::drop_schema (*db); + + assert (db->schema_version () == 0); + + schema_catalog::create_schema (*db, "", false); + + assert (db->schema_version () == 1 && !db->schema_migration ()); + + schema_catalog::migrate_schema (*db, 2); + t.commit (); + } + + assert (db->schema_version () == 2 && !db->schema_migration ()); + + { + transaction t (db->begin ()); + object1 o1 (1); + o1.num = 123; + db->persist (o1); + t.commit (); + } + break; + } + case 2: + { + using namespace v2; + using namespace v3; + + if (embedded) + { + assert (db->schema_version () == 2 && !db->schema_migration ()); + + transaction t (db->begin ()); + schema_catalog::migrate_schema_pre (*db, 3); + t.commit (); + } + + assert (db->schema_version () == 3 && db->schema_migration ()); + + { + transaction t (db->begin ()); + auto_ptr o1 (db->load (1)); + object2 o2 (1); + o2.num = o1->num; + db->persist (o2); + t.commit (); + } + + if (embedded) + { + transaction t (db->begin ()); + schema_catalog::migrate_schema_post (*db, 3); + t.commit (); + + assert (db->schema_version () == 3 && !db->schema_migration ()); + } + break; + } + case 3: + { + using namespace v3; + + // In transaction. + // + { + transaction t (db->begin ()); + assert (db->schema_version () == 3 && !db->schema_migration ()); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr o2 (db->load (1)); + assert (o2->num == 123); + t.commit (); + } + + // Test the case where there is still no version table. + // + db->schema_version_migration (0, false); + + { + transaction t (db->begin ()); + +#ifdef DATABASE_ORACLE + db->execute ("DROP TABLE \"schema_version\""); +#else + db->execute ("DROP TABLE schema_version"); +#endif + t.commit (); + } + + assert (db->schema_version () == 0); + break; + } + default: + { + cerr << "unknown pass number '" << argv[argc - 1] << "'" << endl; + return 1; + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/evolution/version/model.hxx b/odb-tests/evolution/version/model.hxx new file mode 100644 index 0000000..cdda00e --- /dev/null +++ b/odb-tests/evolution/version/model.hxx @@ -0,0 +1,45 @@ +// file : evolution/version/model.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef MODEL_VERSION +# error model.hxx included directly +#endif + +#include + +#pragma db model version(1, MODEL_VERSION) + +#define MODEL_NAMESPACE_IMPL(V) v##V +#define MODEL_NAMESPACE(V) MODEL_NAMESPACE_IMPL(V) + +namespace MODEL_NAMESPACE(MODEL_VERSION) +{ +#if MODEL_VERSION == 2 + #pragma db object + struct object1 + { + object1 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + int num; + }; +#endif + +#if MODEL_VERSION == 3 + #pragma db object + struct object2 + { + object2 (unsigned long id = 0): id_ (id) {} + + #pragma db id + unsigned long id_; + + int num; + }; +#endif +} + +#undef MODEL_NAMESPACE +#undef MODEL_NAMESPACE_IMPL diff --git a/odb-tests/evolution/version/test1.hxx b/odb-tests/evolution/version/test1.hxx new file mode 100644 index 0000000..a50e54c --- /dev/null +++ b/odb-tests/evolution/version/test1.hxx @@ -0,0 +1,9 @@ +// file : evolution/version/test1.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#pragma db model version(1, 1) + +#endif // TEST1_HXX diff --git a/odb-tests/evolution/version/test2.hxx b/odb-tests/evolution/version/test2.hxx new file mode 100644 index 0000000..f7fc1b7 --- /dev/null +++ b/odb-tests/evolution/version/test2.hxx @@ -0,0 +1,11 @@ +// file : evolution/version/test2.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#define MODEL_VERSION 2 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST2_HXX diff --git a/odb-tests/evolution/version/test3.hxx b/odb-tests/evolution/version/test3.hxx new file mode 100644 index 0000000..364ee31 --- /dev/null +++ b/odb-tests/evolution/version/test3.hxx @@ -0,0 +1,11 @@ +// file : evolution/version/test3.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST3_HXX +#define TEST3_HXX + +#define MODEL_VERSION 3 +#include "model.hxx" +#undef MODEL_VERSION + +#endif // TEST3_HXX diff --git a/odb-tests/libcommon/.gitignore b/odb-tests/libcommon/.gitignore new file mode 100644 index 0000000..a994ddc --- /dev/null +++ b/odb-tests/libcommon/.gitignore @@ -0,0 +1,3 @@ +# Generated config header. +# +config.hxx diff --git a/odb-tests/libcommon/buffer.hxx b/odb-tests/libcommon/buffer.hxx new file mode 100644 index 0000000..41b7e46 --- /dev/null +++ b/odb-tests/libcommon/buffer.hxx @@ -0,0 +1,104 @@ +// file : libcommon/buffer.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBCOMMON_BUFFER_HXX +#define LIBCOMMON_BUFFER_HXX + +#include +#include // std::size_t +#include // std::{memcmp,memcpy} + +struct basic_buffer_base +{ + ~basic_buffer_base () + { + operator delete (data_); + } + + basic_buffer_base () + : data_ (0), size_ (0) + { + } + + basic_buffer_base (const void* data, std::size_t size) + : data_ (0), size_ (size) + { + data_ = operator new (size_); + std::memcpy (data_, data, size_); + } + + basic_buffer_base (const basic_buffer_base& y) + : data_ (0), size_ (0) + { + assign (y.data_, y.size_); + } + + basic_buffer_base& + operator= (const basic_buffer_base& y) + { + if (this != &y) + assign (y.data_, y.size_); + + return *this; + } + + void + assign (const void* data, std::size_t size) + { + if (size_ < size) + { + void *p (operator new (size)); + operator delete (data_); + data_ = p; + } + + std::memcpy (data_, data, size); + size_ = size; + } + + std::size_t + size () const + { + return size_; + } + + bool + operator== (const basic_buffer_base& y) const + { + return size_ == y.size_ && std::memcmp (data_, y.data_, size_) == 0; + } + +protected: + void* data_; + std::size_t size_; +}; + +template +struct basic_buffer: basic_buffer_base +{ + basic_buffer () + { + } + + basic_buffer (const T* data, std::size_t size) + : basic_buffer_base (data, size) + { + } + + T* + data () + { + return static_cast (data_); + } + + const T* + data () const + { + return static_cast (data_); + } +}; + +typedef basic_buffer buffer; +typedef basic_buffer ubuffer; + +#endif // LIBCOMMON_BUFFER_HXX diff --git a/odb-tests/libcommon/buildfile b/odb-tests/libcommon/buildfile new file mode 100644 index 0000000..eb61455 --- /dev/null +++ b/odb-tests/libcommon/buildfile @@ -0,0 +1,50 @@ +# file : libcommon/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import intf_libs = libodb%lib{odb} + +for db: $databases + import intf_libs += libodb-$db%lib{odb-$db} + +lib{common}: {hxx ixx txx cxx}{** -config} hxx{config} $intf_libs + +# Generated config file. +# +using autoconf + +hxx{config}: in{config} +{ + DATABASE_MYSQL = $mysql + DATABASE_SQLITE = $sqlite + DATABASE_PGSQL = $pgsql + DATABASE_ORACLE = $oracle + DATABASE_MSSQL = $mssql + MULTI_DATABASE = $multi +} + +# Build options. +# +cxx.poptions =+ "-I$out_root" "-I$src_root" + +{hbmia obja}{*}: cxx.poptions += -DLIBCOMMON_STATIC_BUILD +{hbmis objs}{*}: cxx.poptions += -DLIBCOMMON_SHARED_BUILD + +# Export options. +# +lib{common}: +{ + cxx.export.poptions = "-I$out_root" "-I$src_root" + cxx.export.libs = $intf_libs +} + +liba{common}: cxx.export.poptions += -DLIBCOMMON_STATIC +libs{common}: cxx.export.poptions += -DLIBCOMMON_SHARED + +# For pre-releases use the complete version to make sure they cannot +# be used in place of another pre-release or the final version. See +# the version module for details on the version.* variable values. +# +if $version.pre_release + lib{common}: bin.lib.version = "-$version.project_id" +else + lib{common}: bin.lib.version = "-$version.major.$version.minor" diff --git a/odb-tests/libcommon/common.cxx b/odb-tests/libcommon/common.cxx new file mode 100644 index 0000000..b3e4cfd --- /dev/null +++ b/odb-tests/libcommon/common.cxx @@ -0,0 +1,355 @@ +// file : libcommon/common.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::exit +#include // std::move +#include + +#include + +#include +#include + +using namespace std; +using namespace odb::core; + + +// MySQL. +// +#if defined(DATABASE_MYSQL) + +#include +#include + +static unique_ptr +create_mysql_database (int& argc, char* argv[], bool, size_t max_connections) +{ + namespace mysql = odb::mysql; + + unique_ptr f; + + if (max_connections != 0) + f.reset (new mysql::connection_pool_factory (max_connections)); + + return unique_ptr ( + new mysql::database (argc, argv, false, "", 0, move (f))); +} +#endif // MySQL + + +// SQLite. +// +#if defined(DATABASE_SQLITE) + +#include +#include +#include +#include +#include + +static unique_ptr +create_sqlite_database (int& argc, + char* argv[], + bool schema, + size_t max_connections) +{ + namespace sqlite = odb::sqlite; + + unique_ptr f; + + if (max_connections != 0) + f.reset (new sqlite::connection_pool_factory (max_connections)); + + unique_ptr db ( + new sqlite::database ( + argc, argv, false, + SQLITE_OPEN_READWRITE + | SQLITE_OPEN_CREATE +#ifdef SQLITE_OPEN_URI + | SQLITE_OPEN_URI +#endif + , + true, + "", + move (f))); + + // Create the database schema. Due to bugs in SQLite foreign key + // support for DDL statements, we need to temporarily disable + // foreign keys. + // + if (schema) + { + connection_ptr c (db->connection ()); + + c->execute ("PRAGMA foreign_keys=OFF"); + + transaction t (c->begin ()); + schema_catalog::create_schema (*db); + t.commit (); + + c->execute ("PRAGMA foreign_keys=ON"); + } + + return db; +} +#endif // SQLite + + +// PostgreSQL. +// +#if defined(DATABASE_PGSQL) + +#include +#include + +static unique_ptr +create_pgsql_database (int& argc, char* argv[], bool, size_t max_connections) +{ + namespace pgsql = odb::pgsql; + + unique_ptr f; + + if (max_connections != 0) + f.reset (new pgsql::connection_pool_factory (max_connections)); + + return unique_ptr ( + new pgsql::database (argc, argv, false, "", move (f))); +} +#endif // PostgreSQL + + +// Oracle. +// +#if defined(DATABASE_ORACLE) + +#include +#include + +static unique_ptr +create_oracle_database (int& argc, char* argv[], bool, size_t max_connections) +{ + namespace oracle = odb::oracle; + + unique_ptr f; + + if (max_connections != 0) + f.reset (new oracle::connection_pool_factory (max_connections)); + + // Set client database character set and client national character set + // to UTF-8. + // + return unique_ptr ( + new oracle::database (argc, argv, false, 873, 873, 0, move (f))); +} +#endif // Oracle + +// SQL Server. +// +#if defined(DATABASE_MSSQL) + +#include +#include + +static unique_ptr +create_mssql_database (int& argc, char* argv[], bool, size_t max_connections) +{ + namespace mssql = odb::mssql; + + unique_ptr f; + + if (max_connections != 0) + f.reset (new mssql::connection_pool_factory (max_connections)); + + return unique_ptr ( + new mssql::database (argc, argv, false, "", + mssql::isolation_read_committed, 0, move (f))); +} +#endif // SQL Server + +// +// +unique_ptr +create_database (int argc, + char* argv[], + bool schema, + size_t max_connections, +#if defined(MULTI_DATABASE) + odb::database_id db +#else + odb::database_id +#endif +) +{ + char** argp = argv + 1; // Position of the next argument. Assignment for VC8. + int argn (argc - 1); // Number of arguments left. + +#if defined(MULTI_DATABASE) + // Figure out which database we are creating. We may be given the + // database name as a program argument or as an id. + // + if (db == odb::id_common && argn != 0) + { + string s (*argp); + + if (s == "mysql") + db = odb::id_mysql; + else if (s == "sqlite") + db = odb::id_sqlite; + else if (s == "pgsql") + db = odb::id_pgsql; + else if (s == "oracle") + db = odb::id_oracle; + else if (s == "mssql") + db = odb::id_mssql; + + if (db != odb::id_common) + { + argp++; + argn--; + } + } + + if (db == odb::id_common) + { + cerr << "Usage: " << argv[0] << " [options]" << endl; + exit (1); + } +#endif + + if (argn != 0 && *argp == string ("--help")) + { +#if defined(MULTI_DATABASE) + cout << "Usage: " << argv[0] << " [options]" << endl; +#else + cout << "Usage: " << argv[0] << " [options]" << endl; +#endif + + cout << "Options:" << endl; + +#if defined(MULTI_DATABASE) + switch (db) + { + case odb::id_mysql: +#if defined(DATABASE_MYSQL) + odb::mysql::database::print_usage (cout); +#else + assert (false); +#endif + break; + case odb::id_sqlite: +#if defined(DATABASE_SQLITE) + odb::sqlite::database::print_usage (cout); +#else + assert (false); +#endif + break; + case odb::id_pgsql: +#if defined(DATABASE_PGSQL) + odb::pgsql::database::print_usage (cout); +#else + assert (false); +#endif + break; + case odb::id_oracle: +#if defined(DATABASE_ORACLE) + odb::oracle::database::print_usage (cout); +#else + assert (false); +#endif + break; + case odb::id_mssql: +#if defined(DATABASE_MSSQL) + odb::mssql::database::print_usage (cout); +#else + assert (false); +#endif + break; + case odb::id_common: + assert (false); + } +#elif defined(DATABASE_MYSQL) + odb::mysql::database::print_usage (cout); +#elif defined(DATABASE_SQLITE) + odb::sqlite::database::print_usage (cout); +#elif defined(DATABASE_PGSQL) + odb::pgsql::database::print_usage (cout); +#elif defined(DATABASE_ORACLE) + odb::oracle::database::print_usage (cout); +#elif defined(DATABASE_MSSQL) + odb::mssql::database::print_usage (cout); +#else +# error unknown database +#endif + + exit (0); + } + +#if defined(MULTI_DATABASE) + switch (db) + { + case odb::id_mysql: +#if defined(DATABASE_MYSQL) + return create_mysql_database (argc, argv, schema, max_connections); +#else + assert (false); + break; +#endif + case odb::id_sqlite: +#if defined(DATABASE_SQLITE) + return create_sqlite_database (argc, argv, schema, max_connections); +#else + assert (false); + break; +#endif + case odb::id_pgsql: +#if defined(DATABASE_PGSQL) + return create_pgsql_database (argc, argv, schema, max_connections); +#else + assert (false); + break; +#endif + case odb::id_oracle: +#if defined(DATABASE_ORACLE) + return create_oracle_database (argc, argv, schema, max_connections); +#else + assert (false); + break; +#endif + case odb::id_mssql: +#if defined(DATABASE_MSSQL) + return create_mssql_database (argc, argv, schema, max_connections); +#else + assert (false); + break; +#endif + case odb::id_common: + assert (false); + } + return unique_ptr (); +#elif defined(DATABASE_MYSQL) + return create_mysql_database (argc, argv, schema, max_connections); +#elif defined(DATABASE_SQLITE) + return create_sqlite_database (argc, argv, schema, max_connections); +#elif defined(DATABASE_PGSQL) + return create_pgsql_database (argc, argv, schema, max_connections); +#elif defined(DATABASE_ORACLE) + return create_oracle_database (argc, argv, schema, max_connections); +#elif defined(DATABASE_MSSQL) + return create_mssql_database (argc, argv, schema, max_connections); +#else +# error unknown database +#endif +} + +bool +size_available () +{ +#if defined(MULTI_DATABASE) || \ + defined(DATABASE_SQLITE) || \ + defined(DATABASE_ORACLE) || \ + defined(DATABASE_MSSQL) + return false; +#else + return true; +#endif +} diff --git a/odb-tests/libcommon/common.hxx b/odb-tests/libcommon/common.hxx new file mode 100644 index 0000000..9ab978d --- /dev/null +++ b/odb-tests/libcommon/common.hxx @@ -0,0 +1,47 @@ +// file : libcommon/common.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBCOMMON_COMMON_HXX +#define LIBCOMMON_COMMON_HXX + +#include // std::unique_ptr +#include // std::size_t + +#include +#include + +#include + +LIBCOMMON_SYMEXPORT std::unique_ptr +create_database (int argc, + char* argv[], + bool create_schema = true, + std::size_t max_connections = 0, + odb::database_id db = odb::id_common); + +template +std::unique_ptr +create_specific_database (int argc, + char* argv[], + bool create_schema = true, + std::size_t max_connections = 0) +{ + std::unique_ptr r ( + create_database (argc, argv, + create_schema, + max_connections, + T::database_id)); + + return std::unique_ptr (&dynamic_cast (*r.release ())); +} + +// This function returns an accurate result only if the result iterator +// hasn't been advanced and after the call the result is no longer valid. +// +template +std::size_t +size (odb::result); + +#include + +#endif // LIBCOMMON_COMMON_HXX diff --git a/odb-tests/libcommon/common.txx b/odb-tests/libcommon/common.txx new file mode 100644 index 0000000..caa7481 --- /dev/null +++ b/odb-tests/libcommon/common.txx @@ -0,0 +1,24 @@ +// file : libcommon/common.txx +// license : GNU GPL v2; see accompanying LICENSE file + +// We have to use this helper function instead of just checking which +// database is used because the DATABASE_* macro may not be defined +// in a project that includes this header. +// +LIBCOMMON_SYMEXPORT bool +size_available (); + +template +std::size_t +size (odb::result r) +{ + if (size_available ()) + return r.size (); + else + { + std::size_t n (0); + for (typename odb::result::iterator i (r.begin ()); i != r.end (); ++i) + n++; + return n; + } +} diff --git a/odb-tests/libcommon/concrete.hxx b/odb-tests/libcommon/concrete.hxx new file mode 100644 index 0000000..e0f64a5 --- /dev/null +++ b/odb-tests/libcommon/concrete.hxx @@ -0,0 +1,57 @@ +// file : libcommon/concrete.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBCOMMON_CONCRETE_HXX +#define LIBCOMMON_CONCRETE_HXX + +#include + +// Namespace alias for the concrete database namespace. +// +#if defined(MULTI_DATABASE) + +// Fallback to common interface. +// +#include +#include + +namespace odb_db = odb; + +#elif defined(DATABASE_MYSQL) + +#include +#include + +namespace odb_db = odb::mysql; + +#elif defined(DATABASE_SQLITE) + +#include +#include + +namespace odb_db = odb::sqlite; + +#elif defined(DATABASE_PGSQL) + +#include +#include + +namespace odb_db = odb::pgsql; + +#elif defined(DATABASE_ORACLE) + +#include +#include + +namespace odb_db = odb::oracle; + +#elif defined(DATABASE_MSSQL) + +#include +#include + +namespace odb_db = odb::mssql; + +#endif + +#endif // LIBCOMMON_CONCRETE_HXX diff --git a/odb-tests/libcommon/config.hxx.in b/odb-tests/libcommon/config.hxx.in new file mode 100644 index 0000000..ff90e61 --- /dev/null +++ b/odb-tests/libcommon/config.hxx.in @@ -0,0 +1,14 @@ +// file : libcommon/config.hxx.in +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBCOMMON_CONFIG_HXX +#define LIBCOMMON_CONFIG_HXX + +#undef DATABASE_MYSQL +#undef DATABASE_SQLITE +#undef DATABASE_PGSQL +#undef DATABASE_ORACLE +#undef DATABASE_MSSQL +#undef MULTI_DATABASE + +#endif // LIBCOMMON_CONFIG_HXX diff --git a/odb-tests/libcommon/export.hxx b/odb-tests/libcommon/export.hxx new file mode 100644 index 0000000..0de4565 --- /dev/null +++ b/odb-tests/libcommon/export.hxx @@ -0,0 +1,39 @@ +#pragma once + +// Normally we don't export class templates (but do complete specializations), +// inline functions, and classes with only inline member functions. Exporting +// classes that inherit from non-exported/imported bases (e.g., std::string) +// will end up badly. The only known workarounds are to not inherit or to not +// export. Also, MinGW GCC doesn't like seeing non-exported functions being +// used before their inline definition. The workaround is to reorder code. In +// the end it's all trial and error. + +#if defined(LIBCOMMON_STATIC) // Using static. +# define LIBCOMMON_SYMEXPORT +#elif defined(LIBCOMMON_STATIC_BUILD) // Building static. +# define LIBCOMMON_SYMEXPORT +#elif defined(LIBCOMMON_SHARED) // Using shared. +# ifdef _WIN32 +# define LIBCOMMON_SYMEXPORT __declspec(dllimport) +# else +# define LIBCOMMON_SYMEXPORT +# endif +#elif defined(LIBCOMMON_SHARED_BUILD) // Building shared. +# ifdef _WIN32 +# define LIBCOMMON_SYMEXPORT __declspec(dllexport) +# else +# define LIBCOMMON_SYMEXPORT +# endif +#else +// If none of the above macros are defined, then we assume we are being used +// by some third-party build system that cannot/doesn't signal the library +// type. Note that this fallback works for both static and shared libraries +// provided the library only exports functions (in other words, no global +// exported data) and for the shared case the result will be sub-optimal +// compared to having dllimport. If, however, your library does export data, +// then you will probably want to replace the fallback with the (commented +// out) error since it won't work for the shared case. +// +# define LIBCOMMON_SYMEXPORT // Using static or shared. +//# error define LIBCOMMON_STATIC or LIBCOMMON_SHARED preprocessor macro to signal libcommon library type being linked +#endif diff --git a/odb-tests/manifest b/odb-tests/manifest new file mode 100644 index 0000000..858baa7 --- /dev/null +++ b/odb-tests/manifest @@ -0,0 +1,48 @@ +: 1 +name: odb-tests +version: 2.5.0-b.26.z +project: odb +type: tests +language: c++ +summary: ODB compiler tests +license: GPL-2.0-only +description-file: README.md +url: https://www.codesynthesis.com/products/odb/ +doc-url: https://www.codesynthesis.com/products/odb/doc/manual.xhtml +src-url: https://git.codesynthesis.com/cgit/odb/odb/ +email: odb-users@codesynthesis.com ; Mailing list + +# @@ BUILD2 The odb dependency can only be built with GCC. However, shouldn't +# we test that the odb-generated mappings can be compiled by other +# compilers and properly run afterwards? +# +builds: default +builds: -( +windows -gcc ) ; Requires MinGW GCC. +builds: &gcc ; Requires GCC with plugin support enabled. +builds: &gcc-5+ ; Requires GCC 5 or later. +builds: -static ; Implementation uses plugins and requires -fPIC. + +depends: * build2 >= 0.16.0 +depends: * bpkg >= 0.16.0 + +depends: * odb [2.5.0-b.26.1 2.5.0-b.27) + +depends: libodb [2.5.0-b.26.1 2.5.0-b.27) +depends: libodb-mysql [2.5.0-b.26.1 2.5.0-b.27) ? ($mysql) +depends: libodb-sqlite [2.5.0-b.26.1 2.5.0-b.27) ? ($sqlite) +depends: libodb-pgsql [2.5.0-b.26.1 2.5.0-b.27) ? ($pgsql) +depends: libodb-oracle [2.5.0-b.26.1 2.5.0-b.27) ? ($oracle) +depends: libodb-mssql [2.5.0-b.26.1 2.5.0-b.27) ? ($mssql) + +# Reflect whether libodb-pgsql is likely to support bulk operations. This is +# normally the case on POSIX platforms if libodb-pgsql is linked against libpq +# of the version 14 or above. +# +depends: libpq >= 14.0.0 ? ($pgsql) config.odb_tests.pgsql.bulk_default=true | \ + libpq >= 7.4.0 ? ($pgsql) config.odb_tests.pgsql.bulk_default=false + +# @@ TODO/LATER: use an alternative to automatically detect whether we are +# using MySQL or MariaDB? But maybe we don't need to know? + +depends: mysql >= 5.0.3 ? ($mysql) +depends: psql >= 7.4.0 ? ($pgsql) diff --git a/odb-tests/mssql/custom/custom.sql b/odb-tests/mssql/custom/custom.sql new file mode 100644 index 0000000..44ef512 --- /dev/null +++ b/odb-tests/mssql/custom/custom.sql @@ -0,0 +1,42 @@ +/* This file contains helper functions. + */ + +IF OBJECT_ID('dbo.variant_to_string', 'FN') IS NOT NULL + DROP FUNCTION dbo.variant_to_string; +GO + +IF OBJECT_ID('dbo.string_to_variant', 'FN') IS NOT NULL + DROP FUNCTION dbo.string_to_variant; +GO + +CREATE FUNCTION dbo.variant_to_string (@val SQL_VARIANT) RETURNS VARCHAR(max) +AS +BEGIN + RETURN CAST(SQL_VARIANT_PROPERTY(@val, 'BaseType') AS SYSNAME) + ' ' + + CAST(@val AS VARCHAR(max)) +END; +GO + +CREATE FUNCTION dbo.string_to_variant (@val VARCHAR(max)) RETURNS SQL_VARIANT +AS +BEGIN + DECLARE @ret SQL_VARIANT + + DECLARE @pos BIGINT + DECLARE @vtype SYSNAME + DECLARE @vtext VARCHAR(max) + + SET @pos = CHARINDEX(' ', @val) + SET @vtype = SUBSTRING(@val, 1, @pos - 1) + SET @vtext = SUBSTRING(@val, @pos + 1, LEN(@val)) + + IF @vtype = 'tinyint' SET @ret = CAST(@vtext AS TINYINT) + ELSE IF @vtype = 'smallint' SET @ret = CAST(@vtext AS SMALLINT) + ELSE IF @vtype = 'int' SET @ret = CAST(@vtext AS INT) + ELSE IF @vtype = 'bigint' SET @ret = CAST(@vtext AS BIGINT) + ELSE IF @vtype = 'char' SET @ret = CAST(@vtext AS CHAR(8000)) + ELSE IF @vtype = 'varchar' SET @ret = CAST(@vtext AS VARCHAR(8000)) + + RETURN @ret +END; +GO diff --git a/odb-tests/mssql/custom/driver.cxx b/odb-tests/mssql/custom/driver.cxx new file mode 100644 index 0000000..bde7eb6 --- /dev/null +++ b/odb-tests/mssql/custom/driver.cxx @@ -0,0 +1,135 @@ +// file : mssql/custom/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test custom database type mapping in SQL Server. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +namespace mssql = odb::mssql; +using namespace mssql; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_specific_database (argc, argv)); + + object o (1); + + o.v = variant (123); + o.vv.push_back (variant (string (1024, 'a'))); + o.vv.push_back (variant (123)); + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + o.p = point (1.1111, 2222222222.2); + o.pv.push_back (point (1.1234, 2.2345)); + o.pv.push_back (point (3.3456, 4.4567)); + o.pv.push_back (point (0.0000001, 0.000000001)); // Scientific notation. +#endif + + o.xml = "AAABBBCCC"; + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + + // Query. + // + typedef mssql::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + // Variant comparison. + // + { + result r (db->query (query::v == o.v)); + assert (!r.empty ()); + } + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + // Point comparison. + // + { + result r (db->query (query::p == o.p)); + assert (!r.empty ()); + } + + // Point comparison using native query. + // + { + result r (db->query ( + query::p + ".STEquals(" + query::_val (o.p) + ") = 1")); + assert (!r.empty ()); + } + + // Access to individual members. + // + { + result r (db->query (query::p.x == o.p.x)); + assert (!r.empty ()); + } +#endif + + t.commit (); + } + + // Update. + // +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + o.p.x++; + o.p.y--; + o.pv[1].x--; + o.pv[1].y++; +#endif + + o.xml = "BBBCCCDDD"; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mssql/custom/query.hxx b/odb-tests/mssql/custom/query.hxx new file mode 100644 index 0000000..fc63378 --- /dev/null +++ b/odb-tests/mssql/custom/query.hxx @@ -0,0 +1,183 @@ +// file : mssql/custom/query.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef QUERY_HXX +#define QUERY_HXX + +#include + +#include + +#include "test.hxx" // point + +namespace odb +{ + namespace mssql + { +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + template <> + struct query_column + { + private: + const char* table_; + const char* column_; + const char* conversion_; + + unsigned short prec_; + unsigned short scale_; + + std::string x_column_; + std::string y_column_; + + // Sub-columns for individual members. + // + public: + query_column x, y; + + // is_null, is_not_null + // + public: + query_base + is_null () const + { + query_base q (table_, column_); + q += "IS NULL"; + return q; + } + + query_base + is_not_null () const + { + query_base q (table_, column_); + q += "IS NOT NULL"; + return q; + } + + // = + // + public: + query_base + equal (const point& v) const + { + return equal (val_bind (v)); + } + + query_base + equal (val_bind v) const + { + query_base q (table_, column_); + q += ".STEquals("; + q.append (v, conversion_); + q += ") = 1"; + return q; + } + + query_base + equal (ref_bind r) const + { + query_base q (table_, column_); + q += ".STEquals("; + q.append (r, conversion_); + q += ") = 1"; + return q; + } + + friend query_base + operator== (const query_column& c, const point& v) + { + return c.equal (v); + } + + friend query_base + operator== (const point& v, const query_column& c) + { + return c.equal (v); + } + + friend query_base + operator== (const query_column& c, val_bind v) + { + return c.equal (v); + } + + friend query_base + operator== (val_bind v, const query_column& c) + { + return c.equal (v); + } + + friend query_base + operator== (const query_column& c, ref_bind r) + { + return c.equal (r); + } + + friend query_base + operator== (ref_bind r, const query_column& c) + { + return c.equal (r); + } + + // Column comparison. + // + public: + query_base + operator== (const query_column& c) const + { + query_base q (table_, column_); + q += ".STEquals("; + q.append (c.table (), c.column ()); + q += ") = 1"; + return q; + } + + public: + query_column (const char* table, + const char* column, + const char* conv, + unsigned short prec = 0, + unsigned short scale = 0xFFFF) + : table_ (table), column_ (column), conversion_ (conv), + prec_ (prec), scale_ (scale), + x_column_ (std::string (column) + ".STX"), + y_column_ (std::string (column) + ".STY"), + x (table, x_column_.c_str (), 0), + y (table, y_column_.c_str (), 0) + { + } + + const char* + table () const + { + return table_; + } + + const char* + column () const + { + return column_; + } + + const char* + conversion () const + { + return conversion_; + } + + unsigned short + prec () const + { + return prec_; + } + + unsigned short + scale () const + { + return scale_; + } + }; +#endif // SQL Server > 2005 + } +} + +#endif // QUERY_HXX diff --git a/odb-tests/mssql/custom/test.hxx b/odb-tests/mssql/custom/test.hxx new file mode 100644 index 0000000..4b8a5d7 --- /dev/null +++ b/odb-tests/mssql/custom/test.hxx @@ -0,0 +1,121 @@ +// file : mssql/types/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +// Map SQL Server SQL_VARIANT type to our variant C++ class that is capable +// of storing either an integer or a string (QVariant and boost::variant +// would be natural alternatives to our own type). The SQL Server functions +// that are used in the 'to' and 'from' expressions below are defined in +// the custom.sql file. The other half of this mapping is in traits.hxx +// (value_traits). +// +#pragma db map type("SQL_VARIANT") \ + as("VARCHAR(max)") \ + to("dbo.string_to_variant((?))") \ + from("dbo.variant_to_string((?))") + +#pragma db value type("SQL_VARIANT") +struct variant +{ + variant (unsigned long v = 0): val_type (type_int), int_val (v) {} + variant (const std::string& v): val_type (type_str), str_val (v) {} + + enum {type_int, type_str} val_type; + unsigned long int_val; + std::string str_val; +}; + +inline bool +operator== (const variant& a, const variant& b) +{ + if (a.val_type != b.val_type) + return false; + + switch (a.val_type) + { + case variant::type_int: + return a.int_val == b.int_val; + case variant::type_str: + return a.str_val == b.str_val; + } + + return false; +} + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 +// Map GEOMETRY SQL Server type to the point C++ struct. The other half +// of this mapping is in traits.hxx (value_traits). +// Note that GEOMETRY is not available in SQL Server 2005. +// +#pragma db map type("GEOMETRY") \ + as("VARCHAR(256)") \ + to("GEOMETRY::STGeomFromText((?), 0)") \ + from("(?).STAsText()") + +#pragma db value type("GEOMETRY") +struct point +{ + point () {} + point (double x_, double y_): x (x_), y (y_) {} + + double x; + double y; +}; + +inline bool +operator== (const point& a, const point& b) +{ + return a.x == b.x && a.y == b.y; +} +#endif // SQL Server > 2005 + +// Map XML SQL Server type to std::string (or any other type that provides +// the value_traits specialization). Note also that +// another alternative would be to interface with the XML data type using +// VARBINARY or NVARCHAR. Here we use implicit string to/from XML conversion, +// however, CAST/CONVERT can be used instead for greater control over +// whitespace handling, etc. +// +#pragma db map type("XML *(\\(.+\\))?") as("VARCHAR(max)") + +#pragma db object +struct object +{ + object () {} + object (unsigned long id_) : id (id_) {} + + #pragma db id + unsigned long id; + + variant v; + std::vector vv; + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + point p; + std::vector pv; +#endif + + #pragma db type("XML") + std::string xml; + + bool + operator== (const object& y) const + { + return id == y.id + && vv == y.vv +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + && p == y.p + && pv == y.pv +#endif + && xml == y.xml; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/mssql/custom/traits.cxx b/odb-tests/mssql/custom/traits.cxx new file mode 100644 index 0000000..3f14ae7 --- /dev/null +++ b/odb-tests/mssql/custom/traits.cxx @@ -0,0 +1,128 @@ +// file : mssql/types/traits.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include "traits.hxx" + +using namespace std; + +namespace odb +{ + namespace mssql + { + void value_traits:: + param_callback (const void* context, + size_t*, + const void** buffer, + size_t* size, + chunk_type* chunk, + void* tmp_buf, + size_t tmp_capacity) + { + const variant& v (*static_cast (context)); + string str; + + switch (v.val_type) + { + case variant::type_int: + { + ostringstream os; + os << v.int_val; + + str = "bigint "; + str += os.str (); + break; + } + case variant::type_str: + { + str = "varchar "; + str += v.str_val; + break; + } + } + + // Here we assume that the temoprary buffer is large enough to fit + // the whole string in one go. If that were not the case, then we + // would have had to chunk it. + // + assert (tmp_capacity >= str.size ()); + memcpy (tmp_buf, str.c_str (), str.size ()); + + *buffer = tmp_buf; + *size = str.size (); + *chunk = chunk_one; + } + + void value_traits:: + result_callback (void* context, + size_t*, + void** buffer, + size_t* size, + chunk_type chunk, + size_t, + void* tmp_buf, + size_t tmp_capacity) + { + variant& v (*static_cast (context)); + + switch (chunk) + { + case chunk_null: + case chunk_one: + { + assert (false); // The value cannot be NULL or empty. + break; + } + case chunk_first: + { + // Use the variant's string value as a temporary buffer. If this + // were not possible, we could have allocated one as part of + // context. + // + v.str_val.clear (); + + *buffer = tmp_buf; + *size = tmp_capacity; + break; + } + case chunk_next: + { + v.str_val.append (static_cast (tmp_buf), *size); + + *buffer = tmp_buf; + *size = tmp_capacity; + break; + } + case chunk_last: + { + v.str_val.append (static_cast (tmp_buf), *size); + + // Figure out what we've got. + // + string::size_type p (v.str_val.find (' ')); + assert (p != string::npos); // Must have type followed by value. + string type (v.str_val, 0, p); + string text (v.str_val, p + 1, string::npos); + + if (type == "tinyint" || + type == "smallint" || + type == "int" || + type == "bigint") + { + istringstream is (text); + is >> v.int_val; + v.val_type = variant::type_int; + } + else if (type == "char" || type == "varchar") + { + v.str_val = text; + v.val_type = variant::type_str; + } + else + assert (false); // Unknown type. + + break; + } + } + } + } +} diff --git a/odb-tests/mssql/custom/traits.hxx b/odb-tests/mssql/custom/traits.hxx new file mode 100644 index 0000000..2bd99cb --- /dev/null +++ b/odb-tests/mssql/custom/traits.hxx @@ -0,0 +1,148 @@ +// file : mssql/types/traits.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TRAITS_HXX +#define TRAITS_HXX + +#include // std::numeric_limits +#include +#include // std::memcpy +#include + +#include + +#include "test.hxx" // variant, point + +namespace odb +{ + namespace mssql + { + template <> + class value_traits + { + public: + typedef variant value_type; + typedef variant query_type; + typedef long_callback image_type; + + static void + set_value (variant& v, + result_callback_type& cb, + void*& context) + { + cb = &result_callback; + context = &v; + } + + static void + set_image (param_callback_type& cb, + const void*& context, + bool& is_null, + const variant& v) + { + is_null = false; + cb = ¶m_callback; + context = &v; + } + + static void + param_callback (const void* context, + std::size_t* position, + const void** buffer, + std::size_t* size, + chunk_type* chunk, + void* tmp_buffer, + std::size_t tmp_capacity); + + static void + result_callback (void* context, + std::size_t* position, + void** buffer, + std::size_t* size, + chunk_type chunk, + std::size_t size_left, + void* tmp_buffer, + std::size_t tmp_capacity); + }; + + template <> + struct type_traits + { + static const database_type_id db_type_id = id_long_string; + + struct conversion + { + static const char* to () {return "dbo.string_to_variant((?))";} + }; + }; + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + template <> + class value_traits + { + public: + typedef point value_type; + typedef point query_type; + + typedef char* image_type; + + static void + set_value (point& v, + const char* b, + std::size_t n, + bool is_null) + { + if (is_null) + v = point (); + else + { + // Point format is "POINT (x y)". + // + std::istringstream is (std::string (b + 7, n - 7)); + + is >> v.x; + is >> v.y; + } + } + + static void + set_image (char* b, + std::size_t c, + std::size_t& n, + bool& is_null, + const point& v) + { + is_null = false; + std::ostringstream os; + + // The formula for the number of decimla digits required is given in: + // + // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf + // + os.precision (std::numeric_limits::digits10); + // os.precision (2 + std::numeric_limits::digits * 301/1000); + + os << "POINT (" << v.x << ' ' << v.y << ')'; + + const std::string& s (os.str ()); + n = s.size (); + assert (n <= c); + std::memcpy (b, s.c_str (), n); + } + }; + + template <> + struct type_traits + { + static const database_type_id db_type_id = id_string; + + struct conversion + { + static const char* to () {return "GEOMETRY::STGeomFromText((?), 0)";} + }; + }; +#endif // SQL Server > 2005 + } +} + +#endif // TRAITS_HXX diff --git a/odb-tests/mssql/database/driver.cxx b/odb-tests/mssql/database/driver.cxx new file mode 100644 index 0000000..08ad34f --- /dev/null +++ b/odb-tests/mssql/database/driver.cxx @@ -0,0 +1,105 @@ +// file : mssql/database/driver.cxx +// license : GNU GPL; see accompanying LICENSE file + +// Test that database constructors are unambiguous (compilation only). +// + +#include +#include + +#include + +namespace mssql = odb::mssql; +using namespace mssql; + +static const char* isolation_map[] = {"1", "2", "3", "5", "4"}; + +static bool +check_isolation (connection& c, transaction_isolation i) +{ + std::string s ("SELECT 1 FROM sys.dm_exec_sessions WHERE session_id = @@SPID" + " AND transaction_isolation_level = "); + s += isolation_map[i]; + return c.execute (s) == 1; +} + +int +main (int argc, char* argv[]) +{ + // This code should not execute. + // + if (argc == 0) + { + { + database d1 ("bob", "secret", "db1", "server1"); + database d2 ("bob", "secret", "db1", "server1", "driver1"); + database d3 ("bob", "secret", "db1", "server1", "driver1", "extra"); + database d4 ("bob", "secret", "db1", "server1", "driver1", "extra", + isolation_read_uncommitted); + } + + { + database d1 ("bob", "secret", "db1", protocol_auto); + database d2 ("bob", "secret", "db1", protocol_auto, "server1"); + database d3 ("bob", "secret", "db1", protocol_auto, "server1", "inst1"); + database d4 ("bob", "secret", "db1", protocol_auto, "server1", "inst1", + "driver1"); + database d5 ("bob", "secret", "db1", protocol_auto, "server1", "inst1", + "driver1", "extra"); + database d6 ("bob", "secret", "db1", protocol_auto, "server1", "inst1", + "driver1", "extra", isolation_read_uncommitted); + } + + { + database d1 ("bob", "secret", "db1", "server1", 0); + database d2 ("bob", "secret", "db1", "server1", 999, "driver1"); + database d3 ("bob", "secret", "db1", "server1", 999, "driver1", "extra"); + database d4 ("bob", "secret", "db1", "server1", 999, "driver1", "extra", + isolation_read_uncommitted); + } + + { + database d1 ("conn1"); + database d2 ("conn1", isolation_read_uncommitted); + } + + { + database d1 (argc, argv); + database d2 (argc, argv, false); + database d3 (argc, argv, true, "extra"); + database d4 (argc, argv, false, "extra", isolation_read_uncommitted); + } + } + + // Test transaction isolation levels. + // + { + database d (argc, argv, false, "", isolation_read_uncommitted); + connection_ptr c (d.connection ()); + assert (check_isolation (*c, isolation_read_uncommitted)); + } + + { + database d (argc, argv, false, ""); + connection_ptr c (d.connection ()); + assert (check_isolation (*c, isolation_read_committed)); + } + + { + database d (argc, argv, false, "", isolation_repeatable_read); + connection_ptr c (d.connection ()); + assert (check_isolation (*c, isolation_repeatable_read)); + } + + { + database d (argc, argv, false, "", isolation_snapshot); + connection_ptr c (d.connection ()); + assert (check_isolation (*c, isolation_snapshot)); + } + + { + database d (argc, argv, false, "", isolation_serializable); + connection_ptr c (d.connection ()); + assert (check_isolation (*c, isolation_serializable)); + } +} diff --git a/odb-tests/mssql/native/driver.cxx b/odb-tests/mssql/native/driver.cxx new file mode 100644 index 0000000..f4b4fd7 --- /dev/null +++ b/odb-tests/mssql/native/driver.cxx @@ -0,0 +1,73 @@ +// file : mssql/native/driver.cxx +// license : GNU GPL; see accompanying LICENSE file + +// Test native SQL execution. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +using namespace std; +namespace mssql = odb::mssql; +using namespace mssql; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_specific_database (argc, argv)); + + // Create the database schema. + // + { + transaction t (db->begin ()); + + db->execute ("IF OBJECT_ID('mssql_native_test', 'U') IS NOT NULL\n" + " DROP TABLE mssql_native_test"); + + db->execute ("CREATE TABLE mssql_native_test (n int)"); + + t.commit (); + } + + // Insert a few rows. + // + { + transaction t (db->begin ()); + + assert ( + db->execute ("INSERT INTO mssql_native_test (n) VALUES (1)") == 1); + + assert ( + db->execute ("INSERT INTO mssql_native_test (n) VALUES (2)") == 1); + + t.commit (); + } + + // Select a few rows. + // + { + transaction t (db->begin ()); + + assert ( + db->execute ("SELECT n FROM mssql_native_test WHERE n < 3") == 2); + + assert ( + db->execute ("SELECT n FROM mssql_native_test WHERE n > 3") == 0); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mssql/query/driver.cxx b/odb-tests/mssql/query/driver.cxx new file mode 100644 index 0000000..5600c81 --- /dev/null +++ b/odb-tests/mssql/query/driver.cxx @@ -0,0 +1,188 @@ +// file : mssql/query/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test SQL Server-specific query support aspects. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +namespace mssql = odb::mssql; +using namespace mssql; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_specific_database (argc, argv)); + + { + object o1; + object o2; + object o3; + + o1.num = 1; + o1.str = "aaa"; + o1.nstr = L"aaa"; + o1.lstr.assign (1024, 'a'); + o1.lnstr.assign (1024, L'a'); + o1.smoney = 11000; + o1.money = 1.1; + + o2.num = 2; + o2.str = "bbb"; + o2.nstr = L"bbb"; + o2.lstr.assign (1024, 'b'); + o2.lnstr.assign (1024, L'b'); + o2.smoney = 22000; + o2.money = 2.2; + + o3.num = 3; + o3.str = "ccc"; + o3.nstr = L"ccc"; + o3.lstr.assign (1024, 'c'); + o3.lnstr.assign (1024, L'c'); + o3.smoney = 33000; + o3.money = 3.3; + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + } + + typedef mssql::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + // Money and small money. + // + { + result r (db->query (query::smoney < 22000)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->smoney == 11000); + assert (++i == r.end ()); + } + + { + result r (db->query ("smoney < " + query::_val (2.1F))); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->smoney == 11000); + assert (++i == r.end ()); + } + + { + result r (db->query (query::money < 2.2)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->money == 1.1); + assert (++i == r.end ()); + } + + { + result r (db->query ("money < " + query::_val (2.2))); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->money == 1.1); + assert (++i == r.end ()); + } + + // Short/long string. + // + { + result r (db->query (query::str < "bbb")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->str == "aaa"); + assert (++i == r.end ()); + } + + { + result r (db->query ("str < " + query::_val ("bbb", 3))); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->str == "aaa"); + assert (++i == r.end ()); + } + + { + result r (db->query (query::nstr < L"bbb")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->nstr == L"aaa"); + assert (++i == r.end ()); + } + + { + result r (db->query (query::lstr < string (1024, 'b'))); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->lstr == string (1024, 'a')); + assert (++i == r.end ()); + } + + { + string v (1024, 'b'); + result r (db->query (query::lstr < query::_ref (v))); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->lstr == string (1024, 'a')); + assert (++i == r.end ()); + } + + { + result r (db->query (query::lnstr < wstring (1024, L'b'))); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->lnstr == wstring (1024, L'a')); + assert (++i == r.end ()); + } + + // Test image copying with long data. + // + { + result r (db->query (query::str < "ccc")); + result::iterator i (r.begin ()); + + assert (i != r.end ()); + ++i; + assert (i != r.end ()); + + { + result r (db->query (query::str < "bbb")); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (i->str == "aaa"); + assert (++i == r.end ()); + } + + assert (i->str == "bbb"); // Load from copy. + assert (++i == r.end ()); + } + + t.commit (); + } + + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mssql/query/test.hxx b/odb-tests/mssql/query/test.hxx new file mode 100644 index 0000000..85c644e --- /dev/null +++ b/odb-tests/mssql/query/test.hxx @@ -0,0 +1,38 @@ +// file : mssql/query/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object +struct object +{ + #pragma db id auto + unsigned long id_; + + unsigned int num; + + #pragma db type ("SMALLMONEY") + int smoney; + + #pragma db type ("MONEY") + double money; + + #pragma db type ("VARCHAR(256)") + std::string str; + + #pragma db type ("NVARCHAR(128)") + std::wstring nstr; + + #pragma db type ("VARCHAR(max)") + std::string lstr; + + #pragma db type ("NVARCHAR(max)") + std::wstring lnstr; +}; + +#endif // TEST_HXX diff --git a/odb-tests/mssql/stored-proc/driver.cxx b/odb-tests/mssql/stored-proc/driver.cxx new file mode 100644 index 0000000..2389798 --- /dev/null +++ b/odb-tests/mssql/stored-proc/driver.cxx @@ -0,0 +1,231 @@ +// file : mssql/stored-proc/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test SQL Server stored procedure support. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +namespace mssql = odb::mssql; +using namespace mssql; + +void +create_procedure (database& db, const string& name, const string& body) +{ + transaction t (db.begin ()); + + string s (db.query_value ().name); + + db.execute ( + "IF EXISTS (" + " SELECT * FROM sysobjects" + " WHERE name = '" + name + "' AND user_name(uid) = '" + s +"')" + " DROP PROCEDURE [" + s + "].[" + name + "]"); + + db.execute ("CREATE PROCEDURE [" + s + "].[" + name + "] " + body); + + t.commit (); +} + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_specific_database (argc, argv)); + + object o1 (1, "a"); + object o2 (2, "b"); + object o3 (3, "c"); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + } + + { + create_procedure ( + *db, "select_all_objects", + "AS" + " SELECT num, str FROM mssql_stored_proc_object ORDER BY id;"); + + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query ()); + + for (result::iterator i (r.begin ()); i != r.end (); ++i) + cout << i->num << " " << i->str << endl; + cout << endl; + + t.commit (); + } + + { + create_procedure ( + *db, "select_objects", + "(@id INT, @n VARCHAR(512))" + "AS" + " SELECT str FROM mssql_stored_proc_object " + " WHERE [id] = @id OR [num] = @n ORDER BY id;"); + + typedef mssql::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + result r (db->query ( + query::_val (o1.id) + "," + query::_val (o2.num))); + + for (result::iterator i (r.begin ()); i != r.end (); ++i) + cout << i->str << endl; + cout << endl; + + t.commit (); + } + + { + create_procedure ( + *db, "objects_min_max", + "(@min INT = NULL OUTPUT, @max INT = NULL OUTPUT)" + "AS" + " SELECT @min = MIN(num), @max = MAX(num)" + " FROM mssql_stored_proc_object;"); + + create_procedure ( + *db, "objects_min_max_odb", + "AS" + " DECLARE @min INT, @max INT;" + " EXEC objects_min_max @min OUTPUT, @max OUTPUT;" + " SELECT @min, @max;"); + + transaction t (db->begin ()); + + objects_min_max omm (db->query_value ()); + cout << omm.num_min << " " << omm.num_max << endl + << endl; + + t.commit (); + } + + { + create_procedure ( + *db, "insert_object_id", + "(@n INT, @s VARCHAR(512))" + "AS" + " INSERT INTO mssql_stored_proc_object([num], [str])" + " VALUES(@n, @s);"); + + { + typedef mssql::query query; + + transaction t (db->begin ()); + + db->query_one ( + query::_val (4) + "," + query::_val ("d")); + + auto_ptr o (db->load (4)); + cout << o->num << " " << o->str << endl + << endl; + + t.commit (); + } + + { + typedef mssql::query query; + + transaction t (db->begin ()); + + db->query_one ( + "EXEC insert_object_id" + query::_val (5) + "," + query::_val ("e")); + + auto_ptr o (db->load (5)); + cout << o->num << " " << o->str << endl + << endl; + + t.commit (); + } + } + + { + create_procedure ( + *db, "insert_object_id", + "(@n INT, @s VARCHAR(512), @id INT = NULL OUTPUT)" + "AS" + " INSERT INTO mssql_stored_proc_object([num], [str])" + " VALUES(@n, @s);" + " SET @id = SCOPE_IDENTITY();" + " RETURN 123;"); + + typedef mssql::query query; + + { + create_procedure ( + *db, "insert_object_id_odb", + "(@n INT, @s VARCHAR(512))" + "AS" + " DECLARE @id INT;" + " DECLARE @ret INT;" + " EXEC @ret = insert_object_id @n, @s, @id OUTPUT;" + " SELECT @ret, @id;"); + + transaction t (db->begin ()); + + insert_object_id io ( + db->query_value ( + query::_val (6) + "," + query::_val ("f"))); + + cout << io.ret << " " << io.id << endl + << endl; + + t.commit (); + } + + // An alternative implementation that produces a different + // result set configuration at the ODBC level. + // + { + create_procedure ( + *db, "insert_object_id_odb", + "(@n INT, @s VARCHAR(512))" + "AS" + " DECLARE @id INT;" + " DECLARE @ret INT;" + " DECLARE @tbl TABLE(dummy INT);" + " INSERT INTO @tbl EXEC @ret = insert_object_id @n, @s, @id OUTPUT;" + " SELECT @ret, @id;"); + + transaction t (db->begin ()); + + insert_object_id io ( + db->query_value ( + query::_val (7) + "," + query::_val ("g"))); + + cout << io.ret << " " << io.id << endl + << endl; + + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mssql/stored-proc/test.hxx b/odb-tests/mssql/stored-proc/test.hxx new file mode 100644 index 0000000..5958ea3 --- /dev/null +++ b/odb-tests/mssql/stored-proc/test.hxx @@ -0,0 +1,63 @@ +// file : mssql/stored-proc/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db view query("SELECT SCHEMA_NAME()") +struct default_schema +{ + std::string name; +}; + +#pragma db object +struct object +{ + object () {} + object (unsigned int n, std::string s): num (n), str (s) {} + + #pragma db id auto + unsigned long id; + + unsigned int num; + std::string str; +}; + +#pragma db view +struct no_result {}; + +#pragma db view query("EXEC select_all_objects") +struct select_all_objects +{ + unsigned int num; + std::string str; +}; + +#pragma db view query("EXEC select_objects (?)") +struct select_objects +{ + std::string str; +}; + +#pragma db view query("EXEC objects_min_max_odb") +struct objects_min_max +{ + unsigned int num_min; + unsigned int num_max; +}; + +#pragma db view query("EXEC insert_object_id (?)") +struct insert_object {}; + +#pragma db view query("EXEC insert_object_id_odb (?)") +struct insert_object_id +{ + unsigned int ret; + unsigned long id; +}; + +#endif // TEST_HXX diff --git a/odb-tests/mssql/template/driver.cxx b/odb-tests/mssql/template/driver.cxx new file mode 100644 index 0000000..ded03f1 --- /dev/null +++ b/odb-tests/mssql/template/driver.cxx @@ -0,0 +1,40 @@ +// file : mssql/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +namespace mssql = odb::mssql; +using namespace mssql; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_specific_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mssql/template/template-vc10.vcxproj b/odb-tests/mssql/template/template-vc10.vcxproj new file mode 100644 index 0000000..5875d9b --- /dev/null +++ b/odb-tests/mssql/template/template-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/mssql/template/template-vc10.vcxproj.filters b/odb-tests/mssql/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/mssql/template/template-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/mssql/template/template-vc11.vcxproj b/odb-tests/mssql/template/template-vc11.vcxproj new file mode 100644 index 0000000..0bee18f --- /dev/null +++ b/odb-tests/mssql/template/template-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/mssql/template/template-vc11.vcxproj.filters b/odb-tests/mssql/template/template-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/mssql/template/template-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/mssql/template/template-vc12.vcxproj b/odb-tests/mssql/template/template-vc12.vcxproj new file mode 100644 index 0000000..35ffb0f --- /dev/null +++ b/odb-tests/mssql/template/template-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib64\common.lib;odb-mssql.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/mssql/template/template-vc12.vcxproj.filters b/odb-tests/mssql/template/template-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/mssql/template/template-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/mssql/template/template-vc8.vcproj b/odb-tests/mssql/template/template-vc8.vcproj new file mode 100644 index 0000000..cfd697f --- /dev/null +++ b/odb-tests/mssql/template/template-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/mssql/template/template-vc9.vcproj b/odb-tests/mssql/template/template-vc9.vcproj new file mode 100644 index 0000000..72a95d9 --- /dev/null +++ b/odb-tests/mssql/template/template-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/mssql/template/test.hxx b/odb-tests/mssql/template/test.hxx new file mode 100644 index 0000000..0bc1f95 --- /dev/null +++ b/odb-tests/mssql/template/test.hxx @@ -0,0 +1,25 @@ +// file : mssql/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/mssql/types/driver.cxx b/odb-tests/mssql/types/driver.cxx new file mode 100644 index 0000000..d900a95 --- /dev/null +++ b/odb-tests/mssql/types/driver.cxx @@ -0,0 +1,381 @@ +// file : mssql/types/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test SQL Server type conversion. +// + +#include // std::auto_ptr +#include +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +namespace mssql = odb::mssql; +using namespace mssql; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_specific_database (argc, argv)); + + { + object o (1); + + o.bit_ = 1; + o.utint_ = 222; + o.stint_ = -123; + o.usint_ = 65000; + o.ssint_ = -12345; + o.uint_ = 4294967290U; + o.sint_ = -1234567890; + o.ubint_ = 18446744073709551610ULL; + o.sbint_ = -1234567890123456789LL; + + o.fsm_ = -214748.3648F; + o.dsm_ = 214748.3647; + o.ism_ = -2147483647 -1; + + o.dm1_ = -922337203685477.5808; + o.dm2_ = 922337203685476.3520; // 922337203685477.5807 + o.im_ = 9223372036854775807LL; + + o.f4_ = 123.123F; + o.f8_ = 123.1234567; + + o.schar_ = "short data char "; + o.svchar_ = "short data varchar"; + + o.lchar_.assign (1025, 'a'); + o.lvchar_ = "long data varchar"; // Test the short string optimization. + o.mvchar_.assign (70000, 'm'); + o.text_.assign (70000, 't'); + + o.snchar_ = L"short data nchar\x1FFF\xD7FF "; + o.snvchar_ = L"short data nvarchar \x1FFF\xD7FF"; + + o.lnchar_.assign (513, L'\x1234'); + o.lnvchar_ = L""; // Test empty string. + o.mnvchar_.assign (70000, L'\x2345'); + o.ntext_.assign (70000, L'\x4356'); + + const char sdata[] = "abc""\x00\x01""def"; + memcpy (o.sbin_, sdata, sizeof (sdata)); + o.svbin_.assign (sdata, sdata + sizeof (sdata)); + + string ldata (256 * 1024, '\x01'); + memset (o.lbin_, 2, sizeof (o.lbin_)); + o.lvbin_.assign (50, '\x03'); + o.mvbin_.assign (ldata.begin (), ldata.end ()); + o.image_.assign (ldata.begin (), ldata.end ()); + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + o.date_ = date_time (2011, 12, 20, 0, 0, 0, 0, 0, 0); + o.time7_ = date_time (0, 0, 0, 13, 34, 39, 123456789, 0, 0); + o.time4_ = date_time (0, 0, 0, 13, 34, 39, 123456700, 0, 0); +#endif + o.sdt_ = date_time (2011, 12, 20, 15, 44, 29, 123456700, 0, 0); + o.dt_ = date_time (2011, 12, 20, 15, 44, 29, 123456700, 0, 0); +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + o.dt2_ = date_time (2011, 12, 20, 15, 44, 29, 123456700, 0, 0); + o.dto7_ = date_time (2011, 12, 20, 15, 44, 29, 123456700, 2, 0); + o.dto0_ = date_time (2011, 12, 20, 15, 44, 29, 123456700, 2, 0); +#endif + +#ifdef _WIN32 + // 6F846D41-C89A-4E4D-B22F-56443CFA543F + o.guid_.Data1 = 0x6F846D41; + o.guid_.Data2 = 0xC89A; + o.guid_.Data3 = 0x4E4D; + memcpy (&o.guid_.Data4, "\xB2\x2F\x56\x44\x3C\xFA\x54\x3F", 8); +#endif + memcpy (o.uuid_, "\x6F\x84\x6D\x41\xC8\x9A\x4E\x4D\xB2\x2F" + "\x56\x44\x3C\xFA\x54\x3F", 16); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + o.time7_ = date_time (0, 0, 0, 13, 34, 39, 123456700, 0, 0); + o.time4_ = date_time (0, 0, 0, 13, 34, 39, 123400000, 0, 0); +#endif + o.sdt_ = date_time (2011, 12, 20, 15, 44, 0, 0, 0, 0); + o.dt_ = date_time (2011, 12, 20, 15, 44, 29, 123000000, 0, 0); +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + o.dto0_ = date_time (2011, 12, 20, 15, 44, 29, 0, 2, 0); +#endif + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + + typedef mssql::query query; + typedef odb::result result; + + // Test UUID in queries. + // + { + char uuid[16]; + memcpy (uuid, o.uuid_, 16); + + transaction t (db->begin ()); + + { + result r (db->query (query::uuid == uuid)); + assert (size (r) == 1); + } + + { + result r (db->query (query::uuid == query::_val (uuid))); + assert (size (r) == 1); + } + + { + result r (db->query (query::uuid == query::_ref (uuid))); + assert (size (r) == 1); + } + + { + const char* d (uuid); + result r (db->query (query::uuid == d)); + assert (size (r) == 1); + } + + t.commit (); + } + + // Test short/long data in queries. + // + { + transaction t (db->begin ()); + + { + result r (db->query (query::svchar == o.svchar_)); + assert (size (r) == 1); + } + + { + result r (db->query (query::snvchar == o.snvchar_)); + assert (size (r) == 1); + } + + { + result r (db->query (query::mvchar == o.mvchar_)); + assert (size (r) == 1); + } + + { + result r (db->query (query::mnvchar == o.mnvchar_)); + assert (size (r) == 1); + } + + t.commit (); + } + } + + // Test long NULL data. + // + { + long_null o1 (1); + long_null o2 (2); + o2.str_.reset (new string); + o2.str_->assign (70000, 'x'); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr p1 (db->load (1)); + auto_ptr p2 (db->load (2)); + t.commit (); + + assert (o1 == *p1); + assert (o2 == *p2); + } + } + + // Test long data in containers. + // + { + long_cont o (1); + o.v.push_back (long_comp ("aaa", 123)); + o.v.push_back (long_comp (string (500, 'b'), 234)); + o.v.push_back (long_comp (string (70000, 'c'), 345)); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (1)); + t.commit (); + + assert (o == *p); + } + } + + // Test char/wchar_t arrays. + // + { + char_array o1 (1, "", L""); + char_array o2 (2, "1234567890", L"12345678\x1FFF\xD7FF"); + char_array o3 (3, "1234567890123456", L"12345678901234\x1FFF\xD7FF"); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + } + + // SQL Server returns padded values for CHAR(N)/NCHAR(N). + // + memcpy (o1.s2, " ", 16); + o1.s3[0] = o1.c1 = ' '; + memcpy (o2.s2, "1234567890 ", 16); + + memset (o1.ls2, ' ', 1025); + memset (o2.ls2 + 10, ' ', 1025 - 10); + + memcpy (o1.ws2, L" ", 16 * sizeof (wchar_t)); + o1.ws3[0] = o1.wc1 = L' '; + memcpy (o2.ws2, L"12345678\x1FFF\xD7FF ", 16 * sizeof (wchar_t)); + + for (size_t i (0); i < 257; ++i) + o1.lws2[i] = L' '; + + for (size_t i (10); i < 257; ++i) + o2.lws2[i] = L' '; + + { + transaction t (db->begin ()); + auto_ptr p1 (db->load (1)); + auto_ptr p2 (db->load (2)); + auto_ptr p3 (db->load (3)); + t.commit (); + + assert (o1 == *p1); + assert (o2 == *p2); + assert (o3 == *p3); + } + } + + // Test optimistic concurrency using ROWVERSION. + // + { + rowversion o (123); + o.str = "abc"; + + { + transaction t (db->begin ()); + db->persist (o); + assert (o.ver != 0); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (o.id_)); + assert (p->ver == o.ver); + p->str += 'd'; + db->update (*p); + assert (p->ver > o.ver); + + // Double-check object version was updated. + // + { + auto_ptr p1 (db->load (o.id_)); + assert (p->ver == p1->ver); + } + + o.str += 'D'; + try + { + db->update (o); + assert (false); + } + catch (const odb::object_changed&) {} + db->reload (o); + assert (o.ver == p->ver); + o.str += 'D'; + db->update (o); + t.commit (); + } + } + + { + rowversion_auto o; + o.str = "abc"; + + { + transaction t (db->begin ()); + db->persist (o); + assert (o.ver != 0); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (o.id_)); + assert (p->ver == o.ver); + p->str += 'd'; + db->update (*p); + assert (p->ver > o.ver); + o.str += 'D'; + try + { + db->update (o); + assert (false); + } + catch (const odb::object_changed&) {} + db->reload (o); + assert (o.ver == p->ver); + o.str += 'D'; + db->update (o); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mssql/types/test.hxx b/odb-tests/mssql/types/test.hxx new file mode 100644 index 0000000..5d651a8 --- /dev/null +++ b/odb-tests/mssql/types/test.hxx @@ -0,0 +1,517 @@ +// file : mssql/types/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#ifdef _WIN32 +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include // GUID +#elif defined(HOST_WIN32) +typedef struct _GUID +{ + unsigned int Data1; + unsigned short Data2; + unsigned short Data3; + unsigned char Data4[8]; +} GUID; +#endif + +#include // HAVE_CXX11 + +#include +#include +#include // std::auto_ptr +#include // std::memcmp, std::memcpy, std::str[n]cmp, std::strlen +#include // std::wcslen, std::wcs[n]cmp + +#include + +struct date_time +{ + date_time () + { + } + + date_time (short y, + unsigned short m, + unsigned short d, + unsigned short h, + unsigned short min, + unsigned short sec, + unsigned int f, + short tzh, + short tzm) + : year (y), + month (m), + day (d), + hour (h), + minute (min), + second (sec), + fraction (f), + timezone_hour (tzh), + timezone_minute (tzm) + { + } + + bool + operator== (const date_time& y) const + { + return + year == y.year && + month == y.month && + day == y.day && + hour == y.hour && + minute == y.minute && + second == y.second && + fraction == y.fraction && + timezone_hour == y.timezone_hour && + timezone_minute == y.timezone_minute; + } + + short year; + unsigned short month; + unsigned short day; + unsigned short hour; + unsigned short minute; + unsigned short second; + unsigned int fraction; + short timezone_hour; + short timezone_minute; +}; + +#pragma db object +struct object +{ + object () {} + object (unsigned int id): id_ (id) {} + + #pragma db id + unsigned int id_; + + // Integer types. + // + #pragma db type ("BIT") + unsigned char bit_; + + #pragma db type ("TINYINT") + unsigned char utint_; + + #pragma db type ("TINYINT") + unsigned char stint_; + + #pragma db type ("SMALLINT") + unsigned short usint_; + + #pragma db type ("SMALLINT") + short ssint_; + + #pragma db type ("INT") + unsigned int uint_; + + #pragma db type ("INTEGER") + int sint_; + + #pragma db type ("BIGINT") + unsigned long long ubint_; + + #pragma db type ("BIGINT") + long long sbint_; + + // Floating/fixed point types. + // + #pragma db type ("SMALLMONEY") + float fsm_; + + #pragma db type ("SMALLMONEY") + double dsm_; + + #pragma db type ("SMALLMONEY") + int ism_; + + #pragma db type ("MONEY") + double dm1_; + + #pragma db type ("MONEY") + double dm2_; + + #pragma db type ("MONEY") + long long im_; + + #pragma db type ("REAL") + float f4_; + + #pragma db type ("FLOAT") + double f8_; + + // Strings. + // + #pragma db type ("CHAR(20)") + std::string schar_; + + #pragma db type ("VARCHAR(128)") + std::string svchar_; + + #pragma db type ("CHAR(1025)") + std::string lchar_; + + #pragma db type ("CHARACTER VARYING(8000)") + std::string lvchar_; + + #pragma db type ("VARCHAR(max)") + std::string mvchar_; + + #pragma db type ("TEXT") + std::string text_; + + // National strings. + // + #pragma db type ("NCHAR(20)") + std::wstring snchar_; + + #pragma db type ("NVARCHAR(128)") + std::wstring snvchar_; + + #pragma db type ("NCHAR(513)") + std::wstring lnchar_; + + #pragma db type ("NATIONAL CHARACTER VARYING(4000)") + std::wstring lnvchar_; + + #pragma db type ("NVARCHAR(max)") + std::wstring mnvchar_; + + #pragma db type ("NTEXT") + std::wstring ntext_; + + // Binary. + // + #pragma db type ("BINARY(9)") + unsigned char sbin_[9]; + + #pragma db type ("VARBINARY(256)") + std::vector svbin_; + + #pragma db type ("BINARY(1025)") + char lbin_[1025]; + + #pragma db type ("BINARY VARYING(8000)") + std::vector lvbin_; + + #pragma db type ("VARBINARY(max)") + std::vector mvbin_; + + #pragma db type ("IMAGE") + std::vector image_; + + // Date-time. SQL Server 2005 (9.0) only has DATETIME and SMALLDATETIME. + // +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + #pragma db type ("DATE") + date_time date_; + + #pragma db type ("TIME") + date_time time7_; + + #pragma db type ("TIME(4)") + date_time time4_; +#endif + + #pragma db type ("SMALLDATETIME") + date_time sdt_; + + #pragma db type ("DATETIME") + date_time dt_; + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + #pragma db type ("DATETIME2") + date_time dt2_; + + #pragma db type ("DATETIMEOFFSET") + date_time dto7_; + + #pragma db type ("DATETIMEOFFSET(0)") + date_time dto0_; +#endif + + // Other types. + // +#if defined(_WIN32) || defined(HOST_WIN32) + //#pragma db type ("UNIQUEIDENTIFIER") + GUID guid_; +#endif + + #pragma db type ("UNIQUEIDENTIFIER") + char uuid_[16]; + + bool + operator== (const object& y) const + { + return + id_ == y.id_ && + bit_ == y.bit_ && + utint_ == y.utint_ && + stint_ == y.stint_ && + usint_ == y.usint_ && + ssint_ == y.ssint_ && + uint_ == y.uint_ && + sint_ == y.sint_ && + ubint_ == y.ubint_ && + sbint_ == y.sbint_ && + fsm_ == y.fsm_ && + dsm_ == y.dsm_ && + ism_ == y.ism_ && + dm1_ == y.dm1_ && + dm2_ == y.dm2_ && + im_ == y.im_ && + f4_ == y.f4_ && + f8_ == y.f8_ && + + schar_ == y.schar_ && + svchar_ == y.svchar_ && + lchar_ == y.lchar_ && + lvchar_ == y.lvchar_ && + mvchar_ == y.mvchar_ && + text_ == y.text_ && + + snchar_ == y.snchar_ && + snvchar_ == y.snvchar_ && + lnchar_ == y.lnchar_ && + lnvchar_ == y.lnvchar_ && + mnvchar_ == y.mnvchar_ && + ntext_ == y.ntext_ && + + std::memcmp (sbin_, y.sbin_, sizeof (sbin_)) == 0 && + svbin_ == y.svbin_ && + std::memcmp (lbin_, y.lbin_, sizeof (lbin_)) == 0 && + lvbin_ == y.lvbin_ && + mvbin_ == y.mvbin_ && + image_ == y.image_ + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + && date_ == y.date_ + && time7_ == y.time7_ + && time4_ == y.time4_ +#endif + && sdt_ == y.sdt_ + && dt_ == y.dt_ +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + && dt2_ == y.dt2_ + && dto7_ == y.dto7_ + && dto0_ == y.dto0_ +#endif + +#ifdef _WIN32 + && std::memcmp (&guid_, &y.guid_, sizeof (guid_)) == 0 +#endif + && std::memcmp (uuid_, y.uuid_, sizeof (uuid_)) == 0; + } +}; + +// Test long NULL data. +// +#pragma db object +struct long_null +{ + long_null () {} + long_null (unsigned int id): id_ (id) {} + + #pragma db id + unsigned int id_; + + #pragma db type ("VARCHAR(max)") null +#ifdef HAVE_CXX11 + std::unique_ptr str_; +#else + std::auto_ptr str_; +#endif + + bool + operator== (const long_null& y) const + { + return + id_ == y.id_ && + ((str_.get () == 0 && y.str_.get () == 0) || *str_ == *y.str_); + } +}; + +// Test long data in containers, in particular column re-arrangement. +// +#pragma db value +struct long_comp +{ + long_comp () {} + long_comp (std::string s, unsigned int n): str (s), num (n) {} + + #pragma db type ("VARCHAR(max)") + std::string str; + + unsigned int num; + + bool + operator== (const long_comp& y) const + { + return str == y.str && num == y.num; + } +}; + +#pragma db object +struct long_cont +{ + long_cont () {} + long_cont (unsigned int id): id_ (id) {} + + #pragma db id + unsigned int id_; + + std::vector v; + + bool + operator== (const long_cont& y) const + { + return id_ == y.id_ && v == y.v; + } +}; + +// Test char/wchar_t arrays. +// +#pragma db object +struct char_array +{ + char_array () {} + char_array (unsigned long id, const char* s, const wchar_t* ws) + : id_ (id) + { + std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation. + std::memcpy (s2, s, std::strlen (s) + 1); + s3[0] = c1 = *s; + + std::memcpy (ws1, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t)); + std::memcpy (ws2, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t)); + ws3[0] = wc1 = *ws; + + if (std::strlen (s) == sizeof (s2)) + { + std::memset (ls1, '1', 1025); + ls1[1025] = '\0'; + std::memset (ls2, '2', 1025); + + for (std::size_t i (0); i < 257; ++i) + { + lws1[i] = L'1'; + lws2[i] = L'2'; + } + lws1[257] = L'\0'; + } + else + { + std::memcpy (ls1, s, std::strlen (s) + 1); // VC++ strcpy deprecation. + std::memcpy (ls2, s, std::strlen (s) + 1); + + std::memcpy (lws1, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t)); + std::memcpy (lws2, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t)); + } + } + + #pragma db id + unsigned long id_; + + // + // + char s1[17]; + + #pragma db type("CHAR(16)") + char s2[16]; + + char s3[1]; + char c1; + + // Long data. + // + char ls1[1026]; + + #pragma db type("CHAR(1025)") + char ls2[1025]; + + // + // + wchar_t ws1[17]; + + #pragma db type("NCHAR(16)") + wchar_t ws2[16]; + + wchar_t ws3[1]; + wchar_t wc1; + + // Long data. + // + wchar_t lws1[258]; + + #pragma db type("NCHAR(257)") + wchar_t lws2[257]; + + bool + operator== (const char_array& y) const + { + return id_ == y.id_ && + + std::strcmp (s1, y.s1) == 0 && + std::strncmp (s2, y.s2, sizeof (s2)) == 0 && + s3[0] == y.s3[0] && + c1 == y.c1 && + + std::strcmp (ls1, y.ls1) == 0 && + std::strncmp (ls2, y.ls2, sizeof (ls2)) == 0 && + + std::wcscmp (ws1, y.ws1) == 0 && + std::wcsncmp (ws2, y.ws2, sizeof (ws2) / sizeof (wchar_t)) == 0 && + ws3[0] == y.ws3[0] && + wc1 == y.wc1 && + + std::wcscmp (lws1, y.lws1) == 0 && + std::wcsncmp (lws2, y.lws2, sizeof (lws2) / sizeof (wchar_t)) == 0; + } +}; + +// Test optimistic concurrency using ROWVERSION, both with auto and +// manually-assigned ids. +// +#pragma db object optimistic +struct rowversion +{ + rowversion (unsigned int id = 0): id_ (id), ver (0) {} + + #pragma db id + unsigned int id_; + + #pragma db version type("ROWVERSION") +#ifdef _WIN32 + unsigned __int64 ver; +#else + unsigned long long ver; +#endif + + std::string str; +}; + +#pragma db object optimistic +struct rowversion_auto +{ + rowversion_auto (): ver (0) {} + + #pragma db id auto + unsigned int id_; + + #pragma db version type("ROWVERSION") +#ifdef _WIN32 + unsigned __int64 ver; +#else + unsigned long long ver; +#endif + + std::string str; +}; + +#endif // TEST_HXX diff --git a/odb-tests/mssql/types/traits.hxx b/odb-tests/mssql/types/traits.hxx new file mode 100644 index 0000000..5881f50 --- /dev/null +++ b/odb-tests/mssql/types/traits.hxx @@ -0,0 +1,223 @@ +// file : mssql/types/traits.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TRAITS_HXX +#define TRAITS_HXX + +#include // date, time, datetime, datetimeoffset +#include + +#include "test.hxx" // date_time + +namespace odb +{ + namespace mssql + { + template <> + class value_traits + { + public: + typedef date_time value_type; + typedef date_time query_type; + typedef date image_type; + + static void + set_value (date_time& v, const date& i, bool is_null) + { + if (!is_null) + { + v.year = i.year; + v.month = i.month; + v.day = i.day; + v.hour = 0; + v.minute = 0; + v.second = 0; + v.fraction = 0; + v.timezone_hour = 0; + v.timezone_minute = 0; + } + } + + static void + set_image (date& i, bool& is_null, const date_time& v) + { + is_null = false; + i.year = v.year; + i.month = v.month; + i.day = v.day; + } + }; + + template <> + class value_traits + { + public: + typedef date_time value_type; + typedef date_time query_type; + typedef time image_type; + + static void + set_value (date_time& v, const time& i, bool is_null) + { + if (!is_null) + { + v.year = 0; + v.month = 0; + v.day = 0; + v.hour = i.hour; + v.minute = i.minute; + v.second = i.second; + v.fraction = i.fraction; + v.timezone_hour = 0; + v.timezone_minute = 0; + } + } + + static void + set_image (time& i, unsigned short s, bool& is_null, const date_time& v) + { + const unsigned int divider[8] = + { + 1000000000, + 100000000, + 10000000, + 1000000, + 100000, + 10000, + 1000, + 100 + }; + + is_null = false; + i.hour = v.hour; + i.minute = v.minute; + i.second = v.second; + i.fraction = v.fraction - v.fraction % divider[s]; + } + }; + + template <> + class value_traits + { + public: + typedef date_time value_type; + typedef date_time query_type; + typedef datetime image_type; + + static void + set_value (date_time& v, const datetime& i, bool is_null) + { + if (!is_null) + { + v.year = i.year; + v.month = i.month; + v.day = i.day; + v.hour = i.hour; + v.minute = i.minute; + v.second = i.second; + v.fraction = i.fraction; + v.timezone_hour = 0; + v.timezone_minute = 0; + } + } + + static void + set_image (datetime& i, + unsigned short s, + bool& is_null, + const date_time& v) + { + const unsigned int divider[8] = + { + 1000000000, + 100000000, + 10000000, + 1000000, + 100000, + 10000, + 1000, + 100 + }; + + is_null = false; + i.year = v.year; + i.month = v.month; + i.day = v.day; + i.hour = v.hour; + i.minute = v.minute; + + // Scale value 8 indicates we are dealing with SMALLDATETIME + // which has the minutes precision. + // + if (s != 8) + { + i.second = v.second; + i.fraction = v.fraction - v.fraction % divider[s]; + } + else + { + i.second = 0; + i.fraction = 0; + } + } + }; + + template <> + class value_traits + { + public: + typedef date_time value_type; + typedef date_time query_type; + typedef datetimeoffset image_type; + + static void + set_value (date_time& v, const datetimeoffset& i, bool is_null) + { + if (!is_null) + { + v.year = i.year; + v.month = i.month; + v.day = i.day; + v.hour = i.hour; + v.minute = i.minute; + v.second = i.second; + v.fraction = i.fraction; + v.timezone_hour = i.timezone_hour; + v.timezone_minute = i.timezone_minute; + } + } + + static void + set_image (datetimeoffset& i, + unsigned short s, + bool& is_null, + const date_time& v) + { + const unsigned int divider[8] = + { + 1000000000, + 100000000, + 10000000, + 1000000, + 100000, + 10000, + 1000, + 100 + }; + + is_null = false; + i.year = v.year; + i.month = v.month; + i.day = v.day; + i.hour = v.hour; + i.minute = v.minute; + i.second = v.second; + i.fraction = v.fraction - v.fraction % divider[s]; + i.timezone_hour = v.timezone_hour; + i.timezone_minute = v.timezone_minute; + } + }; + } +} + +#endif // TRAITS_HXX diff --git a/odb-tests/mysql-schema.testscript b/odb-tests/mysql-schema.testscript new file mode 100644 index 0000000..dfa7852 --- /dev/null +++ b/odb-tests/mysql-schema.testscript @@ -0,0 +1,9 @@ +# file : mysql-schema.testscript +# license : GNU GPL v2; see accompanying LICENSE file + +# Create the MySQL database schema creation canned command base. +# +create_schema_cmd = [cmdline] \ + $mysql_client_cmd 2>&1 | \ + sed -e "'"'s/^mysql: \[Warning\] Using a password on the command .*//'"'" | \ + sed -n -e "'"'s/(.+)/\1/p'"'" >&2 diff --git a/odb-tests/mysql.testscript b/odb-tests/mysql.testscript new file mode 100644 index 0000000..e218ece --- /dev/null +++ b/odb-tests/mysql.testscript @@ -0,0 +1,12 @@ +# file : mysql.testscript +# license : GNU GPL v2; see accompanying LICENSE file + +# Create the MySQL database schema creation canned command and setup the test +# driver command line for the subsequent tests. +# +.include mysql-schema.testscript + +schema_file = [path] $out_base/"$schema"($multi ? '-mysql' : '').sql +create_schema = [cmdline] cat "'""$schema_file""'" | $create_schema_cmd + +test.arguments += ($multi ? 'mysql' : ) $mysql_options diff --git a/odb-tests/mysql/custom/buildfile b/odb-tests/mysql/custom/buildfile new file mode 100644 index 0000000..4934e7c --- /dev/null +++ b/odb-tests/mysql/custom/buildfile @@ -0,0 +1,37 @@ +# file : mysql/custom/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($mysql && !$multi || $build.meta_operation == 'dist') \ +"mysql should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-mysql%lib{odb-mysql} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix mysql_custom_ \ + --generate-schema \ + --default-database common \ + --generate-query \ + --hxx-prologue '#include "traits.hxx"' \ + --hxx-prologue '#include "query.hxx"' + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{mysql-client}: include = adhoc diff --git a/odb-tests/mysql/custom/driver.cxx b/odb-tests/mysql/custom/driver.cxx new file mode 100644 index 0000000..526dbdc --- /dev/null +++ b/odb-tests/mysql/custom/driver.cxx @@ -0,0 +1,117 @@ +// file : mysql/custom/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test custom database type mapping in MySQL. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace mysql = odb::mysql; +using namespace mysql; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_specific_database (argc, argv)); + + object o (1); + o.p = point (1.1111, 2222222222.2); + o.pv.push_back (point (1.1234, 2.2345)); + o.pv.push_back (point (3.3456, 4.4567)); + // VC just cannot roundtrip this. +#ifndef _MSC_VER + o.pv.push_back (point (0.0000001, 0.000000001)); // Scientific notation. +#endif + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + + // Query. + // + typedef mysql::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + // Point comparison. + // + { + result r (db->query (query::p == o.p)); + assert (!r.empty ()); + } + + // Point comparison using native query. + // + { + result r (db->query (query::p + "=" + query::_val (o.p))); + assert (!r.empty ()); + } + + // Access to individual members. + // + { + result r (db->query (query::p.x == o.p.x)); + assert (!r.empty ()); + } + + t.commit (); + } + + // Update. + // + o.p.x++; + o.p.y--; + o.pv[1].x--; + o.pv[1].y++; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mysql/custom/query.hxx b/odb-tests/mysql/custom/query.hxx new file mode 100644 index 0000000..2fa8f73 --- /dev/null +++ b/odb-tests/mysql/custom/query.hxx @@ -0,0 +1,160 @@ +// file : mysql/custom/query.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef QUERY_HXX +#define QUERY_HXX + +#include + +#include + +#include "test.hxx" // point + +namespace odb +{ + namespace mysql + { + template <> + struct query_column + { + private: + const char* table_; + const char* column_; + const char* conversion_; + + std::string x_table_; + std::string y_table_; + std::string s_column_; + + // Sub-columns for individual members. + // + public: + query_column x, y; + + // is_null, is_not_null + // + public: + query_base + is_null () const + { + query_base q (table_, column_); + q += "IS NULL"; + return q; + } + + query_base + is_not_null () const + { + query_base q (table_, column_); + q += "IS NOT NULL"; + return q; + } + + // = + // + public: + query_base + equal (const point& v) const + { + return equal (val_bind (v)); + } + + query_base + equal (val_bind v) const + { + query_base q (table_, column_); + q += "="; + q.append (v, conversion_); + return q; + } + + query_base + equal (ref_bind r) const + { + query_base q (table_, column_); + q += "="; + q.append (r, conversion_); + return q; + } + + friend query_base + operator== (const query_column& c, const point& v) + { + return c.equal (v); + } + + friend query_base + operator== (const point& v, const query_column& c) + { + return c.equal (v); + } + + friend query_base + operator== (const query_column& c, val_bind v) + { + return c.equal (v); + } + + friend query_base + operator== (val_bind v, const query_column& c) + { + return c.equal (v); + } + + friend query_base + operator== (const query_column& c, ref_bind r) + { + return c.equal (r); + } + + friend query_base + operator== (ref_bind r, const query_column& c) + { + return c.equal (r); + } + + // Column comparison. + // + public: + query_base + operator== (const query_column& c) const + { + query_base q (table_, column_); + q += "="; + q.append (c.table (), c.column ()); + return q; + } + + public: + query_column (const char* table, const char* column, const char* conv) + : table_ (table), column_ (column), conversion_ (conv), + x_table_ ("ST_X(" + std::string (table)), // @@ Not very clean. + y_table_ ("ST_Y(" + std::string (table)), + s_column_ (std::string (column) + ")"), // X & Y column suffix. + x (x_table_.c_str (), s_column_.c_str (), 0), + y (y_table_.c_str (), s_column_.c_str (), 0) + { + } + + const char* + table () const + { + return table_; + } + + const char* + column () const + { + return column_; + } + + const char* + conversion () const + { + return conversion_; + } + }; + } +} + +#endif // QUERY_HXX diff --git a/odb-tests/mysql/custom/test.hxx b/odb-tests/mysql/custom/test.hxx new file mode 100644 index 0000000..82cc59d --- /dev/null +++ b/odb-tests/mysql/custom/test.hxx @@ -0,0 +1,54 @@ +// file : mysql/custom/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +// Map GEOMETRY MySQL type to the point C++ struct. The other half +// of this mapping is in traits.hxx (value_traits). +// +#pragma db map type("GEOMETRY") \ + as("VARCHAR(256)") \ + to("ST_GeomFromText((?))") \ + from("ST_AsText((?))") + +#pragma db value type("GEOMETRY") +struct point +{ + point () {} + point (double x_, double y_): x (x_), y (y_) {} + + double x; + double y; +}; + +inline bool +operator== (const point& a, const point& b) +{ + return a.x == b.x && a.y == b.y; +} + +#pragma db object +struct object +{ + object () {} + object (unsigned long id_) : id (id_) {} + + #pragma db id + unsigned long id; + + point p; + std::vector pv; + + bool + operator== (const object& y) const + { + return id == y.id && p == y.p && pv == y.pv; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/mysql/custom/testscript b/odb-tests/mysql/custom/testscript new file mode 100644 index 0000000..9bc8839 --- /dev/null +++ b/odb-tests/mysql/custom/testscript @@ -0,0 +1,11 @@ +# file : mysql/custom/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../mysql.testscript + ++$create_schema + +: basics +: +$* diff --git a/odb-tests/mysql/custom/traits.hxx b/odb-tests/mysql/custom/traits.hxx new file mode 100644 index 0000000..5386d86 --- /dev/null +++ b/odb-tests/mysql/custom/traits.hxx @@ -0,0 +1,88 @@ +// file : mysql/types/traits.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TRAITS_HXX +#define TRAITS_HXX + +#include // std::numeric_limits +#include +#include // std::memcpy + +#include + +#include "test.hxx" // point + +namespace odb +{ + namespace mysql + { + template <> + class value_traits + { + public: + typedef point value_type; + typedef point query_type; + + typedef char* image_type; + + static void + set_value (point& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (is_null) + v = point (); + else + { + // Point format is "POINT(x y)". + // + std::istringstream is (std::string (b.data () + 6, n - 6)); + + is >> v.x; + is >> v.y; + } + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const point& v) + { + is_null = false; + std::ostringstream os; + + // The formula for the number of decimla digits required is given in: + // + // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf + // + os.precision (std::numeric_limits::digits10); + // os.precision (2 + std::numeric_limits::digits * 301/1000); + + os << "POINT(" << v.x << ' ' << v.y << ')'; + + const std::string& s (os.str ()); + n = s.size (); + + if (n > b.capacity ()) + b.capacity (n); + + std::memcpy (b.data (), s.c_str (), n); + } + }; + + template <> + struct type_traits + { + static const database_type_id db_type_id = id_string; + + struct conversion + { + static const char* to () {return "ST_GeomFromText((?))";} + }; + }; + } +} + +#endif // TRAITS_HXX diff --git a/odb-tests/mysql/database/buildfile b/odb-tests/mysql/database/buildfile new file mode 100644 index 0000000..304034e --- /dev/null +++ b/odb-tests/mysql/database/buildfile @@ -0,0 +1,11 @@ +# file : mysql/database/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($mysql && !$multi || $build.meta_operation == 'dist') \ +"mysql should be configured via config.odb_tests.database variable as a single database" + +import libs = libodb-mysql%lib{odb-mysql} + +exe{driver}: {hxx cxx}{*} $libs testscript + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/mysql/database/driver.cxx b/odb-tests/mysql/database/driver.cxx new file mode 100644 index 0000000..525ee87 --- /dev/null +++ b/odb-tests/mysql/database/driver.cxx @@ -0,0 +1,72 @@ +// file : mysql/database/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test that database constructors are unambiguous (compilation only). +// + +#include + +#include + +#undef NDEBUG +#include + +using std::string; +namespace mysql = odb::mysql; +using namespace mysql; + +int +main (int argc, char* argv[]) +{ + // This code should not execute. + // + if (argc != 0) + return 0; + + { + database d1 (0, 0, 0); + database d2 ("bob", "secret", "db1"); + database d3 ("bob", "secret", "db1", "server1"); + database d4 ("bob", "secret", "db1", "server1", 999); + database d5 ("bob", "secret", "db1", "server1", 999, "sock1"); + database d6 ("bob", "secret", "db1", "server1", 999, "sock1", "charset1"); + } + + std::string u ("bob"), p ("secret"), db ("bd1"), h ("server1"), + s ("sock1"), cs ("charset1"); + + { + database d1 (u, p, db); + database d2 (u, p, db, h); + database d3 (u, p, db, h, 999); + database d4 (u, p, db, h, 999, &s); + database d5 (u, p, db, h, 999, &s, cs); + } + + { + database d1 (u, 0, db); + database d2 (u, &p, db); + database d3 (u, &p, db, h); + database d4 (u, &p, db, h, 999); + database d5 (u, &p, db, h, 999, &s); + database d6 (u, &p, db, h, 999, &s, cs); + } + + { + database d1 (u, p, db, h, 999, "socket1"); + database d2 (u, p, db, h, 999, s); + database d3 (u, p, db, h, 999, s, cs); + } + + { + database d1 (u, 0, db, h, 999, s); + database d2 (u, &p, db, h, 999, "socket1"); + database d3 (u, &p, db, h, 999, s, cs); + } + + { + database d1 (argc, argv); + database d2 (argc, argv, false); + database d3 (argc, argv, true, "charset1"); + } +} diff --git a/odb-tests/mysql/database/testscript b/odb-tests/mysql/database/testscript new file mode 100644 index 0000000..c2ff256 --- /dev/null +++ b/odb-tests/mysql/database/testscript @@ -0,0 +1,6 @@ +# file : mysql/database/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +: basics +: +$* diff --git a/odb-tests/mysql/index/buildfile b/odb-tests/mysql/index/buildfile new file mode 100644 index 0000000..9cadce3 --- /dev/null +++ b/odb-tests/mysql/index/buildfile @@ -0,0 +1,34 @@ +# file : mysql/index/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($mysql && !$multi || $build.meta_operation == 'dist') \ +"mysql should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-mysql%lib{odb-mysql} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix mysql_index_ \ + --generate-schema \ + --default-database common + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{mysql-client}: include = adhoc diff --git a/odb-tests/mysql/index/driver.cxx b/odb-tests/mysql/index/driver.cxx new file mode 100644 index 0000000..4d0b7ad --- /dev/null +++ b/odb-tests/mysql/index/driver.cxx @@ -0,0 +1,44 @@ +// file : mysql/index/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test MySQL index creation. See also the common test. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace mysql = odb::mysql; +using namespace mysql; + +int +main (int argc, char* argv[]) +{ + try + { + // This is just a schema creation test. + // + unique_ptr db (create_specific_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mysql/index/test.hxx b/odb-tests/mysql/index/test.hxx new file mode 100644 index 0000000..b4f6ae8 --- /dev/null +++ b/odb-tests/mysql/index/test.hxx @@ -0,0 +1,20 @@ +// file : mysql/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object +struct object +{ + #pragma db id auto + unsigned long id_; + + std::string s; + #pragma db index method("BTREE") member(s, "(200) DESC") +}; + +#endif // TEST_HXX diff --git a/odb-tests/mysql/index/testscript b/odb-tests/mysql/index/testscript new file mode 100644 index 0000000..26dfc4f --- /dev/null +++ b/odb-tests/mysql/index/testscript @@ -0,0 +1,11 @@ +# file : mysql/index/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../mysql.testscript + ++$create_schema + +: basics +: +$* diff --git a/odb-tests/mysql/native/buildfile b/odb-tests/mysql/native/buildfile new file mode 100644 index 0000000..57c3c30 --- /dev/null +++ b/odb-tests/mysql/native/buildfile @@ -0,0 +1,16 @@ +# file : mysql/native/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($mysql && !$multi || $build.meta_operation == 'dist') \ +"mysql should be configured via config.odb_tests.database variable as a single database" + +import libs = libodb-mysql%lib{odb-mysql} +import libs += lib{common} + +exe{driver}: {hxx cxx}{*} $libs testscript + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{mysql-client}: include = adhoc diff --git a/odb-tests/mysql/native/driver.cxx b/odb-tests/mysql/native/driver.cxx new file mode 100644 index 0000000..9b34fd2 --- /dev/null +++ b/odb-tests/mysql/native/driver.cxx @@ -0,0 +1,75 @@ +// file : mysql/native/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test native SQL execution. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#undef NDEBUG +#include + +using namespace std; +namespace mysql = odb::mysql; +using namespace mysql; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_specific_database (argc, argv)); + + // Create the database schema. + // + { + transaction t (db->begin ()); + + db->execute ("DROP TABLE IF EXISTS mysql_native_test"); + + db->execute ("CREATE TABLE mysql_native_test (n INT PRIMARY KEY) " + "ENGINE=InnoDB"); + + t.commit (); + } + + // Insert a few rows. + // + { + transaction t (db->begin ()); + + assert ( + db->execute ("INSERT INTO mysql_native_test (n) VALUES (1)") == 1); + + assert ( + db->execute ("INSERT INTO mysql_native_test (n) VALUES (2)") == 1); + + t.commit (); + } + + // Select a few rows. + // + { + transaction t (db->begin ()); + + assert ( + db->execute ("SELECT n FROM mysql_native_test WHERE n < 3") == 2); + + assert ( + db->execute ("SELECT n FROM mysql_native_test WHERE n > 3") == 0); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mysql/native/testscript b/odb-tests/mysql/native/testscript new file mode 100644 index 0000000..21327ff --- /dev/null +++ b/odb-tests/mysql/native/testscript @@ -0,0 +1,9 @@ +# file : mysql/native/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../mysql.testscript + +: basics +: +$* diff --git a/odb-tests/mysql/truncation/buildfile b/odb-tests/mysql/truncation/buildfile new file mode 100644 index 0000000..fbd936b --- /dev/null +++ b/odb-tests/mysql/truncation/buildfile @@ -0,0 +1,35 @@ +# file : mysql/truncation/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($mysql && !$multi || $build.meta_operation == 'dist') \ +"mysql should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-mysql%lib{odb-mysql} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix mysql_truncation_ \ + --generate-schema \ + --default-database common \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{mysql-client}: include = adhoc diff --git a/odb-tests/mysql/truncation/driver.cxx b/odb-tests/mysql/truncation/driver.cxx new file mode 100644 index 0000000..21084f5 --- /dev/null +++ b/odb-tests/mysql/truncation/driver.cxx @@ -0,0 +1,192 @@ +// file : mysql/truncation/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test insufficient buffer/truncation handling. +// + +#include // std::unique_ptr +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace mysql = odb::mysql; +using namespace mysql; + +int +main (int argc, char* argv[]) +{ + // The default pre-allocated buffer is 256 bytes long. + // + string long_str (300, 'c'); // This will get the buffer to 512 + string longer_str (1025, 'b'); + + try + { + // Test basic operations. + // + { + unique_ptr db (create_specific_database (argc, argv)); + + // Run persist/load so that the initial bindings are established + // (version == 0). + // + { + object1 o (1); + o.str_ = "test string"; + + transaction t (db->begin ()); + db->persist (o); + db->load (1, o); + t.commit (); + } + + { + object2 o (2); + o.str_ = "test string"; + + transaction t (db->begin ()); + db->persist (o); + db->load (2, o); + t.commit (); + } + + // Store/load the long string which should trigger buffer growth. + // + { + object1 o (3); + o.str_ = long_str; + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (3)); + assert (o->str_ == long_str); + t.commit (); + } + + // Store/load longer string. + // + { + object1 o (3); + o.str_ = longer_str; + + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (3)); + assert (o->str_ == longer_str); + t.commit (); + } + } + + // Test query. + // + { + typedef mysql::query query; + typedef odb::result result; + + unique_ptr db (create_specific_database (argc, argv)); + + // Run persist/query so that the initial bindings are established + // (version == 0). + // + { + object1 o (20); + o.str_ = "test string"; + + transaction t (db->begin ()); + db->persist (o); + o.id_++; + db->persist (o); + o.id_++; + db->persist (o); + + result r (db->query (query::id == 20)); + assert (r.begin ()->id_ == 20); + t.commit (); + } + + // Test buffer growth with cached result. + // + { + object1 o; + + transaction t (db->begin ()); + + result r (db->query (query::id >= 20)); + result::iterator i (r.begin ()); + + o.id_ = i->id_; + o.str_ = long_str; + + // This forces buffer growth in the middle of result iteration. + // + db->update (o); + + ++i; + assert (i->str_ == "test string"); + + o.id_ = i->id_; + o.str_ = longer_str; + db->update (o); + + ++i; + assert (i->str_ == "test string"); + + t.commit (); + } + } + + // Test containers. + // + { + unique_ptr db (create_specific_database (argc, argv)); + + // Use different connections to persist and load the object. + // + connection_ptr c1 (db->connection ()); + connection_ptr c2 (db->connection ()); + + container o (1); + o.vec_.push_back (string (513, 'x')); + + { + transaction t (c1->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (c2->begin ()); + unique_ptr p (db->load (1)); + t.commit (); + + assert (p->vec_ == o.vec_); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mysql/truncation/test.hxx b/odb-tests/mysql/truncation/test.hxx new file mode 100644 index 0000000..1883b0e --- /dev/null +++ b/odb-tests/mysql/truncation/test.hxx @@ -0,0 +1,48 @@ +// file : mysql/truncation/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +#pragma db object table ("test") +struct object1 +{ + object1 () {} + object1 (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + std::string str_; +}; + +#pragma db object table ("test") +struct object2 +{ + object2 () {} + object2 (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + std::string str_; +}; + +#pragma db object +struct container +{ + container () {} + container (unsigned long id) : id_ (id) {} + + #pragma db id + unsigned long id_; + + std::vector vec_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/mysql/truncation/testscript b/odb-tests/mysql/truncation/testscript new file mode 100644 index 0000000..b9b6792 --- /dev/null +++ b/odb-tests/mysql/truncation/testscript @@ -0,0 +1,11 @@ +# file : mysql/truncation/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../mysql.testscript + ++$create_schema + +: basics +: +$* diff --git a/odb-tests/mysql/types/buildfile b/odb-tests/mysql/types/buildfile new file mode 100644 index 0000000..112a81f --- /dev/null +++ b/odb-tests/mysql/types/buildfile @@ -0,0 +1,36 @@ +# file : mysql/types/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($mysql && !$multi || $build.meta_operation == 'dist') \ +"mysql should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-mysql%lib{odb-mysql} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix mysql_types_ \ + --generate-schema \ + --default-database common \ + --generate-query \ + --hxx-prologue '#include "traits.hxx"' + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{mysql-client}: include = adhoc diff --git a/odb-tests/mysql/types/driver.cxx b/odb-tests/mysql/types/driver.cxx new file mode 100644 index 0000000..2354b04 --- /dev/null +++ b/odb-tests/mysql/types/driver.cxx @@ -0,0 +1,168 @@ +// file : mysql/types/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test MySQL type conversion. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace mysql = odb::mysql; +using namespace mysql; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_specific_database (argc, argv)); + + mysql_version v; + { + transaction t (db->begin ()); + db->query ().begin ().load (v); + t.commit (); + } + + //cerr << "MySQL " << v.major << '.' << v.minor << '.' << v.release + // << " protocol " << v.protocol << endl; + + object o (1); + + o.bool_ = true; + o.schar_ = -123; + o.uchar_ = 123; + o.short_ = -12345; + o.ushort_ = 12345; + o.mint_ = -123456; + o.umint_ = 123456; + o.int_ = -123456; + o.uint_ = 123456; + o.long_long_ = -123456; + o.ulong_long_ = 123456; + + o.float_ = 1.123F; + o.float8_ = 1.123; + o.double_ = 1.123; + o.decimal_ = "123.456"; + + o.date_ = date_time (false, 2010, 8, 29, 0, 0, 0); + o.time_ = date_time (true, 0, 0, 0, 12, 26, 59); + o.date_time_ = date_time (false, 2010, 8, 29, 12, 26, 59); + o.timestamp_ = date_time (false, 2010, 8, 29, 12, 26, 59); + o.year_ = 2010; + + // If we are running against MySQL 5.6.4 or later, add fractional + // seconds and also alter the table to allow sub-second precision. + // + if (v.major > 5 || + (v.major == 5 && (v.minor > 6 || + (v.minor == 6 && v.release >= 4)))) + { + o.time_.microseconds = 123456; + o.date_time_.microseconds = 234567; + o.timestamp_.microseconds = 345678; + + transaction t (db->begin ()); + db->execute ("ALTER TABLE `mysql_types_object`" \ + " MODIFY COLUMN `time` TIME(6)," \ + " MODIFY COLUMN `date_time` DATETIME(6)," \ + " MODIFY COLUMN `timestamp` TIMESTAMP(6)"); + t.commit (); + } + + string short_str (128, 's'); + string medium_str (250, 'm'); + string long_str (2040, 'l'); + + const char* sb (short_str.c_str ()), *se (sb + short_str.size ()); + const char* mb (medium_str.c_str ()), *me (mb + medium_str.size ()); + const char* lb (long_str.c_str ()), *le (lb + long_str.size ()); + + o.char_ = short_str; + o.binary_.assign (sb, se); + o.varchar_ = medium_str; + o.varbinary_.assign (mb, me); + o.tinytext_ = short_str; + o.tinyblob_.assign (sb, se); + o.text_ = long_str; + o.blob_.assign (lb, le); + o.mediumtext_ = long_str; + o.mediumblob_.assign (lb, le); + o.longtext_ = long_str; + o.longblob_.assign (lb, le); + + o.bit_.a = 1; + o.bit_.b = 0; + o.bit_.c = 0; + o.bit_.d = 1; + + o.enum_def_ = green; + o.enum_cst_ = blue; + o.enum_str_ = "green"; + o.set_.insert ("green"); + o.set_.insert ("red"); + o.set_.insert ("blue"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // + // + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + + // Test char array. + // + { + char_array o1 (1, ""); + char_array o2 (2, "1234567890"); + char_array o3 (3, "1234567890123456"); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (1)); + unique_ptr p2 (db->load (2)); + unique_ptr p3 (db->load (3)); + t.commit (); + + assert (o1 == *p1); + assert (o2 == *p2); + assert (o3 == *p3); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/mysql/types/test.hxx b/odb-tests/mysql/types/test.hxx new file mode 100644 index 0000000..82f7496 --- /dev/null +++ b/odb-tests/mysql/types/test.hxx @@ -0,0 +1,328 @@ +// file : mysql/types/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include +#include // std::unique_ptr +#include // std::memcpy, std::str[n]cmp, std::strlen + +#include + +typedef std::vector buffer; + +struct date_time +{ + date_time () + { + } + + date_time (bool n, + unsigned int y, + unsigned int m, + unsigned int d, + unsigned int h, + unsigned int min, + unsigned int sec, + unsigned int msec = 0) + : negative (n), + year (y), + month (m), + day (d), + hour (h), + minute (min), + second (sec), + microseconds (msec) + { + } + + bool + operator== (const date_time& y) const + { + return + negative == y.negative && + year == y.year && + month == y.month && + day == y.day && + hour == y.hour && + minute == y.minute && + second == y.second && + microseconds == y.microseconds; + } + + bool negative; + unsigned int year; + unsigned int month; + unsigned int day; + unsigned int hour; + unsigned int minute; + unsigned int second; + unsigned int microseconds; +}; + +struct bitfield +{ + unsigned int a: 1; + unsigned int b: 1; + unsigned int c: 1; + unsigned int d: 1; +}; + +inline bool +operator== (bitfield x, bitfield y) +{ + return + x.a == y.a && + x.b == y.b && + x.c == y.c && + x.d == y.d; +} + +#pragma db value(bitfield) type ("BIT(4)") + +typedef std::set set; +typedef std::unique_ptr string_ptr; + +enum color {red, green, blue}; + +#pragma db object +struct object +{ + object () {} + object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + // Integral types. + // + #pragma db type ("BOOL") + bool bool_; + + #pragma db type ("TINYINT") + signed char schar_; + + #pragma db type ("TINYINT UNSIGNED") + unsigned char uchar_; + + #pragma db type ("SMALLINT") + short short_; + + #pragma db type ("SMALLINT UNSIGNED") + unsigned short ushort_; + + #pragma db type ("MEDIUMINT") + int mint_; + + #pragma db type ("MEDIUMINT UNSIGNED") + unsigned int umint_; + + #pragma db type ("INT") + int int_; + + #pragma db type ("INT UNSIGNED") + unsigned int uint_; + + #pragma db type ("BIGINT") + long long long_long_; + + #pragma db type ("BIGINT UNSIGNED") + unsigned long long ulong_long_; + + // Float types. + // + #pragma db type ("FLOAT") + float float_; + + #pragma db type ("FLOAT(32)") + double float8_; + + #pragma db type ("DOUBLE") + double double_; + + #pragma db type ("DECIMAL(6,3)") + std::string decimal_; + + // Data-time types. + // + #pragma db type ("DATE") + date_time date_; + + #pragma db type ("TIME") + date_time time_; + + #pragma db type ("DATETIME") + date_time date_time_; + + #pragma db type ("TIMESTAMP") + date_time timestamp_; + + #pragma db type ("YEAR") + short year_; + + // String and binary types. + // + #pragma db type ("CHAR(128)") + std::string char_; + + #pragma db type ("BINARY(128)") + buffer binary_; + + #pragma db type ("VARCHAR(256)") + std::string varchar_; + + #pragma db type ("VARBINARY(256)") + buffer varbinary_; + + #pragma db type ("TINYTEXT") + std::string tinytext_; + + #pragma db type ("TINYBLOB") + buffer tinyblob_; + + #pragma db type ("TEXT") + std::string text_; + + #pragma db type ("BLOB") + buffer blob_; + + #pragma db type ("MEDIUMTEXT") + std::string mediumtext_; + + #pragma db type ("MEDIUMBLOB") + buffer mediumblob_; + + #pragma db type ("LONGTEXT") + std::string longtext_; + + #pragma db type ("LONGBLOB") + buffer longblob_; + + // Other types. + // + // #pragma db type ("BIT(4)") - assigned by #pragma db value + bitfield bit_; + + // Test ENUM representations (integer and string). + // + color enum_def_; + + // Map to a custom MySQL ENUM type. + // + #pragma db type ("ENUM('R', 'G', 'B')") + color enum_cst_; + + #pragma db type ("ENUM('red', 'green', 'blue')") + std::string enum_str_; + + #pragma db type ("SET('red', 'green', 'blue')") + set set_; + + // Test NULL value. + // + #pragma db type ("TEXT") null + string_ptr null_; + + bool + operator== (const object& y) const + { + return + id_ == y.id_ && + bool_ == y.bool_ && + schar_ == y.schar_ && + uchar_ == y.uchar_ && + short_ == y.short_ && + ushort_ == y.ushort_ && + mint_ == y.mint_ && + umint_ == y.umint_ && + int_ == y.int_ && + uint_ == y.uint_ && + long_long_ == y.long_long_ && + ulong_long_ == y.ulong_long_ && + float_ == y.float_ && + float8_ == y.float8_ && + double_ == y.double_ && + decimal_ == y.decimal_ && + date_ == y.date_ && + time_ == y.time_ && + date_time_ == y.date_time_ && + timestamp_ == y.timestamp_ && + year_ == y.year_ && + char_ == y.char_ && + binary_ == y.binary_ && + varchar_ == y.varchar_ && + varbinary_ == y.varbinary_ && + tinytext_ == y.tinytext_ && + tinyblob_ == y.tinyblob_ && + text_ == y.text_ && + blob_ == y.blob_ && + mediumtext_ == y.mediumtext_ && + mediumblob_ == y.mediumblob_ && + longtext_ == y.longtext_ && + longblob_ == y.longblob_ && + bit_ == y.bit_ && + enum_def_ == y.enum_def_ && + enum_cst_ == y.enum_cst_ && + enum_str_ == y.enum_str_ && + set_ == y.set_ && + ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_); + } +}; + +// Test char array. +// +#pragma db object +struct char_array +{ + char_array () {} + char_array (unsigned long id, const char* s) + : id_ (id) + { + std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation. + std::memcpy (s2, s, std::strlen (s) + 1); + s3[0] = c1 = *s; + } + + #pragma db id + unsigned long id_; + + char s1[17]; + + #pragma db type("CHAR(16)") + char s2[16]; + + char s3[1]; + char c1; + + bool + operator== (const char_array& y) const + { + return id_ == y.id_ && + std::strcmp (s1, y.s1) == 0 && + std::strncmp (s2, y.s2, sizeof (s2)) == 0 && + s3[0] == y.s3[0] && + c1 == y.c1; + } +}; + +// MySQL server version view. +// +#pragma db view query( \ + "SELECT " \ + "CAST(SUBSTRING_INDEX(@@version, '.', 1) AS UNSIGNED)," \ + "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '.', 2), '.', -1) AS UNSIGNED)," \ + "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '-', 1), '.', -1) AS UNSIGNED)," \ + "@@protocol_version") +struct mysql_version +{ + unsigned int major; + unsigned int minor; + unsigned int release; + + unsigned int protocol; +}; + +#endif // TEST_HXX diff --git a/odb-tests/mysql/types/testscript b/odb-tests/mysql/types/testscript new file mode 100644 index 0000000..2962d1c --- /dev/null +++ b/odb-tests/mysql/types/testscript @@ -0,0 +1,11 @@ +# file : mysql/types/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../mysql.testscript + ++$create_schema + +: basics +: +$* diff --git a/odb-tests/mysql/types/traits.hxx b/odb-tests/mysql/types/traits.hxx new file mode 100644 index 0000000..d4ce200 --- /dev/null +++ b/odb-tests/mysql/types/traits.hxx @@ -0,0 +1,198 @@ +// file : mysql/types/traits.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TRAITS_HXX +#define TRAITS_HXX + +#include // std::memcpy, std::memset + +#include + +#include "test.hxx" // date_time, string_ptr + +namespace odb +{ + namespace mysql + { + template + class value_traits + { + public: + typedef date_time value_type; + typedef date_time query_type; + typedef MYSQL_TIME image_type; + + static void + set_value (date_time& v, const MYSQL_TIME& i, bool is_null) + { + if (!is_null) + { + v.negative = i.neg; + v.year = i.year; + v.month = i.month; + v.day = i.day; + v.hour = i.hour; + v.minute = i.minute; + v.second = i.second; + v.microseconds = static_cast (i.second_part); + } + else + v = date_time (); + } + + static void + set_image (MYSQL_TIME& i, bool& is_null, const date_time& v) + { + is_null = false; + i.neg = v.negative; + i.year = v.year; + i.month = v.month; + i.day = v.day; + i.hour = v.hour; + i.minute = v.minute; + i.second = v.second; + i.second_part = v.microseconds; + } + }; + + template <> + class value_traits + { + public: + typedef bitfield value_type; + typedef bitfield query_type; + typedef unsigned char* image_type; + + static void + set_value (bitfield& v, + const unsigned char* s, + std::size_t, + bool is_null) + { + if (!is_null) + { + v.a = *s & 1; + v.b = (*s >> 1) & 1; + v.c = (*s >> 2) & 1; + v.d = (*s >> 3) & 1; + } + else + v.a = v.b = v.c = v.d = 0; + } + + static void + set_image (unsigned char* s, + std::size_t, + std::size_t& n, + bool& is_null, + bitfield v) + { + is_null = false; + n = 1; + *s = v.a | (v.b << 1) | (v.c << 2) | (v.d << 3); + } + }; + + template <> + class value_traits + { + public: + typedef set value_type; + typedef set query_type; + typedef details::buffer image_type; + + static void + set_value (set& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + v.clear (); + + if (!is_null) + { + const char* s (b.data ()); + const char* e (s + n); + + while (s < e) + { + const char* p (s); + + while (p < e && *p != ',') + ++p; + + v.insert (std::string (s, p - s)); + s = p; + + if (p != e) + ++s; + } + } + } + + static void + set_image (details::buffer& buf, + std::size_t& n, + bool& is_null, + const set& v) + { + is_null = false; + n = 0; + + for (set::const_iterator b (v.begin ()), i (b); i != v.end (); ++i) + { + std::size_t m (i->size () + (i != b ? 1 : 0)); + + if (n + m > buf.capacity ()) + buf.capacity (n + m, n); + + if (i != b) + buf.data ()[n++] = ','; + + std::memcpy (buf.data () + n, i->c_str (), i->size ()); + n += i->size (); + } + } + }; + + template <> + class value_traits + { + public: + typedef string_ptr value_type; + typedef std::string query_type; + typedef details::buffer image_type; + + static void + set_value (string_ptr& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + v.reset (is_null ? 0 : new std::string (b.data (), n)); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const string_ptr& v) + { + is_null = v.get () == 0; + + if (!is_null) + { + n = v->size (); + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + std::memcpy (b.data (), v->c_str (), n); + } + } + }; + } +} + +#endif // TRAITS_HXX diff --git a/odb-tests/oracle/custom/custom.sql b/odb-tests/oracle/custom/custom.sql new file mode 100644 index 0000000..6e22903 --- /dev/null +++ b/odb-tests/oracle/custom/custom.sql @@ -0,0 +1,53 @@ +/* This file contains custom type definitions and helper functions. + */ + +/* For some reason CREATE OR REPLACE TYPE does not work on Oracle 10.2. */ +BEGIN + BEGIN + EXECUTE IMMEDIATE 'DROP TYPE Numbers'; + EXCEPTION + WHEN OTHERS THEN + IF SQLCODE != -4043 THEN RAISE; END IF; + END; +END; +/ + +CREATE TYPE Numbers AS VARRAY(100) OF NUMBER(10); +/ + +CREATE OR REPLACE FUNCTION string_to_numbers(in_str IN VARCHAR2) RETURN Numbers +IS + ret Numbers := Numbers(); + s_pos NUMBER := 1; + e_pos NUMBER := 0; +BEGIN + IF in_str IS NOT NULL THEN + LOOP + e_pos := INSTR(in_str, ',', s_pos); + EXIT WHEN e_pos = 0; + ret.extend; + ret(ret.COUNT) := CAST(SUBSTR(in_str, s_pos, e_pos - s_pos) AS NUMBER); + s_pos := e_pos + 1; + END LOOP; + ret.extend; + ret(ret.COUNT) := CAST(SUBSTR(in_str, s_pos) AS NUMBER); + END IF; + RETURN ret; +END; +/ + +CREATE OR REPLACE FUNCTION numbers_to_string(in_nums IN Numbers) RETURN VARCHAR2 +IS + ret VARCHAR2(1500); +BEGIN + IF in_nums.COUNT != 0 THEN + FOR i IN in_nums.FIRST .. in_nums.LAST LOOP + IF i != in_nums.FIRST THEN + ret := ret || ','; + END IF; + ret := ret || in_nums(i); + END LOOP; + END IF; + RETURN ret; +END; +/ diff --git a/odb-tests/oracle/custom/driver.cxx b/odb-tests/oracle/custom/driver.cxx new file mode 100644 index 0000000..45f0a4e --- /dev/null +++ b/odb-tests/oracle/custom/driver.cxx @@ -0,0 +1,77 @@ +// file : oracle/custom/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test custom database type mapping in Oracle. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +namespace oracle = odb::oracle; +using namespace oracle; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_specific_database (argc, argv)); + + object o (1); + o.iv.push_back (123); + o.iv.push_back (234); + o.iv.push_back (-345); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + + // Update. + // + o.iv[0]++; + o.iv.pop_back (); + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/oracle/custom/test.hxx b/odb-tests/oracle/custom/test.hxx new file mode 100644 index 0000000..523d50b --- /dev/null +++ b/odb-tests/oracle/custom/test.hxx @@ -0,0 +1,40 @@ +// file : oracle/custom/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +// Map Numbers VARRAY Oracle type to std::vector. This type is defined +// in the custom.sql file along with two helper functions that convert +// between Numbers and its string representation. The other half of this +// mapping is in traits.hxx (value_traits, id_string>). +// +#pragma db map type("Numbers") \ + as("VARCHAR2(1500)") \ + to("CAST(string_to_numbers((?)) AS Numbers)") \ + from("numbers_to_string((?))") + +#pragma db object +struct object +{ + object () {} + object (unsigned long id_) : id (id_) {} + + #pragma db id + unsigned long id; + + #pragma db type("Numbers") + std::vector iv; + + bool + operator== (const object& y) const + { + return id == y.id && iv == y.iv; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/oracle/custom/traits.hxx b/odb-tests/oracle/custom/traits.hxx new file mode 100644 index 0000000..8df2f91 --- /dev/null +++ b/odb-tests/oracle/custom/traits.hxx @@ -0,0 +1,76 @@ +// file : oracle/types/traits.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TRAITS_HXX +#define TRAITS_HXX + +#include +#include +#include // std::memcpy +#include // std::memcpy + +#include + +namespace odb +{ + namespace oracle + { + + template <> + class value_traits, id_string> + { + public: + typedef std::vector value_type; + typedef value_type query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const char* b, + std::size_t n, + bool is_null) + { + v.clear (); + + if (!is_null) + { + // Array format is "n1,n2,n3...". + // + std::istringstream is (std::string (b, n)); + + for (char c; !is.eof (); is >> c) + { + v.push_back (int ()); + is >> v.back (); + } + } + } + + static void + set_image (char* b, + std::size_t c, + std::size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + std::ostringstream os; + + for (value_type::const_iterator i (v.begin ()), e (v.end ()); i != e;) + { + os << *i; + + if (++i != e) + os << ','; + } + + const std::string& s (os.str ()); + n = s.size (); + assert (n <= c); + std::memcpy (b, s.c_str (), n); + } + }; + } +} + +#endif // TRAITS_HXX diff --git a/odb-tests/oracle/database/driver.cxx b/odb-tests/oracle/database/driver.cxx new file mode 100644 index 0000000..499f136 --- /dev/null +++ b/odb-tests/oracle/database/driver.cxx @@ -0,0 +1,33 @@ +// file : oracle/database/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test that database constructors are unambiguous (compilation only). +// + +#include + +namespace oracle = odb::oracle; +using namespace oracle; + +int +main (int argc, char* argv[]) +{ + // This code should not execute. + // + if (argc != 0) + return 0; + + { + database d1 ("bob", "secret", "db1"); + } + + { + database d1 ("bob", "secret", "svc1", "server1"); + database d2 ("bob", "secret", "svc1", "server1", 999); + } + + { + database d1 (argc, argv); + database d2 (argc, argv, false); + } +} diff --git a/odb-tests/oracle/native/driver.cxx b/odb-tests/oracle/native/driver.cxx new file mode 100644 index 0000000..541d21e --- /dev/null +++ b/odb-tests/oracle/native/driver.cxx @@ -0,0 +1,77 @@ +// file : oracle/native/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test native SQL execution. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +using namespace std; +namespace oracle = odb::oracle; +using namespace oracle; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_specific_database (argc, argv)); + + // Create the database schema. + // + { + transaction t (db->begin ()); + + db->execute ("BEGIN " + " EXECUTE IMMEDIATE 'DROP TABLE oracle_native_test'; " + " EXCEPTION " + " WHEN OTHERS THEN " + " IF SQLCODE != -942 THEN RAISE; END IF; " + "END;"); + + db->execute ("CREATE TABLE oracle_native_test (n NUMERIC(10,0))"); + + t.commit (); + } + + // Insert a few rows. + // + { + transaction t (db->begin ()); + + assert ( + db->execute ("INSERT INTO oracle_native_test (n) VALUES (1)") == 1); + + assert ( + db->execute ("INSERT INTO oracle_native_test (n) VALUES (2)") == 1); + + t.commit (); + } + + // Select a few rows. + // + { + transaction t (db->begin ()); + + assert ( + db->execute ("SELECT n FROM oracle_native_test WHERE n < 3") == 2); + + assert ( + db->execute ("SELECT n FROM oracle_native_test WHERE n > 3") == 0); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/oracle/template/driver.cxx b/odb-tests/oracle/template/driver.cxx new file mode 100644 index 0000000..13317df --- /dev/null +++ b/odb-tests/oracle/template/driver.cxx @@ -0,0 +1,40 @@ +// file : oracle/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +namespace oracle = odb::oracle; +using namespace oracle; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_specific_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/oracle/template/template-vc10.vcxproj b/odb-tests/oracle/template/template-vc10.vcxproj new file mode 100644 index 0000000..92066cf --- /dev/null +++ b/odb-tests/oracle/template/template-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/oracle/template/template-vc10.vcxproj.filters b/odb-tests/oracle/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/oracle/template/template-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/oracle/template/template-vc11.vcxproj b/odb-tests/oracle/template/template-vc11.vcxproj new file mode 100644 index 0000000..a92e437 --- /dev/null +++ b/odb-tests/oracle/template/template-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\libcommon\lib64\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/oracle/template/template-vc11.vcxproj.filters b/odb-tests/oracle/template/template-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/oracle/template/template-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/oracle/template/template-vc12.vcxproj b/odb-tests/oracle/template/template-vc12.vcxproj new file mode 100644 index 0000000..de35c03 --- /dev/null +++ b/odb-tests/oracle/template/template-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\libcommon\lib64\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/oracle/template/template-vc12.vcxproj.filters b/odb-tests/oracle/template/template-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/oracle/template/template-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/oracle/template/template-vc8.vcproj b/odb-tests/oracle/template/template-vc8.vcproj new file mode 100644 index 0000000..71e2b52 --- /dev/null +++ b/odb-tests/oracle/template/template-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/oracle/template/template-vc9.vcproj b/odb-tests/oracle/template/template-vc9.vcproj new file mode 100644 index 0000000..de9804e --- /dev/null +++ b/odb-tests/oracle/template/template-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/oracle/template/test.hxx b/odb-tests/oracle/template/test.hxx new file mode 100644 index 0000000..bfa9cc9 --- /dev/null +++ b/odb-tests/oracle/template/test.hxx @@ -0,0 +1,25 @@ +// file : oracle/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/oracle/types/driver.cxx b/odb-tests/oracle/types/driver.cxx new file mode 100644 index 0000000..2e3e2e7 --- /dev/null +++ b/odb-tests/oracle/types/driver.cxx @@ -0,0 +1,366 @@ +// file : oracle/types/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Oracle type conversion. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +namespace oracle = odb::oracle; +using namespace oracle; + +int +main (int argc, char* argv[]) +{ + try + { + // Create an Oracle database instance, setting both the client database + // and national character set to UTF-8. + // + auto_ptr db (create_specific_database (argc, argv)); + + object o (1); + + o.int_ = -123456; + o.uint_ = 123456; + o.long_long_ = -123456; + o.ulong_long_ = 123456; + + o.float_ = 1.123F; + o.double_ = 1.123; + o.num_float_ = 1.123F; + o.num_double_ = 1.123; + o.binary_float_ = 1.123F; + o.binary_double_ = 1.123; + + o.date_ = date_time (2010, 8, 29, 15, 33, 18, 0); + o.timestamp_ = date_time (1996, 3, 9, 18, 2, 54, 123000); + o.interval_ds_ = time_interval (0, 0, 13, 15, 23, 19, 123000); + o.interval_ym_ = time_interval (12, 3, 0, 0, 0, 0, 0); + + string vshort_str (8, 's'); + string short_str (13, 's'); + string medium_str (104, 'm'); + string long_str (1018, 'l'); + string vlong_str (15000, 'v'); + + o.char_ = short_str; + o.varchar2_ = medium_str; + o.clob_.assign (vlong_str.data (), vlong_str.data () + vlong_str.size ()); + + o.nchar_ = vshort_str; + o.nvarchar2_ = medium_str; + o.nclob_.assign (vlong_str.data (), vlong_str.data () + vlong_str.size ()); + + o.empty_c_.push_back (""); + + o.raw_.assign (long_str.data (), long_str.data () + long_str.size ()); + o.blob_.assign (vlong_str.data (), vlong_str.data () + vlong_str.size ()); + + o.strs_.push_back (short_str); + o.strs_.push_back (medium_str); + o.strs_.push_back (long_str); + o.strs_.push_back (vlong_str); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + + // Test character set conversion. + // + const char* unicode_str = "a \xD5\x95 \xEA\xAA\xAA \xF2\xAA\xAA\xAA"; + + // Testing of character set conversion to and from the client's database + // character set is disabled as the server database character set may + // not be able to represent some Unicode characters. If this were the case + // the test outcome would be a false negative. + // + // o.char_ = unicode_str; + // o.varchar2_ = unicode_str; + // o.clob_ = unicode_str; + + o.nchar_ = unicode_str; + o.nvarchar2_ = unicode_str; + o.nclob_ = unicode_str; + + // Persist. + // + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + + // Test 64 bit integers. + // + big_int bi1 (1, 0x8000000000000000LL); + big_int bi2 (2, -123456); + big_int bi3 (3, 0); + big_int bi4 (4, 123456); + big_int bi5 (5, 0xFFFFFFFFFFFFFFFFULL); + + big_uint bui1 (1, 0); + big_uint bui2 (2, 123456); + big_uint bui3 (3, 0xFFFFFFFFFFFFFFFFULL); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (bi1); + db->persist (bi2); + db->persist (bi3); + db->persist (bi4); + db->persist (bi5); + db->persist (bui1); + db->persist (bui2); + db->persist (bui3); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr bil1 (db->load (1)); + auto_ptr bil2 (db->load (2)); + auto_ptr bil3 (db->load (3)); + auto_ptr bil4 (db->load (4)); + auto_ptr bil5 (db->load (5)); + auto_ptr buil1 (db->load (1)); + auto_ptr buil2 (db->load (2)); + auto_ptr buil3 (db->load (3)); + t.commit (); + + assert (bi1 == *bil1); + assert (bi2 == *bil2); + assert (bi3 == *bil3); + assert (bi4 == *bil4); + assert (bi5 == *bil5); + assert (bui1 == *buil1); + assert (bui2 == *buil2); + assert (bui3 == *buil3); + } + + // Test large BLOBs. + // + descriptor b1 (1); + b1.blob.assign (50000, 'b'); + b1.timestamp = date_time (1996, 3, 9, 18, 2, 54, 123000); + b1.interval_ds = time_interval (0, 0, 13, 15, 23, 19, 123000); + b1.interval_ym = time_interval (12, 3, 0, 0, 0, 0, 0); + + descriptor b2 (2); + b2.blob.assign (500000, 'b'); + b2.timestamp = date_time (1997, 4, 10, 19, 3, 55, 234000); + b2.interval_ds = time_interval (0, 0, 14, 16, 24, 20, 234000); + b2.interval_ym = time_interval (13, 4, 0, 0, 0, 0, 0); + + descriptor b3 (3); + b3.blob.assign (5000, 'b'); + b3.timestamp = date_time (1995, 2, 8, 17, 1, 53, 120000); + b3.interval_ds = time_interval (0, 0, 12, 14, 22, 18, 120000); + b3.interval_ym = time_interval (11, 2, 0, 0, 0, 0, 0); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (b1); + db->persist (b2); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr p1 (db->load (1)); + auto_ptr p2 (db->load (2)); + t.commit (); + + assert (b1 == *p1); + assert (b2 == *p2); + } + + // Test image copying with descriptor-based type (LOB, date-time) data. + // + { + typedef oracle::query query; + typedef odb::result result; + + transaction t (db->begin ()); + + // Pre-bind the image for other operations. + // + { + db->persist (b3); + db->update (b3); + db->reload (b3); + db->erase (b3); + } + + + result r (db->query (query::id < 3)); + result::iterator i (r.begin ()); + + assert (i != r.end ()); + + { + result r (db->query (query::id > 1)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (*i == b2); + assert (++i == r.end ()); + } + + assert (*i == b1); // Load from copy (copy c-tor). + + ++i; + assert (i != r.end ()); + + { + result r (db->query (query::id < 2)); + result::iterator i (r.begin ()); + assert (i != r.end ()); + assert (*i == b1); + assert (++i == r.end ()); + } + + assert (*i == b2); // Load from copy (copy assign). + assert (++i == r.end ()); + + // Make sure all other operations are still working. + // + { + db->persist (b3); +#ifdef HAVE_CXX11 + unique_ptr p (db->load (3)); +#else + auto_ptr p (db->load (3)); +#endif + assert (b3 == *p); + b3.blob.push_back (123); + db->update (b3); + db->reload (p); + assert (b3 == *p); + db->erase (b3); + } + + t.commit (); + } + + // Test descriptor management in TIMESTAMP and INTERVAL images. + // + { + typedef oracle::query query; + typedef odb::result result; + + query q (query::timestamp == o.timestamp_ && + query::interval_ym == o.interval_ym_ && + query::interval_ds == o.interval_ds_); + + transaction t (db->begin ()); + + { + result r (db->query (q)); + assert (size (r) == 1); + } + + { + result r (db->query (q)); + assert (size (r) == 1); + } + + { + // Query temporary. + // + result r (db->query ( + query::timestamp == o.timestamp_ && + query::interval_ym == o.interval_ym_ && + query::interval_ds == o.interval_ds_)); + + query dummy (query::timestamp == o.timestamp_ && + query::interval_ym == o.interval_ym_ && + query::interval_ds == o.interval_ds_); + + assert (size (r) == 1); + } + + t.commit (); + } + + // Test char array. + // + { + char_array o1 (1, ""); + char_array o2 (2, "1234567890"); + char_array o3 (3, "1234567890123456"); + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + } + + // Oracle returns padded values for CHAR(N) unless they are + // empty (represented as NULL). + // + memcpy (o2.s2, "1234567890 ", 16); + + { + transaction t (db->begin ()); + auto_ptr p1 (db->load (1)); + auto_ptr p2 (db->load (2)); + auto_ptr p3 (db->load (3)); + t.commit (); + + assert (o1 == *p1); + assert (o2 == *p2); + assert (o3 == *p3); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/oracle/types/test.hxx b/odb-tests/oracle/types/test.hxx new file mode 100644 index 0000000..255bc08 --- /dev/null +++ b/odb-tests/oracle/types/test.hxx @@ -0,0 +1,353 @@ +// file : oracle/types/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include // HAVE_CXX11 + +#include +#include +#include // std::auto_ptr +#include // std::memcpy, std::str[n]cmp, std::strlen + +#include + +struct date_time +{ + date_time () + { + } + + date_time (unsigned short y, + unsigned char m, + unsigned char d, + unsigned char h, + unsigned char min, + unsigned char sec, + unsigned int nsec) + : year (y), + month (m), + day (d), + hour (h), + minute (min), + second (sec), + nanosecond (nsec) + { + } + + bool + operator== (const date_time& y) const + { + return + year == y.year && + month == y.month && + day == y.day && + hour == y.hour && + minute == y.minute && + second == y.second && + nanosecond == y.nanosecond; + } + + unsigned short year; + unsigned char month; + unsigned char day; + unsigned char hour; + unsigned char minute; + unsigned char second; + unsigned int nanosecond; +}; + +struct time_interval +{ + time_interval () + { + } + + time_interval (int y, int m, int d, int h, int min, int sec, int nsec) + : year (y), + month (m), + day (d), + hour (h), + minute (min), + second (sec), + nanosecond (nsec) + { + } + + bool + operator== (const time_interval& y) const + { + return + year == y.year && + month == y.month && + day == y.day && + hour == y.hour && + minute == y.minute && + second == y.second && + nanosecond == y.nanosecond; + } + + int year; + int month; + int day; + int hour; + int minute; + int second; + int nanosecond; +}; + +#ifdef HAVE_CXX11 +typedef std::unique_ptr string_ptr; +#else +typedef std::auto_ptr string_ptr; +#endif + +typedef std::vector strings; + +#pragma db object +struct object +{ + object () {} + object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned int id_; + + // Integral types. + // + #pragma db type ("NUMBER(10)") + int int_; + + #pragma db type ("NUMBER(10)") + unsigned uint_; + + #pragma db type ("NUMBER(19)") + long long long_long_; + + #pragma db type ("NUMBER(20)") + unsigned long long ulong_long_; + + // Float types. + // + #pragma db type ("FLOAT(24)") + float float_; + + #pragma db type ("FLOAT(53)") + double double_; + + #pragma db type ("NUMBER(7,3)") + float num_float_; + + #pragma db type ("NUMBER(15,5)") + double num_double_; + + #pragma db type ("BINARY_FLOAT") + float binary_float_; + + #pragma db type ("BINARY_DOUBLE") + double binary_double_; + + // Data-time types. + // + #pragma db type ("DATE") + date_time date_; + + #pragma db type ("TIMESTAMP(6)") + date_time timestamp_; + + #pragma db type ("INTERVAL DAY TO SECOND") + time_interval interval_ds_; + + #pragma db type ("INTERVAL YEAR TO MONTH") + time_interval interval_ym_; + + // String and binary types. + // + #pragma db type ("CHAR(13)") + std::string char_; + + #pragma db type ("VARCHAR2(512)") null + std::string varchar2_; + + #pragma db type ("NCHAR(8)") + std::string nchar_; + + #pragma db type ("NVARCHAR2(512)") null + std::string nvarchar2_; + + // Oracle treats empty and NULL VARCHAR2 the same. Test that we + // handle this. + // + std::string empty_; + std::vector empty_c_; + + #pragma db type ("RAW(1024)") + std::vector raw_; + + // LOB types. + // + #pragma db type ("BLOB") + std::vector blob_; + + #pragma db type ("CLOB") + std::string clob_; + + #pragma db type ("NCLOB") + std::string nclob_; + + // Test containers of LOBs + // + #pragma db value_type ("CLOB") + strings strs_; + + // Test NULL value. + // + #pragma db type ("VARCHAR2(32)") null + string_ptr null_; + + bool + operator== (const object& y) const + { + return + id_ == y.id_ && + int_ == y.int_ && + uint_ == y.uint_ && + long_long_ == y.long_long_ && + ulong_long_ == y.ulong_long_ && + float_ == y.float_ && + double_ == y.double_ && + num_float_ == y.num_float_ && + num_double_ == y.num_double_ && + binary_float_ == y.binary_float_ && + binary_double_ == y.binary_double_ && + date_ == y.date_ && + timestamp_ == y.timestamp_ && + interval_ds_ == y.interval_ds_ && + interval_ym_ == y.interval_ym_ && + char_ == y.char_ && + varchar2_ == y.varchar2_ && + nchar_ == y.nchar_ && + nvarchar2_ == y.nvarchar2_ && + empty_ == y.empty_ && + empty_c_ == y.empty_c_ && + raw_ == y.raw_ && + blob_ == y.blob_ && + clob_ == y.clob_ && + nclob_ == y.nclob_ && + strs_ == y.strs_ && + ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_); + } +}; + +#pragma db object +struct big_uint +{ + big_uint (unsigned int id = 0, unsigned long long v = 0) + : id_ (id), value (v) + { + } + + #pragma db id + unsigned int id_; + + unsigned long long value; + + bool + operator== (const big_uint& y) const + { + return id_ == y.id_ && value == y.value; + } +}; + +#pragma db object +struct big_int +{ + big_int (unsigned int id = 0, long long v = 0) + : id_ (id), value (v) + { + } + + #pragma db id + unsigned int id_; + + long long value; + + bool + operator== (const big_int& y) const + { + return id_ == y.id_ && value == y.value; + } +}; + +#pragma db object +struct descriptor +{ + descriptor (unsigned int id = 0): id_ (id) {} + + #pragma db id + unsigned int id_; + + #pragma db type ("BLOB") + std::vector blob; + + #pragma db type ("TIMESTAMP(6)") + date_time timestamp; + + #pragma db type ("INTERVAL DAY TO SECOND") + time_interval interval_ds; + + #pragma db type ("INTERVAL YEAR TO MONTH") + time_interval interval_ym; + + bool + operator== (const descriptor& y) const + { + return id_ == y.id_ && + blob == y.blob && + timestamp == y.timestamp && + interval_ds == y.interval_ds && + interval_ym == y.interval_ym; + } +}; + +// Test char array. +// +#pragma db object +struct char_array +{ + char_array () {} + char_array (unsigned long id, const char* s) + : id_ (id) + { + std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation. + std::memcpy (s2, s, std::strlen (s) + 1); + s3[0] = c1 = *s; + } + + #pragma db id + unsigned long id_; + + char s1[17]; + + #pragma db type("CHAR(16)") null + char s2[16]; + + #pragma db null + char s3[1]; + + #pragma db null + char c1; + + bool + operator== (const char_array& y) const + { + return id_ == y.id_ && + std::strcmp (s1, y.s1) == 0 && + std::strncmp (s2, y.s2, sizeof (s2)) == 0 && + s3[0] == y.s3[0] && + c1 == y.c1; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/oracle/types/traits.hxx b/odb-tests/oracle/types/traits.hxx new file mode 100644 index 0000000..ad747d8 --- /dev/null +++ b/odb-tests/oracle/types/traits.hxx @@ -0,0 +1,192 @@ +// file : oracle/types/traits.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TRAITS_HXX +#define TRAITS_HXX + +#include // datetime, interval_ym, interval_ds +#include + +#include + +#include "test.hxx" // date_time, time_interval + +namespace odb +{ + namespace oracle + { + template <> + class value_traits + { + public: + typedef date_time value_type; + typedef date_time query_type; + typedef char* image_type; + + static void + set_value (date_time& v, const char* i, bool is_null) + { + if (!is_null) + { + short y (0); + unsigned char m (0), d (0), h (0), mins (0), s (0); + + details::get_date (i, y, m, d, h, mins, s); + + v.year = y; + v.month = m; + v.day = d; + v.hour = h; + v.minute = mins; + v.second = s; + + // Oracle DATE does not support fractional seconds. + // + v.nanosecond = 0; + } + } + + static void + set_image (char* i, bool& is_null, const date_time& v) + { + is_null = false; + details::set_date (i, + static_cast (v.year), + v.month, + v.day, + v.hour, + v.minute, + v.second); + } + }; + + template <> + class value_traits + { + public: + typedef date_time value_type; + typedef date_time query_type; + typedef datetime image_type; + + static void + set_value (date_time& v, const datetime& i, bool is_null) + { + if (!is_null) + { + sb2 y (0); + ub1 m (0), d (0), h (0), mins (0), s (0); + ub4 ns (0); + + i.get (y, m, d, h, mins, s, ns); + + v.year = y; + v.month = m; + v.day = d; + v.hour = h; + v.minute = mins; + v.second = s; + v.nanosecond = ns; + } + } + + static void + set_image (datetime& i, + bool& is_null, + const date_time& v) + { + is_null = false; + + i.set (static_cast (v.year), + v.month, + v.day, + v.hour, + v.minute, + v.second, + v.nanosecond); + } + }; + + template <> + class value_traits + { + public: + typedef time_interval value_type; + typedef time_interval query_type; + typedef interval_ds image_type; + + static void + set_value (time_interval& v, + const interval_ds& i, + bool is_null) + { + if (!is_null) + { + sb4 d (0), h (0), m (0), s (0), ns (0); + i.get (d, h, m, s, ns); + + v.year = 0; + v.month = 0; + v.day = static_cast (d); + v.hour = static_cast (h); + v.minute = static_cast (m); + v.second = static_cast (s); + v.nanosecond = static_cast (ns); + } + } + + static void + set_image (interval_ds& i, + bool& is_null, + const time_interval& v) + { + is_null = false; + + i.set (v.day, + v.hour, + v.minute, + v.second, + static_cast (v.nanosecond)); + } + }; + + template <> + class value_traits + { + public: + typedef time_interval value_type; + typedef time_interval query_type; + typedef interval_ym image_type; + + static void + set_value (time_interval& v, + const interval_ym& i, + bool is_null) + { + if (!is_null) + { + sb4 y (0), m (0); + i.get (y, m); + + v.year = static_cast (y); + v.month = static_cast (m); + v.day = 0; + v.hour = 0; + v.minute = 0; + v.second = 0; + v.nanosecond = 0; + } + } + + static void + set_image (interval_ym& i, + bool& is_null, + const time_interval& v) + { + is_null = false; + i.set (v.year, v.month); + } + }; + } +} + +#endif // TRAITS_HXX diff --git a/odb-tests/pgsql-schema.testscript b/odb-tests/pgsql-schema.testscript new file mode 100644 index 0000000..8659bcd --- /dev/null +++ b/odb-tests/pgsql-schema.testscript @@ -0,0 +1,6 @@ +# file : pgsql-schema.testscript +# license : GNU GPL v2; see accompanying LICENSE file + +# Create the PostgreSQL database schema creation canned command base. +# +create_schema_cmd = [cmdline] $pgsql_client_cmd diff --git a/odb-tests/pgsql.testscript b/odb-tests/pgsql.testscript new file mode 100644 index 0000000..e4b4636 --- /dev/null +++ b/odb-tests/pgsql.testscript @@ -0,0 +1,12 @@ +# file : pgsql.testscript +# license : GNU GPL v2; see accompanying LICENSE file + +# Create the PostgreSQL database schema creation canned command and setup the +# test driver command line for the subsequent tests. +# +.include pgsql-schema.testscript + +schema_file = [path] $out_base/"$schema"($multi ? '-pgsql' : '').sql +create_schema = [cmdline] $create_schema_cmd -f $schema_file + +test.arguments += ($multi ? 'pgsql' : ) $pgsql_options diff --git a/odb-tests/pgsql/buildfile b/odb-tests/pgsql/buildfile new file mode 100644 index 0000000..c6385c0 --- /dev/null +++ b/odb-tests/pgsql/buildfile @@ -0,0 +1,6 @@ +# file : pgsql/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +./: {*/ -bulk/} + +./: bulk/: include = ($pgsql && !$multi && $pgsql_bulk) diff --git a/odb-tests/pgsql/bulk/buildfile b/odb-tests/pgsql/bulk/buildfile new file mode 100644 index 0000000..6984edb --- /dev/null +++ b/odb-tests/pgsql/bulk/buildfile @@ -0,0 +1,40 @@ +# file : pgsql/bulk/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +if ($build.meta_operation != 'dist') +{ + assert ($pgsql && !$multi) \ + "pgsql should be configured via config.odb_tests.database variable as a single database" + + assert ($pgsql_bulk) "bulk operations are disabled for pgsql" +} + +import libodb = libodb%lib{odb} + +import libs = libpq%lib{pq} +import libs += libodb-pgsql%lib{odb-pgsql} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix pgsql_bulk_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/odb-tests/pgsql/bulk/driver.cxx b/odb-tests/pgsql/bulk/driver.cxx new file mode 100644 index 0000000..ba25542 --- /dev/null +++ b/odb-tests/pgsql/bulk/driver.cxx @@ -0,0 +1,361 @@ +// file : pgsql/bulk/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test transaction savepoints. +// + +#include + +#include +#include +#include +#include +#include + +// Note: hack. +// +#include +#define htonll(x) ((((long long)htonl(x)) << 32) + htonl((x) >> 32)) + +#undef NDEBUG +#include + +static const size_t columns = 3; + +struct data +{ + long long id; + long long idata; + const char* sdata; +}; + +static char* values[columns]; +static int lengths[columns]; +static int formats[columns] = {1, 1, 1}; + +static const unsigned int types[columns] = { + 20, // int8 + 20, // int8 + 25 // text +}; + +static void +init (const struct data* d) +{ + values[0] = (char*)&d->id; + lengths[0] = sizeof (d->id); + + values[1] = (char*)&d->idata; + lengths[1] = sizeof (d->idata); + + values[2] = (char*)d->sdata; + lengths[2] = strlen (d->sdata); +} + +static void +execute (PGconn* conn, const struct data* ds, size_t n) +{ + int sock = PQsocket (conn); + assert (sock != -1); + + if (PQsetnonblocking (conn, 1) == -1 || + PQenterPipelineMode (conn) == 0) + assert (false); + + // True if we've written and read everything, respectively. + // + bool wdone = false; + bool rdone = false; + + size_t wn = 0; + size_t rn = 0; + + while (!rdone) + { + fd_set wds; + if (!wdone) + { + FD_ZERO (&wds); + FD_SET (sock, &wds); + } + + fd_set rds; + FD_ZERO (&rds); + FD_SET (sock, &rds); + + if (select (sock + 1, &rds, wdone ? NULL : &wds, NULL, NULL) == -1) + { + if (errno == EINTR) + continue; + + assert (false); + } + + // Try to minimize the chance of blocking the server by first processing + // the result and then sending more queries. + // + if (FD_ISSET (sock, &rds)) + { + if (PQconsumeInput (conn) == 0) + assert (false); + + while (wn > rn && PQisBusy (conn) == 0) + { + //fprintf (stderr, "PQgetResult %zu\n", rn); + + PGresult* res = PQgetResult (conn); + assert (res != NULL); + ExecStatusType stat = PQresultStatus (res); + + if (stat == PGRES_PIPELINE_SYNC) + { + assert (wdone && rn == n); + PQclear (res); + rdone = true; + break; + } + + if (stat == PGRES_FATAL_ERROR) + { + const char* s = PQresultErrorField (res, PG_DIAG_SQLSTATE); + + if (strcmp (s, "23505") == 0) + fprintf (stderr, "duplicate id at %zu\n", rn); + } + + PQclear (res); + assert (rn != n); + ++rn; + + // We get a NULL result after each query result. + // + { + PGresult* end = PQgetResult (conn); + assert (end == NULL); + } + } + } + + if (!wdone && FD_ISSET (sock, &wds)) + { + // Send queries until we get blocked (write-biased). This feels like + // a better overall strategy to keep the server busy compared to + // sending one query at a time and then re-checking if there is + // anything to read because the results of INSERT/UPDATE/DELETE are + // presumably small and quite a few of them can get buffered before + // the server gets blocked. + // + for (;;) + { + if (wn < n) + { + //fprintf (stderr, "PQsendQueryPrepared %zu\n", wn); + + init (ds + wn); + + if (PQsendQueryPrepared (conn, + "persist_object", + (int)(columns), + values, + lengths, + formats, + 1) == 0) + assert (false); + + if (++wn == n) + { + if (PQpipelineSync (conn) == 0) + assert (false); + + ++wn; + } + } + + // PQflush() result: + // + // 0 -- success (queue is now empty) + // 1 -- blocked + // -1 -- error + // + int r = PQflush (conn); + assert (r != -1); + + if (r == 0) + { + if (wn < n) + { + // If we continue here, then we are write-biased. And if we + // break, then we are read-biased. + // +#if 0 + break; +#else + continue; +#endif + } + + wdone = true; + } + + break; // Blocked or done. + } + } + } + + if (PQexitPipelineMode (conn) == 0 || + PQsetnonblocking (conn, 0) == -1) + assert (false); +} + +static void +test (PGconn* conn) +{ + const size_t batch = 500; + struct data ds[batch]; + + for (size_t i = 0; i != batch; ++i) + { + ds[i].id = htonll (i == batch / 2 ? i - 1 : i); // Cause duplicate PK. + ds[i].idata = htonll (i); + ds[i].sdata = "abc"; + } + + // Prepare the statement. + // + { + PGresult* res = PQprepare ( + conn, + "persist_object", + "INSERT INTO \"pgsql_bulk_object\" " + "(\"id\", " + "\"idata\", " + "\"sdata\") " + "VALUES " + "($1, $2, $3)", + (int)(columns), + types); + assert (PQresultStatus (res) == PGRES_COMMAND_OK); + PQclear (res); + } + + // Begin transaction. + // + { + PGresult* res = PQexec (conn, "begin"); + assert (PQresultStatus (res) == PGRES_COMMAND_OK); + PQclear (res); + } + + execute (conn, ds, batch); + + // Commit transaction. + // + { + PGresult* res = PQexec (conn, "commit"); + assert (PQresultStatus (res) == PGRES_COMMAND_OK); + PQclear (res); + } +} + +#include +#include // std::unique_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace pgsql = odb::pgsql; +using namespace pgsql; + +int +main (int argc, char* argv[]) +{ + bool fail_already_persistent (false); + + for (int i (1); i != argc; ++i) + { + if (strcmp (argv[i], "--fail-already-persistent") == 0) + { + fail_already_persistent = true; + + for (; i != argc - 1; ++i) + argv[i] = argv[i + 1]; + + --argc; + + break; + } + } + + try + { + unique_ptr db (create_specific_database (argc, argv)); + + connection_ptr cn (db->connection ()); + + if (false) + { + PGconn* conn (cn->handle ()); + test (conn); + } + + { + const unsigned long n (500); + + vector os; + + for (unsigned long i (0); i != n; ++i) + { + os.push_back (object {i, i, string (i, 'x')}); + + if (fail_already_persistent && i == n / 2) + os.push_back (object {i, i, to_string (i)}); + } + + { + transaction t (cn->begin ()); + db->persist (os.begin (), os.end ()); + t.commit (); + } + + { + transaction t (cn->begin ()); + db->find (2); + t.commit (); + } + + for (unsigned long i (0); i != n; ++i) + { + //assert (os[i].id == i + 1); + os[i].idata++; + } + + { + transaction t (cn->begin ()); + db->update (os.begin (), os.end ()); + t.commit (); + } + + { + transaction t (cn->begin ()); + db->erase (os.begin (), os.end ()); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/pgsql/bulk/test.hxx b/odb-tests/pgsql/bulk/test.hxx new file mode 100644 index 0000000..25dd138 --- /dev/null +++ b/odb-tests/pgsql/bulk/test.hxx @@ -0,0 +1,34 @@ +// file : pgsql/savepoint/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object bulk(1000) +struct object +{ + /* + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + */ + + #pragma db id //auto + unsigned long id; + + unsigned long idata; + + //#pragma db + std::string sdata; +}; + +#endif // TEST_HXX diff --git a/odb-tests/pgsql/bulk/testscript b/odb-tests/pgsql/bulk/testscript new file mode 100644 index 0000000..60b7d92 --- /dev/null +++ b/odb-tests/pgsql/bulk/testscript @@ -0,0 +1,18 @@ +# file : pgsql/custom/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../pgsql.testscript + ++$create_schema + +: basics +: +{ + $*; + + $* --fail-already-persistent 2>>EOE != 0 + multiple exceptions, 252 elements attempted, 1 failed, fatal: + [251] object already persistent + EOE +} diff --git a/odb-tests/pgsql/custom/buildfile b/odb-tests/pgsql/custom/buildfile new file mode 100644 index 0000000..a5c6717 --- /dev/null +++ b/odb-tests/pgsql/custom/buildfile @@ -0,0 +1,37 @@ +# file : pgsql/custom/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ +"pgsql should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-pgsql%lib{odb-pgsql} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix pgsql_custom_ \ + --generate-schema \ + --default-database common \ + --generate-query \ + --hxx-prologue '#include "traits.hxx"' \ + --hxx-prologue '#include "query.hxx"' + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/odb-tests/pgsql/custom/driver.cxx b/odb-tests/pgsql/custom/driver.cxx new file mode 100644 index 0000000..91ff0ce --- /dev/null +++ b/odb-tests/pgsql/custom/driver.cxx @@ -0,0 +1,125 @@ +// file : pgsql/custom/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test custom database type mapping in PostgreSQL. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace pgsql = odb::pgsql; +using namespace pgsql; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_specific_database (argc, argv)); + + object o (1); + o.p = point (1.1111, 2222222222.2); + o.pv.push_back (point (1.1234, 2.2345)); + o.pv.push_back (point (3.3456, 4.4567)); + o.pv.push_back (point (0.0000001, 0.000000001)); // Scientific notation. + + o.n1 = "23.5154"; + o.n2 = "235154"; + o.n3 = "2222222222222222222222222222.111111111111111111111111111111"; + + o.iv.push_back (123); + o.iv.push_back (234); + o.iv.push_back (-345); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + + // Query. + // + typedef pgsql::query query; + typedef odb::result result; + + { + transaction t (db->begin ()); + + // Point comparison. + // + { + result r (db->query (query::p == o.p)); + assert (!r.empty ()); + } + + // Point comparison using native query. + // + { + result r (db->query (query::p + "~=" + query::_val (o.p))); + assert (!r.empty ()); + } + + // Access to individual members. + // + { + result r (db->query (query::p.x == o.p.x)); + assert (!r.empty ()); + } + + t.commit (); + } + + // Update. + // + o.p.x++; + o.p.y--; + o.pv[1].x--; + o.pv[1].y++; + o.n3 += "999"; + o.iv[0]++; + o.iv.pop_back (); + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/pgsql/custom/query.hxx b/odb-tests/pgsql/custom/query.hxx new file mode 100644 index 0000000..8b89047 --- /dev/null +++ b/odb-tests/pgsql/custom/query.hxx @@ -0,0 +1,158 @@ +// file : pgsql/custom/query.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef QUERY_HXX +#define QUERY_HXX + +#include + +#include + +#include "test.hxx" // point + +namespace odb +{ + namespace pgsql + { + template <> + struct query_column + { + private: + const char* table_; + const char* column_; + const char* conversion_; + + std::string x_column_; + std::string y_column_; + + // Sub-columns for individual members. + // + public: + query_column x, y; + + // is_null, is_not_null + // + public: + query_base + is_null () const + { + query_base q (table_, column_); + q += "IS NULL"; + return q; + } + + query_base + is_not_null () const + { + query_base q (table_, column_); + q += "IS NOT NULL"; + return q; + } + + // = + // + public: + query_base + equal (const point& v) const + { + return equal (val_bind (v)); + } + + query_base + equal (val_bind v) const + { + query_base q (table_, column_); + q += "~="; + q.append (v, conversion_); + return q; + } + + query_base + equal (ref_bind r) const + { + query_base q (table_, column_); + q += "~="; + q.append (r, conversion_); + return q; + } + + friend query_base + operator== (const query_column& c, const point& v) + { + return c.equal (v); + } + + friend query_base + operator== (const point& v, const query_column& c) + { + return c.equal (v); + } + + friend query_base + operator== (const query_column& c, val_bind v) + { + return c.equal (v); + } + + friend query_base + operator== (val_bind v, const query_column& c) + { + return c.equal (v); + } + + friend query_base + operator== (const query_column& c, ref_bind r) + { + return c.equal (r); + } + + friend query_base + operator== (ref_bind r, const query_column& c) + { + return c.equal (r); + } + + // Column comparison. + // + public: + query_base + operator== (const query_column& c) const + { + query_base q (table_, column_); + q += "~="; + q.append (c.table (), c.column ()); + return q; + } + + public: + query_column (const char* table, const char* column, const char* conv) + : table_ (table), column_ (column), conversion_ (conv), + x_column_ (std::string (column) + "[0]"), + y_column_ (std::string (column) + "[1]"), + x (table, x_column_.c_str (), 0), + y (table, y_column_.c_str (), 0) + { + } + + const char* + table () const + { + return table_; + } + + const char* + column () const + { + return column_; + } + + const char* + conversion () const + { + return conversion_; + } + }; + } +} + +#endif // QUERY_HXX diff --git a/odb-tests/pgsql/custom/test.hxx b/odb-tests/pgsql/custom/test.hxx new file mode 100644 index 0000000..ec3d496 --- /dev/null +++ b/odb-tests/pgsql/custom/test.hxx @@ -0,0 +1,86 @@ +// file : pgsql/custom/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +// Map POINT PostgreSQL type to the point C++ struct. The other half +// of this mapping is in traits.hxx (value_traits). +// +#pragma db map type("POINT") as("TEXT") to("(?)::POINT") from("(?)::TEXT") + +#pragma db value type("POINT") +struct point +{ + point () {} + point (double x_, double y_): x (x_), y (y_) {} + + double x; + double y; +}; + +inline bool +operator== (const point& a, const point& b) +{ + return a.x == b.x && a.y == b.y; +} + +// Map NUMERIC PostgreSQL type to std::string (or any other type that +// provides the value_traits specialization). +// +#pragma db map type("NUMERIC *(\\(.+\\))?") \ + as("TEXT") \ + to("(?)::NUMERIC$1") \ + from("(?)::TEXT") + +// Map INTEGER[] PostgreSQL type to std::vector. The other half of +// this mapping is in traits.hxx (value_traits, id_string>). +// +#pragma db map type("INTEGER *\\[(\\d*)\\]") \ + as("TEXT") \ + to("(?)::INTEGER[$1]") \ + from("(?)::TEXT") + +#pragma db object +struct object +{ + object () {} + object (unsigned long id_) : id (id_) {} + + #pragma db id + unsigned long id; + + point p; + std::vector pv; + + #pragma db type("NUMERIC(6, 4)") + std::string n1; + + #pragma db type("NUMERIC(6)") + std::string n2; + + #pragma db type("NUMERIC") + std::string n3; + + #pragma db type("INTEGER [123]") + std::vector iv; + + bool + operator== (const object& y) const + { + return id == y.id && + p == y.p && + pv == y.pv && + n1 == y.n1 && + n2 == y.n2 && + n3 == y.n3 && + iv == y.iv; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/pgsql/custom/testscript b/odb-tests/pgsql/custom/testscript new file mode 100644 index 0000000..8e1448b --- /dev/null +++ b/odb-tests/pgsql/custom/testscript @@ -0,0 +1,11 @@ +# file : pgsql/custom/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../pgsql.testscript + ++$create_schema + +: basics +: +$* diff --git a/odb-tests/pgsql/custom/traits.hxx b/odb-tests/pgsql/custom/traits.hxx new file mode 100644 index 0000000..c45dec0 --- /dev/null +++ b/odb-tests/pgsql/custom/traits.hxx @@ -0,0 +1,166 @@ +// file : pgsql/custom/traits.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TRAITS_HXX +#define TRAITS_HXX + +#include // std::numeric_limits +#include +#include +#include // std::memcpy + +#include + +#include "test.hxx" // point + +namespace odb +{ + namespace pgsql + { + template <> + class value_traits + { + public: + typedef point value_type; + typedef point query_type; + typedef details::buffer image_type; + + static void + set_value (point& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (is_null) + v = point (); + else + { + // Point format is "(x,y)". + // + char c; + std::istringstream is (std::string (b.data (), n)); + + is >> c; // '(' + is >> v.x; + is >> c; // ',' + is >> v.y; + } + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const point& v) + { + is_null = false; + std::ostringstream os; + + // The formula for the number of decimla digits required is given in: + // + // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf + // + os.precision (std::numeric_limits::digits10); + // os.precision (2 + std::numeric_limits::digits * 301/1000); + + os << '(' << v.x << ',' << v.y << ')'; + + const std::string& s (os.str ()); + n = s.size (); + + if (n > b.capacity ()) + b.capacity (n); + + std::memcpy (b.data (), s.c_str (), n); + } + }; + + template <> + struct type_traits + { + static const database_type_id db_type_id = id_string; + + struct conversion + { + static const char* to () {return "(?)::POINT";} + }; + }; + + template <> + class value_traits, id_string> + { + public: + typedef std::vector value_type; + typedef value_type query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + v.clear (); + + if (!is_null) + { + // Array format is "{n1,n2,n3...}". + // + char c; + std::istringstream is (std::string (b.data (), n)); + + is >> c; // '{' + + for (c = static_cast (is.peek ()); c != '}'; is >> c) + { + v.push_back (int ()); + is >> v.back (); + } + } + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + std::ostringstream os; + + os << '{'; + + for (value_type::const_iterator i (v.begin ()), e (v.end ()); i != e;) + { + os << *i; + + if (++i != e) + os << ','; + } + + os << '}'; + + const std::string& s (os.str ()); + n = s.size (); + + if (n > b.capacity ()) + b.capacity (n); + + std::memcpy (b.data (), s.c_str (), n); + } + }; + + template <> + struct type_traits > + { + static const database_type_id db_type_id = id_string; + + struct conversion + { + static const char* to () {return "(?)::INTEGER[]";} + }; + }; + } +} + +#endif // TRAITS_HXX diff --git a/odb-tests/pgsql/database/buildfile b/odb-tests/pgsql/database/buildfile new file mode 100644 index 0000000..6977ea6 --- /dev/null +++ b/odb-tests/pgsql/database/buildfile @@ -0,0 +1,11 @@ +# file : pgsql/database/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ +"pgsql should be configured via config.odb_tests.database variable as a single database" + +import libs = libodb-pgsql%lib{odb-pgsql} + +exe{driver}: {hxx cxx}{*} $libs testscript + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/pgsql/database/driver.cxx b/odb-tests/pgsql/database/driver.cxx new file mode 100644 index 0000000..56bde0a --- /dev/null +++ b/odb-tests/pgsql/database/driver.cxx @@ -0,0 +1,44 @@ +// file : pgsql/database/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test that database constructors are unambiguous (compilation only). +// + +#include + +#undef NDEBUG +#include + +namespace pgsql = odb::pgsql; +using namespace pgsql; + +int +main (int argc, char* argv[]) +{ + // This code should not execute. + // + if (argc != 0) + return 0; + + { + database d1 ("bob", "secret", "db1"); + database d2 ("bob", "secret", "db1", "server1"); + database d3 ("bob", "secret", "db1", "server1", 999); + database d4 ("bob", "secret", "db1", "server1", 999, "extra"); + } + + { + database d1 ("bob", "secret", "db1", "server1", "ext1"); + database d2 ("bob", "secret", "db1", "server1", "ext1", "extra"); + } + + { + database d1 ("conninfo"); + } + + { + database d1 (argc, argv); + database d2 (argc, argv, false); + database d3 (argc, argv, true, "extra"); + } +} diff --git a/odb-tests/pgsql/database/testscript b/odb-tests/pgsql/database/testscript new file mode 100644 index 0000000..f57a8e1 --- /dev/null +++ b/odb-tests/pgsql/database/testscript @@ -0,0 +1,6 @@ +# file : pgsql/database/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +: basics +: +$* diff --git a/odb-tests/pgsql/index/buildfile b/odb-tests/pgsql/index/buildfile new file mode 100644 index 0000000..a84ed9a --- /dev/null +++ b/odb-tests/pgsql/index/buildfile @@ -0,0 +1,34 @@ +# file : pgsql/index/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ +"pgsql should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-pgsql%lib{odb-pgsql} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix pgsql_index_ \ + --generate-schema \ + --default-database common + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/odb-tests/pgsql/index/driver.cxx b/odb-tests/pgsql/index/driver.cxx new file mode 100644 index 0000000..dc4c11e --- /dev/null +++ b/odb-tests/pgsql/index/driver.cxx @@ -0,0 +1,44 @@ +// file : pgsql/index/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test PostgreSQL index creation. See also the common test. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace pgsql = odb::pgsql; +using namespace pgsql; + +int +main (int argc, char* argv[]) +{ + try + { + // This is just a schema creation test. + // + unique_ptr db (create_specific_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/pgsql/index/test.hxx b/odb-tests/pgsql/index/test.hxx new file mode 100644 index 0000000..d728188 --- /dev/null +++ b/odb-tests/pgsql/index/test.hxx @@ -0,0 +1,19 @@ +// file : pgsql/index/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + #pragma db id auto + unsigned long id_; + + int i; + #pragma db index type("UNIQUE CONCURRENTLY") method("BTREE") member(i) +}; + +#endif // TEST_HXX diff --git a/odb-tests/pgsql/index/testscript b/odb-tests/pgsql/index/testscript new file mode 100644 index 0000000..671a8c3 --- /dev/null +++ b/odb-tests/pgsql/index/testscript @@ -0,0 +1,11 @@ +# file : pgsql/index/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../pgsql.testscript + ++$create_schema + +: basics +: +$* diff --git a/odb-tests/pgsql/native/buildfile b/odb-tests/pgsql/native/buildfile new file mode 100644 index 0000000..ec4c80c --- /dev/null +++ b/odb-tests/pgsql/native/buildfile @@ -0,0 +1,16 @@ +# file : pgsql/native/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ +"pgsql should be configured via config.odb_tests.database variable as a single database" + +import libs = libodb-pgsql%lib{odb-pgsql} +import libs += lib{common} + +exe{driver}: {hxx cxx}{*} $libs testscript + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/odb-tests/pgsql/native/driver.cxx b/odb-tests/pgsql/native/driver.cxx new file mode 100644 index 0000000..843db41 --- /dev/null +++ b/odb-tests/pgsql/native/driver.cxx @@ -0,0 +1,75 @@ +// file : pgsql/native/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test PostgreSQL native SQL execution. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#undef NDEBUG +#include + +using namespace std; +namespace pgsql = odb::pgsql; +using namespace pgsql; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_specific_database (argc, argv)); + + // Create the database schema. + // + { + transaction t (db->begin ()); + + db->execute ("DROP TABLE IF EXISTS pgsql_native_test"); + db->execute ("CREATE TABLE pgsql_native_test (n INT PRIMARY KEY)"); + + t.commit (); + } + + // Insert a few rows. + // + { + transaction t (db->begin ()); + + assert ( + db->execute ("INSERT INTO pgsql_native_test (n) VALUES (1)") == 1); + + assert ( + db->execute ("INSERT INTO pgsql_native_test (n) VALUES (2)") == 1); + + t.commit (); + } + + // select a few rows. + // + { + transaction t (db->begin ()); + + assert ( + db->execute ("SELECT n FROM pgsql_native_test WHERE n < 3") == 2); + + assert ( + db->execute ("SELECT n FROM pgsql_native_test WHERE n > 3") == 0); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } + + return 0; +} diff --git a/odb-tests/pgsql/native/testscript b/odb-tests/pgsql/native/testscript new file mode 100644 index 0000000..4fd9d2c --- /dev/null +++ b/odb-tests/pgsql/native/testscript @@ -0,0 +1,9 @@ +# file : pgsql/custom/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../pgsql.testscript + +: basics +: +$* diff --git a/odb-tests/pgsql/truncation/buildfile b/odb-tests/pgsql/truncation/buildfile new file mode 100644 index 0000000..2f2f3a2 --- /dev/null +++ b/odb-tests/pgsql/truncation/buildfile @@ -0,0 +1,35 @@ +# file : pgsql/truncation/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ +"pgsql should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-pgsql%lib{odb-pgsql} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix pgsql_truncation_ \ + --generate-schema \ + --default-database common \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/odb-tests/pgsql/truncation/driver.cxx b/odb-tests/pgsql/truncation/driver.cxx new file mode 100644 index 0000000..337a26e --- /dev/null +++ b/odb-tests/pgsql/truncation/driver.cxx @@ -0,0 +1,163 @@ +// file : pgsql/truncation/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test insufficient buffer/truncation handling. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace pgsql = odb::pgsql; +using namespace pgsql; + +int +main (int argc, char* argv[]) +{ + // The default pre-allocated buffer is 512 bytes long. + // + string long_str (640, 'c'); // This will get the buffer to 1024 + string longer_str (1025, 'b'); + + try + { + // Test basic operations. + // + { + unique_ptr db (create_specific_database (argc, argv)); + + // Run persist/load so that the initial bindings are established + // (version == 0). + // + { + object1 o (1); + o.str_ = "test string"; + + transaction t (db->begin ()); + db->persist (o); + db->load (1, o); + t.commit (); + } + + { + object2 o (2); + o.str_ = "test string"; + + transaction t (db->begin ()); + db->persist (o); + db->load (2, o); + t.commit (); + } + + // Store/load the long string which should trigger buffer growth. + // + { + object1 o (3); + o.str_ = long_str; + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (3)); + assert (o->str_ == long_str); + t.commit (); + } + + // Store/load longer string. + // + { + object1 o (3); + o.str_ = longer_str; + + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (3)); + assert (o->str_ == longer_str); + t.commit (); + } + } + + // Test query. + // + { + typedef pgsql::query query; + typedef odb::result result; + + unique_ptr db (create_specific_database (argc, argv)); + + // Run persist/query so that the initial bindings are established + // (version == 0). + // + { + object1 o (20); + o.str_ = "test string"; + + transaction t (db->begin ()); + db->persist (o); + o.id_++; + db->persist (o); + o.id_++; + db->persist (o); + + result r (db->query (query::id == 20)); + assert (r.begin ()->id_ == 20); + t.commit (); + } + + // Test buffer growth with cached result. + // + { + object1 o; + + transaction t (db->begin ()); + + result r (db->query (query::id >= 20)); + result::iterator i (r.begin ()); + + o.id_ = i->id_; + o.str_ = long_str; + + // This forces buffer growth in the middle of result iteration. + // + db->update (o); + + ++i; + assert (i->str_ == "test string"); + + o.id_ = i->id_; + o.str_ = longer_str; + db->update (o); + + ++i; + assert (i->str_ == "test string"); + + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/pgsql/truncation/test.hxx b/odb-tests/pgsql/truncation/test.hxx new file mode 100644 index 0000000..73110c0 --- /dev/null +++ b/odb-tests/pgsql/truncation/test.hxx @@ -0,0 +1,46 @@ +// file : pgsql/truncation/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object table ("test") +struct object1 +{ + object1 (unsigned long id) + : id_ (id) + { + } + + object1 () + { + } + + #pragma db id + unsigned long id_; + + std::string str_; +}; + +#pragma db object table ("test") +struct object2 +{ + object2 (unsigned long id) + : id_ (id) + { + } + + object2 () + { + } + + #pragma db id + unsigned long id_; + + std::string str_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/pgsql/truncation/testscript b/odb-tests/pgsql/truncation/testscript new file mode 100644 index 0000000..c57b723 --- /dev/null +++ b/odb-tests/pgsql/truncation/testscript @@ -0,0 +1,11 @@ +# file : pgsql/truncation/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../pgsql.testscript + ++$create_schema + +: basics +: +$* diff --git a/odb-tests/pgsql/types/buildfile b/odb-tests/pgsql/types/buildfile new file mode 100644 index 0000000..64f0c02 --- /dev/null +++ b/odb-tests/pgsql/types/buildfile @@ -0,0 +1,36 @@ +# file : pgsql/types/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ +"pgsql should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} +import libcommon = lib{common} +import libs = libodb-pgsql%lib{odb-pgsql} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb and libcommon +# libraries are resolved for the odb_compile ad hoc rule (see build/root.build +# for details). +# +libue{test-meta}: $libodb $libcommon + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix pgsql_types_ \ + --generate-schema \ + --default-database common \ + --generate-query \ + --cxx-prologue '#include "traits.hxx"' + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/odb-tests/pgsql/types/driver.cxx b/odb-tests/pgsql/types/driver.cxx new file mode 100644 index 0000000..710f601 --- /dev/null +++ b/odb-tests/pgsql/types/driver.cxx @@ -0,0 +1,165 @@ +// file : pgsql/types/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test PostgreSQL type conversion. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace pgsql = odb::pgsql; +using namespace pgsql; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_specific_database (argc, argv)); + + object o (1); + + o.bool_ = true; + o.short_ = 12345; + o.int_ = -123456; + o.long_long_ = 123456; + + o.float_ = 1.123F; + o.float8_ = 1.123; + o.double_ = 1.123; + + o.date_ = 4015; + o.time_ = 48180000000LL; + o.timestamp_ = 346896000LL; + + string short_str (128, 's'); + string medium_str (250, 'm'); + string long_str (2040, 'l'); + + o.char_ = short_str; + o.varchar_ = medium_str; + o.text_ = long_str; + + o.bytea_.assign (long_str.c_str (), long_str.c_str () + long_str.size ()); + + unsigned char varbit_buf[8] = {1, 3, 1, 3, 1, 3, 1, 3}; + o.varbit_.size = 52; + o.varbit_.ubuffer_ = ubuffer (varbit_buf, 8); + + o.bit_.a = 0; + o.bit_.b = 1; + o.bit_.c = 0; + o.bit_.d = 1; + + // 6F846D41-C89A-4E4D-B22F-56443CFA543F + memcpy (o.uuid_, "\x6F\x84\x6D\x41\xC8\x9A\x4E\x4D\xB2\x2F" + "\x56\x44\x3C\xFA\x54\x3F", 16); + + o.enum_ = green; + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + + typedef pgsql::query query; + typedef odb::result result; + + // Test UUID in queries. + // + { + char uuid[16]; + memcpy (uuid, o.uuid_, 16); + + transaction t (db->begin ()); + + { + result r (db->query (query::uuid == uuid)); + assert (size (r) == 1); + } + + { + result r (db->query (query::uuid == query::_val (uuid))); + assert (size (r) == 1); + } + + { + result r (db->query (query::uuid == query::_ref (uuid))); + assert (size (r) == 1); + } + + { + const char* d (uuid); + result r (db->query (query::uuid == d)); + assert (size (r) == 1); + } + + t.commit (); + } + + // Test char array. + // + { + char_array o1 (1, ""); + char_array o2 (2, "1234567890"); + char_array o3 (3, "1234567890123456"); + + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + } + + // PostgreSQL returns padded values for CHAR(N). + // + memcpy (o1.s2, " ", 16); + o1.s3[0] = o1.c1 = ' '; + memcpy (o2.s2, "1234567890 ", 16); + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (1)); + unique_ptr p2 (db->load (2)); + unique_ptr p3 (db->load (3)); + t.commit (); + + assert (o1 == *p1); + assert (o2 == *p2); + assert (o3 == *p3); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/pgsql/types/test.hxx b/odb-tests/pgsql/types/test.hxx new file mode 100644 index 0000000..462ebad --- /dev/null +++ b/odb-tests/pgsql/types/test.hxx @@ -0,0 +1,220 @@ +// file : pgsql/types/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include +#include // std::unique_ptr +#include // std::memcmp, std::memcpy, std::str[n]cmp, std::strlen +#include // std::size_t + +#include + +#include + +struct bitfield +{ + unsigned int a: 1; + unsigned int b: 1; + unsigned int c: 1; + unsigned int d: 1; +}; + +inline bool +operator== (bitfield x, bitfield y) +{ + return + x.a == y.a && + x.b == y.b && + x.c == y.c && + x.d == y.d; +} + +struct varbit +{ + std::size_t size; + ubuffer ubuffer_; + + bool + compare (const varbit& x) const + { + if (size != x.size) + return false; + + std::size_t byte_len = size / 8; + + if (std::memcmp (ubuffer_.data (), x.ubuffer_.data (), byte_len) != 0) + return false; + + std::size_t trailing_bits = size % 8; + + if (trailing_bits != 0) + { + unsigned char mask (0xFFU << (8 - trailing_bits)); + + return (ubuffer_.data ()[byte_len] & mask) == + (x.ubuffer_.data ()[byte_len] & mask); + } + + return true; + } +}; + +inline bool +operator== (const varbit& x, const varbit& y) +{ + return x.compare (y); +} + +#pragma db value(bitfield) type ("BIT(4)") + +typedef std::unique_ptr string_ptr; + +enum color {red, green, blue}; + +#pragma db object +struct object +{ + object () {} + object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + // Integral types. + // + #pragma db type ("BOOL") + bool bool_; + + #pragma db type ("SMALLINT") + short short_; + + #pragma db type ("INT") + int int_; + + #pragma db type ("BIGINT") + long long long_long_; + + // Float types. + // + #pragma db type ("REAL") + float float_; + + #pragma db type ("FLOAT(32)") + double float8_; + + #pragma db type ("DOUBLE PRECISION") + double double_; + + // Data-time types. + // + #pragma db type ("DATE") + int date_; + + #pragma db type ("TIME") + long long time_; + + #pragma db type ("TIMESTAMP") + long long timestamp_; + + // String and binary types. + // + #pragma db type ("CHAR(128)") + std::string char_; + + #pragma db type ("VARCHAR(256)") + std::string varchar_; + + #pragma db type ("TEXT") + std::string text_; + + #pragma db type ("BYTEA") + std::vector bytea_; + + #pragma db type ("VARBIT(1024)") + varbit varbit_; + + // #pragma db type ("BIT(4)") - assigned by #pragma db value + bitfield bit_; + + // Other types. + // + #pragma db type ("UUID") + char uuid_[16]; + + // Test ENUM representation. + // + color enum_; + + // Test NULL value. + // + #pragma db type ("TEXT") null + string_ptr null_; + + bool + operator== (const object& y) const + { + return + id_ == y.id_ && + bool_ == y.bool_ && + short_ == y.short_ && + int_ == y.int_ && + long_long_ == y.long_long_ && + float_ == y.float_ && + float8_ == y.float8_ && + double_ == y.double_ && + date_ == y.date_ && + time_ == y.time_ && + timestamp_ == y.timestamp_ && + char_ == y.char_ && + varchar_ == y.varchar_ && + text_ == y.text_ && + bytea_ == y.bytea_ && + bit_ == y.bit_ && + varbit_ == y.varbit_ && + memcmp (uuid_, y.uuid_, 16) == 0 && + enum_ == y.enum_ && + ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_); + } +}; + +// Test char array. +// +#pragma db object +struct char_array +{ + char_array () {} + char_array (unsigned long id, const char* s) + : id_ (id) + { + std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation. + std::memcpy (s2, s, std::strlen (s) + 1); + s3[0] = c1 = *s; + } + + #pragma db id + unsigned long id_; + + char s1[17]; + + #pragma db type("CHAR(16)") + char s2[16]; + + char s3[1]; + char c1; + + bool + operator== (const char_array& y) const + { + return id_ == y.id_ && + std::strcmp (s1, y.s1) == 0 && + std::strncmp (s2, y.s2, sizeof (s2)) == 0 && + s3[0] == y.s3[0] && + c1 == y.c1; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/pgsql/types/testscript b/odb-tests/pgsql/types/testscript new file mode 100644 index 0000000..57218e1 --- /dev/null +++ b/odb-tests/pgsql/types/testscript @@ -0,0 +1,11 @@ +# file : pgsql/types/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../pgsql.testscript + ++$create_schema + +: basics +: +$* diff --git a/odb-tests/pgsql/types/traits.hxx b/odb-tests/pgsql/types/traits.hxx new file mode 100644 index 0000000..a1c8fbe --- /dev/null +++ b/odb-tests/pgsql/types/traits.hxx @@ -0,0 +1,171 @@ +// file : pgsql/types/traits.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TRAITS_HXX +#define TRAITS_HXX + +#include +#include // std::memcpy, std::memset + +#include +#include + +#include "test.hxx" // varbit, ubuffer, string_ptr + +namespace odb +{ + namespace pgsql + { + // The first 4 bytes of the image is a signed int specifying the + // number of significant bits contained by the BIT. The following + // bytes contain the bit data. + // + template <> + class value_traits + { + public: + typedef bitfield value_type; + typedef bitfield query_type; + typedef unsigned char* image_type; + + static void + set_value (bitfield& v, + const unsigned char* i, + std::size_t, + bool is_null) + { + if (!is_null) + { + assert ( + details::endian_traits::ntoh ( + *reinterpret_cast (i)) == 4); + + const unsigned char* d (i + 4); + + v.a = *d >> 4 & 1; + v.b = (*d >> 5) & 1; + v.c = (*d >> 6) & 1; + v.d = (*d >> 7) & 1; + } + else + v.a = v.b = v.c = v.d = 0; + } + + static void + set_image (unsigned char* i, + std::size_t, + std::size_t& n, + bool& is_null, + bitfield v) + { + is_null = false; + n = 5; + + *reinterpret_cast (i) = details::endian_traits::hton (4); + *(i + 4) = v.a << 4 | (v.b << 5) | (v.c << 6) | (v.d << 7); + } + }; + + // The first 4 bytes of the image is a signed int specifying the + // number of significant bits contained by the VARBIT. The following + // bytes contain the VARBIT data. + // + template <> + class value_traits + { + public: + typedef varbit value_type; + typedef varbit query_type; + typedef details::ubuffer image_type; + + static void + set_value (varbit& v, + const details::ubuffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + { + v.size = static_cast ( + details::endian_traits::ntoh ( + *reinterpret_cast (b.data ()))); + + std::size_t byte_len (v.size / 8 + (v.size % 8 > 0 ? 1 : 0)); + assert (n >= byte_len + 4); + + v.ubuffer_.assign (b.data () + 4, byte_len); + } + + else + { + v.size = 0; + v.ubuffer_.assign (0, 0); + } + } + + static void + set_image (details::ubuffer& b, + std::size_t& n, + bool& is_null, + const varbit& v) + { + is_null = false; + n = 4 + v.size / 8 + (v.size % 8 > 0 ? 1 : 0); + + if (n > b.capacity ()) + b.capacity (n); + + // PostgreSQL requires all trailing bits of a VARBIT image + // to be zero. + // + std::memset (b.data (), 0, b.capacity ()); + + *reinterpret_cast (b.data ()) = + details::endian_traits::hton (static_cast (v.size)); + + if (v.size != 0) + std::memcpy (b.data () + 4, v.ubuffer_.data (), n - 4); + } + }; + + template <> + class value_traits + { + public: + typedef string_ptr value_type; + typedef std::string query_type; + typedef details::buffer image_type; + + static void + set_value (string_ptr& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + v.reset (is_null ? 0 : new std::string (b.data (), n)); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const string_ptr& v) + { + is_null = v.get () == 0; + + if (!is_null) + { + n = v->size (); + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + std::memcpy (b.data (), v->c_str (), n); + } + } + }; + } +} + +#endif // TRAITS_HXX diff --git a/odb-tests/qt/common/basic/driver.cxx b/odb-tests/qt/common/basic/driver.cxx new file mode 100644 index 0000000..342a313 --- /dev/null +++ b/odb-tests/qt/common/basic/driver.cxx @@ -0,0 +1,66 @@ +// file : qt/common/basic/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt basic type persistence (common part). +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + object o (1); + o.uuid_ = QUuid::createUuid (); + o.null_ = QUuid (); + o.zero_ = QUuid (); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p (db->load (o.id_)); + t.commit (); + + assert (*p == o); + } + + { + typedef odb::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::uuid == o.uuid_)); + result::iterator i (r.begin ()); + assert (i != r.end () && i->id_ == o.id_); + assert (++i == r.end ()); + t.commit (); + } + + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/common/basic/test.hxx b/odb-tests/qt/common/basic/test.hxx new file mode 100644 index 0000000..e67302e --- /dev/null +++ b/odb-tests/qt/common/basic/test.hxx @@ -0,0 +1,35 @@ +// file : qt/common/basic/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object +struct object +{ + object () {} + object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + QUuid uuid_; + QUuid null_; + + #pragma db not_null + QUuid zero_; + + bool operator== (const object& x) const + { + return id_ == x.id_ && + uuid_ == x.uuid_ && + null_ == x.null_ && + zero_ == x.zero_; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/common/containers/basics/driver.cxx b/odb-tests/qt/common/containers/basics/driver.cxx new file mode 100644 index 0000000..5e38ee1 --- /dev/null +++ b/odb-tests/qt/common/containers/basics/driver.cxx @@ -0,0 +1,569 @@ +// file : qt/common/containers/basics/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test basic Qt containers persistence. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + for (unsigned short i (0); i < 2; ++i) + { + object empty ("empty"), med ("medium"), full ("full"); + + // + // empty + // + + empty.num = 0; + empty.str = ""; + + // + // med + // + + med.num = 999; + med.str = "xxx"; + + // vector + // + med.nv.push_back (123); + med.nv.push_back (234); + + med.sv.push_back ("aaa"); + med.sv.push_back ("bbbb"); + + med.cv.push_back (comp (123, "aaa")); + med.cv.push_back (comp (234, "bbbb")); + + med.uv.push_back (123); + med.uv.push_back (234); + + // list + // + med.sl.push_back ("aaa"); + med.sl.push_back ("bbbb"); + + med.nl.push_back (123); + med.nl.push_back (234); + + med.cl.push_back (comp (123, "aaa")); + med.cl.push_back (comp (234, "bbbb")); + + // linked list + // + med.sll.push_back ("aaa"); + med.sll.push_back ("bbbb"); + + med.nll.push_back (123); + med.nll.push_back (234); + + med.cll.push_back (comp (123, "aaa")); + med.cll.push_back (comp (234, "bbbb")); + + // set + // + med.ns.insert (123); + med.ns.insert (234); + + med.ss.insert ("aaa"); + med.ss.insert ("bbbb"); + + // map + // + med.nsm[123] = "aaa"; + med.nsm[234] = "bbbb"; + + med.snm["aaa"] = 123; + med.snm["bbbb"] = 234; + + med.ncm[123] = comp (123, "aaa"); + med.ncm[234] = comp (234, "bbbb"); + + med.csm[comp (123, "aaa")] = "aaa"; + med.csm[comp (234, "bbbb")] = "bbbb"; + + // multimap + // + med.nsmm.insert (123, "aaa"); + med.nsmm.insert (123, "bbbb"); + med.nsmm.insert (234, "ccccc"); + + med.snmm.insert ("aaa", 123); + med.snmm.insert ("aaa", 234); + med.snmm.insert ("bbb", 345); + + med.ncmm.insert (123, comp (123, "aaa")); + med.ncmm.insert (123, comp (234, "bbbb")); + med.ncmm.insert (234, comp (345, "ccccc")); + + // hash + // + med.nsh[123] = "aaa"; + med.nsh[234] = "bbbb"; + + med.snh["aaa"] = 123; + med.snh["bbb"] = 234; + + med.sch["iii"] = comp (123, "aaa"); + med.sch["jjj"] = comp (234, "bbbb"); + + // multihash + // + med.nsmh.insert (123, "aaa"); + med.nsmh.insert (123, "bbbb"); + med.nsmh.insert (234, "ccccc"); + + med.snmh.insert ("aaa", 123); + med.snmh.insert ("aaa", 234); + med.snmh.insert ("bbb", 345); + + med.ncmh.insert (123, comp (123, "aaa")); + med.ncmh.insert (123, comp (234, "bbbb")); + med.ncmh.insert (234, comp (345, "ccccc")); + + // + // full + // + + full.num = 9999; + full.str = "xxxx"; + + // vector + // + full.nv.push_back (1234); + full.nv.push_back (2345); + full.nv.push_back (3456); + + full.sv.push_back ("aaaa"); + full.sv.push_back ("bbbbb"); + full.sv.push_back ("cccccc"); + + full.cv.push_back (comp (1234, "aaaa")); + full.cv.push_back (comp (2345, "bbbbb")); + full.cv.push_back (comp (3456, "cccccc")); + + full.uv.push_back (1234); + full.uv.push_back (2345); + full.uv.push_back (3456); + + // list + // + full.sl.push_back ("aaaa"); + full.sl.push_back ("bbbbb"); + full.sl.push_back ("cccccc"); + + full.nl.push_back (1234); + full.nl.push_back (2345); + full.nl.push_back (3456); + + full.cl.push_back (comp (1234, "aaaa")); + full.cl.push_back (comp (2345, "bbbbb")); + full.cl.push_back (comp (3456, "cccccc")); + + // linked list + // + full.sll.push_back ("aaaa"); + full.sll.push_back ("bbbbb"); + full.sll.push_back ("cccccc"); + + full.nll.push_back (1234); + full.nll.push_back (2345); + full.nll.push_back (3456); + + full.cll.push_back (comp (1234, "aaaa")); + full.cll.push_back (comp (2345, "bbbbb")); + full.cll.push_back (comp (3456, "cccccc")); + + // set + // + full.ns.insert (1234); + full.ns.insert (2345); + full.ns.insert (3456); + + full.ss.insert ("aaaa"); + full.ss.insert ("bbbbb"); + full.ss.insert ("cccccc"); + + // map + // + full.nsm[1234] = "aaaa"; + full.nsm[2345] = "bbbbb"; + full.nsm[3456] = "cccccc"; + + full.snm["aaaa"] = 1234; + full.snm["bbbb"] = 2345; + full.snm["cccc"] = 3456; + + full.ncm[1234] = comp (1234, "aaaa"); + full.ncm[2345] = comp (2345, "bbbbb"); + full.ncm[3456] = comp (3456, "cccccc"); + + full.csm[comp (1234, "aaaa")] = "aaaa"; + full.csm[comp (2345, "bbbb")] = "bbbbb"; + full.csm[comp (3456, "cccc")] = "cccccc"; + + // multimap + // + full.nsmm.insert (1234, "aaaa"); + full.nsmm.insert (1234, "bbbbb"); + full.nsmm.insert (2345, "cccccc"); + full.nsmm.insert (2345, "ddddddd"); + + full.snmm.insert ("aaaa", 1234); + full.snmm.insert ("aaaa", 2345); + full.snmm.insert ("bbbb", 3456); + full.snmm.insert ("bbbb", 4567); + + full.ncmm.insert (1234, comp (1234, "aaaa")); + full.ncmm.insert (1234, comp (2345, "bbbbb")); + full.ncmm.insert (2345, comp (3456, "cccccc")); + full.ncmm.insert (2345, comp (4567, "ddddddd")); + + // hash + // + full.nsh[1234] = "aaaa"; + full.nsh[2345] = "bbbbb"; + full.nsh[3456] = "cccccc"; + + full.snh["aaaa"] = 1234; + full.snh["bbbb"] = 2345; + full.snh["cccc"] = 3456; + + full.sch["iiii"] = comp (1234, "aaaa"); + full.sch["jjjj"] = comp (2345, "bbbbb"); + full.sch["kkkk"] = comp (3456, "cccccc"); + + // multihash + // + full.nsmh.insert (1234, "aaaa"); + full.nsmh.insert (1234, "bbbbb"); + full.nsmh.insert (2345, "cccccc"); + full.nsmh.insert (2345, "ddddddd"); + + full.snmh.insert ("aaaa", 1234); + full.snmh.insert ("aaaa", 2345); + full.snmh.insert ("bbbb", 3456); + full.snmh.insert ("bbbb", 4567); + + full.ncmh.insert (1234, comp (1234, "aaaa")); + full.ncmh.insert (1234, comp (2345, "bbbbb")); + full.ncmh.insert (2345, comp (3456, "cccccc")); + full.ncmh.insert (2345, comp (4567, "ddddddd")); + + // persist + // + { + transaction t (db->begin ()); + db->persist (empty); + db->persist (med); + db->persist (full); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + auto_ptr e (db->load ("empty")); + auto_ptr m (db->load ("medium")); + auto_ptr f (db->load ("full")); + t.commit (); + + assert (empty == *e); + assert (med == *m); + assert (full == *f); + } + + // + // empty + // + + empty.num = 99; + empty.str = "xx"; + + // vector + // + empty.nv.push_back (12); + empty.sv.push_back ("aa"); + empty.cv.push_back (comp (12, "aa")); + empty.uv.push_back (12); + + // list + // + empty.sl.push_back ("aa"); + empty.nl.push_back (12); + empty.cl.push_back (comp (12, "aa")); + + // linked list + // + empty.nll.push_back (12); + empty.sll.push_back ("aa"); + empty.cll.push_back (comp (12, "aa")); + + // set + // + empty.ns.insert (12); + empty.ss.insert ("aa"); + + // map + // + empty.nsm[12] = "aa"; + empty.snm["aa"] = 12; + empty.ncm[12] = comp (12, "aa"); + empty.csm[comp (12, "aa")] = "aa"; + + // multimap + // + empty.nsmm.insert (12, "aa"); + empty.nsmm.insert (12, "bbb"); + empty.nsmm.insert (23, "cccc"); + empty.snmm.insert ("aa", 12); + empty.snmm.insert ("aa", 23); + empty.snmm.insert ("bb", 34); + empty.ncmm.insert (12, comp (12, "aa")); + empty.ncmm.insert (12, comp (23, "bb")); + empty.ncmm.insert (23, comp (34, "cc")); + + // hash + // + empty.nsh[12] = "aa"; + empty.snh["aa"] = 12; + empty.sch["ii"] = comp (12, "aa"); + + // multihash + // + empty.nsmh.insert (12, "aa"); + empty.nsmh.insert (12, "bbb"); + empty.nsmh.insert (23, "cccc"); + empty.snmh.insert ("aa", 12); + empty.snmh.insert ("aa", 23); + empty.snmh.insert ("bb", 34); + empty.ncmh.insert (12, comp (12, "aa")); + empty.ncmh.insert (12, comp (23, "bb")); + empty.ncmh.insert (23, comp (34, "cc")); + + // + // med + // + + med.num = 0; + med.str = ""; + + // vector + // + med.nv.clear (); + med.sv.clear (); + med.cv.clear (); + med.uv.clear (); + + // list + // + med.sl.clear (); + med.nl.clear (); + med.cl.clear (); + + // linked list + // + med.nll.clear (); + med.sll.clear (); + med.cll.clear (); + + // set + // + med.ns.clear (); + med.ss.clear (); + + // map + // + med.nsm.clear (); + med.snm.clear (); + med.ncm.clear (); + med.csm.clear (); + + // multimap + // + med.nsmm.clear (); + med.snmm.clear (); + med.ncmm.clear (); + + // hash + // + med.nsh.clear (); + med.snh.clear (); + med.sch.clear (); + + // multihash + // + med.nsmh.clear (); + med.snmh.clear (); + med.ncmh.clear (); + + + // + // full + // + + full.num++; + full.str += "x"; + + // vector + // + full.nv.back ()++; + full.nv.push_back (4567); + + full.sv.back () += "c"; + full.sv.push_back ("ddddddd"); + + full.cv.back ().num++; + full.cv.back ().str += "c"; + full.cv.push_back (comp (4567, "ddddddd")); + + full.uv.back ()++; + full.uv.push_back (4567); + + // list + // + full.sl.back () += "c"; + full.sl.push_back ("ddddddd"); + + full.nl.back ()++; + full.nl.push_back (4567); + + full.cl.back ().num++; + full.cl.back ().str += "c"; + full.cl.push_back (comp (4567, "ddddddd")); + + // linked list + // + full.sll.back () += "c"; + full.sll.push_back ("ddddddd"); + + full.nll.back ()++; + full.nll.push_back (4567); + + full.cll.back ().num++; + full.cll.back ().str += "c"; + full.cll.push_back (comp (4567, "ddddddd")); + + // set + // + full.ns.insert (4567); + full.ss.insert ("ddddddd"); + + // map + // + full.nsm[3456] += "c"; + full.nsm[4567] = "ddddddd"; + + full.snm["cccc"]++; + full.snm["dddd"] = 4567; + + full.ncm[3456].num++; + full.ncm[3456].str += "c"; + full.ncm[4567] = comp (4567, "ddddddd"); + + full.csm[comp (3456, "cccc")] += "c"; + full.csm[comp (4567, "dddd")] = "ddddddd"; + + // multimap + // + full.nsmm.find (2345).value () += "d"; + full.nsmm.insert (3456, "eeeeeeee"); + + full.snmm.find ("bbbb").value ()++; + full.snmm.insert ("cccc", 5678); + + full.ncmm.find (1234).value ().num++; + full.ncmm.find (2345).value ().str += "d"; + full.ncmm.insert (3456, comp (5678, "eeeeeeee")); + + // hash + // + full.nsh[3456] += "c"; + full.nsh[4567] = "ddddddd"; + + full.snh["cccc"]++; + full.snh["dddd"] = 4567; + + full.sch["iiii"].num++; + full.sch["jjjj"].str += "b"; + full.sch["kkkk"] = comp (4567, "dddddddd"); + + // multihash + // + full.nsmh.find (2345).value () += "d"; + full.nsmh.insert (3456, "eeeeeeee"); + + full.snmh.find ("bbbb").value ()++; + full.snmh.insert ("cccc", 5678); + + full.ncmh.find (1234).value ().num++; + full.ncmh.find (2345).value ().str += "d"; + full.ncmh.insert (3456, comp (5678, "eeeeeeee")); + + // update + // + { + transaction t (db->begin ()); + db->update (empty); + db->update (med); + db->update (full); + t.commit (); + } + + // load & check + // + { + transaction t (db->begin ()); + auto_ptr e (db->load ("empty")); + auto_ptr m (db->load ("medium")); + auto_ptr f (db->load ("full")); + t.commit (); + + assert (empty == *e); + assert (med == *m); + assert (full == *f); + } + + // erase + // + if (i == 0) + { + transaction t (db->begin ()); + db->erase ("empty"); + db->erase ("medium"); + db->erase ("full"); + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/common/containers/basics/test.hxx b/odb-tests/qt/common/containers/basics/test.hxx new file mode 100644 index 0000000..2c61c88 --- /dev/null +++ b/odb-tests/qt/common/containers/basics/test.hxx @@ -0,0 +1,224 @@ +// file : qt/common/containers/basics/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#pragma db value +struct comp +{ + comp () {} + comp (int n, const QString& s) : num (n), str (s) {} + + #pragma db column("number") + int num; + QString str; +}; + +inline bool +operator== (const comp& x, const comp& y) +{ + return x.num == y.num && x.str == y.str; +} + +inline bool +operator< (const comp& x, const comp& y) +{ + return x.num != y.num ? x.num < y.num : x.str < y.str; +} + +typedef QVector num_vector; +typedef QVector str_vector; +typedef QVector comp_vector; + +typedef QList num_list; +typedef QList str_list; +typedef QList comp_list; + +typedef QLinkedList num_linked_list; +typedef QLinkedList str_linked_list; +typedef QLinkedList comp_linked_list; + +typedef QSet num_set; +typedef QSet str_set; + +typedef QMap num_str_map; +typedef QMap str_num_map; +typedef QMap num_comp_map; +typedef QMap comp_str_map; + +typedef QMultiMap num_str_multimap; +typedef QMultiMap str_num_multimap; +typedef QMultiMap num_comp_multimap; + +typedef QHash num_str_hash; +typedef QHash str_num_hash; +typedef QHash str_comp_hash; + +typedef QMultiHash num_str_multihash; +typedef QMultiHash str_num_multihash; +typedef QMultiHash num_comp_multihash; + +#pragma db value +struct cont_comp1 +{ + // This composite value does not have any columns. + // + num_vector sv; // Have the name "conflict" with the one in the object. +}; + +#pragma db value +struct cont_comp2 +{ + cont_comp2 (): num (777), str ("ggg") {} + + int num; + str_list sl; + QString str; +}; + +#pragma db object +struct object +{ + object (): nv (comp1_.sv), sl (comp2_.sl) {} + object (const QString& id) : id_ (id), nv (comp1_.sv), sl (comp2_.sl) {} + + #pragma db id + QString id_; + + int num; + + cont_comp1 comp1_; + cont_comp2 comp2_; + + // vector + // + #pragma db transient + num_vector& nv; + + #pragma db table("object_strings") id_column ("obj_id") + str_vector sv; + + #pragma db value_column("") + comp_vector cv; + + #pragma db unordered + num_vector uv; + + // list + // + #pragma db transient + str_list& sl; + + num_list nl; + comp_list cl; + + // linked list + // + str_linked_list sll; + num_linked_list nll; + comp_linked_list cll; + + // set + // + num_set ns; + str_set ss; + + // map + // + num_str_map nsm; + str_num_map snm; + num_comp_map ncm; + comp_str_map csm; + + // multimap + // + num_str_multimap nsmm; + str_num_multimap snmm; + num_comp_multimap ncmm; + + // hash + // + num_str_hash nsh; + str_num_hash snh; + str_comp_hash sch; + + // multihash + // + num_str_multihash nsmh; + str_num_multihash snmh; + num_comp_multihash ncmh; + + QString str; +}; + +inline bool +operator== (const object& x, const object& y) +{ + if (x.uv.size () != y.uv.size ()) + return false; + + int xs (0), ys (0); + + for (num_vector::size_type i (0); i < x.uv.size (); ++i) + { + xs += x.uv[i]; + ys += y.uv[i]; + } + + return + x.id_ == y.id_ && + x.num == y.num && + + x.comp2_.num == y.comp2_.num && + x.comp2_.str == y.comp2_.str && + + x.nv == y.nv && + x.sv == y.sv && + x.cv == y.cv && + xs == ys && + + x.sl == y.sl && + x.nl == y.nl && + x.cl == y.cl && + + x.nll == y.nll && + x.sll == y.sll && + x.cll == y.cll && + + x.ns == y.ns && + x.ss == y.ss && + + x.nsm == y.nsm && + x.snm == y.snm && + x.ncm == y.ncm && + x.csm == y.csm && + + x.nsmm.uniqueKeys () == y.nsmm.uniqueKeys () && + x.snmm.uniqueKeys () == y.snmm.uniqueKeys () && + x.ncmm.uniqueKeys () == y.ncmm.uniqueKeys () && + + x.nsh == y.nsh && + x.snh == y.snh && + x.sch == y.sch && + + x.nsmh.uniqueKeys () == y.nsmh.uniqueKeys () && + x.snmh.uniqueKeys () == y.snmh.uniqueKeys () && + x.ncmh.uniqueKeys () == y.ncmh.uniqueKeys () && + + x.str == y.str; +} + +#endif // TEST_HXX diff --git a/odb-tests/qt/common/containers/change-tracking/driver.cxx b/odb-tests/qt/common/containers/change-tracking/driver.cxx new file mode 100644 index 0000000..8157d96 --- /dev/null +++ b/odb-tests/qt/common/containers/change-tracking/driver.cxx @@ -0,0 +1,643 @@ +// file : qt/common/containers/change-tracking/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test change-tracking Qt containers. +// + +#include // HAVE_CXX11 + +#include // std::auto_ptr +#include +#include + +#ifdef HAVE_CXX11 +# include // std::move +#endif + +#include // QT_VERSION, Q_FOREACH +#include + +#include +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +struct counting_tracer: odb::tracer +{ + void + reset (transaction& tr) {u = i = d = s = t = 0; tr.tracer (*this);} + + virtual void + execute (odb::connection&, const char* stmt) + { + string p (stmt, 6); + if (p == "UPDATE") + u++; + else if (p == "INSERT") + i++; + else if (p == "DELETE") + d++; + else if (p == "SELECT") + s++; + t++; + } + + size_t u, i, d, s, t; +}; + +static counting_tracer tr; + +// Compilation test: instantiate all the functions. Only do this if we +// have a fairly recent version of Qt, otherwise some underlying +// functions will be missing. +// +#if QT_VERSION >= 0x050000 +template class QOdbList; +template class QOdbListIteratorImpl >; +template class QOdbListIterator; +template class QMutableOdbListIterator; +#endif + +void +f (const QList&) {} + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + // Test extended interface. + // + { + typedef QOdbList list; + + list ol; + QList ql; + f (ol); // Implicit conversion to QList. + list ol1 (ql); // Initialization from QList. + ol = ql; // Assignement from QList. + + // Container comparison. + // + if (ol != ol1 || + ol != ql || + ql != ol1) + ol.clear (); + + // Container operators. + // + ol += ol1; + ol += ql; + ol = ol1 + ql; + ol = ql + ol1; + + // Iterator comparison/conversion. + // +#ifndef QT_STRICT_ITERATORS + list::const_iterator i (ol.begin ()); + if (i != ol.end ()) + i = ol.end (); +#endif + + Q_FOREACH (const int& i, ol) + cerr << i; + } + + auto_ptr db (create_database (argc, argv)); + + // Test traits logic. + // + { + object o ("1"); + o.i = 123; + o.s.push_back ("a"); + + assert (!o.s._tracking ()); + + // persist + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + assert (o.s._tracking ()); + + // load + // + { + transaction t (db->begin ()); +#ifdef HAVE_CXX11 + unique_ptr p (db->load ("1")); +#else + auto_ptr p (db->load ("1")); +#endif + assert (p->s._tracking ()); + t.commit (); + } + + // update + // + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + assert (o.s._tracking ()); + + // erase + // + { + transaction t (db->begin ()); + db->erase (o); + t.commit (); + } + + assert (!o.s._tracking ()); + } + + // Test change tracking. + // + object o ("1"); + o.i = 123; + o.s.push_back ("a"); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // push_back/pop_back + // + { + o.s.push_back ("b"); // insert + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.i == 1 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.pop_back (); + o.s.push_back ("c"); // update + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 2 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.pop_back (); // delete + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.d == 1 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.push_back ("b"); + o.s.pop_back (); // no-op + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.t == 1); + assert (*db->load ("1") == o); + t.commit (); + } + + // insert + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.insert (o.s.begin (), "a1"); // insert front + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 3 && tr.i == 1 && tr.t == 4); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.insert (o.s.begin () + 1, "a2"); // insert middle + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 3 && tr.i == 1 && tr.t == 4); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.insert (o.s.end (), "b1"); // insert back + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.i == 1 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + // erase + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + o.s.push_back ("d"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.erase (o.s.begin ()); // erase front + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 4 && tr.d == 1 && tr.t == 5); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.erase (o.s.begin () + 1); // erase middle + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 2 && tr.d == 1 && tr.t == 3); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.erase (o.s.end () - 1); // erase back + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.d == 1 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + // modify + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + o.s.push_back ("d"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.modify (1) += 'b'; + o.s.modify_back () += 'd'; + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 3 && tr.t == 3); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.modify_front () += 'a'; + o.s.modify_back () += 'd'; + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 3 && tr.t == 3); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.begin ().modify () += 'a'; + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 2 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.mbegin (); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 5 && tr.t == 5); + assert (*db->load ("1") == o); + t.commit (); + } + + // clear + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.clear (); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.d == 1 && tr.t == 2); + assert (*db->load ("1") == o); + t.commit (); + } + + // assign + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + QList v; + v.push_back ("1"); + v.push_back ("2"); + v.push_back ("3"); + v.push_back ("4"); + o.s = v; + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 4 && tr.i == 1 && tr.t == 5); + assert (*db->load ("1") == o); + t.commit (); + } + + // removeOne/removeAll + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + o.s.push_back ("a"); + o.s.push_back ("d"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.removeOne ("c"); + assert (o.s.size () == 5 && o.s[3] == "a"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 3 && tr.d == 1 && tr.t == 4); + assert (*db->load ("1") == o); + t.commit (); + } + + { + o.s.removeAll ("a"); + assert (o.s.size () == 2 && o.s[0] == "b" && o.s[1] == "d"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 3 && tr.d == 1 && tr.t == 4); + assert (*db->load ("1") == o); + t.commit (); + } + + // Transaction rollback. + // + { + o.s.clear (); + o.s.push_back ("a"); + o.s.push_back ("b"); + o.s.push_back ("c"); + + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (*db->load ("1") == o); + t.commit (); + } + + { + { + o.s.push_back ("d"); + + transaction t (db->begin ()); + db->update (o); + t.rollback (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.i == 4 && tr.d == 1 && tr.t == 6); + t.commit (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (o); + assert (tr.u == 1 && tr.t == 1); + t.commit (); + } + } + + // Armed copy. + // + { + +#ifdef HAVE_CXX11 + unique_ptr c; +#else + auto_ptr c; +#endif + + + { + o.s.pop_back (); + + transaction t (db->begin ()); + db->update (o); + c.reset (new object (o)); + t.rollback (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.i == 3 && tr.d == 1 && tr.t == 5); + t.commit (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.t == 1); + t.commit (); + } + } + + // Armed swap. + // +#if QT_VERSION >= 0x040800 + { + object c (o); + + { + o.s.push_back ("d"); + + transaction t (db->begin ()); + db->update (o); + assert (o.s._tracking () && !c.s._tracking ()); + c.s.swap (o.s); + assert (!o.s._tracking () && c.s._tracking ()); + t.rollback (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.i == 4 && tr.d == 1 && tr.t == 6); + t.commit (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.t == 1); + t.commit (); + } + } +#endif + + // Armed move. + // +#ifdef HAVE_CXX11 + { + unique_ptr c; + + { + o.s.pop_back (); + + transaction t (db->begin ()); + db->update (o); + assert (o.s._tracking ()); + c.reset (new object (std::move (o))); + assert (!o.s._tracking () && c->s._tracking ()); + t.rollback (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.i == 2 && tr.d == 1 && tr.t == 4); + t.commit (); + } + + { + transaction t (db->begin ()); + tr.reset (t); + db->update (c); + assert (tr.u == 1 && tr.t == 1); + t.commit (); + } + } +#endif + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/common/containers/change-tracking/test.hxx b/odb-tests/qt/common/containers/change-tracking/test.hxx new file mode 100644 index 0000000..6067581 --- /dev/null +++ b/odb-tests/qt/common/containers/change-tracking/test.hxx @@ -0,0 +1,46 @@ +// file : qt/common/containers/change-tracking/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include // HAVE_CXX11 + +#include + +#ifdef HAVE_CXX11 +# include // std::move +#endif + +#include + +#include +#include + +#ifdef HAVE_CXX11 +#pragma db object pointer(std::unique_ptr) +#else +#pragma db object pointer(std::auto_ptr) +#endif +struct object +{ + object () {} + object (const QString& id): id_ (id) {} + +#ifdef HAVE_CXX11 + object (const object& x): id_ (x.id_), i (x.i), s (x.s) {} + object (object&& x): id_ (std::move (x.id_)), i (x.i), s (std::move (x.s)) {} +#endif + + #pragma db id + QString id_; + + unsigned int i; + + QOdbList s; + + inline bool + operator== (const object& o) {return id_ == o.id_ && i == o.i && s == o.s;} +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/common/smart-ptr/driver.cxx b/odb-tests/qt/common/smart-ptr/driver.cxx new file mode 100644 index 0000000..2c7c38a --- /dev/null +++ b/odb-tests/qt/common/smart-ptr/driver.cxx @@ -0,0 +1,248 @@ +// file : qt/common/smart-ptr/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt smart pointers. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +// Force instantiation of all QLazySharedPointer and QLazyWeakPointer +// class template members. +// +template class QLazySharedPointer; +template class QLazyWeakPointer; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + QSharedPointer c1 (new cont (1)); + QSharedPointer c2 (new cont (2)); + + // Test boolean conversion operator. + // + { + assert (!QLazySharedPointer ()); + assert (!QLazyWeakPointer ()); + assert (QLazySharedPointer (c1)); + assert (QLazySharedPointer (*db, 1)); + assert (QLazyWeakPointer (c1)); + assert (QLazyWeakPointer (*db, 1)); + } + + // Test loaded () implementation. + // + { + assert (QLazySharedPointer ().loaded ()); + assert (!QLazySharedPointer (c1).loaded ()); + assert (!QLazySharedPointer (*db, 1).loaded ()); + assert (QLazySharedPointer (*db, c1).loaded ()); + assert (QLazyWeakPointer ().loaded ()); + assert (!QLazyWeakPointer (c1).loaded ()); + assert (!QLazyWeakPointer (*db, 1).loaded ()); + assert (QLazyWeakPointer (*db, c1).loaded ()); + } + + // Test comparison operators. + // + { + // Transient QLazySharedPointer. + // + assert (QLazySharedPointer () == QLazySharedPointer ()); + assert (QLazySharedPointer () != QLazySharedPointer (c1)); + assert (QLazySharedPointer (c1) != QLazySharedPointer (c2)); + assert (QLazySharedPointer (c2) == QLazySharedPointer (c2)); + + // Persistent QLazySharedPointer. + // + QLazySharedPointer ls1 (*db, 1), ls2 (*db, c2); + assert (ls1 != QLazySharedPointer ()); + assert (ls1 != QLazySharedPointer (c1)); + assert (ls1 == QLazySharedPointer (*db, c1)); + assert (ls1 != ls2); + assert (ls2 == QLazySharedPointer (c2)); + + // Transient QLazyWeakPointer. + // + assert (QLazyWeakPointer () == QLazyWeakPointer ()); + assert (QLazyWeakPointer () != QLazyWeakPointer (c1)); + assert (QLazyWeakPointer (c1) != QLazyWeakPointer (c2)); + assert (QLazyWeakPointer (c2) == QLazyWeakPointer (c2)); + assert (QLazyWeakPointer () == QLazySharedPointer ()); + assert (QLazyWeakPointer () != QLazySharedPointer (c1)); + assert (QLazyWeakPointer (c1) != QLazySharedPointer (c2)); + assert (QLazyWeakPointer (c2) == QLazySharedPointer (c2)); + + // Persistent QLazyWeakPointer. + // + QLazyWeakPointer lw1 (*db, 1), lw2 (*db, c2); + assert (lw1 != QLazyWeakPointer ()); + assert (lw1 != QLazyWeakPointer (c1)); + assert (lw1 == QLazyWeakPointer (*db, c1)); + assert (lw1 != lw2); + assert (lw2 == QLazyWeakPointer (c2)); + assert (ls1 == lw1); + assert (ls1 != QLazyWeakPointer (c1)); + assert (ls1 == QLazyWeakPointer (*db, c1)); + assert (ls1 != lw2); + assert (ls2 == QLazyWeakPointer (c2)); + } + + // Test swap. + // + { + QLazySharedPointer lx (*db, 1), ly; + swap (lx, ly); + + assert (lx.isNull ()); + assert (ly == QLazySharedPointer (*db, c1)); + } + + // Persist. + // + QSharedPointer o1 (new obj (1)); + QSharedPointer o2 (new obj (2)); + QSharedPointer o3 (new obj (3)); + QSharedPointer o4 (new obj (4)); + + o1->c = c1; + o2->c = c1; + o3->c = c2; + o4->c = c2; + + { + transaction t (db->begin ()); + + db->persist (c1); + + db->persist (o1); + db->persist (o2); + db->persist (o3); + db->persist (o4); + + db->persist (c2); + + t.commit (); + } + + // Load. + // + { + session s; + transaction t (db->begin ()); + + QSharedPointer c (db->load (1)); + QSharedPointer o (db->load (1)); + + // Ensure that lazy pointers are present but not loaded. + // + assert (c->o.size () == 2); + assert (!c->o[0].loaded ()); + assert (!c->o[1].loaded ()); + assert (!o->c.loaded ()); + + // Ensure that the correct object IDs were loaded. + // + assert (c->o[0].objectId () == 1); + assert (c->o[1].objectId () == 2); + assert (o->c.objectId () == 1); + + // Load the lazy pointer targets ensuring that the loaded + // targets correspond to the cached session objects. + // + QSharedPointer cl (o->c.load ()); + QSharedPointer ol (c->o[0].load ()); + + assert (c->o[0].loaded ()); + assert (o->c.loaded ()); + + assert (cl == c); + assert (ol == o); + + t.commit (); + } + + // Test lazy weak locking and reloading. + // + { + // No session. + // + transaction t (db->begin ()); + QSharedPointer c (db->load (1)); + + // Lock. + // + assert (!c->o[1].loaded ()); + QLazySharedPointer l (c->o[1].toStrongRef ()); + assert (!l.loaded ()); + assert (l.objectId () == c->o[1].objectId ()); + + // Reload. + // + assert (!c->o[1].loaded ()); + + QSharedPointer ol (c->o[1].load ()); + assert (c->o[1].loaded ()); + + ol.clear (); + assert (!c->o[1].loaded ()); + + ol = c->o[1].load (); + assert (c->o[1].loaded ()); + + t.commit (); + } + + // + // Test QSharedPointer as a value wrapper. + // + + { + obj2 o1 (1); + obj2 o2 (2); + o2.num = QSharedPointer (new unsigned long (123)); + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + QSharedPointer o1 (db->load (1)); + QSharedPointer o2 (db->load (2)); + t.commit (); + + assert (!o1->num); + assert (o2->num && *o2->num == 123); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/common/smart-ptr/test.hxx b/odb-tests/qt/common/smart-ptr/test.hxx new file mode 100644 index 0000000..2c8bf36 --- /dev/null +++ b/odb-tests/qt/common/smart-ptr/test.hxx @@ -0,0 +1,77 @@ +// file : qt/common/smart-ptr/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#include +#include + +struct obj; + +#pragma db object +struct cont +{ + cont () + { + } + + cont (unsigned long id) + : id (id) + { + } + + #pragma db id + unsigned long id; + + typedef std::vector > obj_list; + + #pragma db inverse(c) value_not_null + obj_list o; +}; + +#pragma db object +struct obj +{ + obj () + { + } + + obj (unsigned long id) + : id (id) + { + } + + #pragma db id + unsigned long id; + + #pragma db not_null + QLazySharedPointer c; +}; + +// Test QSharedPointer as a value wrapper. +// +#pragma db object +struct obj2 +{ + obj2 () + { + } + + obj2 (unsigned long id) + : id (id) + { + } + + #pragma db id + unsigned long id; + + #pragma db null + QSharedPointer num; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/common/template/driver.cxx b/odb-tests/qt/common/template/driver.cxx new file mode 100644 index 0000000..30f9fc6 --- /dev/null +++ b/odb-tests/qt/common/template/driver.cxx @@ -0,0 +1,43 @@ +// file : qt/common/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/common/template/template-qt4-vc10.vcxproj b/odb-tests/qt/common/template/template-qt4-vc10.vcxproj new file mode 100644 index 0000000..fddcac3 --- /dev/null +++ b/odb-tests/qt/common/template/template-qt4-vc10.vcxproj @@ -0,0 +1,177 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + + +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/common/template/template-qt4-vc10.vcxproj.filters b/odb-tests/qt/common/template/template-qt4-vc10.vcxproj.filters new file mode 100644 index 0000000..f3ee658 --- /dev/null +++ b/odb-tests/qt/common/template/template-qt4-vc10.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test-odb.cxx) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/common/template/template-qt4-vc11.vcxproj b/odb-tests/qt/common/template/template-qt4-vc11.vcxproj new file mode 100644 index 0000000..a71ac6b --- /dev/null +++ b/odb-tests/qt/common/template/template-qt4-vc11.vcxproj @@ -0,0 +1,181 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + + +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/common/template/template-qt4-vc11.vcxproj.filters b/odb-tests/qt/common/template/template-qt4-vc11.vcxproj.filters new file mode 100644 index 0000000..f3ee658 --- /dev/null +++ b/odb-tests/qt/common/template/template-qt4-vc11.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test-odb.cxx) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/common/template/template-qt4-vc12.vcxproj b/odb-tests/qt/common/template/template-qt4-vc12.vcxproj new file mode 100644 index 0000000..eaa4d12 --- /dev/null +++ b/odb-tests/qt/common/template/template-qt4-vc12.vcxproj @@ -0,0 +1,185 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + + +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/common/template/template-qt4-vc12.vcxproj.filters b/odb-tests/qt/common/template/template-qt4-vc12.vcxproj.filters new file mode 100644 index 0000000..f3ee658 --- /dev/null +++ b/odb-tests/qt/common/template/template-qt4-vc12.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test-odb.cxx) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/common/template/template-qt4-vc8.vcproj b/odb-tests/qt/common/template/template-qt4-vc8.vcproj new file mode 100644 index 0000000..63fc22c --- /dev/null +++ b/odb-tests/qt/common/template/template-qt4-vc8.vcproj @@ -0,0 +1,353 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/common/template/template-qt4-vc9.vcproj b/odb-tests/qt/common/template/template-qt4-vc9.vcproj new file mode 100644 index 0000000..b37675e --- /dev/null +++ b/odb-tests/qt/common/template/template-qt4-vc9.vcproj @@ -0,0 +1,360 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/common/template/template-qt5-vc10.vcxproj b/odb-tests/qt/common/template/template-qt5-vc10.vcxproj new file mode 100644 index 0000000..add071a --- /dev/null +++ b/odb-tests/qt/common/template/template-qt5-vc10.vcxproj @@ -0,0 +1,177 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + + +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/common/template/template-qt5-vc10.vcxproj.filters b/odb-tests/qt/common/template/template-qt5-vc10.vcxproj.filters new file mode 100644 index 0000000..f3ee658 --- /dev/null +++ b/odb-tests/qt/common/template/template-qt5-vc10.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test-odb.cxx) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/common/template/template-qt5-vc11.vcxproj b/odb-tests/qt/common/template/template-qt5-vc11.vcxproj new file mode 100644 index 0000000..07daa25 --- /dev/null +++ b/odb-tests/qt/common/template/template-qt5-vc11.vcxproj @@ -0,0 +1,181 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + + +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/common/template/template-qt5-vc11.vcxproj.filters b/odb-tests/qt/common/template/template-qt5-vc11.vcxproj.filters new file mode 100644 index 0000000..f3ee658 --- /dev/null +++ b/odb-tests/qt/common/template/template-qt5-vc11.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test-odb.cxx) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/common/template/template-qt5-vc12.vcxproj b/odb-tests/qt/common/template/template-qt5-vc12.vcxproj new file mode 100644 index 0000000..a64ba40 --- /dev/null +++ b/odb-tests/qt/common/template/template-qt5-vc12.vcxproj @@ -0,0 +1,185 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + + +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/common/template/template-qt5-vc12.vcxproj.filters b/odb-tests/qt/common/template/template-qt5-vc12.vcxproj.filters new file mode 100644 index 0000000..f3ee658 --- /dev/null +++ b/odb-tests/qt/common/template/template-qt5-vc12.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test-odb.cxx) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/common/template/template-qt5-vc9.vcproj b/odb-tests/qt/common/template/template-qt5-vc9.vcproj new file mode 100644 index 0000000..57b4edc --- /dev/null +++ b/odb-tests/qt/common/template/template-qt5-vc9.vcproj @@ -0,0 +1,360 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/common/template/test.hxx b/odb-tests/qt/common/template/test.hxx new file mode 100644 index 0000000..6f38186 --- /dev/null +++ b/odb-tests/qt/common/template/test.hxx @@ -0,0 +1,25 @@ +// file : qt/common/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/mssql/basic/driver.cxx b/odb-tests/qt/mssql/basic/driver.cxx new file mode 100644 index 0000000..fca335d --- /dev/null +++ b/odb-tests/qt/mssql/basic/driver.cxx @@ -0,0 +1,65 @@ +// file : qt/mssql/basic/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt basic type persistence. SQL Server version. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + object o; + o.id_ = "object 1"; + o.sstr_ = QString (512, 's'); + o.lstr_ = QString (65000, 'l'); // Test temp buffer boundary. + o.snstr_ = QString (512, QChar (0x1234)); + o.lnstr_ = QString (65536, QChar (0x2345)); + o.sbuf_ = QByteArray (512, 0x01); + o.lbuf_ = QByteArray (65536, 0x02); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (o.id_)); + t.commit (); + + assert (*p == o); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/mssql/basic/test.hxx b/odb-tests/qt/mssql/basic/test.hxx new file mode 100644 index 0000000..bce87b6 --- /dev/null +++ b/odb-tests/qt/mssql/basic/test.hxx @@ -0,0 +1,46 @@ +// file : qt/mssql/basic/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object +struct object +{ + bool + operator== (const object& x) const + { + return + id_ == x.id_ && + sstr_ == x.sstr_ && + lstr_ == x.lstr_ && + snstr_ == x.snstr_ && + lnstr_ == x.lnstr_ && + sbuf_ == x.sbuf_ && + lbuf_ == x.lbuf_; + } + + #pragma db id + QString id_; + + QString sstr_; + + #pragma db type ("VARCHAR(max)") + QString lstr_; + + #pragma db type ("NVARCHAR(512)") + QString snstr_; + + #pragma db type ("NVARCHAR(max)") + QString lnstr_; + + #pragma db type ("VARBINARY(512)") + QByteArray sbuf_; + + QByteArray lbuf_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/mssql/date-time/driver.cxx b/odb-tests/qt/mssql/date-time/driver.cxx new file mode 100644 index 0000000..9b4320e --- /dev/null +++ b/odb-tests/qt/mssql/date-time/driver.cxx @@ -0,0 +1,94 @@ +// file : qt/mssql/date-time/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt date/time type persistence. SQL Server version. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + object o; + + // Check persistence of null values. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (ol->is_null ()); + } + + // Check persistence of valid dates and times. + // +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + QDateTime t (QDateTime::currentDateTime ()); + + o.date = t.date (); + o.date_time = t; +#endif + + // In DATETIME fractional seconds are rounded to .000, .003, or .007. + // + o.date_time_dt = QDateTime (QDate (2012, 1, 14), + QTime (11, 57, 13, 3)); + + // SMALLDATETIME doesn't have seconds (always 0). + // + o.date_time_sdt = QDateTime (QDate (2012, 1, 14), + QTime (11, 57, 0, 0)); + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + o.time = t.time (); +#endif + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (*ol == o); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/mssql/date-time/test.hxx b/odb-tests/qt/mssql/date-time/test.hxx new file mode 100644 index 0000000..71769b9 --- /dev/null +++ b/odb-tests/qt/mssql/date-time/test.hxx @@ -0,0 +1,68 @@ +// file : qt/mssql/date-time/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object +struct object +{ + #pragma db id auto + unsigned long id; + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + QDate date; + + QDateTime date_time; +#endif + + #pragma db type ("DATETIME") + QDateTime date_time_dt; + + #pragma db type ("SMALLDATETIME") + QDateTime date_time_sdt; + +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + QTime time; +#endif + + bool + operator== (const object& x) const + { + return + id == x.id +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + && date == x.date + && date_time == x.date_time +#endif + && date_time_dt == x.date_time_dt + && date_time_sdt == x.date_time_sdt +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + && time == x.time +#endif + ; + } + + bool + is_null () const + { + return + true +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + && date.isNull () + && date_time.isNull () +#endif + && date_time_dt.isNull () + && date_time_sdt.isNull () +#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 + && time.isNull () +#endif + ; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/mssql/template/driver.cxx b/odb-tests/qt/mssql/template/driver.cxx new file mode 100644 index 0000000..97ef6ef --- /dev/null +++ b/odb-tests/qt/mssql/template/driver.cxx @@ -0,0 +1,43 @@ +// file : qt/mssql/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/mssql/template/template-qt4-vc10.vcxproj b/odb-tests/qt/mssql/template/template-qt4-vc10.vcxproj new file mode 100644 index 0000000..e4902d0 --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt4-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mssql/template/template-qt4-vc10.vcxproj.filters b/odb-tests/qt/mssql/template/template-qt4-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt4-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mssql/template/template-qt4-vc11.vcxproj b/odb-tests/qt/mssql/template/template-qt4-vc11.vcxproj new file mode 100644 index 0000000..b9dd89c --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt4-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mssql/template/template-qt4-vc11.vcxproj.filters b/odb-tests/qt/mssql/template/template-qt4-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt4-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mssql/template/template-qt4-vc12.vcxproj b/odb-tests/qt/mssql/template/template-qt4-vc12.vcxproj new file mode 100644 index 0000000..0916a38 --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt4-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mssql/template/template-qt4-vc12.vcxproj.filters b/odb-tests/qt/mssql/template/template-qt4-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt4-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mssql/template/template-qt4-vc8.vcproj b/odb-tests/qt/mssql/template/template-qt4-vc8.vcproj new file mode 100644 index 0000000..38916fa --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt4-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/mssql/template/template-qt4-vc9.vcproj b/odb-tests/qt/mssql/template/template-qt4-vc9.vcproj new file mode 100644 index 0000000..da1b5ab --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt4-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/mssql/template/template-qt5-vc10.vcxproj b/odb-tests/qt/mssql/template/template-qt5-vc10.vcxproj new file mode 100644 index 0000000..508e262 --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt5-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mssql/template/template-qt5-vc10.vcxproj.filters b/odb-tests/qt/mssql/template/template-qt5-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt5-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mssql/template/template-qt5-vc11.vcxproj b/odb-tests/qt/mssql/template/template-qt5-vc11.vcxproj new file mode 100644 index 0000000..a974034 --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt5-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mssql/template/template-qt5-vc11.vcxproj.filters b/odb-tests/qt/mssql/template/template-qt5-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt5-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mssql/template/template-qt5-vc12.vcxproj b/odb-tests/qt/mssql/template/template-qt5-vc12.vcxproj new file mode 100644 index 0000000..40e2fbb --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt5-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mssql/template/template-qt5-vc12.vcxproj.filters b/odb-tests/qt/mssql/template/template-qt5-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt5-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mssql/template/template-qt5-vc9.vcproj b/odb-tests/qt/mssql/template/template-qt5-vc9.vcproj new file mode 100644 index 0000000..66ea9ab --- /dev/null +++ b/odb-tests/qt/mssql/template/template-qt5-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/mssql/template/test.hxx b/odb-tests/qt/mssql/template/test.hxx new file mode 100644 index 0000000..033703a --- /dev/null +++ b/odb-tests/qt/mssql/template/test.hxx @@ -0,0 +1,25 @@ +// file : qt/mssql/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/mysql/basic/driver.cxx b/odb-tests/qt/mysql/basic/driver.cxx new file mode 100644 index 0000000..b685d68 --- /dev/null +++ b/odb-tests/qt/mysql/basic/driver.cxx @@ -0,0 +1,60 @@ +// file : qt/mysql/basic/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt basic type persistence. MySQL version. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + object o; + o.str = "Constantin Michael"; + o.blob = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (o.str)); + t.commit (); + + assert (*p == o); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/mysql/basic/test.hxx b/odb-tests/qt/mysql/basic/test.hxx new file mode 100644 index 0000000..6dd246e --- /dev/null +++ b/odb-tests/qt/mysql/basic/test.hxx @@ -0,0 +1,27 @@ +// file : qt/mysql/basic/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object +struct object +{ + bool + operator== (const object& x) const + { + return + str == x.str && + blob == x.blob; + } + + #pragma db id + QString str; + + QByteArray blob; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/mysql/date-time/driver.cxx b/odb-tests/qt/mysql/date-time/driver.cxx new file mode 100644 index 0000000..94cf653 --- /dev/null +++ b/odb-tests/qt/mysql/date-time/driver.cxx @@ -0,0 +1,178 @@ +// file : qt/mysql/date-time/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt date/time type persistence. MySQL version. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +bool +test_out_of_range_value (object&, database&); + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + mysql_version v; + { + transaction t (db->begin ()); + db->query ().begin ().load (v); + t.commit (); + } + + // If we are running against MySQL 5.6.4 or later alter the tables + // to allow sub-second precision. + // + bool fs (v.major > 5 || + (v.major == 5 && (v.minor > 6 || + (v.minor == 6 && v.release >= 4)))); + if (fs) + { + transaction t (db->begin ()); + db->execute ("ALTER TABLE `qt_mysql_dt_object`" \ + " MODIFY COLUMN `date_time` DATETIME(3)," \ + " MODIFY COLUMN `timestamp` TIMESTAMP(3) NULL," \ + " MODIFY COLUMN `time` TIME(3)"); + t.commit (); + } + + // + // Check valid dates and times. + // + + object o; + + // Check persistence of null values. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (ol->is_null ()); + } + + // Check persistence of valid dates and times. + // + + // Create a QDateTime containing the current date and time + // but with the milliseconds zeroed. MySQL prior to 5.6.4 + // does not support sub-second prevision. + // + QDateTime t (QDateTime::currentDateTime ()); + + if (!fs) + t.setTime (QTime (t.time ().hour (), + t.time ().minute (), + t.time ().second ())); + + o.date = t.date (); + o.date_time = t; + o.timestamp = t; + o.time = t.time (); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (*ol == o); + } + + // + // Check invalid dates and times. + // + + { + // Test out of range dates. + // + object or1, or2; + or1.date = QDate (999, 12, 31); + or2.date = QDate (10000, 1, 1); + + transaction t (db->begin ()); + assert (test_out_of_range_value (or1, *db)); + assert (test_out_of_range_value (or2, *db)); + t.commit (); + } + + { + // Test out of range date-times. + // + object or1, or2; + or1.date_time = QDateTime (QDate (999, 12, 31), QTime (23, 59, 59)); + or2.date_time = QDateTime (QDate (10000, 1, 1)); + + transaction t (db->begin ()); + assert (test_out_of_range_value (or1, *db)); + assert (test_out_of_range_value (or2, *db)); + t.commit (); + } + + { + // Test out of range timestamps. + // + object or1, or2; + or1.timestamp = QDateTime (QDate (1970, 1, 1)); + or2.timestamp = QDateTime (QDate (2038, 1, 19), QTime (3, 14, 8)); + + transaction t (db->begin ()); + assert (test_out_of_range_value (or1, *db)); + assert (test_out_of_range_value (or2, *db)); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} + +bool +test_out_of_range_value (object& x, database& db) +{ + try + { + db.persist (x); + return false; + } + catch (const odb::qt::date_time::value_out_of_range&) + { + } + + return true; +} diff --git a/odb-tests/qt/mysql/date-time/test.hxx b/odb-tests/qt/mysql/date-time/test.hxx new file mode 100644 index 0000000..ba31da5 --- /dev/null +++ b/odb-tests/qt/mysql/date-time/test.hxx @@ -0,0 +1,70 @@ +// file : qt/mysql/date-time/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#include + +#pragma db object +struct object +{ + bool + operator== (const object& x) const + { + return + id == x.id && + date == x.date && + date_time == x.date_time && + timestamp == x.timestamp && + time == x.time; + } + + bool + is_null () const + { + return + date.isNull () && + date_time.isNull () && + timestamp.isNull () && + time.isNull (); + } + + #pragma db id auto + unsigned long id; + + QDate date; + QDateTime date_time; + + // Make timestamp NULL-able to suppress the auto-initialization and + // auto-update characteristics of the TIMESTAMP datatype, and to + // allow NULL values. + // + #pragma db type("TIMESTAMP") null + QDateTime timestamp; + + QTime time; +}; + +// MySQL server version view. +// +#pragma db view query( \ + "SELECT " \ + "CAST(SUBSTRING_INDEX(@@version, '.', 1) AS UNSIGNED)," \ + "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '.', 2), '.', -1) AS UNSIGNED)," \ + "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '-', 1), '.', -1) AS UNSIGNED)," \ + "@@protocol_version") +struct mysql_version +{ + unsigned int major; + unsigned int minor; + unsigned int release; + + unsigned int protocol; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/mysql/template/driver.cxx b/odb-tests/qt/mysql/template/driver.cxx new file mode 100644 index 0000000..1e293b4 --- /dev/null +++ b/odb-tests/qt/mysql/template/driver.cxx @@ -0,0 +1,43 @@ +// file : qt/mysql/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/mysql/template/template-qt4-vc10.vcxproj b/odb-tests/qt/mysql/template/template-qt4-vc10.vcxproj new file mode 100644 index 0000000..0f57bbe --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt4-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mysql/template/template-qt4-vc10.vcxproj.filters b/odb-tests/qt/mysql/template/template-qt4-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt4-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mysql/template/template-qt4-vc11.vcxproj b/odb-tests/qt/mysql/template/template-qt4-vc11.vcxproj new file mode 100644 index 0000000..33cb785 --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt4-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mysql/template/template-qt4-vc11.vcxproj.filters b/odb-tests/qt/mysql/template/template-qt4-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt4-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mysql/template/template-qt4-vc12.vcxproj b/odb-tests/qt/mysql/template/template-qt4-vc12.vcxproj new file mode 100644 index 0000000..6a2812a --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt4-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mysql/template/template-qt4-vc12.vcxproj.filters b/odb-tests/qt/mysql/template/template-qt4-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt4-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mysql/template/template-qt4-vc8.vcproj b/odb-tests/qt/mysql/template/template-qt4-vc8.vcproj new file mode 100644 index 0000000..25e096f --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt4-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/mysql/template/template-qt4-vc9.vcproj b/odb-tests/qt/mysql/template/template-qt4-vc9.vcproj new file mode 100644 index 0000000..a904d40 --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt4-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/mysql/template/template-qt5-vc10.vcxproj b/odb-tests/qt/mysql/template/template-qt5-vc10.vcxproj new file mode 100644 index 0000000..27eb1a8 --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt5-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mysql/template/template-qt5-vc10.vcxproj.filters b/odb-tests/qt/mysql/template/template-qt5-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt5-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mysql/template/template-qt5-vc11.vcxproj b/odb-tests/qt/mysql/template/template-qt5-vc11.vcxproj new file mode 100644 index 0000000..7a2e2b9 --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt5-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mysql/template/template-qt5-vc11.vcxproj.filters b/odb-tests/qt/mysql/template/template-qt5-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt5-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mysql/template/template-qt5-vc12.vcxproj b/odb-tests/qt/mysql/template/template-qt5-vc12.vcxproj new file mode 100644 index 0000000..f75d5d3 --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt5-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/mysql/template/template-qt5-vc12.vcxproj.filters b/odb-tests/qt/mysql/template/template-qt5-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt5-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/mysql/template/template-qt5-vc9.vcproj b/odb-tests/qt/mysql/template/template-qt5-vc9.vcproj new file mode 100644 index 0000000..c17267b --- /dev/null +++ b/odb-tests/qt/mysql/template/template-qt5-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/mysql/template/test.hxx b/odb-tests/qt/mysql/template/test.hxx new file mode 100644 index 0000000..94b806d --- /dev/null +++ b/odb-tests/qt/mysql/template/test.hxx @@ -0,0 +1,25 @@ +// file : qt/mysql/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/oracle/basic/driver.cxx b/odb-tests/qt/oracle/basic/driver.cxx new file mode 100644 index 0000000..43a20e2 --- /dev/null +++ b/odb-tests/qt/oracle/basic/driver.cxx @@ -0,0 +1,81 @@ +// file : qt/oracle/basic/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt basic type persistence. Oracle version. +// + +#include // std::auto_ptr +#include +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + string short_str (13, 's'); + string medium_str (150, 'm'); + string long_str (20000, 'v'); + // Oracle UTF-8 support is limited to 3-byte sequences. + // + string unicode_str ("a \xD5\x95 \xEA\xAA\xAA \xE2\x82\xAC bcdef"); + + object o; + + o.char_= QString::fromStdString (short_str); + o.varchar2 = QString::fromStdString (medium_str); + o.clob = QString::fromStdString (long_str); + + // fromStdString() assumes ASCII in Qt4 and UTF-8 in Qt5. + // + o.nchar= QString::fromUtf8 (unicode_str.c_str (), + static_cast (unicode_str.size ())); + o.nvarchar2 = QString::fromUtf8 (unicode_str.c_str (), + static_cast (unicode_str.size ())); + o.nclob = QString::fromStdString (long_str); + + o.raw = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); + o.blob = QByteArray (long_str.c_str (), + static_cast (long_str.size ())); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (o.varchar2)); + t.commit (); + assert (*p == o); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/oracle/basic/test.hxx b/odb-tests/qt/oracle/basic/test.hxx new file mode 100644 index 0000000..6781a97 --- /dev/null +++ b/odb-tests/qt/oracle/basic/test.hxx @@ -0,0 +1,51 @@ +// file : qt/oracle/basic/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object +struct object +{ + bool + operator== (const object& x) const + { + return + varchar2 == x.varchar2 && + char_ == x.char_ && + nchar == x.nchar && + nvarchar2 == x.nvarchar2 && + clob == x.clob && + nclob == x.nclob && + blob == x.blob && + raw == x.raw; + } + + #pragma db id + QString varchar2; + + #pragma db type ("CHAR(13)") + QString char_; + + #pragma db type ("NCHAR(13)") + QString nchar; + + #pragma db type ("NVARCHAR2(512)") + QString nvarchar2; + + #pragma db type ("CLOB") + QString clob; + + #pragma db type ("NCLOB") + QString nclob; + + QByteArray blob; + + #pragma db type ("RAW(128)") + QByteArray raw; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/oracle/date-time/driver.cxx b/odb-tests/qt/oracle/date-time/driver.cxx new file mode 100644 index 0000000..d13fab7 --- /dev/null +++ b/odb-tests/qt/oracle/date-time/driver.cxx @@ -0,0 +1,80 @@ +// file : qt/oracle/date-time/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt date/time type persistence. Oracle version. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + object o; + + // Check persistence of null values. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (ol->is_null ()); + } + + // Check persistence of valid dates and times. + // + QDateTime t (QDateTime::currentDateTime ()); + + o.date = t.date (); + o.date_time = t; + o.date_time_d = QDateTime (QDate (2012, 6, 27), QTime (14, 17, 05, 0)); + o.time = t.time (); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (*ol == o); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/oracle/date-time/test.hxx b/odb-tests/qt/oracle/date-time/test.hxx new file mode 100644 index 0000000..93bc5b7 --- /dev/null +++ b/odb-tests/qt/oracle/date-time/test.hxx @@ -0,0 +1,45 @@ +// file : qt/oracle/date-time/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#pragma db object +struct object +{ + bool + operator== (const object& x) const + { + return + id == x.id && + date == x.date && + date_time == x.date_time && + date_time_d == x.date_time_d && + time == x.time; + } + + bool + is_null () const + { + return + date.isNull () && + date_time.isNull () && + date_time_d.isNull () && + time.isNull (); + } + + #pragma db id auto + unsigned long id; + + QDate date; + QDateTime date_time; + #pragma db type("DATE") + QDateTime date_time_d; + QTime time; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/oracle/template/driver.cxx b/odb-tests/qt/oracle/template/driver.cxx new file mode 100644 index 0000000..9b092a9 --- /dev/null +++ b/odb-tests/qt/oracle/template/driver.cxx @@ -0,0 +1,43 @@ +// file : qt/oracle/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/oracle/template/template-qt4-vc10.vcxproj b/odb-tests/qt/oracle/template/template-qt4-vc10.vcxproj new file mode 100644 index 0000000..6e7c369 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt4-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/oracle/template/template-qt4-vc10.vcxproj.filters b/odb-tests/qt/oracle/template/template-qt4-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt4-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/oracle/template/template-qt4-vc11.vcxproj b/odb-tests/qt/oracle/template/template-qt4-vc11.vcxproj new file mode 100644 index 0000000..ad1e888 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt4-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/oracle/template/template-qt4-vc11.vcxproj.filters b/odb-tests/qt/oracle/template/template-qt4-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt4-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/oracle/template/template-qt4-vc12.vcxproj b/odb-tests/qt/oracle/template/template-qt4-vc12.vcxproj new file mode 100644 index 0000000..88dffa8 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt4-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/oracle/template/template-qt4-vc12.vcxproj.filters b/odb-tests/qt/oracle/template/template-qt4-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt4-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/oracle/template/template-qt4-vc8.vcproj b/odb-tests/qt/oracle/template/template-qt4-vc8.vcproj new file mode 100644 index 0000000..187254b --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt4-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/oracle/template/template-qt4-vc9.vcproj b/odb-tests/qt/oracle/template/template-qt4-vc9.vcproj new file mode 100644 index 0000000..292b899 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt4-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/oracle/template/template-qt5-vc10.vcxproj b/odb-tests/qt/oracle/template/template-qt5-vc10.vcxproj new file mode 100644 index 0000000..c388d6b --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt5-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/oracle/template/template-qt5-vc10.vcxproj.filters b/odb-tests/qt/oracle/template/template-qt5-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt5-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/oracle/template/template-qt5-vc11.vcxproj b/odb-tests/qt/oracle/template/template-qt5-vc11.vcxproj new file mode 100644 index 0000000..79d5d15 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt5-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/oracle/template/template-qt5-vc11.vcxproj.filters b/odb-tests/qt/oracle/template/template-qt5-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt5-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/oracle/template/template-qt5-vc12.vcxproj b/odb-tests/qt/oracle/template/template-qt5-vc12.vcxproj new file mode 100644 index 0000000..2ae82a6 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt5-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/oracle/template/template-qt5-vc12.vcxproj.filters b/odb-tests/qt/oracle/template/template-qt5-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt5-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/oracle/template/template-qt5-vc9.vcproj b/odb-tests/qt/oracle/template/template-qt5-vc9.vcproj new file mode 100644 index 0000000..2712157 --- /dev/null +++ b/odb-tests/qt/oracle/template/template-qt5-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/oracle/template/test.hxx b/odb-tests/qt/oracle/template/test.hxx new file mode 100644 index 0000000..0ad65cf --- /dev/null +++ b/odb-tests/qt/oracle/template/test.hxx @@ -0,0 +1,25 @@ +// file : qt/oracle/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/pgsql/basic/driver.cxx b/odb-tests/qt/pgsql/basic/driver.cxx new file mode 100644 index 0000000..4c6a78a --- /dev/null +++ b/odb-tests/qt/pgsql/basic/driver.cxx @@ -0,0 +1,60 @@ +// file : qt/pgsql/basic/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt basic type persistence. PostgreSQL version. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + object o; + o.str = "Constantin Michael"; + o.blob = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (o.str)); + t.commit (); + + assert (*p == o); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/pgsql/basic/test.hxx b/odb-tests/qt/pgsql/basic/test.hxx new file mode 100644 index 0000000..d4a1ba6 --- /dev/null +++ b/odb-tests/qt/pgsql/basic/test.hxx @@ -0,0 +1,27 @@ +// file : qt/pgsql/basic/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object +struct object +{ + bool + operator== (const object& x) const + { + return + str == x.str && + blob == x.blob; + } + + #pragma db id + QString str; + + QByteArray blob; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/pgsql/date-time/driver.cxx b/odb-tests/qt/pgsql/date-time/driver.cxx new file mode 100644 index 0000000..43a676d --- /dev/null +++ b/odb-tests/qt/pgsql/date-time/driver.cxx @@ -0,0 +1,108 @@ +// file : qt/pgsql/date-time/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt date/time type persistence. PostgreSQL version. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +bool +test_out_of_range_value (object&, database&); + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + // Check persistence of null values. + // + { + object o; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (ol->is_null ()); + } + } + + // Check persistence of valid dates and times. + // + { + QDateTime ct (QDateTime::currentDateTime ()); + + object o; + o.date = ct.date (); + o.time = ct.time (); + o.date_time = ct; + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (*ol == o); + } + } + + // Test a QDateTime value before PG epoch. + // + { + object o; + o.date_time = QDateTime (QDate (1969, 12, 31), QTime (23, 59, 59, 123)); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol (db->load (o.id)); + t.commit (); + + assert (*ol == o); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/pgsql/date-time/test.hxx b/odb-tests/qt/pgsql/date-time/test.hxx new file mode 100644 index 0000000..2da5587 --- /dev/null +++ b/odb-tests/qt/pgsql/date-time/test.hxx @@ -0,0 +1,43 @@ +// file : qt/pgsql/date-time/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#include + +#pragma db object +struct object +{ + bool + operator== (const object& x) const + { + return + id == x.id && + date == x.date && + time == x.time && + date_time == x.date_time; + } + + bool + is_null () const + { + return + date.isNull () && + time.isNull () && + date_time.isNull (); + } + + #pragma db id auto + unsigned long id; + + QDate date; + QTime time; + QDateTime date_time; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/pgsql/template/driver.cxx b/odb-tests/qt/pgsql/template/driver.cxx new file mode 100644 index 0000000..71934a7 --- /dev/null +++ b/odb-tests/qt/pgsql/template/driver.cxx @@ -0,0 +1,43 @@ +// file : qt/pgsql/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/pgsql/template/template-qt4-vc10.vcxproj b/odb-tests/qt/pgsql/template/template-qt4-vc10.vcxproj new file mode 100644 index 0000000..1c1e1a7 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt4-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/pgsql/template/template-qt4-vc10.vcxproj.filters b/odb-tests/qt/pgsql/template/template-qt4-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt4-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/pgsql/template/template-qt4-vc11.vcxproj b/odb-tests/qt/pgsql/template/template-qt4-vc11.vcxproj new file mode 100644 index 0000000..a7e7a86 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt4-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/pgsql/template/template-qt4-vc11.vcxproj.filters b/odb-tests/qt/pgsql/template/template-qt4-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt4-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/pgsql/template/template-qt4-vc12.vcxproj b/odb-tests/qt/pgsql/template/template-qt4-vc12.vcxproj new file mode 100644 index 0000000..f1b9924 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt4-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/pgsql/template/template-qt4-vc12.vcxproj.filters b/odb-tests/qt/pgsql/template/template-qt4-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt4-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/pgsql/template/template-qt4-vc8.vcproj b/odb-tests/qt/pgsql/template/template-qt4-vc8.vcproj new file mode 100644 index 0000000..3f364d2 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt4-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/pgsql/template/template-qt4-vc9.vcproj b/odb-tests/qt/pgsql/template/template-qt4-vc9.vcproj new file mode 100644 index 0000000..2e9e84b --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt4-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/pgsql/template/template-qt5-vc10.vcxproj b/odb-tests/qt/pgsql/template/template-qt5-vc10.vcxproj new file mode 100644 index 0000000..cb6aa0c --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt5-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/pgsql/template/template-qt5-vc10.vcxproj.filters b/odb-tests/qt/pgsql/template/template-qt5-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt5-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/pgsql/template/template-qt5-vc11.vcxproj b/odb-tests/qt/pgsql/template/template-qt5-vc11.vcxproj new file mode 100644 index 0000000..863bd51 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt5-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/pgsql/template/template-qt5-vc11.vcxproj.filters b/odb-tests/qt/pgsql/template/template-qt5-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt5-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/pgsql/template/template-qt5-vc12.vcxproj b/odb-tests/qt/pgsql/template/template-qt5-vc12.vcxproj new file mode 100644 index 0000000..5d958c2 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt5-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/pgsql/template/template-qt5-vc12.vcxproj.filters b/odb-tests/qt/pgsql/template/template-qt5-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt5-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/pgsql/template/template-qt5-vc9.vcproj b/odb-tests/qt/pgsql/template/template-qt5-vc9.vcproj new file mode 100644 index 0000000..b32a1e7 --- /dev/null +++ b/odb-tests/qt/pgsql/template/template-qt5-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/pgsql/template/test.hxx b/odb-tests/qt/pgsql/template/test.hxx new file mode 100644 index 0000000..8b866bd --- /dev/null +++ b/odb-tests/qt/pgsql/template/test.hxx @@ -0,0 +1,25 @@ +// file : qt/pgsql/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/sqlite/basic/driver.cxx b/odb-tests/qt/sqlite/basic/driver.cxx new file mode 100644 index 0000000..3bae10b --- /dev/null +++ b/odb-tests/qt/sqlite/basic/driver.cxx @@ -0,0 +1,60 @@ +// file : qt/sqlite/basic/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt basic type persistence. SQLite version. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + object o; + o.str = QString::fromUtf8 ("Constantin Micha\xC3\x88l"); + o.blob = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr p (db->load (o.str)); + t.commit (); + + assert (*p == o); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/sqlite/basic/test.hxx b/odb-tests/qt/sqlite/basic/test.hxx new file mode 100644 index 0000000..b0cdf46 --- /dev/null +++ b/odb-tests/qt/sqlite/basic/test.hxx @@ -0,0 +1,27 @@ +// file : qt/sqlite/basic/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object +struct object +{ + bool + operator== (const object& x) const + { + return + str == x.str && + blob == x.blob; + } + + #pragma db id + QString str; + + QByteArray blob; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/sqlite/date-time/driver.cxx b/odb-tests/qt/sqlite/date-time/driver.cxx new file mode 100644 index 0000000..adf7889 --- /dev/null +++ b/odb-tests/qt/sqlite/date-time/driver.cxx @@ -0,0 +1,140 @@ +// file : qt/sqlite/date-time/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt date/time type persistence. SQLite version. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +bool +test_out_of_range_value (object&, database&); + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + // Check persistence of null values. + // + object o1; + { + transaction t (db->begin ()); + db->persist (o1); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol1 (db->load (o1.id)); + t.commit (); + + assert (ol1->is_null ()); + } + + QDateTime ct (QDateTime::currentDateTime ()); + QDateTime ct_no_ms = QDateTime (QDate (ct.date ().year (), + ct.date ().month (), + ct.date ().day ()), + QTime (ct.time ().hour (), + ct.time ().minute (), + ct.time ().second ())); + + // Check persistence of valid dates and times. + // + object o2; + { + o2.date = ct.date (); + o2.unix_day = ct.date (); + o2.time = ct.time (); + + // QTime stored as SQLite INTEGER has second resolution. + // The millsecond part is zeroed to avoid false negatives. + // + o2.seconds = ct_no_ms.time (); + + o2.date_time = ct; + + // UNIX time has second reolution. The millsecond part is + // zeroed to avoid false negatives. + // + o2.unix_time = ct_no_ms; + + transaction t (db->begin ()); + db->persist (o2); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr ol2 (db->load (o2.id)); + t.commit (); + + assert (*ol2 == o2); + } + + // Test out of range values for QDateTime traits UNIX time + // implementation. + // + { + object o; + o.unix_time = QDateTime (QDate (1969, 12, 31), + QTime (23, 59, 59), + Qt::UTC); + + assert (test_out_of_range_value (o, *db)); + } + + // Test out of range values for QDate traits UNIX time + // implementation. + // + { + object o; + o.unix_day = QDate (QDate (1969, 12, 31)); + + assert (test_out_of_range_value (o, *db)); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} + +bool +test_out_of_range_value (object& x, database& db) +{ + try + { + transaction t (db.begin ()); + db.persist (x); + t.rollback (); + + return false; + } + catch (const odb::qt::date_time::value_out_of_range&) + { + } + + return true; +} diff --git a/odb-tests/qt/sqlite/date-time/test.hxx b/odb-tests/qt/sqlite/date-time/test.hxx new file mode 100644 index 0000000..9795846 --- /dev/null +++ b/odb-tests/qt/sqlite/date-time/test.hxx @@ -0,0 +1,60 @@ +// file : qt/sqlite/date-time/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include + +#include + +#pragma db object +struct object +{ + bool + operator== (const object& x) const + { + return + id == x.id && + date == x.date && + unix_day == x.unix_day && + time == x.time && + seconds == x.seconds && + date_time == x.date_time && + unix_time == x.unix_time; + } + + bool + is_null () const + { + return + date.isNull () && + unix_day.isNull () && + time.isNull () && + seconds.isNull () && + date_time.isNull () && + unix_time.isNull (); + } + + #pragma db id auto + unsigned long id; + + QDate date; + + #pragma db type ("INTEGER") + QDate unix_day; + + QTime time; + + #pragma db type ("INTEGER") + QTime seconds; + + QDateTime date_time; + + #pragma db type ("INTEGER") + QDateTime unix_time; +}; + +#endif // TEST_HXX diff --git a/odb-tests/qt/sqlite/template/driver.cxx b/odb-tests/qt/sqlite/template/driver.cxx new file mode 100644 index 0000000..dc1181c --- /dev/null +++ b/odb-tests/qt/sqlite/template/driver.cxx @@ -0,0 +1,43 @@ +// file : qt/sqlite/template/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr db (create_database (argc, argv)); + + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/sqlite/template/template-qt4-vc10.vcxproj b/odb-tests/qt/sqlite/template/template-qt4-vc10.vcxproj new file mode 100644 index 0000000..5d4cd02 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt4-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/sqlite/template/template-qt4-vc10.vcxproj.filters b/odb-tests/qt/sqlite/template/template-qt4-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt4-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/sqlite/template/template-qt4-vc11.vcxproj b/odb-tests/qt/sqlite/template/template-qt4-vc11.vcxproj new file mode 100644 index 0000000..217b75e --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt4-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/sqlite/template/template-qt4-vc11.vcxproj.filters b/odb-tests/qt/sqlite/template/template-qt4-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt4-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/sqlite/template/template-qt4-vc12.vcxproj b/odb-tests/qt/sqlite/template/template-qt4-vc12.vcxproj new file mode 100644 index 0000000..43959de --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt4-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/sqlite/template/template-qt4-vc12.vcxproj.filters b/odb-tests/qt/sqlite/template/template-qt4-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt4-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/sqlite/template/template-qt4-vc8.vcproj b/odb-tests/qt/sqlite/template/template-qt4-vc8.vcproj new file mode 100644 index 0000000..16623a8 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt4-vc8.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/sqlite/template/template-qt4-vc9.vcproj b/odb-tests/qt/sqlite/template/template-qt4-vc9.vcproj new file mode 100644 index 0000000..b52f2ec --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt4-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/sqlite/template/template-qt5-vc10.vcxproj b/odb-tests/qt/sqlite/template/template-qt5-vc10.vcxproj new file mode 100644 index 0000000..b0f2c28 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt5-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/sqlite/template/template-qt5-vc10.vcxproj.filters b/odb-tests/qt/sqlite/template/template-qt5-vc10.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt5-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/sqlite/template/template-qt5-vc11.vcxproj b/odb-tests/qt/sqlite/template/template-qt5-vc11.vcxproj new file mode 100644 index 0000000..d0ca5d9 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt5-vc11.vcxproj @@ -0,0 +1,184 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/sqlite/template/template-qt5-vc11.vcxproj.filters b/odb-tests/qt/sqlite/template/template-qt5-vc11.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt5-vc11.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/sqlite/template/template-qt5-vc12.vcxproj b/odb-tests/qt/sqlite/template/template-qt5-vc12.vcxproj new file mode 100644 index 0000000..dc303a6 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt5-vc12.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + v120 + Unicode + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + true + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) + Console + true + true + true + + +__ifelse__(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +__ifelse__(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/odb-tests/qt/sqlite/template/template-qt5-vc12.vcxproj.filters b/odb-tests/qt/sqlite/template/template-qt5-vc12.vcxproj.filters new file mode 100644 index 0000000..8ac18a3 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt5-vc12.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__ifelse__(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/odb-tests/qt/sqlite/template/template-qt5-vc9.vcproj b/odb-tests/qt/sqlite/template/template-qt5-vc9.vcproj new file mode 100644 index 0000000..79c9389 --- /dev/null +++ b/odb-tests/qt/sqlite/template/template-qt5-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +__ifelse__(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/odb-tests/qt/sqlite/template/test.hxx b/odb-tests/qt/sqlite/template/test.hxx new file mode 100644 index 0000000..1a8d616 --- /dev/null +++ b/odb-tests/qt/sqlite/template/test.hxx @@ -0,0 +1,25 @@ +// file : qt/sqlite/template/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/sqlite.testscript b/odb-tests/sqlite.testscript new file mode 100644 index 0000000..986bb37 --- /dev/null +++ b/odb-tests/sqlite.testscript @@ -0,0 +1,10 @@ +# file : sqlite.testscript +# license : GNU GPL v2; see accompanying LICENSE file + +# Setup the test driver command line for the subsequent SQLite tests. +# +# Note that for SQLite the schema is created implicitly by the database object +# creation function called by the test driver. +# +test.arguments += ($multi ? 'sqlite' : ) $sqlite_options +test.cleanups += &odb-test.db # See database-options.testscript for details. diff --git a/odb-tests/sqlite/attach/buildfile b/odb-tests/sqlite/attach/buildfile new file mode 100644 index 0000000..959f050 --- /dev/null +++ b/odb-tests/sqlite/attach/buildfile @@ -0,0 +1,32 @@ +# file : sqlite/attach/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ +"sqlite should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-sqlite%lib{odb-sqlite} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix sqlitex_attach_ \ + --generate-schema \ + --default-database common \ + --generate-query \ + --schema main + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/sqlite/attach/driver.cxx b/odb-tests/sqlite/attach/driver.cxx new file mode 100644 index 0000000..25d279f --- /dev/null +++ b/odb-tests/sqlite/attach/driver.cxx @@ -0,0 +1,109 @@ +// file : sqlite/attach/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test attached database support. +// + +#include // std::unique_ptr +#include + +#include + +#include +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace sqlite = odb::sqlite; +using namespace sqlite; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr mdb (create_specific_database (argc, argv)); + + { + object o ("one"); + + connection_ptr c (mdb->connection ()); + + database adb (c, ":memory:", "adb"); + + // Create schema similar to create_database(). + // + { + c->execute ("PRAGMA foreign_keys=OFF"); + + transaction t (c->begin ()); + odb::schema_catalog::create_schema (adb); + t.commit (); + + c->execute ("PRAGMA foreign_keys=ON"); + } + + { + transaction t (c->begin ()); + mdb->persist (o); + adb.persist (o); + t.commit (); + } + + { + transaction t (c->begin ()); + unique_ptr p (adb.load (o.id)); + t.commit (); + + assert (p->str == o.str); + } + + { + o.str = "two"; + + transaction t (c->begin ()); + adb.update (o); + t.commit (); + } + + { + typedef sqlite::query query; + + transaction t (c->begin ()); + unique_ptr p (adb.query_one (query::str == "two")); + t.commit (); + + assert (p->str == o.str); + } + + { + transaction t (c->begin ()); + adb.erase (o); + t.commit (); + } + + { + transaction t (c->begin ()); + unique_ptr p (mdb->load (o.id)); + t.commit (); + + assert (p.get () != 0); + } + + adb.detach (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/sqlite/attach/test.hxx b/odb-tests/sqlite/attach/test.hxx new file mode 100644 index 0000000..b3b8f63 --- /dev/null +++ b/odb-tests/sqlite/attach/test.hxx @@ -0,0 +1,32 @@ +// file : sqlite/attach/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +#include + +#pragma db object +struct object +{ + explicit + object (const std::string& s): str (s) {} + + #pragma db id auto + unsigned long id; + + #pragma db unique + std::string str; + +private: + object () {} + + friend class odb::access; +}; + +#endif // TEST_HXX diff --git a/odb-tests/sqlite/attach/testscript b/odb-tests/sqlite/attach/testscript new file mode 100644 index 0000000..db5089d --- /dev/null +++ b/odb-tests/sqlite/attach/testscript @@ -0,0 +1,9 @@ +# file : sqlite/attach/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../sqlite.testscript + +: basics +: +$* diff --git a/odb-tests/sqlite/auto/buildfile b/odb-tests/sqlite/auto/buildfile new file mode 100644 index 0000000..2c70b7c --- /dev/null +++ b/odb-tests/sqlite/auto/buildfile @@ -0,0 +1,32 @@ +# file : sqlite/auto/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ +"sqlite should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-sqlite%lib{odb-sqlite} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix sqlitex_auto_ \ + --generate-schema \ + --default-database common \ + --generate-query \ + --sqlite-lax-auto-id + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/sqlite/auto/driver.cxx b/odb-tests/sqlite/auto/driver.cxx new file mode 100644 index 0000000..bcd42c1 --- /dev/null +++ b/odb-tests/sqlite/auto/driver.cxx @@ -0,0 +1,76 @@ +// file : sqlite/auto/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test manual/automatic id assignment. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace sqlite = odb::sqlite; +using namespace sqlite; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_specific_database (argc, argv)); + + // object + // + { + unsigned long id1, id2, id3; + { + object o1 (1, "one"); + object o2 ("two"); + object o3 (3, "three"); + + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + + id1 = *o1.id_; + id2 = *o2.id_; + id3 = *o3.id_; + + assert (id1 == 1); + assert (id3 == 3); + + assert (id2 != id1); + assert (id2 != id3); + } + + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (id1)); + unique_ptr o2 (db->load (id2)); + unique_ptr o3 (db->load (id3)); + t.commit (); + + assert (*o1->id_ == id1 && o1->str_ == "one"); + assert (*o2->id_ == id2 && o2->str_ == "two"); + assert (*o3->id_ == id3 && o3->str_ == "three"); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/sqlite/auto/test.hxx b/odb-tests/sqlite/auto/test.hxx new file mode 100644 index 0000000..9905182 --- /dev/null +++ b/odb-tests/sqlite/auto/test.hxx @@ -0,0 +1,32 @@ +// file : sqlite/auto/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +#include + +#pragma db object +struct object +{ + explicit + object (const std::string& str): str_ (str) {} + object (unsigned long id, const std::string& str): id_ (id), str_ (str) {} + + #pragma db auto id + odb::nullable id_; + + std::string str_; + +private: + object () {} + + friend class odb::access; +}; + +#endif // TEST_HXX diff --git a/odb-tests/sqlite/auto/testscript b/odb-tests/sqlite/auto/testscript new file mode 100644 index 0000000..a5a7da5 --- /dev/null +++ b/odb-tests/sqlite/auto/testscript @@ -0,0 +1,9 @@ +# file : sqlite/auto/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../sqlite.testscript + +: basics +: +$* diff --git a/odb-tests/sqlite/custom/buildfile b/odb-tests/sqlite/custom/buildfile new file mode 100644 index 0000000..3325762 --- /dev/null +++ b/odb-tests/sqlite/custom/buildfile @@ -0,0 +1,31 @@ +# file : sqlite/custom/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ +"sqlite should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-sqlite%lib{odb-sqlite} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix sqlitex_custom_ \ + --generate-schema \ + --default-database common \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/sqlite/custom/driver.cxx b/odb-tests/sqlite/custom/driver.cxx new file mode 100644 index 0000000..0627708 --- /dev/null +++ b/odb-tests/sqlite/custom/driver.cxx @@ -0,0 +1,78 @@ +// file : sqlite/custom/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test custom database type mapping in SQLite. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace sqlite = odb::sqlite; +using namespace sqlite; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_specific_database (argc, argv)); + + object o (1); + o.nv.push_back ("123"); // INTEGER + o.nv.push_back ("1.23"); // REAL + o.nv.push_back ("abc"); // TEXT + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + + // Update. + // + o.nv[1] += "4"; + + { + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/sqlite/custom/test.hxx b/odb-tests/sqlite/custom/test.hxx new file mode 100644 index 0000000..54a2ba3 --- /dev/null +++ b/odb-tests/sqlite/custom/test.hxx @@ -0,0 +1,39 @@ +// file : sqlite/custom/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#include + +// Map NUMERIC SQLite type to std::string (or any other type that +// provides the value_traits specialization). By +// default ODB treats NUMERIC as REAL. Note also that we don't +// need to specify to/from conversions since SQLite will convert +// implicitly. +// +#pragma db map type("NUMERIC") as("TEXT") + +#pragma db object +struct object +{ + object () {} + object (unsigned long id_): id (id_) {} + + #pragma db id + unsigned long id; + + #pragma db value_type("NUMERIC") + std::vector nv; + + bool + operator== (const object& y) const + { + return id == y.id && nv == y.nv; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/sqlite/custom/testscript b/odb-tests/sqlite/custom/testscript new file mode 100644 index 0000000..53561ae --- /dev/null +++ b/odb-tests/sqlite/custom/testscript @@ -0,0 +1,9 @@ +# file : sqlite/custom/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../sqlite.testscript + +: basics +: +$* diff --git a/odb-tests/sqlite/database/buildfile b/odb-tests/sqlite/database/buildfile new file mode 100644 index 0000000..e74ab1a --- /dev/null +++ b/odb-tests/sqlite/database/buildfile @@ -0,0 +1,11 @@ +# file : sqlite/database/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ +"sqlite should be configured via config.odb_tests.database variable as a single database" + +import libs = libodb-sqlite%lib{odb-sqlite} + +exe{driver}: {hxx cxx}{*} $libs testscript + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/sqlite/database/driver.cxx b/odb-tests/sqlite/database/driver.cxx new file mode 100644 index 0000000..5e16653 --- /dev/null +++ b/odb-tests/sqlite/database/driver.cxx @@ -0,0 +1,40 @@ +// file : sqlite/database/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test that database constructors are unambiguous and some other things. +// + +#include + +#undef NDEBUG +#include + +namespace sqlite = odb::sqlite; +using namespace sqlite; + +int +main (int argc, char* argv[]) +{ + // Test UTF-16 to UTF-8 conversion. + // +#ifdef _WIN32 + { + database d (L"t\x00C8st"); + assert (d.name () == "t\xC3\x88st"); + } +#endif + + // This code should not execute. + // + if (argc != 0) + return 0; + + { + database d1 ("db1"); + } + + { + database d1 (argc, argv); + database d2 (argc, argv, false); + } +} diff --git a/odb-tests/sqlite/database/testscript b/odb-tests/sqlite/database/testscript new file mode 100644 index 0000000..b9c0f5f --- /dev/null +++ b/odb-tests/sqlite/database/testscript @@ -0,0 +1,6 @@ +# file : sqlite/database/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +: basics +: +$* diff --git a/odb-tests/sqlite/native/buildfile b/odb-tests/sqlite/native/buildfile new file mode 100644 index 0000000..49aa05b --- /dev/null +++ b/odb-tests/sqlite/native/buildfile @@ -0,0 +1,12 @@ +# file : sqlite/native/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ +"sqlite should be configured via config.odb_tests.database variable as a single database" + +import libs = libodb-sqlite%lib{odb-sqlite} +import libs += lib{common} + +exe{driver}: {hxx cxx}{*} $libs testscript + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/sqlite/native/driver.cxx b/odb-tests/sqlite/native/driver.cxx new file mode 100644 index 0000000..c87aa5d --- /dev/null +++ b/odb-tests/sqlite/native/driver.cxx @@ -0,0 +1,74 @@ +// file : sqlite/native/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test native SQL execution. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#undef NDEBUG +#include + +using namespace std; +namespace sqlite = odb::sqlite; +using namespace sqlite; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db ( + create_specific_database (argc, argv, false)); + + // Create the database schema. + // + { + transaction t (db->begin ()); + + db->execute ("DROP TABLE IF EXISTS sqlitex_native_test"); + db->execute ("CREATE TABLE sqlitex_native_test (n INTEGER PRIMARY KEY)"); + + t.commit (); + } + + // Insert a few rows. + // + { + transaction t (db->begin ()); + + assert ( + db->execute ("INSERT INTO sqlitex_native_test (n) VALUES (1)") == 1); + + assert ( + db->execute ("INSERT INTO sqlitex_native_test (n) VALUES (2)") == 1); + + t.commit (); + } + + // Select a few rows. + // + { + transaction t (db->begin ()); + + assert ( + db->execute ("SELECT n FROM sqlitex_native_test WHERE n < 3") == 2); + + assert ( + db->execute ("SELECT n FROM sqlitex_native_test WHERE n > 3") == 0); + + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/sqlite/native/testscript b/odb-tests/sqlite/native/testscript new file mode 100644 index 0000000..16f05e0 --- /dev/null +++ b/odb-tests/sqlite/native/testscript @@ -0,0 +1,9 @@ +# file : sqlite/native/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../sqlite.testscript + +: basics +: +$* diff --git a/odb-tests/sqlite/stream/buildfile b/odb-tests/sqlite/stream/buildfile new file mode 100644 index 0000000..fb8f605 --- /dev/null +++ b/odb-tests/sqlite/stream/buildfile @@ -0,0 +1,31 @@ +# file : sqlite/stream/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ +"sqlite should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} +import libodb_sqlite = libodb-sqlite%lib{odb-sqlite} +import libs = lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb and +# libodb-sqlite libraries are resolved for the odb_compile ad hoc rule (see +# build/root.build for details). +# +libue{test-meta}: $libodb $libodb_sqlite + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix sqlitex_stream_ \ + --generate-schema \ + --default-database common \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/sqlite/stream/driver.cxx b/odb-tests/sqlite/stream/driver.cxx new file mode 100644 index 0000000..86522ec --- /dev/null +++ b/odb-tests/sqlite/stream/driver.cxx @@ -0,0 +1,281 @@ +// file : sqlite/stream/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test SQLite BLOB/TEXT incremental I/O. +// + +#include +#include // std::unique_ptr +#include + +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace sqlite = odb::sqlite; +using namespace sqlite; + +template +void +print (const S&) +{ + /* + cerr << s.db () << '.' + << s.table () << '.' + << s.column () << '#' + << s.rowid () << endl; + */ +} + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_specific_database (argc, argv)); + + string txt (1024 * 1024, 't'); + vector blb (1024 * 1024, 'b'); + + object o; + + { + transaction tx (db->begin ()); + + o.t.size (txt.size ()); + o.b.size (blb.size ()); + o.bv.push_back (blob (blb.size ())); + o.bv.push_back (blob (blb.size ())); + + db->persist (o); + + print (o.t); + print (o.b); + print (o.bv[0]); + print (o.bv[1]); + + blob_stream bs (o.b, true); + bs.write (blb.data (), blb.size ()); + + text_stream ts (o.t, true); + ts.write (txt.data (), txt.size ()); + + for (vector::iterator i (o.bv.begin ()); i != o.bv.end (); ++i) + { + blob_stream bs (*i, true); + bs.write (blb.data (), blb.size ()); + } + + tx.commit (); + } + + { + transaction tx (db->begin ()); + unique_ptr p (db->load (o.id)); + + print (p->t); + print (p->b); + print (p->bv[0]); + print (p->bv[1]); + + text_stream ts (p->t, false); + string t (ts.size (), '*'); + ts.read (const_cast (t.c_str ()), t.size ()); + assert (t == txt); + + blob_stream bs (p->b, false); + vector b (bs.size (), '\0'); + bs.read (b.data (), b.size ()); + assert (b == blb); + + for (vector::iterator i (p->bv.begin ()); i != p->bv.end (); ++i) + { + blob_stream bs (*i, false); + vector b (bs.size (), '\0'); + bs.read (b.data (), b.size ()); + assert (b == blb); + } + + assert (p->nb.null ()); + + tx.commit (); + } + + txt.resize (txt.size () + 1, 't'); + txt[0] = 'A'; + txt[txt.size () - 1] = 'Z'; + + blb.resize (blb.size () - 1); + blb.front () = 'A'; + blb.back () = 'Z'; + + { + transaction tx (db->begin ()); + + o.t.clear (); + o.t.size (txt.size ()); + + o.b.clear (); + o.b.size (blb.size ()); + + o.bv[0].clear (); + o.bv[0].size (blb.size ()); + + o.bv[1].clear (); + o.bv[1].size (blb.size ()); + + o.nb = blob (blb.size ()); + + db->update (o); + + print (o.t); + print (o.b); + print (o.bv[0]); + print (o.bv[1]); + print (*o.nb); + + { + text_stream ts (o.t, true); + ts.write (txt.data (), txt.size ()); + } + + { + blob_stream bs (o.b, true); + bs.write (blb.data (), blb.size ()); + } + + for (vector::iterator i (o.bv.begin ()); i != o.bv.end (); ++i) + { + blob_stream bs (*i, true); + bs.write (blb.data (), blb.size ()); + } + + { + blob_stream bs (*o.nb, true); + bs.write (blb.data (), blb.size ()); + } + + tx.commit (); + } + + { + transaction tx (db->begin ()); + unique_ptr p (db->load (o.id)); + + print (p->t); + print (p->b); + print (p->bv[0]); + print (p->bv[1]); + print (*p->nb); + + text_stream ts (p->t, false); + string t (ts.size (), '*'); + ts.read (const_cast (t.c_str ()), t.size ()); + assert (t == txt); + + blob_stream bs (p->b, false); + vector b (bs.size (), '\0'); + bs.read (b.data (), b.size ()); + assert (b == blb); + + for (vector::iterator i (p->bv.begin ()); i != p->bv.end (); ++i) + { + blob_stream bs (*i, false); + vector b (bs.size (), '\0'); + bs.read (b.data (), b.size ()); + assert (b == blb); + } + + { + blob_stream bs (*p->nb, false); + vector b (bs.size (), '\0'); + bs.read (b.data (), b.size ()); + assert (b == blb); + } + + tx.commit (); + } + + // Test query. + // + + txt.resize (32); + blb.resize (64); + + { + transaction tx (db->begin ()); + + o.t.size (txt.size ()); + o.b.size (blb.size ()); + o.bv.clear (); + o.nb.reset (); + + db->update (o); + + text_stream ts (o.t, true); + ts.write (txt.data (), txt.size ()); + + blob_stream bs (o.b, true); + bs.write (blb.data (), blb.size ()); + + tx.commit (); + } + + { + typedef sqlite::query query; + transaction tx (db->begin ()); + + { + object o1 (db->query_value (query::t == txt)); + + blob_stream bs (o1.b, false); + vector b (bs.size (), '\0'); + bs.read (b.data (), b.size ()); + assert (b == blb); + } + + { + object o1 (db->query_value (query::b == blb)); + + text_stream ts (o1.t, false); + string t (ts.size (), '*'); + ts.read (const_cast (t.c_str ()), t.size ()); + assert (t == txt); + } + + tx.commit (); + } + + // Test view. + // + { + typedef sqlite::query query; + transaction tx (db->begin ()); + + view v (db->query_value (query::t == txt)); + + blob_stream bs (v.b, false); + vector b (bs.size (), '\0'); + bs.read (b.data (), b.size ()); + assert (b == blb); + + tx.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/sqlite/stream/test.hxx b/odb-tests/sqlite/stream/test.hxx new file mode 100644 index 0000000..9189a87 --- /dev/null +++ b/odb-tests/sqlite/stream/test.hxx @@ -0,0 +1,37 @@ +// file : sqlite/stream/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#include +#include + +#include +#include + +#pragma db object +struct object +{ + #pragma db id auto + unsigned long id; + + odb::sqlite::text t; + + #pragma db column("_123foo_bar") + odb::sqlite::blob b; + + std::vector bv; + + odb::nullable nb; +}; + +#pragma db view object(object) +struct view +{ + odb::sqlite::blob b; +}; + +#endif // TEST_HXX diff --git a/odb-tests/sqlite/stream/testscript b/odb-tests/sqlite/stream/testscript new file mode 100644 index 0000000..2b9f019 --- /dev/null +++ b/odb-tests/sqlite/stream/testscript @@ -0,0 +1,9 @@ +# file : sqlite/stream/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../sqlite.testscript + +: basics +: +$* diff --git a/odb-tests/sqlite/transaction/buildfile b/odb-tests/sqlite/transaction/buildfile new file mode 100644 index 0000000..e29092d --- /dev/null +++ b/odb-tests/sqlite/transaction/buildfile @@ -0,0 +1,30 @@ +# file : sqlite/transaction/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ +"sqlite should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-sqlite%lib{odb-sqlite} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix sqlitex_transaction_ \ + --generate-schema \ + --default-database common + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/sqlite/transaction/driver.cxx b/odb-tests/sqlite/transaction/driver.cxx new file mode 100644 index 0000000..80a0804 --- /dev/null +++ b/odb-tests/sqlite/transaction/driver.cxx @@ -0,0 +1,61 @@ +// file : sqlite/transaction/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test esoteric SQLite transaction semantics aspects. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace sqlite = odb::sqlite; +using namespace sqlite; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_specific_database (argc, argv)); + + // In SQLite, when a commit fails because of the deferred foreign + // key constraint violation, the transaction is not automatically + // rolled back. Make sure we compensate for that. + // + try + { + object o; + o.p = odb::lazy_ptr (*db, 0); + + transaction t (db->begin ()); + db->persist(o); + t.commit (); + } + catch (const odb::exception&) + { + } + + // Make sure we can start a new transaction. + // + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/sqlite/transaction/test.hxx b/odb-tests/sqlite/transaction/test.hxx new file mode 100644 index 0000000..bfb981b --- /dev/null +++ b/odb-tests/sqlite/transaction/test.hxx @@ -0,0 +1,26 @@ +// file : sqlite/transaction/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object +struct object1 +{ + #pragma db id + unsigned long id_; +}; + +#pragma db object +struct object +{ + #pragma db id auto + unsigned long id_; + + odb::lazy_ptr p; +}; + +#endif // TEST_HXX diff --git a/odb-tests/sqlite/transaction/testscript b/odb-tests/sqlite/transaction/testscript new file mode 100644 index 0000000..c3388cb --- /dev/null +++ b/odb-tests/sqlite/transaction/testscript @@ -0,0 +1,9 @@ +# file : sqlite/transaction/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../sqlite.testscript + +: basics +: +$* diff --git a/odb-tests/sqlite/truncation/buildfile b/odb-tests/sqlite/truncation/buildfile new file mode 100644 index 0000000..9a014e6 --- /dev/null +++ b/odb-tests/sqlite/truncation/buildfile @@ -0,0 +1,31 @@ +# file : sqlite/truncation/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ +"sqlite should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-sqlite%lib{odb-sqlite} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix sqlitex_truncation_ \ + --generate-schema \ + --default-database common \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/sqlite/truncation/driver.cxx b/odb-tests/sqlite/truncation/driver.cxx new file mode 100644 index 0000000..a2f6d66 --- /dev/null +++ b/odb-tests/sqlite/truncation/driver.cxx @@ -0,0 +1,163 @@ +// file : sqlite/truncation/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test insufficient buffer/truncation handling. +// + +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace sqlite = odb::sqlite; +using namespace sqlite; + +int +main (int argc, char* argv[]) +{ + // The default pre-allocated buffer is 512 bytes long. + // + string long_str (640, 'c'); // This will get the buffer to 1024 + string longer_str (1025, 'b'); + + try + { + // Test basic operations. + // + { + unique_ptr db (create_specific_database (argc, argv)); + + // Run persist/load so that the initial bindings are established + // (version == 0). + // + { + object1 o (1); + o.str_ = "test string"; + + transaction t (db->begin ()); + db->persist (o); + db->load (1, o); + t.commit (); + } + + { + object2 o (2); + o.str_ = "test string"; + + transaction t (db->begin ()); + db->persist (o); + db->load (2, o); + t.commit (); + } + + // Store/load the long string which should trigger buffer growth. + // + { + object1 o (3); + o.str_ = long_str; + + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (3)); + assert (o->str_ == long_str); + t.commit (); + } + + // Store/load longer string. + // + { + object1 o (3); + o.str_ = longer_str; + + transaction t (db->begin ()); + db->update (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o (db->load (3)); + assert (o->str_ == longer_str); + t.commit (); + } + } + + // Test query. + // + { + unique_ptr db (create_specific_database (argc, argv)); + + typedef sqlite::query query; + typedef odb::result result; + + // Run persist/query so that the initial bindings are established + // (version == 0). + // + { + object1 o (20); + o.str_ = "test string"; + + transaction t (db->begin ()); + db->persist (o); + o.id_++; + db->persist (o); + o.id_++; + db->persist (o); + + result r (db->query (query::id == 20)); + assert (r.begin ()->id_ == 20); + t.commit (); + } + + // Test buffer growth with cached result. + // + { + object1 o; + + transaction t (db->begin ()); + + result r (db->query (query::id >= 20)); + result::iterator i (r.begin ()); + + o.id_ = i->id_; + o.str_ = long_str; + + // This forces buffer growth in the middle of result iteration. + // + db->update (o); + + ++i; + assert (i->str_ == "test string"); + + o.id_ = i->id_; + o.str_ = longer_str; + db->update (o); + + ++i; + assert (i->str_ == "test string"); + + t.commit (); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/sqlite/truncation/test.hxx b/odb-tests/sqlite/truncation/test.hxx new file mode 100644 index 0000000..8ca44ea --- /dev/null +++ b/odb-tests/sqlite/truncation/test.hxx @@ -0,0 +1,46 @@ +// file : sqlite/truncation/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object table ("test") +struct object1 +{ + object1 (unsigned long id) + : id_ (id) + { + } + + object1 () + { + } + + #pragma db id + unsigned long id_; + + std::string str_; +}; + +#pragma db object table ("test") +struct object2 +{ + object2 (unsigned long id) + : id_ (id) + { + } + + object2 () + { + } + + #pragma db id + unsigned long id_; + + std::string str_; +}; + +#endif // TEST_HXX diff --git a/odb-tests/sqlite/truncation/testscript b/odb-tests/sqlite/truncation/testscript new file mode 100644 index 0000000..97e04f7 --- /dev/null +++ b/odb-tests/sqlite/truncation/testscript @@ -0,0 +1,9 @@ +# file : sqlite/truncation/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../sqlite.testscript + +: basics +: +$* diff --git a/odb-tests/sqlite/types/buildfile b/odb-tests/sqlite/types/buildfile new file mode 100644 index 0000000..1bf719d --- /dev/null +++ b/odb-tests/sqlite/types/buildfile @@ -0,0 +1,32 @@ +# file : sqlite/types/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ +"sqlite should be configured via config.odb_tests.database variable as a single database" + +import libodb = libodb%lib{odb} + +import libs = libodb-sqlite%lib{odb-sqlite} +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix sqlitex_types_ \ + --generate-schema \ + --default-database common \ + --generate-query \ + --cxx-prologue '#include "traits.hxx"' + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/odb-tests/sqlite/types/driver.cxx b/odb-tests/sqlite/types/driver.cxx new file mode 100644 index 0000000..b444d94 --- /dev/null +++ b/odb-tests/sqlite/types/driver.cxx @@ -0,0 +1,113 @@ +// file : sqlite/types/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test SQLite type conversion. +// + +#include // std::numeric_limits +#include // std::unique_ptr +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +#undef NDEBUG +#include + +using namespace std; +namespace sqlite = odb::sqlite; +using namespace sqlite; + +int +main (int argc, char* argv[]) +{ + try + { + unique_ptr db (create_specific_database (argc, argv)); + + object o (1); + + o.bool_ = true; + o.integer_ = -123456; + o.real_ = 1.123; + o.nan_ = numeric_limits::quiet_NaN (); + + string long_str (2040, 'l'); + + o.text_ = long_str; +#ifdef _WIN32 + o.wtext_ = L"t\x00C8st string"; +#endif + o.blob_.assign (long_str.c_str (), long_str.c_str () + long_str.size ()); + + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr o1 (db->load (1)); + t.commit (); + + assert (o == *o1); + } + +#ifdef _WIN32 + { + typedef sqlite::query query; + typedef odb::result result; + + transaction t (db->begin ()); + result r (db->query (query::wtext == L"t\x00C8st string")); + assert (!r.empty ()); + t.commit (); + } +#endif + + // Test char/wchar_t arrays + // + { +#ifndef _WIN32 + char_array o1 (1, ""); + char_array o2 (2, "1234567890"); + char_array o3 (3, "12345678901234567"); +#else + char_array o1 (1, "", L""); + char_array o2 (2, "1234567890", L"123456789\x00C8"); + char_array o3 (3, "12345678901234567", L"1234567890123456\x00C8"); +#endif + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + } + + { + transaction t (db->begin ()); + unique_ptr p1 (db->load (1)); + unique_ptr p2 (db->load (2)); + unique_ptr p3 (db->load (3)); + t.commit (); + + assert (o1 == *p1); + assert (o2 == *p2); + assert (o3 == *p3); + } + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/sqlite/types/test.hxx b/odb-tests/sqlite/types/test.hxx new file mode 100644 index 0000000..fe0b274 --- /dev/null +++ b/odb-tests/sqlite/types/test.hxx @@ -0,0 +1,125 @@ +// file : sqlite/types/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include +#include +#include // std::unique_ptr +#include // std::memcpy, std::str[n]cmp, std::strlen + +#ifdef _WIN32 +# include // std::wcslen, std::wcs[n]cmp +#endif + +#include + +typedef std::unique_ptr string_ptr; + +#pragma db object +struct object +{ + object () {} + object (unsigned long id): id_ (id) {} + + #pragma db id + unsigned long id_; + + #pragma db type("BOOL") + bool bool_; + + #pragma db type("INTEGER") + int integer_; + + #pragma db type("REAL") + double real_; + + double nan_; // Represented in SQLite as NULL. + + #pragma db type("TEXT") + std::string text_; + +#ifdef _WIN32 + std::wstring wtext_; +#endif + + #pragma db type("BLOB") + std::vector blob_; + + // Test NULL value. + // + #pragma db type("TEXT") null + string_ptr null_; + + bool + operator== (const object& y) const + { + return id_ == y.id_ + && bool_ == y.bool_ + && integer_ == y.integer_ + && real_ == y.real_ + && nan_ != nan_ + && text_ == y.text_ +#ifdef _WIN32 + && wtext_ == y.wtext_ +#endif + && blob_ == y.blob_ + && ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_); + } +}; + +// Test char/wchar_t arrays. +// +#pragma db object +struct char_array +{ + char_array () {} + char_array (unsigned long id + , const char* s +#ifdef _WIN32 + , const wchar_t* ws +#endif + ) + : id_ (id) + { + std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation. + s2[0] = c1 = *s; + +#ifdef _WIN32 + std::memcpy (ws1, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t)); + ws2[0] = wc1 = *ws; +#endif + } + + #pragma db id + unsigned long id_; + + char s1[17]; + char s2[1]; + char c1; + +#ifdef _WIN32 + wchar_t ws1[17]; + wchar_t ws2[1]; + wchar_t wc1; +#endif + + bool + operator== (const char_array& y) const + { + return id_ == y.id_ + && std::strncmp (s1, y.s1, sizeof (s1)) == 0 + && s2[0] == y.s2[0] + && c1 == y.c1 +#ifdef _WIN32 + && std::wcsncmp (ws1, y.ws1, sizeof (ws1) / 2) == 0 + && ws2[0] == y.ws2[0] + && wc1 == y.wc1 +#endif + ; + } +}; + +#endif // TEST_HXX diff --git a/odb-tests/sqlite/types/testscript b/odb-tests/sqlite/types/testscript new file mode 100644 index 0000000..5e50d32 --- /dev/null +++ b/odb-tests/sqlite/types/testscript @@ -0,0 +1,9 @@ +# file : sqlite/types/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../database-options.testscript +.include ../../sqlite.testscript + +: basics +: +$* diff --git a/odb-tests/sqlite/types/traits.hxx b/odb-tests/sqlite/types/traits.hxx new file mode 100644 index 0000000..9483f58 --- /dev/null +++ b/odb-tests/sqlite/types/traits.hxx @@ -0,0 +1,57 @@ +// file : sqlite/types/traits.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TRAITS_HXX +#define TRAITS_HXX + +#include // std::memcpy, std::memset + +#include + +#include "test.hxx" // string_ptr + +namespace odb +{ + namespace sqlite + { + template <> + class value_traits + { + public: + typedef string_ptr value_type; + typedef std::string query_type; + typedef details::buffer image_type; + + static void + set_value (string_ptr& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + v.reset (is_null ? 0 : new std::string (b.data (), n)); + } + + static void + set_image (details::buffer& b, + std::size_t& n, + bool& is_null, + const string_ptr& v) + { + is_null = v.get () == 0; + + if (!is_null) + { + n = v->size (); + + if (n > b.capacity ()) + b.capacity (n); + + if (n != 0) + std::memcpy (b.data (), v->c_str (), n); + } + } + }; + } +} + +#endif // TRAITS_HXX diff --git a/oracle/custom/custom.sql b/oracle/custom/custom.sql deleted file mode 100644 index 6e22903..0000000 --- a/oracle/custom/custom.sql +++ /dev/null @@ -1,53 +0,0 @@ -/* This file contains custom type definitions and helper functions. - */ - -/* For some reason CREATE OR REPLACE TYPE does not work on Oracle 10.2. */ -BEGIN - BEGIN - EXECUTE IMMEDIATE 'DROP TYPE Numbers'; - EXCEPTION - WHEN OTHERS THEN - IF SQLCODE != -4043 THEN RAISE; END IF; - END; -END; -/ - -CREATE TYPE Numbers AS VARRAY(100) OF NUMBER(10); -/ - -CREATE OR REPLACE FUNCTION string_to_numbers(in_str IN VARCHAR2) RETURN Numbers -IS - ret Numbers := Numbers(); - s_pos NUMBER := 1; - e_pos NUMBER := 0; -BEGIN - IF in_str IS NOT NULL THEN - LOOP - e_pos := INSTR(in_str, ',', s_pos); - EXIT WHEN e_pos = 0; - ret.extend; - ret(ret.COUNT) := CAST(SUBSTR(in_str, s_pos, e_pos - s_pos) AS NUMBER); - s_pos := e_pos + 1; - END LOOP; - ret.extend; - ret(ret.COUNT) := CAST(SUBSTR(in_str, s_pos) AS NUMBER); - END IF; - RETURN ret; -END; -/ - -CREATE OR REPLACE FUNCTION numbers_to_string(in_nums IN Numbers) RETURN VARCHAR2 -IS - ret VARCHAR2(1500); -BEGIN - IF in_nums.COUNT != 0 THEN - FOR i IN in_nums.FIRST .. in_nums.LAST LOOP - IF i != in_nums.FIRST THEN - ret := ret || ','; - END IF; - ret := ret || in_nums(i); - END LOOP; - END IF; - RETURN ret; -END; -/ diff --git a/oracle/custom/driver.cxx b/oracle/custom/driver.cxx deleted file mode 100644 index 45f0a4e..0000000 --- a/oracle/custom/driver.cxx +++ /dev/null @@ -1,77 +0,0 @@ -// file : oracle/custom/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test custom database type mapping in Oracle. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -namespace oracle = odb::oracle; -using namespace oracle; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_specific_database (argc, argv)); - - object o (1); - o.iv.push_back (123); - o.iv.push_back (234); - o.iv.push_back (-345); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - - // Update. - // - o.iv[0]++; - o.iv.pop_back (); - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/oracle/custom/test.hxx b/oracle/custom/test.hxx deleted file mode 100644 index 523d50b..0000000 --- a/oracle/custom/test.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// file : oracle/custom/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -// Map Numbers VARRAY Oracle type to std::vector. This type is defined -// in the custom.sql file along with two helper functions that convert -// between Numbers and its string representation. The other half of this -// mapping is in traits.hxx (value_traits, id_string>). -// -#pragma db map type("Numbers") \ - as("VARCHAR2(1500)") \ - to("CAST(string_to_numbers((?)) AS Numbers)") \ - from("numbers_to_string((?))") - -#pragma db object -struct object -{ - object () {} - object (unsigned long id_) : id (id_) {} - - #pragma db id - unsigned long id; - - #pragma db type("Numbers") - std::vector iv; - - bool - operator== (const object& y) const - { - return id == y.id && iv == y.iv; - } -}; - -#endif // TEST_HXX diff --git a/oracle/custom/traits.hxx b/oracle/custom/traits.hxx deleted file mode 100644 index 8df2f91..0000000 --- a/oracle/custom/traits.hxx +++ /dev/null @@ -1,76 +0,0 @@ -// file : oracle/types/traits.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TRAITS_HXX -#define TRAITS_HXX - -#include -#include -#include // std::memcpy -#include // std::memcpy - -#include - -namespace odb -{ - namespace oracle - { - - template <> - class value_traits, id_string> - { - public: - typedef std::vector value_type; - typedef value_type query_type; - typedef details::buffer image_type; - - static void - set_value (value_type& v, - const char* b, - std::size_t n, - bool is_null) - { - v.clear (); - - if (!is_null) - { - // Array format is "n1,n2,n3...". - // - std::istringstream is (std::string (b, n)); - - for (char c; !is.eof (); is >> c) - { - v.push_back (int ()); - is >> v.back (); - } - } - } - - static void - set_image (char* b, - std::size_t c, - std::size_t& n, - bool& is_null, - const value_type& v) - { - is_null = false; - std::ostringstream os; - - for (value_type::const_iterator i (v.begin ()), e (v.end ()); i != e;) - { - os << *i; - - if (++i != e) - os << ','; - } - - const std::string& s (os.str ()); - n = s.size (); - assert (n <= c); - std::memcpy (b, s.c_str (), n); - } - }; - } -} - -#endif // TRAITS_HXX diff --git a/oracle/database/driver.cxx b/oracle/database/driver.cxx deleted file mode 100644 index 499f136..0000000 --- a/oracle/database/driver.cxx +++ /dev/null @@ -1,33 +0,0 @@ -// file : oracle/database/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test that database constructors are unambiguous (compilation only). -// - -#include - -namespace oracle = odb::oracle; -using namespace oracle; - -int -main (int argc, char* argv[]) -{ - // This code should not execute. - // - if (argc != 0) - return 0; - - { - database d1 ("bob", "secret", "db1"); - } - - { - database d1 ("bob", "secret", "svc1", "server1"); - database d2 ("bob", "secret", "svc1", "server1", 999); - } - - { - database d1 (argc, argv); - database d2 (argc, argv, false); - } -} diff --git a/oracle/native/driver.cxx b/oracle/native/driver.cxx deleted file mode 100644 index 541d21e..0000000 --- a/oracle/native/driver.cxx +++ /dev/null @@ -1,77 +0,0 @@ -// file : oracle/native/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test native SQL execution. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -using namespace std; -namespace oracle = odb::oracle; -using namespace oracle; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_specific_database (argc, argv)); - - // Create the database schema. - // - { - transaction t (db->begin ()); - - db->execute ("BEGIN " - " EXECUTE IMMEDIATE 'DROP TABLE oracle_native_test'; " - " EXCEPTION " - " WHEN OTHERS THEN " - " IF SQLCODE != -942 THEN RAISE; END IF; " - "END;"); - - db->execute ("CREATE TABLE oracle_native_test (n NUMERIC(10,0))"); - - t.commit (); - } - - // Insert a few rows. - // - { - transaction t (db->begin ()); - - assert ( - db->execute ("INSERT INTO oracle_native_test (n) VALUES (1)") == 1); - - assert ( - db->execute ("INSERT INTO oracle_native_test (n) VALUES (2)") == 1); - - t.commit (); - } - - // Select a few rows. - // - { - transaction t (db->begin ()); - - assert ( - db->execute ("SELECT n FROM oracle_native_test WHERE n < 3") == 2); - - assert ( - db->execute ("SELECT n FROM oracle_native_test WHERE n > 3") == 0); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/oracle/template/driver.cxx b/oracle/template/driver.cxx deleted file mode 100644 index 13317df..0000000 --- a/oracle/template/driver.cxx +++ /dev/null @@ -1,40 +0,0 @@ -// file : oracle/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -namespace oracle = odb::oracle; -using namespace oracle; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_specific_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/oracle/template/template-vc10.vcxproj b/oracle/template/template-vc10.vcxproj deleted file mode 100644 index 92066cf..0000000 --- a/oracle/template/template-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/oracle/template/template-vc10.vcxproj.filters b/oracle/template/template-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/oracle/template/template-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/oracle/template/template-vc11.vcxproj b/oracle/template/template-vc11.vcxproj deleted file mode 100644 index a92e437..0000000 --- a/oracle/template/template-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\libcommon\lib64\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/oracle/template/template-vc11.vcxproj.filters b/oracle/template/template-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/oracle/template/template-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/oracle/template/template-vc12.vcxproj b/oracle/template/template-vc12.vcxproj deleted file mode 100644 index de35c03..0000000 --- a/oracle/template/template-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-d.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\libcommon\lib64\common.lib;odb-oracle.lib;odb.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/oracle/template/template-vc12.vcxproj.filters b/oracle/template/template-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/oracle/template/template-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/oracle/template/template-vc8.vcproj b/oracle/template/template-vc8.vcproj deleted file mode 100644 index 71e2b52..0000000 --- a/oracle/template/template-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/oracle/template/template-vc9.vcproj b/oracle/template/template-vc9.vcproj deleted file mode 100644 index de9804e..0000000 --- a/oracle/template/template-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), __value__(src_base)/, ) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/oracle/template/test.hxx b/oracle/template/test.hxx deleted file mode 100644 index bfa9cc9..0000000 --- a/oracle/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : oracle/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/oracle/types/driver.cxx b/oracle/types/driver.cxx deleted file mode 100644 index 2e3e2e7..0000000 --- a/oracle/types/driver.cxx +++ /dev/null @@ -1,366 +0,0 @@ -// file : oracle/types/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Oracle type conversion. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -namespace oracle = odb::oracle; -using namespace oracle; - -int -main (int argc, char* argv[]) -{ - try - { - // Create an Oracle database instance, setting both the client database - // and national character set to UTF-8. - // - auto_ptr db (create_specific_database (argc, argv)); - - object o (1); - - o.int_ = -123456; - o.uint_ = 123456; - o.long_long_ = -123456; - o.ulong_long_ = 123456; - - o.float_ = 1.123F; - o.double_ = 1.123; - o.num_float_ = 1.123F; - o.num_double_ = 1.123; - o.binary_float_ = 1.123F; - o.binary_double_ = 1.123; - - o.date_ = date_time (2010, 8, 29, 15, 33, 18, 0); - o.timestamp_ = date_time (1996, 3, 9, 18, 2, 54, 123000); - o.interval_ds_ = time_interval (0, 0, 13, 15, 23, 19, 123000); - o.interval_ym_ = time_interval (12, 3, 0, 0, 0, 0, 0); - - string vshort_str (8, 's'); - string short_str (13, 's'); - string medium_str (104, 'm'); - string long_str (1018, 'l'); - string vlong_str (15000, 'v'); - - o.char_ = short_str; - o.varchar2_ = medium_str; - o.clob_.assign (vlong_str.data (), vlong_str.data () + vlong_str.size ()); - - o.nchar_ = vshort_str; - o.nvarchar2_ = medium_str; - o.nclob_.assign (vlong_str.data (), vlong_str.data () + vlong_str.size ()); - - o.empty_c_.push_back (""); - - o.raw_.assign (long_str.data (), long_str.data () + long_str.size ()); - o.blob_.assign (vlong_str.data (), vlong_str.data () + vlong_str.size ()); - - o.strs_.push_back (short_str); - o.strs_.push_back (medium_str); - o.strs_.push_back (long_str); - o.strs_.push_back (vlong_str); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - - // Test character set conversion. - // - const char* unicode_str = "a \xD5\x95 \xEA\xAA\xAA \xF2\xAA\xAA\xAA"; - - // Testing of character set conversion to and from the client's database - // character set is disabled as the server database character set may - // not be able to represent some Unicode characters. If this were the case - // the test outcome would be a false negative. - // - // o.char_ = unicode_str; - // o.varchar2_ = unicode_str; - // o.clob_ = unicode_str; - - o.nchar_ = unicode_str; - o.nvarchar2_ = unicode_str; - o.nclob_ = unicode_str; - - // Persist. - // - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - - // Test 64 bit integers. - // - big_int bi1 (1, 0x8000000000000000LL); - big_int bi2 (2, -123456); - big_int bi3 (3, 0); - big_int bi4 (4, 123456); - big_int bi5 (5, 0xFFFFFFFFFFFFFFFFULL); - - big_uint bui1 (1, 0); - big_uint bui2 (2, 123456); - big_uint bui3 (3, 0xFFFFFFFFFFFFFFFFULL); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (bi1); - db->persist (bi2); - db->persist (bi3); - db->persist (bi4); - db->persist (bi5); - db->persist (bui1); - db->persist (bui2); - db->persist (bui3); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr bil1 (db->load (1)); - auto_ptr bil2 (db->load (2)); - auto_ptr bil3 (db->load (3)); - auto_ptr bil4 (db->load (4)); - auto_ptr bil5 (db->load (5)); - auto_ptr buil1 (db->load (1)); - auto_ptr buil2 (db->load (2)); - auto_ptr buil3 (db->load (3)); - t.commit (); - - assert (bi1 == *bil1); - assert (bi2 == *bil2); - assert (bi3 == *bil3); - assert (bi4 == *bil4); - assert (bi5 == *bil5); - assert (bui1 == *buil1); - assert (bui2 == *buil2); - assert (bui3 == *buil3); - } - - // Test large BLOBs. - // - descriptor b1 (1); - b1.blob.assign (50000, 'b'); - b1.timestamp = date_time (1996, 3, 9, 18, 2, 54, 123000); - b1.interval_ds = time_interval (0, 0, 13, 15, 23, 19, 123000); - b1.interval_ym = time_interval (12, 3, 0, 0, 0, 0, 0); - - descriptor b2 (2); - b2.blob.assign (500000, 'b'); - b2.timestamp = date_time (1997, 4, 10, 19, 3, 55, 234000); - b2.interval_ds = time_interval (0, 0, 14, 16, 24, 20, 234000); - b2.interval_ym = time_interval (13, 4, 0, 0, 0, 0, 0); - - descriptor b3 (3); - b3.blob.assign (5000, 'b'); - b3.timestamp = date_time (1995, 2, 8, 17, 1, 53, 120000); - b3.interval_ds = time_interval (0, 0, 12, 14, 22, 18, 120000); - b3.interval_ym = time_interval (11, 2, 0, 0, 0, 0, 0); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (b1); - db->persist (b2); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr p1 (db->load (1)); - auto_ptr p2 (db->load (2)); - t.commit (); - - assert (b1 == *p1); - assert (b2 == *p2); - } - - // Test image copying with descriptor-based type (LOB, date-time) data. - // - { - typedef oracle::query query; - typedef odb::result result; - - transaction t (db->begin ()); - - // Pre-bind the image for other operations. - // - { - db->persist (b3); - db->update (b3); - db->reload (b3); - db->erase (b3); - } - - - result r (db->query (query::id < 3)); - result::iterator i (r.begin ()); - - assert (i != r.end ()); - - { - result r (db->query (query::id > 1)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (*i == b2); - assert (++i == r.end ()); - } - - assert (*i == b1); // Load from copy (copy c-tor). - - ++i; - assert (i != r.end ()); - - { - result r (db->query (query::id < 2)); - result::iterator i (r.begin ()); - assert (i != r.end ()); - assert (*i == b1); - assert (++i == r.end ()); - } - - assert (*i == b2); // Load from copy (copy assign). - assert (++i == r.end ()); - - // Make sure all other operations are still working. - // - { - db->persist (b3); -#ifdef HAVE_CXX11 - unique_ptr p (db->load (3)); -#else - auto_ptr p (db->load (3)); -#endif - assert (b3 == *p); - b3.blob.push_back (123); - db->update (b3); - db->reload (p); - assert (b3 == *p); - db->erase (b3); - } - - t.commit (); - } - - // Test descriptor management in TIMESTAMP and INTERVAL images. - // - { - typedef oracle::query query; - typedef odb::result result; - - query q (query::timestamp == o.timestamp_ && - query::interval_ym == o.interval_ym_ && - query::interval_ds == o.interval_ds_); - - transaction t (db->begin ()); - - { - result r (db->query (q)); - assert (size (r) == 1); - } - - { - result r (db->query (q)); - assert (size (r) == 1); - } - - { - // Query temporary. - // - result r (db->query ( - query::timestamp == o.timestamp_ && - query::interval_ym == o.interval_ym_ && - query::interval_ds == o.interval_ds_)); - - query dummy (query::timestamp == o.timestamp_ && - query::interval_ym == o.interval_ym_ && - query::interval_ds == o.interval_ds_); - - assert (size (r) == 1); - } - - t.commit (); - } - - // Test char array. - // - { - char_array o1 (1, ""); - char_array o2 (2, "1234567890"); - char_array o3 (3, "1234567890123456"); - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - } - - // Oracle returns padded values for CHAR(N) unless they are - // empty (represented as NULL). - // - memcpy (o2.s2, "1234567890 ", 16); - - { - transaction t (db->begin ()); - auto_ptr p1 (db->load (1)); - auto_ptr p2 (db->load (2)); - auto_ptr p3 (db->load (3)); - t.commit (); - - assert (o1 == *p1); - assert (o2 == *p2); - assert (o3 == *p3); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/oracle/types/test.hxx b/oracle/types/test.hxx deleted file mode 100644 index 255bc08..0000000 --- a/oracle/types/test.hxx +++ /dev/null @@ -1,353 +0,0 @@ -// file : oracle/types/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include // HAVE_CXX11 - -#include -#include -#include // std::auto_ptr -#include // std::memcpy, std::str[n]cmp, std::strlen - -#include - -struct date_time -{ - date_time () - { - } - - date_time (unsigned short y, - unsigned char m, - unsigned char d, - unsigned char h, - unsigned char min, - unsigned char sec, - unsigned int nsec) - : year (y), - month (m), - day (d), - hour (h), - minute (min), - second (sec), - nanosecond (nsec) - { - } - - bool - operator== (const date_time& y) const - { - return - year == y.year && - month == y.month && - day == y.day && - hour == y.hour && - minute == y.minute && - second == y.second && - nanosecond == y.nanosecond; - } - - unsigned short year; - unsigned char month; - unsigned char day; - unsigned char hour; - unsigned char minute; - unsigned char second; - unsigned int nanosecond; -}; - -struct time_interval -{ - time_interval () - { - } - - time_interval (int y, int m, int d, int h, int min, int sec, int nsec) - : year (y), - month (m), - day (d), - hour (h), - minute (min), - second (sec), - nanosecond (nsec) - { - } - - bool - operator== (const time_interval& y) const - { - return - year == y.year && - month == y.month && - day == y.day && - hour == y.hour && - minute == y.minute && - second == y.second && - nanosecond == y.nanosecond; - } - - int year; - int month; - int day; - int hour; - int minute; - int second; - int nanosecond; -}; - -#ifdef HAVE_CXX11 -typedef std::unique_ptr string_ptr; -#else -typedef std::auto_ptr string_ptr; -#endif - -typedef std::vector strings; - -#pragma db object -struct object -{ - object () {} - object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned int id_; - - // Integral types. - // - #pragma db type ("NUMBER(10)") - int int_; - - #pragma db type ("NUMBER(10)") - unsigned uint_; - - #pragma db type ("NUMBER(19)") - long long long_long_; - - #pragma db type ("NUMBER(20)") - unsigned long long ulong_long_; - - // Float types. - // - #pragma db type ("FLOAT(24)") - float float_; - - #pragma db type ("FLOAT(53)") - double double_; - - #pragma db type ("NUMBER(7,3)") - float num_float_; - - #pragma db type ("NUMBER(15,5)") - double num_double_; - - #pragma db type ("BINARY_FLOAT") - float binary_float_; - - #pragma db type ("BINARY_DOUBLE") - double binary_double_; - - // Data-time types. - // - #pragma db type ("DATE") - date_time date_; - - #pragma db type ("TIMESTAMP(6)") - date_time timestamp_; - - #pragma db type ("INTERVAL DAY TO SECOND") - time_interval interval_ds_; - - #pragma db type ("INTERVAL YEAR TO MONTH") - time_interval interval_ym_; - - // String and binary types. - // - #pragma db type ("CHAR(13)") - std::string char_; - - #pragma db type ("VARCHAR2(512)") null - std::string varchar2_; - - #pragma db type ("NCHAR(8)") - std::string nchar_; - - #pragma db type ("NVARCHAR2(512)") null - std::string nvarchar2_; - - // Oracle treats empty and NULL VARCHAR2 the same. Test that we - // handle this. - // - std::string empty_; - std::vector empty_c_; - - #pragma db type ("RAW(1024)") - std::vector raw_; - - // LOB types. - // - #pragma db type ("BLOB") - std::vector blob_; - - #pragma db type ("CLOB") - std::string clob_; - - #pragma db type ("NCLOB") - std::string nclob_; - - // Test containers of LOBs - // - #pragma db value_type ("CLOB") - strings strs_; - - // Test NULL value. - // - #pragma db type ("VARCHAR2(32)") null - string_ptr null_; - - bool - operator== (const object& y) const - { - return - id_ == y.id_ && - int_ == y.int_ && - uint_ == y.uint_ && - long_long_ == y.long_long_ && - ulong_long_ == y.ulong_long_ && - float_ == y.float_ && - double_ == y.double_ && - num_float_ == y.num_float_ && - num_double_ == y.num_double_ && - binary_float_ == y.binary_float_ && - binary_double_ == y.binary_double_ && - date_ == y.date_ && - timestamp_ == y.timestamp_ && - interval_ds_ == y.interval_ds_ && - interval_ym_ == y.interval_ym_ && - char_ == y.char_ && - varchar2_ == y.varchar2_ && - nchar_ == y.nchar_ && - nvarchar2_ == y.nvarchar2_ && - empty_ == y.empty_ && - empty_c_ == y.empty_c_ && - raw_ == y.raw_ && - blob_ == y.blob_ && - clob_ == y.clob_ && - nclob_ == y.nclob_ && - strs_ == y.strs_ && - ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_); - } -}; - -#pragma db object -struct big_uint -{ - big_uint (unsigned int id = 0, unsigned long long v = 0) - : id_ (id), value (v) - { - } - - #pragma db id - unsigned int id_; - - unsigned long long value; - - bool - operator== (const big_uint& y) const - { - return id_ == y.id_ && value == y.value; - } -}; - -#pragma db object -struct big_int -{ - big_int (unsigned int id = 0, long long v = 0) - : id_ (id), value (v) - { - } - - #pragma db id - unsigned int id_; - - long long value; - - bool - operator== (const big_int& y) const - { - return id_ == y.id_ && value == y.value; - } -}; - -#pragma db object -struct descriptor -{ - descriptor (unsigned int id = 0): id_ (id) {} - - #pragma db id - unsigned int id_; - - #pragma db type ("BLOB") - std::vector blob; - - #pragma db type ("TIMESTAMP(6)") - date_time timestamp; - - #pragma db type ("INTERVAL DAY TO SECOND") - time_interval interval_ds; - - #pragma db type ("INTERVAL YEAR TO MONTH") - time_interval interval_ym; - - bool - operator== (const descriptor& y) const - { - return id_ == y.id_ && - blob == y.blob && - timestamp == y.timestamp && - interval_ds == y.interval_ds && - interval_ym == y.interval_ym; - } -}; - -// Test char array. -// -#pragma db object -struct char_array -{ - char_array () {} - char_array (unsigned long id, const char* s) - : id_ (id) - { - std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation. - std::memcpy (s2, s, std::strlen (s) + 1); - s3[0] = c1 = *s; - } - - #pragma db id - unsigned long id_; - - char s1[17]; - - #pragma db type("CHAR(16)") null - char s2[16]; - - #pragma db null - char s3[1]; - - #pragma db null - char c1; - - bool - operator== (const char_array& y) const - { - return id_ == y.id_ && - std::strcmp (s1, y.s1) == 0 && - std::strncmp (s2, y.s2, sizeof (s2)) == 0 && - s3[0] == y.s3[0] && - c1 == y.c1; - } -}; - -#endif // TEST_HXX diff --git a/oracle/types/traits.hxx b/oracle/types/traits.hxx deleted file mode 100644 index ad747d8..0000000 --- a/oracle/types/traits.hxx +++ /dev/null @@ -1,192 +0,0 @@ -// file : oracle/types/traits.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TRAITS_HXX -#define TRAITS_HXX - -#include // datetime, interval_ym, interval_ds -#include - -#include - -#include "test.hxx" // date_time, time_interval - -namespace odb -{ - namespace oracle - { - template <> - class value_traits - { - public: - typedef date_time value_type; - typedef date_time query_type; - typedef char* image_type; - - static void - set_value (date_time& v, const char* i, bool is_null) - { - if (!is_null) - { - short y (0); - unsigned char m (0), d (0), h (0), mins (0), s (0); - - details::get_date (i, y, m, d, h, mins, s); - - v.year = y; - v.month = m; - v.day = d; - v.hour = h; - v.minute = mins; - v.second = s; - - // Oracle DATE does not support fractional seconds. - // - v.nanosecond = 0; - } - } - - static void - set_image (char* i, bool& is_null, const date_time& v) - { - is_null = false; - details::set_date (i, - static_cast (v.year), - v.month, - v.day, - v.hour, - v.minute, - v.second); - } - }; - - template <> - class value_traits - { - public: - typedef date_time value_type; - typedef date_time query_type; - typedef datetime image_type; - - static void - set_value (date_time& v, const datetime& i, bool is_null) - { - if (!is_null) - { - sb2 y (0); - ub1 m (0), d (0), h (0), mins (0), s (0); - ub4 ns (0); - - i.get (y, m, d, h, mins, s, ns); - - v.year = y; - v.month = m; - v.day = d; - v.hour = h; - v.minute = mins; - v.second = s; - v.nanosecond = ns; - } - } - - static void - set_image (datetime& i, - bool& is_null, - const date_time& v) - { - is_null = false; - - i.set (static_cast (v.year), - v.month, - v.day, - v.hour, - v.minute, - v.second, - v.nanosecond); - } - }; - - template <> - class value_traits - { - public: - typedef time_interval value_type; - typedef time_interval query_type; - typedef interval_ds image_type; - - static void - set_value (time_interval& v, - const interval_ds& i, - bool is_null) - { - if (!is_null) - { - sb4 d (0), h (0), m (0), s (0), ns (0); - i.get (d, h, m, s, ns); - - v.year = 0; - v.month = 0; - v.day = static_cast (d); - v.hour = static_cast (h); - v.minute = static_cast (m); - v.second = static_cast (s); - v.nanosecond = static_cast (ns); - } - } - - static void - set_image (interval_ds& i, - bool& is_null, - const time_interval& v) - { - is_null = false; - - i.set (v.day, - v.hour, - v.minute, - v.second, - static_cast (v.nanosecond)); - } - }; - - template <> - class value_traits - { - public: - typedef time_interval value_type; - typedef time_interval query_type; - typedef interval_ym image_type; - - static void - set_value (time_interval& v, - const interval_ym& i, - bool is_null) - { - if (!is_null) - { - sb4 y (0), m (0); - i.get (y, m); - - v.year = static_cast (y); - v.month = static_cast (m); - v.day = 0; - v.hour = 0; - v.minute = 0; - v.second = 0; - v.nanosecond = 0; - } - } - - static void - set_image (interval_ym& i, - bool& is_null, - const time_interval& v) - { - is_null = false; - i.set (v.year, v.month); - } - }; - } -} - -#endif // TRAITS_HXX diff --git a/pgsql-schema.testscript b/pgsql-schema.testscript deleted file mode 100644 index 8659bcd..0000000 --- a/pgsql-schema.testscript +++ /dev/null @@ -1,6 +0,0 @@ -# file : pgsql-schema.testscript -# license : GNU GPL v2; see accompanying LICENSE file - -# Create the PostgreSQL database schema creation canned command base. -# -create_schema_cmd = [cmdline] $pgsql_client_cmd diff --git a/pgsql.testscript b/pgsql.testscript deleted file mode 100644 index e4b4636..0000000 --- a/pgsql.testscript +++ /dev/null @@ -1,12 +0,0 @@ -# file : pgsql.testscript -# license : GNU GPL v2; see accompanying LICENSE file - -# Create the PostgreSQL database schema creation canned command and setup the -# test driver command line for the subsequent tests. -# -.include pgsql-schema.testscript - -schema_file = [path] $out_base/"$schema"($multi ? '-pgsql' : '').sql -create_schema = [cmdline] $create_schema_cmd -f $schema_file - -test.arguments += ($multi ? 'pgsql' : ) $pgsql_options diff --git a/pgsql/buildfile b/pgsql/buildfile deleted file mode 100644 index c6385c0..0000000 --- a/pgsql/buildfile +++ /dev/null @@ -1,6 +0,0 @@ -# file : pgsql/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -./: {*/ -bulk/} - -./: bulk/: include = ($pgsql && !$multi && $pgsql_bulk) diff --git a/pgsql/bulk/buildfile b/pgsql/bulk/buildfile deleted file mode 100644 index 6984edb..0000000 --- a/pgsql/bulk/buildfile +++ /dev/null @@ -1,40 +0,0 @@ -# file : pgsql/bulk/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -if ($build.meta_operation != 'dist') -{ - assert ($pgsql && !$multi) \ - "pgsql should be configured via config.odb_tests.database variable as a single database" - - assert ($pgsql_bulk) "bulk operations are disabled for pgsql" -} - -import libodb = libodb%lib{odb} - -import libs = libpq%lib{pq} -import libs += libodb-pgsql%lib{odb-pgsql} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix pgsql_bulk_ \ - --generate-schema \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/pgsql/bulk/driver.cxx b/pgsql/bulk/driver.cxx deleted file mode 100644 index ba25542..0000000 --- a/pgsql/bulk/driver.cxx +++ /dev/null @@ -1,361 +0,0 @@ -// file : pgsql/bulk/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test transaction savepoints. -// - -#include - -#include -#include -#include -#include -#include - -// Note: hack. -// -#include -#define htonll(x) ((((long long)htonl(x)) << 32) + htonl((x) >> 32)) - -#undef NDEBUG -#include - -static const size_t columns = 3; - -struct data -{ - long long id; - long long idata; - const char* sdata; -}; - -static char* values[columns]; -static int lengths[columns]; -static int formats[columns] = {1, 1, 1}; - -static const unsigned int types[columns] = { - 20, // int8 - 20, // int8 - 25 // text -}; - -static void -init (const struct data* d) -{ - values[0] = (char*)&d->id; - lengths[0] = sizeof (d->id); - - values[1] = (char*)&d->idata; - lengths[1] = sizeof (d->idata); - - values[2] = (char*)d->sdata; - lengths[2] = strlen (d->sdata); -} - -static void -execute (PGconn* conn, const struct data* ds, size_t n) -{ - int sock = PQsocket (conn); - assert (sock != -1); - - if (PQsetnonblocking (conn, 1) == -1 || - PQenterPipelineMode (conn) == 0) - assert (false); - - // True if we've written and read everything, respectively. - // - bool wdone = false; - bool rdone = false; - - size_t wn = 0; - size_t rn = 0; - - while (!rdone) - { - fd_set wds; - if (!wdone) - { - FD_ZERO (&wds); - FD_SET (sock, &wds); - } - - fd_set rds; - FD_ZERO (&rds); - FD_SET (sock, &rds); - - if (select (sock + 1, &rds, wdone ? NULL : &wds, NULL, NULL) == -1) - { - if (errno == EINTR) - continue; - - assert (false); - } - - // Try to minimize the chance of blocking the server by first processing - // the result and then sending more queries. - // - if (FD_ISSET (sock, &rds)) - { - if (PQconsumeInput (conn) == 0) - assert (false); - - while (wn > rn && PQisBusy (conn) == 0) - { - //fprintf (stderr, "PQgetResult %zu\n", rn); - - PGresult* res = PQgetResult (conn); - assert (res != NULL); - ExecStatusType stat = PQresultStatus (res); - - if (stat == PGRES_PIPELINE_SYNC) - { - assert (wdone && rn == n); - PQclear (res); - rdone = true; - break; - } - - if (stat == PGRES_FATAL_ERROR) - { - const char* s = PQresultErrorField (res, PG_DIAG_SQLSTATE); - - if (strcmp (s, "23505") == 0) - fprintf (stderr, "duplicate id at %zu\n", rn); - } - - PQclear (res); - assert (rn != n); - ++rn; - - // We get a NULL result after each query result. - // - { - PGresult* end = PQgetResult (conn); - assert (end == NULL); - } - } - } - - if (!wdone && FD_ISSET (sock, &wds)) - { - // Send queries until we get blocked (write-biased). This feels like - // a better overall strategy to keep the server busy compared to - // sending one query at a time and then re-checking if there is - // anything to read because the results of INSERT/UPDATE/DELETE are - // presumably small and quite a few of them can get buffered before - // the server gets blocked. - // - for (;;) - { - if (wn < n) - { - //fprintf (stderr, "PQsendQueryPrepared %zu\n", wn); - - init (ds + wn); - - if (PQsendQueryPrepared (conn, - "persist_object", - (int)(columns), - values, - lengths, - formats, - 1) == 0) - assert (false); - - if (++wn == n) - { - if (PQpipelineSync (conn) == 0) - assert (false); - - ++wn; - } - } - - // PQflush() result: - // - // 0 -- success (queue is now empty) - // 1 -- blocked - // -1 -- error - // - int r = PQflush (conn); - assert (r != -1); - - if (r == 0) - { - if (wn < n) - { - // If we continue here, then we are write-biased. And if we - // break, then we are read-biased. - // -#if 0 - break; -#else - continue; -#endif - } - - wdone = true; - } - - break; // Blocked or done. - } - } - } - - if (PQexitPipelineMode (conn) == 0 || - PQsetnonblocking (conn, 0) == -1) - assert (false); -} - -static void -test (PGconn* conn) -{ - const size_t batch = 500; - struct data ds[batch]; - - for (size_t i = 0; i != batch; ++i) - { - ds[i].id = htonll (i == batch / 2 ? i - 1 : i); // Cause duplicate PK. - ds[i].idata = htonll (i); - ds[i].sdata = "abc"; - } - - // Prepare the statement. - // - { - PGresult* res = PQprepare ( - conn, - "persist_object", - "INSERT INTO \"pgsql_bulk_object\" " - "(\"id\", " - "\"idata\", " - "\"sdata\") " - "VALUES " - "($1, $2, $3)", - (int)(columns), - types); - assert (PQresultStatus (res) == PGRES_COMMAND_OK); - PQclear (res); - } - - // Begin transaction. - // - { - PGresult* res = PQexec (conn, "begin"); - assert (PQresultStatus (res) == PGRES_COMMAND_OK); - PQclear (res); - } - - execute (conn, ds, batch); - - // Commit transaction. - // - { - PGresult* res = PQexec (conn, "commit"); - assert (PQresultStatus (res) == PGRES_COMMAND_OK); - PQclear (res); - } -} - -#include -#include // std::unique_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace pgsql = odb::pgsql; -using namespace pgsql; - -int -main (int argc, char* argv[]) -{ - bool fail_already_persistent (false); - - for (int i (1); i != argc; ++i) - { - if (strcmp (argv[i], "--fail-already-persistent") == 0) - { - fail_already_persistent = true; - - for (; i != argc - 1; ++i) - argv[i] = argv[i + 1]; - - --argc; - - break; - } - } - - try - { - unique_ptr db (create_specific_database (argc, argv)); - - connection_ptr cn (db->connection ()); - - if (false) - { - PGconn* conn (cn->handle ()); - test (conn); - } - - { - const unsigned long n (500); - - vector os; - - for (unsigned long i (0); i != n; ++i) - { - os.push_back (object {i, i, string (i, 'x')}); - - if (fail_already_persistent && i == n / 2) - os.push_back (object {i, i, to_string (i)}); - } - - { - transaction t (cn->begin ()); - db->persist (os.begin (), os.end ()); - t.commit (); - } - - { - transaction t (cn->begin ()); - db->find (2); - t.commit (); - } - - for (unsigned long i (0); i != n; ++i) - { - //assert (os[i].id == i + 1); - os[i].idata++; - } - - { - transaction t (cn->begin ()); - db->update (os.begin (), os.end ()); - t.commit (); - } - - { - transaction t (cn->begin ()); - db->erase (os.begin (), os.end ()); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/pgsql/bulk/test.hxx b/pgsql/bulk/test.hxx deleted file mode 100644 index 25dd138..0000000 --- a/pgsql/bulk/test.hxx +++ /dev/null @@ -1,34 +0,0 @@ -// file : pgsql/savepoint/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object bulk(1000) -struct object -{ - /* - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - */ - - #pragma db id //auto - unsigned long id; - - unsigned long idata; - - //#pragma db - std::string sdata; -}; - -#endif // TEST_HXX diff --git a/pgsql/bulk/testscript b/pgsql/bulk/testscript deleted file mode 100644 index 60b7d92..0000000 --- a/pgsql/bulk/testscript +++ /dev/null @@ -1,18 +0,0 @@ -# file : pgsql/custom/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../pgsql.testscript - -+$create_schema - -: basics -: -{ - $*; - - $* --fail-already-persistent 2>>EOE != 0 - multiple exceptions, 252 elements attempted, 1 failed, fatal: - [251] object already persistent - EOE -} diff --git a/pgsql/custom/buildfile b/pgsql/custom/buildfile deleted file mode 100644 index a5c6717..0000000 --- a/pgsql/custom/buildfile +++ /dev/null @@ -1,37 +0,0 @@ -# file : pgsql/custom/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ -"pgsql should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-pgsql%lib{odb-pgsql} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix pgsql_custom_ \ - --generate-schema \ - --default-database common \ - --generate-query \ - --hxx-prologue '#include "traits.hxx"' \ - --hxx-prologue '#include "query.hxx"' - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/pgsql/custom/driver.cxx b/pgsql/custom/driver.cxx deleted file mode 100644 index 91ff0ce..0000000 --- a/pgsql/custom/driver.cxx +++ /dev/null @@ -1,125 +0,0 @@ -// file : pgsql/custom/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test custom database type mapping in PostgreSQL. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace pgsql = odb::pgsql; -using namespace pgsql; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_specific_database (argc, argv)); - - object o (1); - o.p = point (1.1111, 2222222222.2); - o.pv.push_back (point (1.1234, 2.2345)); - o.pv.push_back (point (3.3456, 4.4567)); - o.pv.push_back (point (0.0000001, 0.000000001)); // Scientific notation. - - o.n1 = "23.5154"; - o.n2 = "235154"; - o.n3 = "2222222222222222222222222222.111111111111111111111111111111"; - - o.iv.push_back (123); - o.iv.push_back (234); - o.iv.push_back (-345); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - - // Query. - // - typedef pgsql::query query; - typedef odb::result result; - - { - transaction t (db->begin ()); - - // Point comparison. - // - { - result r (db->query (query::p == o.p)); - assert (!r.empty ()); - } - - // Point comparison using native query. - // - { - result r (db->query (query::p + "~=" + query::_val (o.p))); - assert (!r.empty ()); - } - - // Access to individual members. - // - { - result r (db->query (query::p.x == o.p.x)); - assert (!r.empty ()); - } - - t.commit (); - } - - // Update. - // - o.p.x++; - o.p.y--; - o.pv[1].x--; - o.pv[1].y++; - o.n3 += "999"; - o.iv[0]++; - o.iv.pop_back (); - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/pgsql/custom/query.hxx b/pgsql/custom/query.hxx deleted file mode 100644 index 8b89047..0000000 --- a/pgsql/custom/query.hxx +++ /dev/null @@ -1,158 +0,0 @@ -// file : pgsql/custom/query.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef QUERY_HXX -#define QUERY_HXX - -#include - -#include - -#include "test.hxx" // point - -namespace odb -{ - namespace pgsql - { - template <> - struct query_column - { - private: - const char* table_; - const char* column_; - const char* conversion_; - - std::string x_column_; - std::string y_column_; - - // Sub-columns for individual members. - // - public: - query_column x, y; - - // is_null, is_not_null - // - public: - query_base - is_null () const - { - query_base q (table_, column_); - q += "IS NULL"; - return q; - } - - query_base - is_not_null () const - { - query_base q (table_, column_); - q += "IS NOT NULL"; - return q; - } - - // = - // - public: - query_base - equal (const point& v) const - { - return equal (val_bind (v)); - } - - query_base - equal (val_bind v) const - { - query_base q (table_, column_); - q += "~="; - q.append (v, conversion_); - return q; - } - - query_base - equal (ref_bind r) const - { - query_base q (table_, column_); - q += "~="; - q.append (r, conversion_); - return q; - } - - friend query_base - operator== (const query_column& c, const point& v) - { - return c.equal (v); - } - - friend query_base - operator== (const point& v, const query_column& c) - { - return c.equal (v); - } - - friend query_base - operator== (const query_column& c, val_bind v) - { - return c.equal (v); - } - - friend query_base - operator== (val_bind v, const query_column& c) - { - return c.equal (v); - } - - friend query_base - operator== (const query_column& c, ref_bind r) - { - return c.equal (r); - } - - friend query_base - operator== (ref_bind r, const query_column& c) - { - return c.equal (r); - } - - // Column comparison. - // - public: - query_base - operator== (const query_column& c) const - { - query_base q (table_, column_); - q += "~="; - q.append (c.table (), c.column ()); - return q; - } - - public: - query_column (const char* table, const char* column, const char* conv) - : table_ (table), column_ (column), conversion_ (conv), - x_column_ (std::string (column) + "[0]"), - y_column_ (std::string (column) + "[1]"), - x (table, x_column_.c_str (), 0), - y (table, y_column_.c_str (), 0) - { - } - - const char* - table () const - { - return table_; - } - - const char* - column () const - { - return column_; - } - - const char* - conversion () const - { - return conversion_; - } - }; - } -} - -#endif // QUERY_HXX diff --git a/pgsql/custom/test.hxx b/pgsql/custom/test.hxx deleted file mode 100644 index ec3d496..0000000 --- a/pgsql/custom/test.hxx +++ /dev/null @@ -1,86 +0,0 @@ -// file : pgsql/custom/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -// Map POINT PostgreSQL type to the point C++ struct. The other half -// of this mapping is in traits.hxx (value_traits). -// -#pragma db map type("POINT") as("TEXT") to("(?)::POINT") from("(?)::TEXT") - -#pragma db value type("POINT") -struct point -{ - point () {} - point (double x_, double y_): x (x_), y (y_) {} - - double x; - double y; -}; - -inline bool -operator== (const point& a, const point& b) -{ - return a.x == b.x && a.y == b.y; -} - -// Map NUMERIC PostgreSQL type to std::string (or any other type that -// provides the value_traits specialization). -// -#pragma db map type("NUMERIC *(\\(.+\\))?") \ - as("TEXT") \ - to("(?)::NUMERIC$1") \ - from("(?)::TEXT") - -// Map INTEGER[] PostgreSQL type to std::vector. The other half of -// this mapping is in traits.hxx (value_traits, id_string>). -// -#pragma db map type("INTEGER *\\[(\\d*)\\]") \ - as("TEXT") \ - to("(?)::INTEGER[$1]") \ - from("(?)::TEXT") - -#pragma db object -struct object -{ - object () {} - object (unsigned long id_) : id (id_) {} - - #pragma db id - unsigned long id; - - point p; - std::vector pv; - - #pragma db type("NUMERIC(6, 4)") - std::string n1; - - #pragma db type("NUMERIC(6)") - std::string n2; - - #pragma db type("NUMERIC") - std::string n3; - - #pragma db type("INTEGER [123]") - std::vector iv; - - bool - operator== (const object& y) const - { - return id == y.id && - p == y.p && - pv == y.pv && - n1 == y.n1 && - n2 == y.n2 && - n3 == y.n3 && - iv == y.iv; - } -}; - -#endif // TEST_HXX diff --git a/pgsql/custom/testscript b/pgsql/custom/testscript deleted file mode 100644 index 8e1448b..0000000 --- a/pgsql/custom/testscript +++ /dev/null @@ -1,11 +0,0 @@ -# file : pgsql/custom/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../pgsql.testscript - -+$create_schema - -: basics -: -$* diff --git a/pgsql/custom/traits.hxx b/pgsql/custom/traits.hxx deleted file mode 100644 index c45dec0..0000000 --- a/pgsql/custom/traits.hxx +++ /dev/null @@ -1,166 +0,0 @@ -// file : pgsql/custom/traits.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TRAITS_HXX -#define TRAITS_HXX - -#include // std::numeric_limits -#include -#include -#include // std::memcpy - -#include - -#include "test.hxx" // point - -namespace odb -{ - namespace pgsql - { - template <> - class value_traits - { - public: - typedef point value_type; - typedef point query_type; - typedef details::buffer image_type; - - static void - set_value (point& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - if (is_null) - v = point (); - else - { - // Point format is "(x,y)". - // - char c; - std::istringstream is (std::string (b.data (), n)); - - is >> c; // '(' - is >> v.x; - is >> c; // ',' - is >> v.y; - } - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const point& v) - { - is_null = false; - std::ostringstream os; - - // The formula for the number of decimla digits required is given in: - // - // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf - // - os.precision (std::numeric_limits::digits10); - // os.precision (2 + std::numeric_limits::digits * 301/1000); - - os << '(' << v.x << ',' << v.y << ')'; - - const std::string& s (os.str ()); - n = s.size (); - - if (n > b.capacity ()) - b.capacity (n); - - std::memcpy (b.data (), s.c_str (), n); - } - }; - - template <> - struct type_traits - { - static const database_type_id db_type_id = id_string; - - struct conversion - { - static const char* to () {return "(?)::POINT";} - }; - }; - - template <> - class value_traits, id_string> - { - public: - typedef std::vector value_type; - typedef value_type query_type; - typedef details::buffer image_type; - - static void - set_value (value_type& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - v.clear (); - - if (!is_null) - { - // Array format is "{n1,n2,n3...}". - // - char c; - std::istringstream is (std::string (b.data (), n)); - - is >> c; // '{' - - for (c = static_cast (is.peek ()); c != '}'; is >> c) - { - v.push_back (int ()); - is >> v.back (); - } - } - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const value_type& v) - { - is_null = false; - std::ostringstream os; - - os << '{'; - - for (value_type::const_iterator i (v.begin ()), e (v.end ()); i != e;) - { - os << *i; - - if (++i != e) - os << ','; - } - - os << '}'; - - const std::string& s (os.str ()); - n = s.size (); - - if (n > b.capacity ()) - b.capacity (n); - - std::memcpy (b.data (), s.c_str (), n); - } - }; - - template <> - struct type_traits > - { - static const database_type_id db_type_id = id_string; - - struct conversion - { - static const char* to () {return "(?)::INTEGER[]";} - }; - }; - } -} - -#endif // TRAITS_HXX diff --git a/pgsql/database/buildfile b/pgsql/database/buildfile deleted file mode 100644 index 6977ea6..0000000 --- a/pgsql/database/buildfile +++ /dev/null @@ -1,11 +0,0 @@ -# file : pgsql/database/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ -"pgsql should be configured via config.odb_tests.database variable as a single database" - -import libs = libodb-pgsql%lib{odb-pgsql} - -exe{driver}: {hxx cxx}{*} $libs testscript - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/pgsql/database/driver.cxx b/pgsql/database/driver.cxx deleted file mode 100644 index 56bde0a..0000000 --- a/pgsql/database/driver.cxx +++ /dev/null @@ -1,44 +0,0 @@ -// file : pgsql/database/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test that database constructors are unambiguous (compilation only). -// - -#include - -#undef NDEBUG -#include - -namespace pgsql = odb::pgsql; -using namespace pgsql; - -int -main (int argc, char* argv[]) -{ - // This code should not execute. - // - if (argc != 0) - return 0; - - { - database d1 ("bob", "secret", "db1"); - database d2 ("bob", "secret", "db1", "server1"); - database d3 ("bob", "secret", "db1", "server1", 999); - database d4 ("bob", "secret", "db1", "server1", 999, "extra"); - } - - { - database d1 ("bob", "secret", "db1", "server1", "ext1"); - database d2 ("bob", "secret", "db1", "server1", "ext1", "extra"); - } - - { - database d1 ("conninfo"); - } - - { - database d1 (argc, argv); - database d2 (argc, argv, false); - database d3 (argc, argv, true, "extra"); - } -} diff --git a/pgsql/database/testscript b/pgsql/database/testscript deleted file mode 100644 index f57a8e1..0000000 --- a/pgsql/database/testscript +++ /dev/null @@ -1,6 +0,0 @@ -# file : pgsql/database/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -: basics -: -$* diff --git a/pgsql/index/buildfile b/pgsql/index/buildfile deleted file mode 100644 index a84ed9a..0000000 --- a/pgsql/index/buildfile +++ /dev/null @@ -1,34 +0,0 @@ -# file : pgsql/index/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ -"pgsql should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-pgsql%lib{odb-pgsql} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix pgsql_index_ \ - --generate-schema \ - --default-database common - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/pgsql/index/driver.cxx b/pgsql/index/driver.cxx deleted file mode 100644 index dc4c11e..0000000 --- a/pgsql/index/driver.cxx +++ /dev/null @@ -1,44 +0,0 @@ -// file : pgsql/index/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test PostgreSQL index creation. See also the common test. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace pgsql = odb::pgsql; -using namespace pgsql; - -int -main (int argc, char* argv[]) -{ - try - { - // This is just a schema creation test. - // - unique_ptr db (create_specific_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/pgsql/index/test.hxx b/pgsql/index/test.hxx deleted file mode 100644 index d728188..0000000 --- a/pgsql/index/test.hxx +++ /dev/null @@ -1,19 +0,0 @@ -// file : pgsql/index/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - #pragma db id auto - unsigned long id_; - - int i; - #pragma db index type("UNIQUE CONCURRENTLY") method("BTREE") member(i) -}; - -#endif // TEST_HXX diff --git a/pgsql/index/testscript b/pgsql/index/testscript deleted file mode 100644 index 671a8c3..0000000 --- a/pgsql/index/testscript +++ /dev/null @@ -1,11 +0,0 @@ -# file : pgsql/index/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../pgsql.testscript - -+$create_schema - -: basics -: -$* diff --git a/pgsql/native/buildfile b/pgsql/native/buildfile deleted file mode 100644 index ec4c80c..0000000 --- a/pgsql/native/buildfile +++ /dev/null @@ -1,16 +0,0 @@ -# file : pgsql/native/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ -"pgsql should be configured via config.odb_tests.database variable as a single database" - -import libs = libodb-pgsql%lib{odb-pgsql} -import libs += lib{common} - -exe{driver}: {hxx cxx}{*} $libs testscript - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/pgsql/native/driver.cxx b/pgsql/native/driver.cxx deleted file mode 100644 index 843db41..0000000 --- a/pgsql/native/driver.cxx +++ /dev/null @@ -1,75 +0,0 @@ -// file : pgsql/native/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test PostgreSQL native SQL execution. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#undef NDEBUG -#include - -using namespace std; -namespace pgsql = odb::pgsql; -using namespace pgsql; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_specific_database (argc, argv)); - - // Create the database schema. - // - { - transaction t (db->begin ()); - - db->execute ("DROP TABLE IF EXISTS pgsql_native_test"); - db->execute ("CREATE TABLE pgsql_native_test (n INT PRIMARY KEY)"); - - t.commit (); - } - - // Insert a few rows. - // - { - transaction t (db->begin ()); - - assert ( - db->execute ("INSERT INTO pgsql_native_test (n) VALUES (1)") == 1); - - assert ( - db->execute ("INSERT INTO pgsql_native_test (n) VALUES (2)") == 1); - - t.commit (); - } - - // select a few rows. - // - { - transaction t (db->begin ()); - - assert ( - db->execute ("SELECT n FROM pgsql_native_test WHERE n < 3") == 2); - - assert ( - db->execute ("SELECT n FROM pgsql_native_test WHERE n > 3") == 0); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } - - return 0; -} diff --git a/pgsql/native/testscript b/pgsql/native/testscript deleted file mode 100644 index 4fd9d2c..0000000 --- a/pgsql/native/testscript +++ /dev/null @@ -1,9 +0,0 @@ -# file : pgsql/custom/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../pgsql.testscript - -: basics -: -$* diff --git a/pgsql/truncation/buildfile b/pgsql/truncation/buildfile deleted file mode 100644 index 2f2f3a2..0000000 --- a/pgsql/truncation/buildfile +++ /dev/null @@ -1,35 +0,0 @@ -# file : pgsql/truncation/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ -"pgsql should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-pgsql%lib{odb-pgsql} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix pgsql_truncation_ \ - --generate-schema \ - --default-database common \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/pgsql/truncation/driver.cxx b/pgsql/truncation/driver.cxx deleted file mode 100644 index 337a26e..0000000 --- a/pgsql/truncation/driver.cxx +++ /dev/null @@ -1,163 +0,0 @@ -// file : pgsql/truncation/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test insufficient buffer/truncation handling. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace pgsql = odb::pgsql; -using namespace pgsql; - -int -main (int argc, char* argv[]) -{ - // The default pre-allocated buffer is 512 bytes long. - // - string long_str (640, 'c'); // This will get the buffer to 1024 - string longer_str (1025, 'b'); - - try - { - // Test basic operations. - // - { - unique_ptr db (create_specific_database (argc, argv)); - - // Run persist/load so that the initial bindings are established - // (version == 0). - // - { - object1 o (1); - o.str_ = "test string"; - - transaction t (db->begin ()); - db->persist (o); - db->load (1, o); - t.commit (); - } - - { - object2 o (2); - o.str_ = "test string"; - - transaction t (db->begin ()); - db->persist (o); - db->load (2, o); - t.commit (); - } - - // Store/load the long string which should trigger buffer growth. - // - { - object1 o (3); - o.str_ = long_str; - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (3)); - assert (o->str_ == long_str); - t.commit (); - } - - // Store/load longer string. - // - { - object1 o (3); - o.str_ = longer_str; - - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (3)); - assert (o->str_ == longer_str); - t.commit (); - } - } - - // Test query. - // - { - typedef pgsql::query query; - typedef odb::result result; - - unique_ptr db (create_specific_database (argc, argv)); - - // Run persist/query so that the initial bindings are established - // (version == 0). - // - { - object1 o (20); - o.str_ = "test string"; - - transaction t (db->begin ()); - db->persist (o); - o.id_++; - db->persist (o); - o.id_++; - db->persist (o); - - result r (db->query (query::id == 20)); - assert (r.begin ()->id_ == 20); - t.commit (); - } - - // Test buffer growth with cached result. - // - { - object1 o; - - transaction t (db->begin ()); - - result r (db->query (query::id >= 20)); - result::iterator i (r.begin ()); - - o.id_ = i->id_; - o.str_ = long_str; - - // This forces buffer growth in the middle of result iteration. - // - db->update (o); - - ++i; - assert (i->str_ == "test string"); - - o.id_ = i->id_; - o.str_ = longer_str; - db->update (o); - - ++i; - assert (i->str_ == "test string"); - - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/pgsql/truncation/test.hxx b/pgsql/truncation/test.hxx deleted file mode 100644 index 73110c0..0000000 --- a/pgsql/truncation/test.hxx +++ /dev/null @@ -1,46 +0,0 @@ -// file : pgsql/truncation/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object table ("test") -struct object1 -{ - object1 (unsigned long id) - : id_ (id) - { - } - - object1 () - { - } - - #pragma db id - unsigned long id_; - - std::string str_; -}; - -#pragma db object table ("test") -struct object2 -{ - object2 (unsigned long id) - : id_ (id) - { - } - - object2 () - { - } - - #pragma db id - unsigned long id_; - - std::string str_; -}; - -#endif // TEST_HXX diff --git a/pgsql/truncation/testscript b/pgsql/truncation/testscript deleted file mode 100644 index c57b723..0000000 --- a/pgsql/truncation/testscript +++ /dev/null @@ -1,11 +0,0 @@ -# file : pgsql/truncation/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../pgsql.testscript - -+$create_schema - -: basics -: -$* diff --git a/pgsql/types/buildfile b/pgsql/types/buildfile deleted file mode 100644 index 64f0c02..0000000 --- a/pgsql/types/buildfile +++ /dev/null @@ -1,36 +0,0 @@ -# file : pgsql/types/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($pgsql && !$multi || $build.meta_operation == 'dist') \ -"pgsql should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} -import libcommon = lib{common} -import libs = libodb-pgsql%lib{odb-pgsql} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb and libcommon -# libraries are resolved for the odb_compile ad hoc rule (see build/root.build -# for details). -# -libue{test-meta}: $libodb $libcommon - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix pgsql_types_ \ - --generate-schema \ - --default-database common \ - --generate-query \ - --cxx-prologue '#include "traits.hxx"' - -cxx.poptions =+ "-I$out_base" "-I$src_base" - -# Testscript's run-time prerequisites. -# -exe{driver}: ../../alias{pgsql-client}: include = adhoc diff --git a/pgsql/types/driver.cxx b/pgsql/types/driver.cxx deleted file mode 100644 index 710f601..0000000 --- a/pgsql/types/driver.cxx +++ /dev/null @@ -1,165 +0,0 @@ -// file : pgsql/types/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test PostgreSQL type conversion. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace pgsql = odb::pgsql; -using namespace pgsql; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_specific_database (argc, argv)); - - object o (1); - - o.bool_ = true; - o.short_ = 12345; - o.int_ = -123456; - o.long_long_ = 123456; - - o.float_ = 1.123F; - o.float8_ = 1.123; - o.double_ = 1.123; - - o.date_ = 4015; - o.time_ = 48180000000LL; - o.timestamp_ = 346896000LL; - - string short_str (128, 's'); - string medium_str (250, 'm'); - string long_str (2040, 'l'); - - o.char_ = short_str; - o.varchar_ = medium_str; - o.text_ = long_str; - - o.bytea_.assign (long_str.c_str (), long_str.c_str () + long_str.size ()); - - unsigned char varbit_buf[8] = {1, 3, 1, 3, 1, 3, 1, 3}; - o.varbit_.size = 52; - o.varbit_.ubuffer_ = ubuffer (varbit_buf, 8); - - o.bit_.a = 0; - o.bit_.b = 1; - o.bit_.c = 0; - o.bit_.d = 1; - - // 6F846D41-C89A-4E4D-B22F-56443CFA543F - memcpy (o.uuid_, "\x6F\x84\x6D\x41\xC8\x9A\x4E\x4D\xB2\x2F" - "\x56\x44\x3C\xFA\x54\x3F", 16); - - o.enum_ = green; - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - - typedef pgsql::query query; - typedef odb::result result; - - // Test UUID in queries. - // - { - char uuid[16]; - memcpy (uuid, o.uuid_, 16); - - transaction t (db->begin ()); - - { - result r (db->query (query::uuid == uuid)); - assert (size (r) == 1); - } - - { - result r (db->query (query::uuid == query::_val (uuid))); - assert (size (r) == 1); - } - - { - result r (db->query (query::uuid == query::_ref (uuid))); - assert (size (r) == 1); - } - - { - const char* d (uuid); - result r (db->query (query::uuid == d)); - assert (size (r) == 1); - } - - t.commit (); - } - - // Test char array. - // - { - char_array o1 (1, ""); - char_array o2 (2, "1234567890"); - char_array o3 (3, "1234567890123456"); - - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - } - - // PostgreSQL returns padded values for CHAR(N). - // - memcpy (o1.s2, " ", 16); - o1.s3[0] = o1.c1 = ' '; - memcpy (o2.s2, "1234567890 ", 16); - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (1)); - unique_ptr p2 (db->load (2)); - unique_ptr p3 (db->load (3)); - t.commit (); - - assert (o1 == *p1); - assert (o2 == *p2); - assert (o3 == *p3); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/pgsql/types/test.hxx b/pgsql/types/test.hxx deleted file mode 100644 index 462ebad..0000000 --- a/pgsql/types/test.hxx +++ /dev/null @@ -1,220 +0,0 @@ -// file : pgsql/types/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include -#include // std::unique_ptr -#include // std::memcmp, std::memcpy, std::str[n]cmp, std::strlen -#include // std::size_t - -#include - -#include - -struct bitfield -{ - unsigned int a: 1; - unsigned int b: 1; - unsigned int c: 1; - unsigned int d: 1; -}; - -inline bool -operator== (bitfield x, bitfield y) -{ - return - x.a == y.a && - x.b == y.b && - x.c == y.c && - x.d == y.d; -} - -struct varbit -{ - std::size_t size; - ubuffer ubuffer_; - - bool - compare (const varbit& x) const - { - if (size != x.size) - return false; - - std::size_t byte_len = size / 8; - - if (std::memcmp (ubuffer_.data (), x.ubuffer_.data (), byte_len) != 0) - return false; - - std::size_t trailing_bits = size % 8; - - if (trailing_bits != 0) - { - unsigned char mask (0xFFU << (8 - trailing_bits)); - - return (ubuffer_.data ()[byte_len] & mask) == - (x.ubuffer_.data ()[byte_len] & mask); - } - - return true; - } -}; - -inline bool -operator== (const varbit& x, const varbit& y) -{ - return x.compare (y); -} - -#pragma db value(bitfield) type ("BIT(4)") - -typedef std::unique_ptr string_ptr; - -enum color {red, green, blue}; - -#pragma db object -struct object -{ - object () {} - object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - // Integral types. - // - #pragma db type ("BOOL") - bool bool_; - - #pragma db type ("SMALLINT") - short short_; - - #pragma db type ("INT") - int int_; - - #pragma db type ("BIGINT") - long long long_long_; - - // Float types. - // - #pragma db type ("REAL") - float float_; - - #pragma db type ("FLOAT(32)") - double float8_; - - #pragma db type ("DOUBLE PRECISION") - double double_; - - // Data-time types. - // - #pragma db type ("DATE") - int date_; - - #pragma db type ("TIME") - long long time_; - - #pragma db type ("TIMESTAMP") - long long timestamp_; - - // String and binary types. - // - #pragma db type ("CHAR(128)") - std::string char_; - - #pragma db type ("VARCHAR(256)") - std::string varchar_; - - #pragma db type ("TEXT") - std::string text_; - - #pragma db type ("BYTEA") - std::vector bytea_; - - #pragma db type ("VARBIT(1024)") - varbit varbit_; - - // #pragma db type ("BIT(4)") - assigned by #pragma db value - bitfield bit_; - - // Other types. - // - #pragma db type ("UUID") - char uuid_[16]; - - // Test ENUM representation. - // - color enum_; - - // Test NULL value. - // - #pragma db type ("TEXT") null - string_ptr null_; - - bool - operator== (const object& y) const - { - return - id_ == y.id_ && - bool_ == y.bool_ && - short_ == y.short_ && - int_ == y.int_ && - long_long_ == y.long_long_ && - float_ == y.float_ && - float8_ == y.float8_ && - double_ == y.double_ && - date_ == y.date_ && - time_ == y.time_ && - timestamp_ == y.timestamp_ && - char_ == y.char_ && - varchar_ == y.varchar_ && - text_ == y.text_ && - bytea_ == y.bytea_ && - bit_ == y.bit_ && - varbit_ == y.varbit_ && - memcmp (uuid_, y.uuid_, 16) == 0 && - enum_ == y.enum_ && - ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_); - } -}; - -// Test char array. -// -#pragma db object -struct char_array -{ - char_array () {} - char_array (unsigned long id, const char* s) - : id_ (id) - { - std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation. - std::memcpy (s2, s, std::strlen (s) + 1); - s3[0] = c1 = *s; - } - - #pragma db id - unsigned long id_; - - char s1[17]; - - #pragma db type("CHAR(16)") - char s2[16]; - - char s3[1]; - char c1; - - bool - operator== (const char_array& y) const - { - return id_ == y.id_ && - std::strcmp (s1, y.s1) == 0 && - std::strncmp (s2, y.s2, sizeof (s2)) == 0 && - s3[0] == y.s3[0] && - c1 == y.c1; - } -}; - -#endif // TEST_HXX diff --git a/pgsql/types/testscript b/pgsql/types/testscript deleted file mode 100644 index 57218e1..0000000 --- a/pgsql/types/testscript +++ /dev/null @@ -1,11 +0,0 @@ -# file : pgsql/types/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../pgsql.testscript - -+$create_schema - -: basics -: -$* diff --git a/pgsql/types/traits.hxx b/pgsql/types/traits.hxx deleted file mode 100644 index a1c8fbe..0000000 --- a/pgsql/types/traits.hxx +++ /dev/null @@ -1,171 +0,0 @@ -// file : pgsql/types/traits.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TRAITS_HXX -#define TRAITS_HXX - -#include -#include // std::memcpy, std::memset - -#include -#include - -#include "test.hxx" // varbit, ubuffer, string_ptr - -namespace odb -{ - namespace pgsql - { - // The first 4 bytes of the image is a signed int specifying the - // number of significant bits contained by the BIT. The following - // bytes contain the bit data. - // - template <> - class value_traits - { - public: - typedef bitfield value_type; - typedef bitfield query_type; - typedef unsigned char* image_type; - - static void - set_value (bitfield& v, - const unsigned char* i, - std::size_t, - bool is_null) - { - if (!is_null) - { - assert ( - details::endian_traits::ntoh ( - *reinterpret_cast (i)) == 4); - - const unsigned char* d (i + 4); - - v.a = *d >> 4 & 1; - v.b = (*d >> 5) & 1; - v.c = (*d >> 6) & 1; - v.d = (*d >> 7) & 1; - } - else - v.a = v.b = v.c = v.d = 0; - } - - static void - set_image (unsigned char* i, - std::size_t, - std::size_t& n, - bool& is_null, - bitfield v) - { - is_null = false; - n = 5; - - *reinterpret_cast (i) = details::endian_traits::hton (4); - *(i + 4) = v.a << 4 | (v.b << 5) | (v.c << 6) | (v.d << 7); - } - }; - - // The first 4 bytes of the image is a signed int specifying the - // number of significant bits contained by the VARBIT. The following - // bytes contain the VARBIT data. - // - template <> - class value_traits - { - public: - typedef varbit value_type; - typedef varbit query_type; - typedef details::ubuffer image_type; - - static void - set_value (varbit& v, - const details::ubuffer& b, - std::size_t n, - bool is_null) - { - if (!is_null) - { - v.size = static_cast ( - details::endian_traits::ntoh ( - *reinterpret_cast (b.data ()))); - - std::size_t byte_len (v.size / 8 + (v.size % 8 > 0 ? 1 : 0)); - assert (n >= byte_len + 4); - - v.ubuffer_.assign (b.data () + 4, byte_len); - } - - else - { - v.size = 0; - v.ubuffer_.assign (0, 0); - } - } - - static void - set_image (details::ubuffer& b, - std::size_t& n, - bool& is_null, - const varbit& v) - { - is_null = false; - n = 4 + v.size / 8 + (v.size % 8 > 0 ? 1 : 0); - - if (n > b.capacity ()) - b.capacity (n); - - // PostgreSQL requires all trailing bits of a VARBIT image - // to be zero. - // - std::memset (b.data (), 0, b.capacity ()); - - *reinterpret_cast (b.data ()) = - details::endian_traits::hton (static_cast (v.size)); - - if (v.size != 0) - std::memcpy (b.data () + 4, v.ubuffer_.data (), n - 4); - } - }; - - template <> - class value_traits - { - public: - typedef string_ptr value_type; - typedef std::string query_type; - typedef details::buffer image_type; - - static void - set_value (string_ptr& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - v.reset (is_null ? 0 : new std::string (b.data (), n)); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const string_ptr& v) - { - is_null = v.get () == 0; - - if (!is_null) - { - n = v->size (); - - if (n > b.capacity ()) - b.capacity (n); - - if (n != 0) - std::memcpy (b.data (), v->c_str (), n); - } - } - }; - } -} - -#endif // TRAITS_HXX diff --git a/qt/common/basic/driver.cxx b/qt/common/basic/driver.cxx deleted file mode 100644 index 342a313..0000000 --- a/qt/common/basic/driver.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// file : qt/common/basic/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt basic type persistence (common part). -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - object o (1); - o.uuid_ = QUuid::createUuid (); - o.null_ = QUuid (); - o.zero_ = QUuid (); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr p (db->load (o.id_)); - t.commit (); - - assert (*p == o); - } - - { - typedef odb::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::uuid == o.uuid_)); - result::iterator i (r.begin ()); - assert (i != r.end () && i->id_ == o.id_); - assert (++i == r.end ()); - t.commit (); - } - - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/common/basic/test.hxx b/qt/common/basic/test.hxx deleted file mode 100644 index e67302e..0000000 --- a/qt/common/basic/test.hxx +++ /dev/null @@ -1,35 +0,0 @@ -// file : qt/common/basic/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object -struct object -{ - object () {} - object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - QUuid uuid_; - QUuid null_; - - #pragma db not_null - QUuid zero_; - - bool operator== (const object& x) const - { - return id_ == x.id_ && - uuid_ == x.uuid_ && - null_ == x.null_ && - zero_ == x.zero_; - } -}; - -#endif // TEST_HXX diff --git a/qt/common/containers/basics/driver.cxx b/qt/common/containers/basics/driver.cxx deleted file mode 100644 index 5e38ee1..0000000 --- a/qt/common/containers/basics/driver.cxx +++ /dev/null @@ -1,569 +0,0 @@ -// file : qt/common/containers/basics/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test basic Qt containers persistence. -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - for (unsigned short i (0); i < 2; ++i) - { - object empty ("empty"), med ("medium"), full ("full"); - - // - // empty - // - - empty.num = 0; - empty.str = ""; - - // - // med - // - - med.num = 999; - med.str = "xxx"; - - // vector - // - med.nv.push_back (123); - med.nv.push_back (234); - - med.sv.push_back ("aaa"); - med.sv.push_back ("bbbb"); - - med.cv.push_back (comp (123, "aaa")); - med.cv.push_back (comp (234, "bbbb")); - - med.uv.push_back (123); - med.uv.push_back (234); - - // list - // - med.sl.push_back ("aaa"); - med.sl.push_back ("bbbb"); - - med.nl.push_back (123); - med.nl.push_back (234); - - med.cl.push_back (comp (123, "aaa")); - med.cl.push_back (comp (234, "bbbb")); - - // linked list - // - med.sll.push_back ("aaa"); - med.sll.push_back ("bbbb"); - - med.nll.push_back (123); - med.nll.push_back (234); - - med.cll.push_back (comp (123, "aaa")); - med.cll.push_back (comp (234, "bbbb")); - - // set - // - med.ns.insert (123); - med.ns.insert (234); - - med.ss.insert ("aaa"); - med.ss.insert ("bbbb"); - - // map - // - med.nsm[123] = "aaa"; - med.nsm[234] = "bbbb"; - - med.snm["aaa"] = 123; - med.snm["bbbb"] = 234; - - med.ncm[123] = comp (123, "aaa"); - med.ncm[234] = comp (234, "bbbb"); - - med.csm[comp (123, "aaa")] = "aaa"; - med.csm[comp (234, "bbbb")] = "bbbb"; - - // multimap - // - med.nsmm.insert (123, "aaa"); - med.nsmm.insert (123, "bbbb"); - med.nsmm.insert (234, "ccccc"); - - med.snmm.insert ("aaa", 123); - med.snmm.insert ("aaa", 234); - med.snmm.insert ("bbb", 345); - - med.ncmm.insert (123, comp (123, "aaa")); - med.ncmm.insert (123, comp (234, "bbbb")); - med.ncmm.insert (234, comp (345, "ccccc")); - - // hash - // - med.nsh[123] = "aaa"; - med.nsh[234] = "bbbb"; - - med.snh["aaa"] = 123; - med.snh["bbb"] = 234; - - med.sch["iii"] = comp (123, "aaa"); - med.sch["jjj"] = comp (234, "bbbb"); - - // multihash - // - med.nsmh.insert (123, "aaa"); - med.nsmh.insert (123, "bbbb"); - med.nsmh.insert (234, "ccccc"); - - med.snmh.insert ("aaa", 123); - med.snmh.insert ("aaa", 234); - med.snmh.insert ("bbb", 345); - - med.ncmh.insert (123, comp (123, "aaa")); - med.ncmh.insert (123, comp (234, "bbbb")); - med.ncmh.insert (234, comp (345, "ccccc")); - - // - // full - // - - full.num = 9999; - full.str = "xxxx"; - - // vector - // - full.nv.push_back (1234); - full.nv.push_back (2345); - full.nv.push_back (3456); - - full.sv.push_back ("aaaa"); - full.sv.push_back ("bbbbb"); - full.sv.push_back ("cccccc"); - - full.cv.push_back (comp (1234, "aaaa")); - full.cv.push_back (comp (2345, "bbbbb")); - full.cv.push_back (comp (3456, "cccccc")); - - full.uv.push_back (1234); - full.uv.push_back (2345); - full.uv.push_back (3456); - - // list - // - full.sl.push_back ("aaaa"); - full.sl.push_back ("bbbbb"); - full.sl.push_back ("cccccc"); - - full.nl.push_back (1234); - full.nl.push_back (2345); - full.nl.push_back (3456); - - full.cl.push_back (comp (1234, "aaaa")); - full.cl.push_back (comp (2345, "bbbbb")); - full.cl.push_back (comp (3456, "cccccc")); - - // linked list - // - full.sll.push_back ("aaaa"); - full.sll.push_back ("bbbbb"); - full.sll.push_back ("cccccc"); - - full.nll.push_back (1234); - full.nll.push_back (2345); - full.nll.push_back (3456); - - full.cll.push_back (comp (1234, "aaaa")); - full.cll.push_back (comp (2345, "bbbbb")); - full.cll.push_back (comp (3456, "cccccc")); - - // set - // - full.ns.insert (1234); - full.ns.insert (2345); - full.ns.insert (3456); - - full.ss.insert ("aaaa"); - full.ss.insert ("bbbbb"); - full.ss.insert ("cccccc"); - - // map - // - full.nsm[1234] = "aaaa"; - full.nsm[2345] = "bbbbb"; - full.nsm[3456] = "cccccc"; - - full.snm["aaaa"] = 1234; - full.snm["bbbb"] = 2345; - full.snm["cccc"] = 3456; - - full.ncm[1234] = comp (1234, "aaaa"); - full.ncm[2345] = comp (2345, "bbbbb"); - full.ncm[3456] = comp (3456, "cccccc"); - - full.csm[comp (1234, "aaaa")] = "aaaa"; - full.csm[comp (2345, "bbbb")] = "bbbbb"; - full.csm[comp (3456, "cccc")] = "cccccc"; - - // multimap - // - full.nsmm.insert (1234, "aaaa"); - full.nsmm.insert (1234, "bbbbb"); - full.nsmm.insert (2345, "cccccc"); - full.nsmm.insert (2345, "ddddddd"); - - full.snmm.insert ("aaaa", 1234); - full.snmm.insert ("aaaa", 2345); - full.snmm.insert ("bbbb", 3456); - full.snmm.insert ("bbbb", 4567); - - full.ncmm.insert (1234, comp (1234, "aaaa")); - full.ncmm.insert (1234, comp (2345, "bbbbb")); - full.ncmm.insert (2345, comp (3456, "cccccc")); - full.ncmm.insert (2345, comp (4567, "ddddddd")); - - // hash - // - full.nsh[1234] = "aaaa"; - full.nsh[2345] = "bbbbb"; - full.nsh[3456] = "cccccc"; - - full.snh["aaaa"] = 1234; - full.snh["bbbb"] = 2345; - full.snh["cccc"] = 3456; - - full.sch["iiii"] = comp (1234, "aaaa"); - full.sch["jjjj"] = comp (2345, "bbbbb"); - full.sch["kkkk"] = comp (3456, "cccccc"); - - // multihash - // - full.nsmh.insert (1234, "aaaa"); - full.nsmh.insert (1234, "bbbbb"); - full.nsmh.insert (2345, "cccccc"); - full.nsmh.insert (2345, "ddddddd"); - - full.snmh.insert ("aaaa", 1234); - full.snmh.insert ("aaaa", 2345); - full.snmh.insert ("bbbb", 3456); - full.snmh.insert ("bbbb", 4567); - - full.ncmh.insert (1234, comp (1234, "aaaa")); - full.ncmh.insert (1234, comp (2345, "bbbbb")); - full.ncmh.insert (2345, comp (3456, "cccccc")); - full.ncmh.insert (2345, comp (4567, "ddddddd")); - - // persist - // - { - transaction t (db->begin ()); - db->persist (empty); - db->persist (med); - db->persist (full); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - auto_ptr e (db->load ("empty")); - auto_ptr m (db->load ("medium")); - auto_ptr f (db->load ("full")); - t.commit (); - - assert (empty == *e); - assert (med == *m); - assert (full == *f); - } - - // - // empty - // - - empty.num = 99; - empty.str = "xx"; - - // vector - // - empty.nv.push_back (12); - empty.sv.push_back ("aa"); - empty.cv.push_back (comp (12, "aa")); - empty.uv.push_back (12); - - // list - // - empty.sl.push_back ("aa"); - empty.nl.push_back (12); - empty.cl.push_back (comp (12, "aa")); - - // linked list - // - empty.nll.push_back (12); - empty.sll.push_back ("aa"); - empty.cll.push_back (comp (12, "aa")); - - // set - // - empty.ns.insert (12); - empty.ss.insert ("aa"); - - // map - // - empty.nsm[12] = "aa"; - empty.snm["aa"] = 12; - empty.ncm[12] = comp (12, "aa"); - empty.csm[comp (12, "aa")] = "aa"; - - // multimap - // - empty.nsmm.insert (12, "aa"); - empty.nsmm.insert (12, "bbb"); - empty.nsmm.insert (23, "cccc"); - empty.snmm.insert ("aa", 12); - empty.snmm.insert ("aa", 23); - empty.snmm.insert ("bb", 34); - empty.ncmm.insert (12, comp (12, "aa")); - empty.ncmm.insert (12, comp (23, "bb")); - empty.ncmm.insert (23, comp (34, "cc")); - - // hash - // - empty.nsh[12] = "aa"; - empty.snh["aa"] = 12; - empty.sch["ii"] = comp (12, "aa"); - - // multihash - // - empty.nsmh.insert (12, "aa"); - empty.nsmh.insert (12, "bbb"); - empty.nsmh.insert (23, "cccc"); - empty.snmh.insert ("aa", 12); - empty.snmh.insert ("aa", 23); - empty.snmh.insert ("bb", 34); - empty.ncmh.insert (12, comp (12, "aa")); - empty.ncmh.insert (12, comp (23, "bb")); - empty.ncmh.insert (23, comp (34, "cc")); - - // - // med - // - - med.num = 0; - med.str = ""; - - // vector - // - med.nv.clear (); - med.sv.clear (); - med.cv.clear (); - med.uv.clear (); - - // list - // - med.sl.clear (); - med.nl.clear (); - med.cl.clear (); - - // linked list - // - med.nll.clear (); - med.sll.clear (); - med.cll.clear (); - - // set - // - med.ns.clear (); - med.ss.clear (); - - // map - // - med.nsm.clear (); - med.snm.clear (); - med.ncm.clear (); - med.csm.clear (); - - // multimap - // - med.nsmm.clear (); - med.snmm.clear (); - med.ncmm.clear (); - - // hash - // - med.nsh.clear (); - med.snh.clear (); - med.sch.clear (); - - // multihash - // - med.nsmh.clear (); - med.snmh.clear (); - med.ncmh.clear (); - - - // - // full - // - - full.num++; - full.str += "x"; - - // vector - // - full.nv.back ()++; - full.nv.push_back (4567); - - full.sv.back () += "c"; - full.sv.push_back ("ddddddd"); - - full.cv.back ().num++; - full.cv.back ().str += "c"; - full.cv.push_back (comp (4567, "ddddddd")); - - full.uv.back ()++; - full.uv.push_back (4567); - - // list - // - full.sl.back () += "c"; - full.sl.push_back ("ddddddd"); - - full.nl.back ()++; - full.nl.push_back (4567); - - full.cl.back ().num++; - full.cl.back ().str += "c"; - full.cl.push_back (comp (4567, "ddddddd")); - - // linked list - // - full.sll.back () += "c"; - full.sll.push_back ("ddddddd"); - - full.nll.back ()++; - full.nll.push_back (4567); - - full.cll.back ().num++; - full.cll.back ().str += "c"; - full.cll.push_back (comp (4567, "ddddddd")); - - // set - // - full.ns.insert (4567); - full.ss.insert ("ddddddd"); - - // map - // - full.nsm[3456] += "c"; - full.nsm[4567] = "ddddddd"; - - full.snm["cccc"]++; - full.snm["dddd"] = 4567; - - full.ncm[3456].num++; - full.ncm[3456].str += "c"; - full.ncm[4567] = comp (4567, "ddddddd"); - - full.csm[comp (3456, "cccc")] += "c"; - full.csm[comp (4567, "dddd")] = "ddddddd"; - - // multimap - // - full.nsmm.find (2345).value () += "d"; - full.nsmm.insert (3456, "eeeeeeee"); - - full.snmm.find ("bbbb").value ()++; - full.snmm.insert ("cccc", 5678); - - full.ncmm.find (1234).value ().num++; - full.ncmm.find (2345).value ().str += "d"; - full.ncmm.insert (3456, comp (5678, "eeeeeeee")); - - // hash - // - full.nsh[3456] += "c"; - full.nsh[4567] = "ddddddd"; - - full.snh["cccc"]++; - full.snh["dddd"] = 4567; - - full.sch["iiii"].num++; - full.sch["jjjj"].str += "b"; - full.sch["kkkk"] = comp (4567, "dddddddd"); - - // multihash - // - full.nsmh.find (2345).value () += "d"; - full.nsmh.insert (3456, "eeeeeeee"); - - full.snmh.find ("bbbb").value ()++; - full.snmh.insert ("cccc", 5678); - - full.ncmh.find (1234).value ().num++; - full.ncmh.find (2345).value ().str += "d"; - full.ncmh.insert (3456, comp (5678, "eeeeeeee")); - - // update - // - { - transaction t (db->begin ()); - db->update (empty); - db->update (med); - db->update (full); - t.commit (); - } - - // load & check - // - { - transaction t (db->begin ()); - auto_ptr e (db->load ("empty")); - auto_ptr m (db->load ("medium")); - auto_ptr f (db->load ("full")); - t.commit (); - - assert (empty == *e); - assert (med == *m); - assert (full == *f); - } - - // erase - // - if (i == 0) - { - transaction t (db->begin ()); - db->erase ("empty"); - db->erase ("medium"); - db->erase ("full"); - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/common/containers/basics/test.hxx b/qt/common/containers/basics/test.hxx deleted file mode 100644 index 2c61c88..0000000 --- a/qt/common/containers/basics/test.hxx +++ /dev/null @@ -1,224 +0,0 @@ -// file : qt/common/containers/basics/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#pragma db value -struct comp -{ - comp () {} - comp (int n, const QString& s) : num (n), str (s) {} - - #pragma db column("number") - int num; - QString str; -}; - -inline bool -operator== (const comp& x, const comp& y) -{ - return x.num == y.num && x.str == y.str; -} - -inline bool -operator< (const comp& x, const comp& y) -{ - return x.num != y.num ? x.num < y.num : x.str < y.str; -} - -typedef QVector num_vector; -typedef QVector str_vector; -typedef QVector comp_vector; - -typedef QList num_list; -typedef QList str_list; -typedef QList comp_list; - -typedef QLinkedList num_linked_list; -typedef QLinkedList str_linked_list; -typedef QLinkedList comp_linked_list; - -typedef QSet num_set; -typedef QSet str_set; - -typedef QMap num_str_map; -typedef QMap str_num_map; -typedef QMap num_comp_map; -typedef QMap comp_str_map; - -typedef QMultiMap num_str_multimap; -typedef QMultiMap str_num_multimap; -typedef QMultiMap num_comp_multimap; - -typedef QHash num_str_hash; -typedef QHash str_num_hash; -typedef QHash str_comp_hash; - -typedef QMultiHash num_str_multihash; -typedef QMultiHash str_num_multihash; -typedef QMultiHash num_comp_multihash; - -#pragma db value -struct cont_comp1 -{ - // This composite value does not have any columns. - // - num_vector sv; // Have the name "conflict" with the one in the object. -}; - -#pragma db value -struct cont_comp2 -{ - cont_comp2 (): num (777), str ("ggg") {} - - int num; - str_list sl; - QString str; -}; - -#pragma db object -struct object -{ - object (): nv (comp1_.sv), sl (comp2_.sl) {} - object (const QString& id) : id_ (id), nv (comp1_.sv), sl (comp2_.sl) {} - - #pragma db id - QString id_; - - int num; - - cont_comp1 comp1_; - cont_comp2 comp2_; - - // vector - // - #pragma db transient - num_vector& nv; - - #pragma db table("object_strings") id_column ("obj_id") - str_vector sv; - - #pragma db value_column("") - comp_vector cv; - - #pragma db unordered - num_vector uv; - - // list - // - #pragma db transient - str_list& sl; - - num_list nl; - comp_list cl; - - // linked list - // - str_linked_list sll; - num_linked_list nll; - comp_linked_list cll; - - // set - // - num_set ns; - str_set ss; - - // map - // - num_str_map nsm; - str_num_map snm; - num_comp_map ncm; - comp_str_map csm; - - // multimap - // - num_str_multimap nsmm; - str_num_multimap snmm; - num_comp_multimap ncmm; - - // hash - // - num_str_hash nsh; - str_num_hash snh; - str_comp_hash sch; - - // multihash - // - num_str_multihash nsmh; - str_num_multihash snmh; - num_comp_multihash ncmh; - - QString str; -}; - -inline bool -operator== (const object& x, const object& y) -{ - if (x.uv.size () != y.uv.size ()) - return false; - - int xs (0), ys (0); - - for (num_vector::size_type i (0); i < x.uv.size (); ++i) - { - xs += x.uv[i]; - ys += y.uv[i]; - } - - return - x.id_ == y.id_ && - x.num == y.num && - - x.comp2_.num == y.comp2_.num && - x.comp2_.str == y.comp2_.str && - - x.nv == y.nv && - x.sv == y.sv && - x.cv == y.cv && - xs == ys && - - x.sl == y.sl && - x.nl == y.nl && - x.cl == y.cl && - - x.nll == y.nll && - x.sll == y.sll && - x.cll == y.cll && - - x.ns == y.ns && - x.ss == y.ss && - - x.nsm == y.nsm && - x.snm == y.snm && - x.ncm == y.ncm && - x.csm == y.csm && - - x.nsmm.uniqueKeys () == y.nsmm.uniqueKeys () && - x.snmm.uniqueKeys () == y.snmm.uniqueKeys () && - x.ncmm.uniqueKeys () == y.ncmm.uniqueKeys () && - - x.nsh == y.nsh && - x.snh == y.snh && - x.sch == y.sch && - - x.nsmh.uniqueKeys () == y.nsmh.uniqueKeys () && - x.snmh.uniqueKeys () == y.snmh.uniqueKeys () && - x.ncmh.uniqueKeys () == y.ncmh.uniqueKeys () && - - x.str == y.str; -} - -#endif // TEST_HXX diff --git a/qt/common/containers/change-tracking/driver.cxx b/qt/common/containers/change-tracking/driver.cxx deleted file mode 100644 index 8157d96..0000000 --- a/qt/common/containers/change-tracking/driver.cxx +++ /dev/null @@ -1,643 +0,0 @@ -// file : qt/common/containers/change-tracking/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test change-tracking Qt containers. -// - -#include // HAVE_CXX11 - -#include // std::auto_ptr -#include -#include - -#ifdef HAVE_CXX11 -# include // std::move -#endif - -#include // QT_VERSION, Q_FOREACH -#include - -#include -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -struct counting_tracer: odb::tracer -{ - void - reset (transaction& tr) {u = i = d = s = t = 0; tr.tracer (*this);} - - virtual void - execute (odb::connection&, const char* stmt) - { - string p (stmt, 6); - if (p == "UPDATE") - u++; - else if (p == "INSERT") - i++; - else if (p == "DELETE") - d++; - else if (p == "SELECT") - s++; - t++; - } - - size_t u, i, d, s, t; -}; - -static counting_tracer tr; - -// Compilation test: instantiate all the functions. Only do this if we -// have a fairly recent version of Qt, otherwise some underlying -// functions will be missing. -// -#if QT_VERSION >= 0x050000 -template class QOdbList; -template class QOdbListIteratorImpl >; -template class QOdbListIterator; -template class QMutableOdbListIterator; -#endif - -void -f (const QList&) {} - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - // Test extended interface. - // - { - typedef QOdbList list; - - list ol; - QList ql; - f (ol); // Implicit conversion to QList. - list ol1 (ql); // Initialization from QList. - ol = ql; // Assignement from QList. - - // Container comparison. - // - if (ol != ol1 || - ol != ql || - ql != ol1) - ol.clear (); - - // Container operators. - // - ol += ol1; - ol += ql; - ol = ol1 + ql; - ol = ql + ol1; - - // Iterator comparison/conversion. - // -#ifndef QT_STRICT_ITERATORS - list::const_iterator i (ol.begin ()); - if (i != ol.end ()) - i = ol.end (); -#endif - - Q_FOREACH (const int& i, ol) - cerr << i; - } - - auto_ptr db (create_database (argc, argv)); - - // Test traits logic. - // - { - object o ("1"); - o.i = 123; - o.s.push_back ("a"); - - assert (!o.s._tracking ()); - - // persist - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - assert (o.s._tracking ()); - - // load - // - { - transaction t (db->begin ()); -#ifdef HAVE_CXX11 - unique_ptr p (db->load ("1")); -#else - auto_ptr p (db->load ("1")); -#endif - assert (p->s._tracking ()); - t.commit (); - } - - // update - // - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - assert (o.s._tracking ()); - - // erase - // - { - transaction t (db->begin ()); - db->erase (o); - t.commit (); - } - - assert (!o.s._tracking ()); - } - - // Test change tracking. - // - object o ("1"); - o.i = 123; - o.s.push_back ("a"); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // push_back/pop_back - // - { - o.s.push_back ("b"); // insert - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.i == 1 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.pop_back (); - o.s.push_back ("c"); // update - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 2 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.pop_back (); // delete - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.d == 1 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.push_back ("b"); - o.s.pop_back (); // no-op - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.t == 1); - assert (*db->load ("1") == o); - t.commit (); - } - - // insert - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.insert (o.s.begin (), "a1"); // insert front - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 3 && tr.i == 1 && tr.t == 4); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.insert (o.s.begin () + 1, "a2"); // insert middle - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 3 && tr.i == 1 && tr.t == 4); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.insert (o.s.end (), "b1"); // insert back - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.i == 1 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - // erase - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - o.s.push_back ("d"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.erase (o.s.begin ()); // erase front - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 4 && tr.d == 1 && tr.t == 5); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.erase (o.s.begin () + 1); // erase middle - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 2 && tr.d == 1 && tr.t == 3); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.erase (o.s.end () - 1); // erase back - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.d == 1 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - // modify - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - o.s.push_back ("d"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.modify (1) += 'b'; - o.s.modify_back () += 'd'; - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 3 && tr.t == 3); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.modify_front () += 'a'; - o.s.modify_back () += 'd'; - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 3 && tr.t == 3); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.begin ().modify () += 'a'; - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 2 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.mbegin (); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 5 && tr.t == 5); - assert (*db->load ("1") == o); - t.commit (); - } - - // clear - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.clear (); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.d == 1 && tr.t == 2); - assert (*db->load ("1") == o); - t.commit (); - } - - // assign - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - QList v; - v.push_back ("1"); - v.push_back ("2"); - v.push_back ("3"); - v.push_back ("4"); - o.s = v; - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 4 && tr.i == 1 && tr.t == 5); - assert (*db->load ("1") == o); - t.commit (); - } - - // removeOne/removeAll - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - o.s.push_back ("a"); - o.s.push_back ("d"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.removeOne ("c"); - assert (o.s.size () == 5 && o.s[3] == "a"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 3 && tr.d == 1 && tr.t == 4); - assert (*db->load ("1") == o); - t.commit (); - } - - { - o.s.removeAll ("a"); - assert (o.s.size () == 2 && o.s[0] == "b" && o.s[1] == "d"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 3 && tr.d == 1 && tr.t == 4); - assert (*db->load ("1") == o); - t.commit (); - } - - // Transaction rollback. - // - { - o.s.clear (); - o.s.push_back ("a"); - o.s.push_back ("b"); - o.s.push_back ("c"); - - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (*db->load ("1") == o); - t.commit (); - } - - { - { - o.s.push_back ("d"); - - transaction t (db->begin ()); - db->update (o); - t.rollback (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.i == 4 && tr.d == 1 && tr.t == 6); - t.commit (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (o); - assert (tr.u == 1 && tr.t == 1); - t.commit (); - } - } - - // Armed copy. - // - { - -#ifdef HAVE_CXX11 - unique_ptr c; -#else - auto_ptr c; -#endif - - - { - o.s.pop_back (); - - transaction t (db->begin ()); - db->update (o); - c.reset (new object (o)); - t.rollback (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.i == 3 && tr.d == 1 && tr.t == 5); - t.commit (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.t == 1); - t.commit (); - } - } - - // Armed swap. - // -#if QT_VERSION >= 0x040800 - { - object c (o); - - { - o.s.push_back ("d"); - - transaction t (db->begin ()); - db->update (o); - assert (o.s._tracking () && !c.s._tracking ()); - c.s.swap (o.s); - assert (!o.s._tracking () && c.s._tracking ()); - t.rollback (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.i == 4 && tr.d == 1 && tr.t == 6); - t.commit (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.t == 1); - t.commit (); - } - } -#endif - - // Armed move. - // -#ifdef HAVE_CXX11 - { - unique_ptr c; - - { - o.s.pop_back (); - - transaction t (db->begin ()); - db->update (o); - assert (o.s._tracking ()); - c.reset (new object (std::move (o))); - assert (!o.s._tracking () && c->s._tracking ()); - t.rollback (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.i == 2 && tr.d == 1 && tr.t == 4); - t.commit (); - } - - { - transaction t (db->begin ()); - tr.reset (t); - db->update (c); - assert (tr.u == 1 && tr.t == 1); - t.commit (); - } - } -#endif - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/common/containers/change-tracking/test.hxx b/qt/common/containers/change-tracking/test.hxx deleted file mode 100644 index 6067581..0000000 --- a/qt/common/containers/change-tracking/test.hxx +++ /dev/null @@ -1,46 +0,0 @@ -// file : qt/common/containers/change-tracking/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include // HAVE_CXX11 - -#include - -#ifdef HAVE_CXX11 -# include // std::move -#endif - -#include - -#include -#include - -#ifdef HAVE_CXX11 -#pragma db object pointer(std::unique_ptr) -#else -#pragma db object pointer(std::auto_ptr) -#endif -struct object -{ - object () {} - object (const QString& id): id_ (id) {} - -#ifdef HAVE_CXX11 - object (const object& x): id_ (x.id_), i (x.i), s (x.s) {} - object (object&& x): id_ (std::move (x.id_)), i (x.i), s (std::move (x.s)) {} -#endif - - #pragma db id - QString id_; - - unsigned int i; - - QOdbList s; - - inline bool - operator== (const object& o) {return id_ == o.id_ && i == o.i && s == o.s;} -}; - -#endif // TEST_HXX diff --git a/qt/common/smart-ptr/driver.cxx b/qt/common/smart-ptr/driver.cxx deleted file mode 100644 index 2c7c38a..0000000 --- a/qt/common/smart-ptr/driver.cxx +++ /dev/null @@ -1,248 +0,0 @@ -// file : qt/common/smart-ptr/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt smart pointers. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -// Force instantiation of all QLazySharedPointer and QLazyWeakPointer -// class template members. -// -template class QLazySharedPointer; -template class QLazyWeakPointer; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - QSharedPointer c1 (new cont (1)); - QSharedPointer c2 (new cont (2)); - - // Test boolean conversion operator. - // - { - assert (!QLazySharedPointer ()); - assert (!QLazyWeakPointer ()); - assert (QLazySharedPointer (c1)); - assert (QLazySharedPointer (*db, 1)); - assert (QLazyWeakPointer (c1)); - assert (QLazyWeakPointer (*db, 1)); - } - - // Test loaded () implementation. - // - { - assert (QLazySharedPointer ().loaded ()); - assert (!QLazySharedPointer (c1).loaded ()); - assert (!QLazySharedPointer (*db, 1).loaded ()); - assert (QLazySharedPointer (*db, c1).loaded ()); - assert (QLazyWeakPointer ().loaded ()); - assert (!QLazyWeakPointer (c1).loaded ()); - assert (!QLazyWeakPointer (*db, 1).loaded ()); - assert (QLazyWeakPointer (*db, c1).loaded ()); - } - - // Test comparison operators. - // - { - // Transient QLazySharedPointer. - // - assert (QLazySharedPointer () == QLazySharedPointer ()); - assert (QLazySharedPointer () != QLazySharedPointer (c1)); - assert (QLazySharedPointer (c1) != QLazySharedPointer (c2)); - assert (QLazySharedPointer (c2) == QLazySharedPointer (c2)); - - // Persistent QLazySharedPointer. - // - QLazySharedPointer ls1 (*db, 1), ls2 (*db, c2); - assert (ls1 != QLazySharedPointer ()); - assert (ls1 != QLazySharedPointer (c1)); - assert (ls1 == QLazySharedPointer (*db, c1)); - assert (ls1 != ls2); - assert (ls2 == QLazySharedPointer (c2)); - - // Transient QLazyWeakPointer. - // - assert (QLazyWeakPointer () == QLazyWeakPointer ()); - assert (QLazyWeakPointer () != QLazyWeakPointer (c1)); - assert (QLazyWeakPointer (c1) != QLazyWeakPointer (c2)); - assert (QLazyWeakPointer (c2) == QLazyWeakPointer (c2)); - assert (QLazyWeakPointer () == QLazySharedPointer ()); - assert (QLazyWeakPointer () != QLazySharedPointer (c1)); - assert (QLazyWeakPointer (c1) != QLazySharedPointer (c2)); - assert (QLazyWeakPointer (c2) == QLazySharedPointer (c2)); - - // Persistent QLazyWeakPointer. - // - QLazyWeakPointer lw1 (*db, 1), lw2 (*db, c2); - assert (lw1 != QLazyWeakPointer ()); - assert (lw1 != QLazyWeakPointer (c1)); - assert (lw1 == QLazyWeakPointer (*db, c1)); - assert (lw1 != lw2); - assert (lw2 == QLazyWeakPointer (c2)); - assert (ls1 == lw1); - assert (ls1 != QLazyWeakPointer (c1)); - assert (ls1 == QLazyWeakPointer (*db, c1)); - assert (ls1 != lw2); - assert (ls2 == QLazyWeakPointer (c2)); - } - - // Test swap. - // - { - QLazySharedPointer lx (*db, 1), ly; - swap (lx, ly); - - assert (lx.isNull ()); - assert (ly == QLazySharedPointer (*db, c1)); - } - - // Persist. - // - QSharedPointer o1 (new obj (1)); - QSharedPointer o2 (new obj (2)); - QSharedPointer o3 (new obj (3)); - QSharedPointer o4 (new obj (4)); - - o1->c = c1; - o2->c = c1; - o3->c = c2; - o4->c = c2; - - { - transaction t (db->begin ()); - - db->persist (c1); - - db->persist (o1); - db->persist (o2); - db->persist (o3); - db->persist (o4); - - db->persist (c2); - - t.commit (); - } - - // Load. - // - { - session s; - transaction t (db->begin ()); - - QSharedPointer c (db->load (1)); - QSharedPointer o (db->load (1)); - - // Ensure that lazy pointers are present but not loaded. - // - assert (c->o.size () == 2); - assert (!c->o[0].loaded ()); - assert (!c->o[1].loaded ()); - assert (!o->c.loaded ()); - - // Ensure that the correct object IDs were loaded. - // - assert (c->o[0].objectId () == 1); - assert (c->o[1].objectId () == 2); - assert (o->c.objectId () == 1); - - // Load the lazy pointer targets ensuring that the loaded - // targets correspond to the cached session objects. - // - QSharedPointer cl (o->c.load ()); - QSharedPointer ol (c->o[0].load ()); - - assert (c->o[0].loaded ()); - assert (o->c.loaded ()); - - assert (cl == c); - assert (ol == o); - - t.commit (); - } - - // Test lazy weak locking and reloading. - // - { - // No session. - // - transaction t (db->begin ()); - QSharedPointer c (db->load (1)); - - // Lock. - // - assert (!c->o[1].loaded ()); - QLazySharedPointer l (c->o[1].toStrongRef ()); - assert (!l.loaded ()); - assert (l.objectId () == c->o[1].objectId ()); - - // Reload. - // - assert (!c->o[1].loaded ()); - - QSharedPointer ol (c->o[1].load ()); - assert (c->o[1].loaded ()); - - ol.clear (); - assert (!c->o[1].loaded ()); - - ol = c->o[1].load (); - assert (c->o[1].loaded ()); - - t.commit (); - } - - // - // Test QSharedPointer as a value wrapper. - // - - { - obj2 o1 (1); - obj2 o2 (2); - o2.num = QSharedPointer (new unsigned long (123)); - - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - QSharedPointer o1 (db->load (1)); - QSharedPointer o2 (db->load (2)); - t.commit (); - - assert (!o1->num); - assert (o2->num && *o2->num == 123); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/common/smart-ptr/test.hxx b/qt/common/smart-ptr/test.hxx deleted file mode 100644 index 2c8bf36..0000000 --- a/qt/common/smart-ptr/test.hxx +++ /dev/null @@ -1,77 +0,0 @@ -// file : qt/common/smart-ptr/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#include -#include - -struct obj; - -#pragma db object -struct cont -{ - cont () - { - } - - cont (unsigned long id) - : id (id) - { - } - - #pragma db id - unsigned long id; - - typedef std::vector > obj_list; - - #pragma db inverse(c) value_not_null - obj_list o; -}; - -#pragma db object -struct obj -{ - obj () - { - } - - obj (unsigned long id) - : id (id) - { - } - - #pragma db id - unsigned long id; - - #pragma db not_null - QLazySharedPointer c; -}; - -// Test QSharedPointer as a value wrapper. -// -#pragma db object -struct obj2 -{ - obj2 () - { - } - - obj2 (unsigned long id) - : id (id) - { - } - - #pragma db id - unsigned long id; - - #pragma db null - QSharedPointer num; -}; - -#endif // TEST_HXX diff --git a/qt/common/template/driver.cxx b/qt/common/template/driver.cxx deleted file mode 100644 index 30f9fc6..0000000 --- a/qt/common/template/driver.cxx +++ /dev/null @@ -1,43 +0,0 @@ -// file : qt/common/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/common/template/template-qt4-vc10.vcxproj b/qt/common/template/template-qt4-vc10.vcxproj deleted file mode 100644 index fddcac3..0000000 --- a/qt/common/template/template-qt4-vc10.vcxproj +++ /dev/null @@ -1,177 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - - -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/qt/common/template/template-qt4-vc10.vcxproj.filters b/qt/common/template/template-qt4-vc10.vcxproj.filters deleted file mode 100644 index f3ee658..0000000 --- a/qt/common/template/template-qt4-vc10.vcxproj.filters +++ /dev/null @@ -1,24 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test-odb.cxx) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/common/template/template-qt4-vc11.vcxproj b/qt/common/template/template-qt4-vc11.vcxproj deleted file mode 100644 index a71ac6b..0000000 --- a/qt/common/template/template-qt4-vc11.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - - -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/qt/common/template/template-qt4-vc11.vcxproj.filters b/qt/common/template/template-qt4-vc11.vcxproj.filters deleted file mode 100644 index f3ee658..0000000 --- a/qt/common/template/template-qt4-vc11.vcxproj.filters +++ /dev/null @@ -1,24 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test-odb.cxx) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/common/template/template-qt4-vc12.vcxproj b/qt/common/template/template-qt4-vc12.vcxproj deleted file mode 100644 index eaa4d12..0000000 --- a/qt/common/template/template-qt4-vc12.vcxproj +++ /dev/null @@ -1,185 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - - -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/qt/common/template/template-qt4-vc12.vcxproj.filters b/qt/common/template/template-qt4-vc12.vcxproj.filters deleted file mode 100644 index f3ee658..0000000 --- a/qt/common/template/template-qt4-vc12.vcxproj.filters +++ /dev/null @@ -1,24 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test-odb.cxx) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/common/template/template-qt4-vc8.vcproj b/qt/common/template/template-qt4-vc8.vcproj deleted file mode 100644 index 63fc22c..0000000 --- a/qt/common/template/template-qt4-vc8.vcproj +++ /dev/null @@ -1,353 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx) -__file_entries__(extra_headers) - - - - - diff --git a/qt/common/template/template-qt4-vc9.vcproj b/qt/common/template/template-qt4-vc9.vcproj deleted file mode 100644 index b37675e..0000000 --- a/qt/common/template/template-qt4-vc9.vcproj +++ /dev/null @@ -1,360 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx) -__file_entries__(extra_headers) - - - - - diff --git a/qt/common/template/template-qt5-vc10.vcxproj b/qt/common/template/template-qt5-vc10.vcxproj deleted file mode 100644 index add071a..0000000 --- a/qt/common/template/template-qt5-vc10.vcxproj +++ /dev/null @@ -1,177 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - - -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/qt/common/template/template-qt5-vc10.vcxproj.filters b/qt/common/template/template-qt5-vc10.vcxproj.filters deleted file mode 100644 index f3ee658..0000000 --- a/qt/common/template/template-qt5-vc10.vcxproj.filters +++ /dev/null @@ -1,24 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test-odb.cxx) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/common/template/template-qt5-vc11.vcxproj b/qt/common/template/template-qt5-vc11.vcxproj deleted file mode 100644 index 07daa25..0000000 --- a/qt/common/template/template-qt5-vc11.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - - -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/qt/common/template/template-qt5-vc11.vcxproj.filters b/qt/common/template/template-qt5-vc11.vcxproj.filters deleted file mode 100644 index f3ee658..0000000 --- a/qt/common/template/template-qt5-vc11.vcxproj.filters +++ /dev/null @@ -1,24 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test-odb.cxx) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/common/template/template-qt5-vc12.vcxproj b/qt/common/template/template-qt5-vc12.vcxproj deleted file mode 100644 index a64ba40..0000000 --- a/qt/common/template/template-qt5-vc12.vcxproj +++ /dev/null @@ -1,185 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-__value__(database)-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;__upcase__(database_)__upcase__(__value__(database));HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-__value__(database).lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - - -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - - - - diff --git a/qt/common/template/template-qt5-vc12.vcxproj.filters b/qt/common/template/template-qt5-vc12.vcxproj.filters deleted file mode 100644 index f3ee658..0000000 --- a/qt/common/template/template-qt5-vc12.vcxproj.filters +++ /dev/null @@ -1,24 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__source_filter_entry__(test-odb.cxx) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/common/template/template-qt5-vc9.vcproj b/qt/common/template/template-qt5-vc9.vcproj deleted file mode 100644 index 57b4edc..0000000 --- a/qt/common/template/template-qt5-vc9.vcproj +++ /dev/null @@ -1,360 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__source_entry__(test-odb.cxx) -__source_entries__(extra_sources) - - -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe --database __value__(database) __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx) -__file_entries__(extra_headers) - - - - - diff --git a/qt/common/template/test.hxx b/qt/common/template/test.hxx deleted file mode 100644 index 6f38186..0000000 --- a/qt/common/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : qt/common/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/qt/mssql/basic/driver.cxx b/qt/mssql/basic/driver.cxx deleted file mode 100644 index fca335d..0000000 --- a/qt/mssql/basic/driver.cxx +++ /dev/null @@ -1,65 +0,0 @@ -// file : qt/mssql/basic/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt basic type persistence. SQL Server version. -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - object o; - o.id_ = "object 1"; - o.sstr_ = QString (512, 's'); - o.lstr_ = QString (65000, 'l'); // Test temp buffer boundary. - o.snstr_ = QString (512, QChar (0x1234)); - o.lnstr_ = QString (65536, QChar (0x2345)); - o.sbuf_ = QByteArray (512, 0x01); - o.lbuf_ = QByteArray (65536, 0x02); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (o.id_)); - t.commit (); - - assert (*p == o); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/mssql/basic/test.hxx b/qt/mssql/basic/test.hxx deleted file mode 100644 index bce87b6..0000000 --- a/qt/mssql/basic/test.hxx +++ /dev/null @@ -1,46 +0,0 @@ -// file : qt/mssql/basic/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object -struct object -{ - bool - operator== (const object& x) const - { - return - id_ == x.id_ && - sstr_ == x.sstr_ && - lstr_ == x.lstr_ && - snstr_ == x.snstr_ && - lnstr_ == x.lnstr_ && - sbuf_ == x.sbuf_ && - lbuf_ == x.lbuf_; - } - - #pragma db id - QString id_; - - QString sstr_; - - #pragma db type ("VARCHAR(max)") - QString lstr_; - - #pragma db type ("NVARCHAR(512)") - QString snstr_; - - #pragma db type ("NVARCHAR(max)") - QString lnstr_; - - #pragma db type ("VARBINARY(512)") - QByteArray sbuf_; - - QByteArray lbuf_; -}; - -#endif // TEST_HXX diff --git a/qt/mssql/date-time/driver.cxx b/qt/mssql/date-time/driver.cxx deleted file mode 100644 index 9b4320e..0000000 --- a/qt/mssql/date-time/driver.cxx +++ /dev/null @@ -1,94 +0,0 @@ -// file : qt/mssql/date-time/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt date/time type persistence. SQL Server version. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - object o; - - // Check persistence of null values. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (ol->is_null ()); - } - - // Check persistence of valid dates and times. - // -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - QDateTime t (QDateTime::currentDateTime ()); - - o.date = t.date (); - o.date_time = t; -#endif - - // In DATETIME fractional seconds are rounded to .000, .003, or .007. - // - o.date_time_dt = QDateTime (QDate (2012, 1, 14), - QTime (11, 57, 13, 3)); - - // SMALLDATETIME doesn't have seconds (always 0). - // - o.date_time_sdt = QDateTime (QDate (2012, 1, 14), - QTime (11, 57, 0, 0)); - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - o.time = t.time (); -#endif - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (*ol == o); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/mssql/date-time/test.hxx b/qt/mssql/date-time/test.hxx deleted file mode 100644 index 71769b9..0000000 --- a/qt/mssql/date-time/test.hxx +++ /dev/null @@ -1,68 +0,0 @@ -// file : qt/mssql/date-time/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object -struct object -{ - #pragma db id auto - unsigned long id; - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - QDate date; - - QDateTime date_time; -#endif - - #pragma db type ("DATETIME") - QDateTime date_time_dt; - - #pragma db type ("SMALLDATETIME") - QDateTime date_time_sdt; - -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - QTime time; -#endif - - bool - operator== (const object& x) const - { - return - id == x.id -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - && date == x.date - && date_time == x.date_time -#endif - && date_time_dt == x.date_time_dt - && date_time_sdt == x.date_time_sdt -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - && time == x.time -#endif - ; - } - - bool - is_null () const - { - return - true -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - && date.isNull () - && date_time.isNull () -#endif - && date_time_dt.isNull () - && date_time_sdt.isNull () -#if !defined(MSSQL_SERVER_VERSION) || MSSQL_SERVER_VERSION >= 1000 - && time.isNull () -#endif - ; - } -}; - -#endif // TEST_HXX diff --git a/qt/mssql/template/driver.cxx b/qt/mssql/template/driver.cxx deleted file mode 100644 index 97ef6ef..0000000 --- a/qt/mssql/template/driver.cxx +++ /dev/null @@ -1,43 +0,0 @@ -// file : qt/mssql/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/mssql/template/template-qt4-vc10.vcxproj b/qt/mssql/template/template-qt4-vc10.vcxproj deleted file mode 100644 index e4902d0..0000000 --- a/qt/mssql/template/template-qt4-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mssql/template/template-qt4-vc10.vcxproj.filters b/qt/mssql/template/template-qt4-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mssql/template/template-qt4-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mssql/template/template-qt4-vc11.vcxproj b/qt/mssql/template/template-qt4-vc11.vcxproj deleted file mode 100644 index b9dd89c..0000000 --- a/qt/mssql/template/template-qt4-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mssql/template/template-qt4-vc11.vcxproj.filters b/qt/mssql/template/template-qt4-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mssql/template/template-qt4-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mssql/template/template-qt4-vc12.vcxproj b/qt/mssql/template/template-qt4-vc12.vcxproj deleted file mode 100644 index 0916a38..0000000 --- a/qt/mssql/template/template-qt4-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mssql/template/template-qt4-vc12.vcxproj.filters b/qt/mssql/template/template-qt4-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mssql/template/template-qt4-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mssql/template/template-qt4-vc8.vcproj b/qt/mssql/template/template-qt4-vc8.vcproj deleted file mode 100644 index 38916fa..0000000 --- a/qt/mssql/template/template-qt4-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/mssql/template/template-qt4-vc9.vcproj b/qt/mssql/template/template-qt4-vc9.vcproj deleted file mode 100644 index da1b5ab..0000000 --- a/qt/mssql/template/template-qt4-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/mssql/template/template-qt5-vc10.vcxproj b/qt/mssql/template/template-qt5-vc10.vcxproj deleted file mode 100644 index 508e262..0000000 --- a/qt/mssql/template/template-qt5-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mssql/template/template-qt5-vc10.vcxproj.filters b/qt/mssql/template/template-qt5-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mssql/template/template-qt5-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mssql/template/template-qt5-vc11.vcxproj b/qt/mssql/template/template-qt5-vc11.vcxproj deleted file mode 100644 index a974034..0000000 --- a/qt/mssql/template/template-qt5-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mssql/template/template-qt5-vc11.vcxproj.filters b/qt/mssql/template/template-qt5-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mssql/template/template-qt5-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mssql/template/template-qt5-vc12.vcxproj b/qt/mssql/template/template-qt5-vc12.vcxproj deleted file mode 100644 index 40e2fbb..0000000 --- a/qt/mssql/template/template-qt5-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mssql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mssql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mssql/template/template-qt5-vc12.vcxproj.filters b/qt/mssql/template/template-qt5-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mssql/template/template-qt5-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mssql/template/template-qt5-vc9.vcproj b/qt/mssql/template/template-qt5-vc9.vcproj deleted file mode 100644 index 66ea9ab..0000000 --- a/qt/mssql/template/template-qt5-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/mssql/template/test.hxx b/qt/mssql/template/test.hxx deleted file mode 100644 index 033703a..0000000 --- a/qt/mssql/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : qt/mssql/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/qt/mysql/basic/driver.cxx b/qt/mysql/basic/driver.cxx deleted file mode 100644 index b685d68..0000000 --- a/qt/mysql/basic/driver.cxx +++ /dev/null @@ -1,60 +0,0 @@ -// file : qt/mysql/basic/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt basic type persistence. MySQL version. -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - object o; - o.str = "Constantin Michael"; - o.blob = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (o.str)); - t.commit (); - - assert (*p == o); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/mysql/basic/test.hxx b/qt/mysql/basic/test.hxx deleted file mode 100644 index 6dd246e..0000000 --- a/qt/mysql/basic/test.hxx +++ /dev/null @@ -1,27 +0,0 @@ -// file : qt/mysql/basic/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object -struct object -{ - bool - operator== (const object& x) const - { - return - str == x.str && - blob == x.blob; - } - - #pragma db id - QString str; - - QByteArray blob; -}; - -#endif // TEST_HXX diff --git a/qt/mysql/date-time/driver.cxx b/qt/mysql/date-time/driver.cxx deleted file mode 100644 index 94cf653..0000000 --- a/qt/mysql/date-time/driver.cxx +++ /dev/null @@ -1,178 +0,0 @@ -// file : qt/mysql/date-time/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt date/time type persistence. MySQL version. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -bool -test_out_of_range_value (object&, database&); - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - mysql_version v; - { - transaction t (db->begin ()); - db->query ().begin ().load (v); - t.commit (); - } - - // If we are running against MySQL 5.6.4 or later alter the tables - // to allow sub-second precision. - // - bool fs (v.major > 5 || - (v.major == 5 && (v.minor > 6 || - (v.minor == 6 && v.release >= 4)))); - if (fs) - { - transaction t (db->begin ()); - db->execute ("ALTER TABLE `qt_mysql_dt_object`" \ - " MODIFY COLUMN `date_time` DATETIME(3)," \ - " MODIFY COLUMN `timestamp` TIMESTAMP(3) NULL," \ - " MODIFY COLUMN `time` TIME(3)"); - t.commit (); - } - - // - // Check valid dates and times. - // - - object o; - - // Check persistence of null values. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (ol->is_null ()); - } - - // Check persistence of valid dates and times. - // - - // Create a QDateTime containing the current date and time - // but with the milliseconds zeroed. MySQL prior to 5.6.4 - // does not support sub-second prevision. - // - QDateTime t (QDateTime::currentDateTime ()); - - if (!fs) - t.setTime (QTime (t.time ().hour (), - t.time ().minute (), - t.time ().second ())); - - o.date = t.date (); - o.date_time = t; - o.timestamp = t; - o.time = t.time (); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (*ol == o); - } - - // - // Check invalid dates and times. - // - - { - // Test out of range dates. - // - object or1, or2; - or1.date = QDate (999, 12, 31); - or2.date = QDate (10000, 1, 1); - - transaction t (db->begin ()); - assert (test_out_of_range_value (or1, *db)); - assert (test_out_of_range_value (or2, *db)); - t.commit (); - } - - { - // Test out of range date-times. - // - object or1, or2; - or1.date_time = QDateTime (QDate (999, 12, 31), QTime (23, 59, 59)); - or2.date_time = QDateTime (QDate (10000, 1, 1)); - - transaction t (db->begin ()); - assert (test_out_of_range_value (or1, *db)); - assert (test_out_of_range_value (or2, *db)); - t.commit (); - } - - { - // Test out of range timestamps. - // - object or1, or2; - or1.timestamp = QDateTime (QDate (1970, 1, 1)); - or2.timestamp = QDateTime (QDate (2038, 1, 19), QTime (3, 14, 8)); - - transaction t (db->begin ()); - assert (test_out_of_range_value (or1, *db)); - assert (test_out_of_range_value (or2, *db)); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} - -bool -test_out_of_range_value (object& x, database& db) -{ - try - { - db.persist (x); - return false; - } - catch (const odb::qt::date_time::value_out_of_range&) - { - } - - return true; -} diff --git a/qt/mysql/date-time/test.hxx b/qt/mysql/date-time/test.hxx deleted file mode 100644 index ba31da5..0000000 --- a/qt/mysql/date-time/test.hxx +++ /dev/null @@ -1,70 +0,0 @@ -// file : qt/mysql/date-time/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#include - -#pragma db object -struct object -{ - bool - operator== (const object& x) const - { - return - id == x.id && - date == x.date && - date_time == x.date_time && - timestamp == x.timestamp && - time == x.time; - } - - bool - is_null () const - { - return - date.isNull () && - date_time.isNull () && - timestamp.isNull () && - time.isNull (); - } - - #pragma db id auto - unsigned long id; - - QDate date; - QDateTime date_time; - - // Make timestamp NULL-able to suppress the auto-initialization and - // auto-update characteristics of the TIMESTAMP datatype, and to - // allow NULL values. - // - #pragma db type("TIMESTAMP") null - QDateTime timestamp; - - QTime time; -}; - -// MySQL server version view. -// -#pragma db view query( \ - "SELECT " \ - "CAST(SUBSTRING_INDEX(@@version, '.', 1) AS UNSIGNED)," \ - "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '.', 2), '.', -1) AS UNSIGNED)," \ - "CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(@@version, '-', 1), '.', -1) AS UNSIGNED)," \ - "@@protocol_version") -struct mysql_version -{ - unsigned int major; - unsigned int minor; - unsigned int release; - - unsigned int protocol; -}; - -#endif // TEST_HXX diff --git a/qt/mysql/template/driver.cxx b/qt/mysql/template/driver.cxx deleted file mode 100644 index 1e293b4..0000000 --- a/qt/mysql/template/driver.cxx +++ /dev/null @@ -1,43 +0,0 @@ -// file : qt/mysql/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/mysql/template/template-qt4-vc10.vcxproj b/qt/mysql/template/template-qt4-vc10.vcxproj deleted file mode 100644 index 0f57bbe..0000000 --- a/qt/mysql/template/template-qt4-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mysql/template/template-qt4-vc10.vcxproj.filters b/qt/mysql/template/template-qt4-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mysql/template/template-qt4-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mysql/template/template-qt4-vc11.vcxproj b/qt/mysql/template/template-qt4-vc11.vcxproj deleted file mode 100644 index 33cb785..0000000 --- a/qt/mysql/template/template-qt4-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mysql/template/template-qt4-vc11.vcxproj.filters b/qt/mysql/template/template-qt4-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mysql/template/template-qt4-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mysql/template/template-qt4-vc12.vcxproj b/qt/mysql/template/template-qt4-vc12.vcxproj deleted file mode 100644 index 6a2812a..0000000 --- a/qt/mysql/template/template-qt4-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mysql/template/template-qt4-vc12.vcxproj.filters b/qt/mysql/template/template-qt4-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mysql/template/template-qt4-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mysql/template/template-qt4-vc8.vcproj b/qt/mysql/template/template-qt4-vc8.vcproj deleted file mode 100644 index 25e096f..0000000 --- a/qt/mysql/template/template-qt4-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/mysql/template/template-qt4-vc9.vcproj b/qt/mysql/template/template-qt4-vc9.vcproj deleted file mode 100644 index a904d40..0000000 --- a/qt/mysql/template/template-qt4-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/mysql/template/template-qt5-vc10.vcxproj b/qt/mysql/template/template-qt5-vc10.vcxproj deleted file mode 100644 index 27eb1a8..0000000 --- a/qt/mysql/template/template-qt5-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mysql/template/template-qt5-vc10.vcxproj.filters b/qt/mysql/template/template-qt5-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mysql/template/template-qt5-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mysql/template/template-qt5-vc11.vcxproj b/qt/mysql/template/template-qt5-vc11.vcxproj deleted file mode 100644 index 7a2e2b9..0000000 --- a/qt/mysql/template/template-qt5-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mysql/template/template-qt5-vc11.vcxproj.filters b/qt/mysql/template/template-qt5-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mysql/template/template-qt5-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mysql/template/template-qt5-vc12.vcxproj b/qt/mysql/template/template-qt5-vc12.vcxproj deleted file mode 100644 index f75d5d3..0000000 --- a/qt/mysql/template/template-qt5-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/mysql/template/template-qt5-vc12.vcxproj.filters b/qt/mysql/template/template-qt5-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/mysql/template/template-qt5-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/mysql/template/template-qt5-vc9.vcproj b/qt/mysql/template/template-qt5-vc9.vcproj deleted file mode 100644 index c17267b..0000000 --- a/qt/mysql/template/template-qt5-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/mysql/template/test.hxx b/qt/mysql/template/test.hxx deleted file mode 100644 index 94b806d..0000000 --- a/qt/mysql/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : qt/mysql/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/qt/oracle/basic/driver.cxx b/qt/oracle/basic/driver.cxx deleted file mode 100644 index 43a20e2..0000000 --- a/qt/oracle/basic/driver.cxx +++ /dev/null @@ -1,81 +0,0 @@ -// file : qt/oracle/basic/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt basic type persistence. Oracle version. -// - -#include // std::auto_ptr -#include -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - string short_str (13, 's'); - string medium_str (150, 'm'); - string long_str (20000, 'v'); - // Oracle UTF-8 support is limited to 3-byte sequences. - // - string unicode_str ("a \xD5\x95 \xEA\xAA\xAA \xE2\x82\xAC bcdef"); - - object o; - - o.char_= QString::fromStdString (short_str); - o.varchar2 = QString::fromStdString (medium_str); - o.clob = QString::fromStdString (long_str); - - // fromStdString() assumes ASCII in Qt4 and UTF-8 in Qt5. - // - o.nchar= QString::fromUtf8 (unicode_str.c_str (), - static_cast (unicode_str.size ())); - o.nvarchar2 = QString::fromUtf8 (unicode_str.c_str (), - static_cast (unicode_str.size ())); - o.nclob = QString::fromStdString (long_str); - - o.raw = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); - o.blob = QByteArray (long_str.c_str (), - static_cast (long_str.size ())); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (o.varchar2)); - t.commit (); - assert (*p == o); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/oracle/basic/test.hxx b/qt/oracle/basic/test.hxx deleted file mode 100644 index 6781a97..0000000 --- a/qt/oracle/basic/test.hxx +++ /dev/null @@ -1,51 +0,0 @@ -// file : qt/oracle/basic/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object -struct object -{ - bool - operator== (const object& x) const - { - return - varchar2 == x.varchar2 && - char_ == x.char_ && - nchar == x.nchar && - nvarchar2 == x.nvarchar2 && - clob == x.clob && - nclob == x.nclob && - blob == x.blob && - raw == x.raw; - } - - #pragma db id - QString varchar2; - - #pragma db type ("CHAR(13)") - QString char_; - - #pragma db type ("NCHAR(13)") - QString nchar; - - #pragma db type ("NVARCHAR2(512)") - QString nvarchar2; - - #pragma db type ("CLOB") - QString clob; - - #pragma db type ("NCLOB") - QString nclob; - - QByteArray blob; - - #pragma db type ("RAW(128)") - QByteArray raw; -}; - -#endif // TEST_HXX diff --git a/qt/oracle/date-time/driver.cxx b/qt/oracle/date-time/driver.cxx deleted file mode 100644 index d13fab7..0000000 --- a/qt/oracle/date-time/driver.cxx +++ /dev/null @@ -1,80 +0,0 @@ -// file : qt/oracle/date-time/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt date/time type persistence. Oracle version. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - object o; - - // Check persistence of null values. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (ol->is_null ()); - } - - // Check persistence of valid dates and times. - // - QDateTime t (QDateTime::currentDateTime ()); - - o.date = t.date (); - o.date_time = t; - o.date_time_d = QDateTime (QDate (2012, 6, 27), QTime (14, 17, 05, 0)); - o.time = t.time (); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (*ol == o); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/oracle/date-time/test.hxx b/qt/oracle/date-time/test.hxx deleted file mode 100644 index 93bc5b7..0000000 --- a/qt/oracle/date-time/test.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// file : qt/oracle/date-time/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#pragma db object -struct object -{ - bool - operator== (const object& x) const - { - return - id == x.id && - date == x.date && - date_time == x.date_time && - date_time_d == x.date_time_d && - time == x.time; - } - - bool - is_null () const - { - return - date.isNull () && - date_time.isNull () && - date_time_d.isNull () && - time.isNull (); - } - - #pragma db id auto - unsigned long id; - - QDate date; - QDateTime date_time; - #pragma db type("DATE") - QDateTime date_time_d; - QTime time; -}; - -#endif // TEST_HXX diff --git a/qt/oracle/template/driver.cxx b/qt/oracle/template/driver.cxx deleted file mode 100644 index 9b092a9..0000000 --- a/qt/oracle/template/driver.cxx +++ /dev/null @@ -1,43 +0,0 @@ -// file : qt/oracle/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/oracle/template/template-qt4-vc10.vcxproj b/qt/oracle/template/template-qt4-vc10.vcxproj deleted file mode 100644 index 6e7c369..0000000 --- a/qt/oracle/template/template-qt4-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/oracle/template/template-qt4-vc10.vcxproj.filters b/qt/oracle/template/template-qt4-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/oracle/template/template-qt4-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/oracle/template/template-qt4-vc11.vcxproj b/qt/oracle/template/template-qt4-vc11.vcxproj deleted file mode 100644 index ad1e888..0000000 --- a/qt/oracle/template/template-qt4-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/oracle/template/template-qt4-vc11.vcxproj.filters b/qt/oracle/template/template-qt4-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/oracle/template/template-qt4-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/oracle/template/template-qt4-vc12.vcxproj b/qt/oracle/template/template-qt4-vc12.vcxproj deleted file mode 100644 index 88dffa8..0000000 --- a/qt/oracle/template/template-qt4-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/oracle/template/template-qt4-vc12.vcxproj.filters b/qt/oracle/template/template-qt4-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/oracle/template/template-qt4-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/oracle/template/template-qt4-vc8.vcproj b/qt/oracle/template/template-qt4-vc8.vcproj deleted file mode 100644 index 187254b..0000000 --- a/qt/oracle/template/template-qt4-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/oracle/template/template-qt4-vc9.vcproj b/qt/oracle/template/template-qt4-vc9.vcproj deleted file mode 100644 index 292b899..0000000 --- a/qt/oracle/template/template-qt4-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/oracle/template/template-qt5-vc10.vcxproj b/qt/oracle/template/template-qt5-vc10.vcxproj deleted file mode 100644 index c388d6b..0000000 --- a/qt/oracle/template/template-qt5-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/oracle/template/template-qt5-vc10.vcxproj.filters b/qt/oracle/template/template-qt5-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/oracle/template/template-qt5-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/oracle/template/template-qt5-vc11.vcxproj b/qt/oracle/template/template-qt5-vc11.vcxproj deleted file mode 100644 index 79d5d15..0000000 --- a/qt/oracle/template/template-qt5-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/oracle/template/template-qt5-vc11.vcxproj.filters b/qt/oracle/template/template-qt5-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/oracle/template/template-qt5-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/oracle/template/template-qt5-vc12.vcxproj b/qt/oracle/template/template-qt5-vc12.vcxproj deleted file mode 100644 index 2ae82a6..0000000 --- a/qt/oracle/template/template-qt5-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-oracle-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-oracle.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/oracle/template/template-qt5-vc12.vcxproj.filters b/qt/oracle/template/template-qt5-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/oracle/template/template-qt5-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/oracle/template/template-qt5-vc9.vcproj b/qt/oracle/template/template-qt5-vc9.vcproj deleted file mode 100644 index 2712157..0000000 --- a/qt/oracle/template/template-qt5-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/oracle/template/test.hxx b/qt/oracle/template/test.hxx deleted file mode 100644 index 0ad65cf..0000000 --- a/qt/oracle/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : qt/oracle/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/qt/pgsql/basic/driver.cxx b/qt/pgsql/basic/driver.cxx deleted file mode 100644 index 4c6a78a..0000000 --- a/qt/pgsql/basic/driver.cxx +++ /dev/null @@ -1,60 +0,0 @@ -// file : qt/pgsql/basic/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt basic type persistence. PostgreSQL version. -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - object o; - o.str = "Constantin Michael"; - o.blob = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (o.str)); - t.commit (); - - assert (*p == o); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/pgsql/basic/test.hxx b/qt/pgsql/basic/test.hxx deleted file mode 100644 index d4a1ba6..0000000 --- a/qt/pgsql/basic/test.hxx +++ /dev/null @@ -1,27 +0,0 @@ -// file : qt/pgsql/basic/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object -struct object -{ - bool - operator== (const object& x) const - { - return - str == x.str && - blob == x.blob; - } - - #pragma db id - QString str; - - QByteArray blob; -}; - -#endif // TEST_HXX diff --git a/qt/pgsql/date-time/driver.cxx b/qt/pgsql/date-time/driver.cxx deleted file mode 100644 index 43a676d..0000000 --- a/qt/pgsql/date-time/driver.cxx +++ /dev/null @@ -1,108 +0,0 @@ -// file : qt/pgsql/date-time/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt date/time type persistence. PostgreSQL version. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -bool -test_out_of_range_value (object&, database&); - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - // Check persistence of null values. - // - { - object o; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (ol->is_null ()); - } - } - - // Check persistence of valid dates and times. - // - { - QDateTime ct (QDateTime::currentDateTime ()); - - object o; - o.date = ct.date (); - o.time = ct.time (); - o.date_time = ct; - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (*ol == o); - } - } - - // Test a QDateTime value before PG epoch. - // - { - object o; - o.date_time = QDateTime (QDate (1969, 12, 31), QTime (23, 59, 59, 123)); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol (db->load (o.id)); - t.commit (); - - assert (*ol == o); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/pgsql/date-time/test.hxx b/qt/pgsql/date-time/test.hxx deleted file mode 100644 index 2da5587..0000000 --- a/qt/pgsql/date-time/test.hxx +++ /dev/null @@ -1,43 +0,0 @@ -// file : qt/pgsql/date-time/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#include - -#pragma db object -struct object -{ - bool - operator== (const object& x) const - { - return - id == x.id && - date == x.date && - time == x.time && - date_time == x.date_time; - } - - bool - is_null () const - { - return - date.isNull () && - time.isNull () && - date_time.isNull (); - } - - #pragma db id auto - unsigned long id; - - QDate date; - QTime time; - QDateTime date_time; -}; - -#endif // TEST_HXX diff --git a/qt/pgsql/template/driver.cxx b/qt/pgsql/template/driver.cxx deleted file mode 100644 index 71934a7..0000000 --- a/qt/pgsql/template/driver.cxx +++ /dev/null @@ -1,43 +0,0 @@ -// file : qt/pgsql/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/pgsql/template/template-qt4-vc10.vcxproj b/qt/pgsql/template/template-qt4-vc10.vcxproj deleted file mode 100644 index 1c1e1a7..0000000 --- a/qt/pgsql/template/template-qt4-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/pgsql/template/template-qt4-vc10.vcxproj.filters b/qt/pgsql/template/template-qt4-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/pgsql/template/template-qt4-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/pgsql/template/template-qt4-vc11.vcxproj b/qt/pgsql/template/template-qt4-vc11.vcxproj deleted file mode 100644 index a7e7a86..0000000 --- a/qt/pgsql/template/template-qt4-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/pgsql/template/template-qt4-vc11.vcxproj.filters b/qt/pgsql/template/template-qt4-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/pgsql/template/template-qt4-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/pgsql/template/template-qt4-vc12.vcxproj b/qt/pgsql/template/template-qt4-vc12.vcxproj deleted file mode 100644 index f1b9924..0000000 --- a/qt/pgsql/template/template-qt4-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/pgsql/template/template-qt4-vc12.vcxproj.filters b/qt/pgsql/template/template-qt4-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/pgsql/template/template-qt4-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/pgsql/template/template-qt4-vc8.vcproj b/qt/pgsql/template/template-qt4-vc8.vcproj deleted file mode 100644 index 3f364d2..0000000 --- a/qt/pgsql/template/template-qt4-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/pgsql/template/template-qt4-vc9.vcproj b/qt/pgsql/template/template-qt4-vc9.vcproj deleted file mode 100644 index 2e9e84b..0000000 --- a/qt/pgsql/template/template-qt4-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/pgsql/template/template-qt5-vc10.vcxproj b/qt/pgsql/template/template-qt5-vc10.vcxproj deleted file mode 100644 index cb6aa0c..0000000 --- a/qt/pgsql/template/template-qt5-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/pgsql/template/template-qt5-vc10.vcxproj.filters b/qt/pgsql/template/template-qt5-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/pgsql/template/template-qt5-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/pgsql/template/template-qt5-vc11.vcxproj b/qt/pgsql/template/template-qt5-vc11.vcxproj deleted file mode 100644 index 863bd51..0000000 --- a/qt/pgsql/template/template-qt5-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/pgsql/template/template-qt5-vc11.vcxproj.filters b/qt/pgsql/template/template-qt5-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/pgsql/template/template-qt5-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/pgsql/template/template-qt5-vc12.vcxproj b/qt/pgsql/template/template-qt5-vc12.vcxproj deleted file mode 100644 index 5d958c2..0000000 --- a/qt/pgsql/template/template-qt5-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-pgsql-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-pgsql.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/pgsql/template/template-qt5-vc12.vcxproj.filters b/qt/pgsql/template/template-qt5-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/pgsql/template/template-qt5-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/pgsql/template/template-qt5-vc9.vcproj b/qt/pgsql/template/template-qt5-vc9.vcproj deleted file mode 100644 index b32a1e7..0000000 --- a/qt/pgsql/template/template-qt5-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/pgsql/template/test.hxx b/qt/pgsql/template/test.hxx deleted file mode 100644 index 8b866bd..0000000 --- a/qt/pgsql/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : qt/pgsql/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/qt/sqlite/basic/driver.cxx b/qt/sqlite/basic/driver.cxx deleted file mode 100644 index 3bae10b..0000000 --- a/qt/sqlite/basic/driver.cxx +++ /dev/null @@ -1,60 +0,0 @@ -// file : qt/sqlite/basic/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt basic type persistence. SQLite version. -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - object o; - o.str = QString::fromUtf8 ("Constantin Micha\xC3\x88l"); - o.blob = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - auto_ptr p (db->load (o.str)); - t.commit (); - - assert (*p == o); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/sqlite/basic/test.hxx b/qt/sqlite/basic/test.hxx deleted file mode 100644 index b0cdf46..0000000 --- a/qt/sqlite/basic/test.hxx +++ /dev/null @@ -1,27 +0,0 @@ -// file : qt/sqlite/basic/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object -struct object -{ - bool - operator== (const object& x) const - { - return - str == x.str && - blob == x.blob; - } - - #pragma db id - QString str; - - QByteArray blob; -}; - -#endif // TEST_HXX diff --git a/qt/sqlite/date-time/driver.cxx b/qt/sqlite/date-time/driver.cxx deleted file mode 100644 index adf7889..0000000 --- a/qt/sqlite/date-time/driver.cxx +++ /dev/null @@ -1,140 +0,0 @@ -// file : qt/sqlite/date-time/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt date/time type persistence. SQLite version. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -bool -test_out_of_range_value (object&, database&); - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - // Check persistence of null values. - // - object o1; - { - transaction t (db->begin ()); - db->persist (o1); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol1 (db->load (o1.id)); - t.commit (); - - assert (ol1->is_null ()); - } - - QDateTime ct (QDateTime::currentDateTime ()); - QDateTime ct_no_ms = QDateTime (QDate (ct.date ().year (), - ct.date ().month (), - ct.date ().day ()), - QTime (ct.time ().hour (), - ct.time ().minute (), - ct.time ().second ())); - - // Check persistence of valid dates and times. - // - object o2; - { - o2.date = ct.date (); - o2.unix_day = ct.date (); - o2.time = ct.time (); - - // QTime stored as SQLite INTEGER has second resolution. - // The millsecond part is zeroed to avoid false negatives. - // - o2.seconds = ct_no_ms.time (); - - o2.date_time = ct; - - // UNIX time has second reolution. The millsecond part is - // zeroed to avoid false negatives. - // - o2.unix_time = ct_no_ms; - - transaction t (db->begin ()); - db->persist (o2); - t.commit (); - } - - { - transaction t (db->begin ()); - auto_ptr ol2 (db->load (o2.id)); - t.commit (); - - assert (*ol2 == o2); - } - - // Test out of range values for QDateTime traits UNIX time - // implementation. - // - { - object o; - o.unix_time = QDateTime (QDate (1969, 12, 31), - QTime (23, 59, 59), - Qt::UTC); - - assert (test_out_of_range_value (o, *db)); - } - - // Test out of range values for QDate traits UNIX time - // implementation. - // - { - object o; - o.unix_day = QDate (QDate (1969, 12, 31)); - - assert (test_out_of_range_value (o, *db)); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} - -bool -test_out_of_range_value (object& x, database& db) -{ - try - { - transaction t (db.begin ()); - db.persist (x); - t.rollback (); - - return false; - } - catch (const odb::qt::date_time::value_out_of_range&) - { - } - - return true; -} diff --git a/qt/sqlite/date-time/test.hxx b/qt/sqlite/date-time/test.hxx deleted file mode 100644 index 9795846..0000000 --- a/qt/sqlite/date-time/test.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// file : qt/sqlite/date-time/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include - -#include - -#pragma db object -struct object -{ - bool - operator== (const object& x) const - { - return - id == x.id && - date == x.date && - unix_day == x.unix_day && - time == x.time && - seconds == x.seconds && - date_time == x.date_time && - unix_time == x.unix_time; - } - - bool - is_null () const - { - return - date.isNull () && - unix_day.isNull () && - time.isNull () && - seconds.isNull () && - date_time.isNull () && - unix_time.isNull (); - } - - #pragma db id auto - unsigned long id; - - QDate date; - - #pragma db type ("INTEGER") - QDate unix_day; - - QTime time; - - #pragma db type ("INTEGER") - QTime seconds; - - QDateTime date_time; - - #pragma db type ("INTEGER") - QDateTime unix_time; -}; - -#endif // TEST_HXX diff --git a/qt/sqlite/template/driver.cxx b/qt/sqlite/template/driver.cxx deleted file mode 100644 index dc1181c..0000000 --- a/qt/sqlite/template/driver.cxx +++ /dev/null @@ -1,43 +0,0 @@ -// file : qt/sqlite/template/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// PLACE TEST DESCRIPTION HERE -// - -#include // std::auto_ptr -#include -#include - -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - QCoreApplication app (argc, argv); - - try - { - auto_ptr db (create_database (argc, argv)); - - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/sqlite/template/template-qt4-vc10.vcxproj b/qt/sqlite/template/template-qt4-vc10.vcxproj deleted file mode 100644 index 5d4cd02..0000000 --- a/qt/sqlite/template/template-qt4-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/sqlite/template/template-qt4-vc10.vcxproj.filters b/qt/sqlite/template/template-qt4-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/sqlite/template/template-qt4-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/sqlite/template/template-qt4-vc11.vcxproj b/qt/sqlite/template/template-qt4-vc11.vcxproj deleted file mode 100644 index 217b75e..0000000 --- a/qt/sqlite/template/template-qt4-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/sqlite/template/template-qt4-vc11.vcxproj.filters b/qt/sqlite/template/template-qt4-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/sqlite/template/template-qt4-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/sqlite/template/template-qt4-vc12.vcxproj b/qt/sqlite/template/template-qt4-vc12.vcxproj deleted file mode 100644 index 43959de..0000000 --- a/qt/sqlite/template/template-qt4-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;QtCored4.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;QtCore4.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/sqlite/template/template-qt4-vc12.vcxproj.filters b/qt/sqlite/template/template-qt4-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/sqlite/template/template-qt4-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/sqlite/template/template-qt4-vc8.vcproj b/qt/sqlite/template/template-qt4-vc8.vcproj deleted file mode 100644 index 16623a8..0000000 --- a/qt/sqlite/template/template-qt4-vc8.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1400 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/sqlite/template/template-qt4-vc9.vcproj b/qt/sqlite/template/template-qt4-vc9.vcproj deleted file mode 100644 index b52f2ec..0000000 --- a/qt/sqlite/template/template-qt4-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/sqlite/template/template-qt5-vc10.vcxproj b/qt/sqlite/template/template-qt5-vc10.vcxproj deleted file mode 100644 index b0f2c28..0000000 --- a/qt/sqlite/template/template-qt5-vc10.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - Unicode - - - Application - true - Unicode - - - Application - false - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1600 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/sqlite/template/template-qt5-vc10.vcxproj.filters b/qt/sqlite/template/template-qt5-vc10.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/sqlite/template/template-qt5-vc10.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/sqlite/template/template-qt5-vc11.vcxproj b/qt/sqlite/template/template-qt5-vc11.vcxproj deleted file mode 100644 index d0ca5d9..0000000 --- a/qt/sqlite/template/template-qt5-vc11.vcxproj +++ /dev/null @@ -1,184 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v110 - Unicode - - - Application - true - v110 - Unicode - - - Application - false - v110 - true - Unicode - - - Application - false - v110 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/sqlite/template/template-qt5-vc11.vcxproj.filters b/qt/sqlite/template/template-qt5-vc11.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/sqlite/template/template-qt5-vc11.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/sqlite/template/template-qt5-vc12.vcxproj b/qt/sqlite/template/template-qt5-vc12.vcxproj deleted file mode 100644 index dc303a6..0000000 --- a/qt/sqlite/template/template-qt5-vc12.vcxproj +++ /dev/null @@ -1,188 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {__uuid__()} - Win32Proj - __value__(name) - - - - Application - true - v120 - Unicode - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - - - - - - - true - $(Configuration)\ - driver - - - true - $(Platform)\$(Configuration)\ - driver - - - false - $(Configuration)\ - driver - - - false - $(Platform)\$(Configuration)\ - driver - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-qt-d.lib;odb-d.lib;Qt5Cored.lib;%(AdditionalDependencies) - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) - $(SolutionDir)\..\..\libcommon - 4068;4355;4800;4290;%(DisableSpecificWarnings) - true - - - $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb-qt.lib;odb.lib;Qt5Core.lib;%(AdditionalDependencies) - Console - true - true - true - - -__ifelse__(__value__(odb_options),,, -m4_dnl - -__custom_build_entry__( -test.hxx, -odb test.hxx, -odb.exe --std c++11 __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1700 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) - ) - -__ifelse__(__value__(odb_options),,, -__header_entry__(test-odb.hxx) -__header_entry__(test-odb.ixx)) -__header_entries__(extra_headers) - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - - - - diff --git a/qt/sqlite/template/template-qt5-vc12.vcxproj.filters b/qt/sqlite/template/template-qt5-vc12.vcxproj.filters deleted file mode 100644 index 8ac18a3..0000000 --- a/qt/sqlite/template/template-qt5-vc12.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {__uuid__()} - cxx - - - {__uuid__()} - h;hxx;ixx;txx - - - -__ifelse__(__value__(odb_options),,, -__header_filter_entry__(test.hxx) -__header_filter_entry__(test-odb.hxx) -__header_filter_entry__(test-odb.ixx)) -__header_filter_entries__(extra_headers) - - -__source_filter_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) -__source_filter_entries__(extra_sources) - - \ No newline at end of file diff --git a/qt/sqlite/template/template-qt5-vc9.vcproj b/qt/sqlite/template/template-qt5-vc9.vcproj deleted file mode 100644 index 79c9389..0000000 --- a/qt/sqlite/template/template-qt5-vc9.vcproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -__source_entry__(driver.cxx) -__ifelse__(__value__(odb_options),,,__source_entry__(test-odb.cxx)) -__source_entries__(extra_sources) - - -__ifelse__(__value__(odb_options),,, -__file_entry_custom_build__( -test.hxx, -odb test.hxx, -odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -DODB_MSC_VER=1500 -I$(SolutionDir)\..\..\libcommon)) test.hxx, -test-odb.hxx;test-odb.ixx;test-odb.cxx) -__file_entry__(test-odb.hxx) -__file_entry__(test-odb.ixx)) -__file_entries__(extra_headers) - - - - - diff --git a/qt/sqlite/template/test.hxx b/qt/sqlite/template/test.hxx deleted file mode 100644 index 1a8d616..0000000 --- a/qt/sqlite/template/test.hxx +++ /dev/null @@ -1,25 +0,0 @@ -// file : qt/sqlite/template/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct object -{ - object (unsigned long id) - : id_ (id) - { - } - - object () - { - } - - #pragma db id - unsigned long id_; -}; - -#endif // TEST_HXX diff --git a/repositories.manifest b/repositories.manifest deleted file mode 100644 index a5b9faa..0000000 --- a/repositories.manifest +++ /dev/null @@ -1,44 +0,0 @@ -: 1 -summary: ODB test suite repository - -: -role: prerequisite -location: https://git.codesynthesis.com/odb/libodb.git##HEAD - -: -role: prerequisite -location: https://git.codesynthesis.com/odb/libodb-mysql.git##HEAD - -: -role: prerequisite -location: https://git.codesynthesis.com/odb/libodb-sqlite.git##HEAD - -: -role: prerequisite -location: https://git.codesynthesis.com/odb/libodb-pgsql.git##HEAD - -: -role: prerequisite -location: https://git.codesynthesis.com/odb/libodb-oracle.git##HEAD - -: -role: prerequisite -location: https://git.codesynthesis.com/odb/libodb-mssql.git##HEAD - -: -role: prerequisite -location: https://git.codesynthesis.com/odb/odb.git##HEAD - -# @@ TMP Uncomment when mysql package is added to mysql.git repository. -# -#: -#role: prerequisite -#location: https://git.build2.org/packaging/mysql/mysql.git##HEAD - -: -role: prerequisite -location: https://git.build2.org/packaging/sqlite/sqlite.git##HEAD - -: -role: prerequisite -location: https://git.build2.org/packaging/postgresql/postgresql.git##HEAD diff --git a/sqlite.testscript b/sqlite.testscript deleted file mode 100644 index 986bb37..0000000 --- a/sqlite.testscript +++ /dev/null @@ -1,10 +0,0 @@ -# file : sqlite.testscript -# license : GNU GPL v2; see accompanying LICENSE file - -# Setup the test driver command line for the subsequent SQLite tests. -# -# Note that for SQLite the schema is created implicitly by the database object -# creation function called by the test driver. -# -test.arguments += ($multi ? 'sqlite' : ) $sqlite_options -test.cleanups += &odb-test.db # See database-options.testscript for details. diff --git a/sqlite/attach/buildfile b/sqlite/attach/buildfile deleted file mode 100644 index 959f050..0000000 --- a/sqlite/attach/buildfile +++ /dev/null @@ -1,32 +0,0 @@ -# file : sqlite/attach/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ -"sqlite should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-sqlite%lib{odb-sqlite} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix sqlitex_attach_ \ - --generate-schema \ - --default-database common \ - --generate-query \ - --schema main - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/sqlite/attach/driver.cxx b/sqlite/attach/driver.cxx deleted file mode 100644 index 25d279f..0000000 --- a/sqlite/attach/driver.cxx +++ /dev/null @@ -1,109 +0,0 @@ -// file : sqlite/attach/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test attached database support. -// - -#include // std::unique_ptr -#include - -#include - -#include -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace sqlite = odb::sqlite; -using namespace sqlite; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr mdb (create_specific_database (argc, argv)); - - { - object o ("one"); - - connection_ptr c (mdb->connection ()); - - database adb (c, ":memory:", "adb"); - - // Create schema similar to create_database(). - // - { - c->execute ("PRAGMA foreign_keys=OFF"); - - transaction t (c->begin ()); - odb::schema_catalog::create_schema (adb); - t.commit (); - - c->execute ("PRAGMA foreign_keys=ON"); - } - - { - transaction t (c->begin ()); - mdb->persist (o); - adb.persist (o); - t.commit (); - } - - { - transaction t (c->begin ()); - unique_ptr p (adb.load (o.id)); - t.commit (); - - assert (p->str == o.str); - } - - { - o.str = "two"; - - transaction t (c->begin ()); - adb.update (o); - t.commit (); - } - - { - typedef sqlite::query query; - - transaction t (c->begin ()); - unique_ptr p (adb.query_one (query::str == "two")); - t.commit (); - - assert (p->str == o.str); - } - - { - transaction t (c->begin ()); - adb.erase (o); - t.commit (); - } - - { - transaction t (c->begin ()); - unique_ptr p (mdb->load (o.id)); - t.commit (); - - assert (p.get () != 0); - } - - adb.detach (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/sqlite/attach/test.hxx b/sqlite/attach/test.hxx deleted file mode 100644 index b3b8f63..0000000 --- a/sqlite/attach/test.hxx +++ /dev/null @@ -1,32 +0,0 @@ -// file : sqlite/attach/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -#include - -#pragma db object -struct object -{ - explicit - object (const std::string& s): str (s) {} - - #pragma db id auto - unsigned long id; - - #pragma db unique - std::string str; - -private: - object () {} - - friend class odb::access; -}; - -#endif // TEST_HXX diff --git a/sqlite/attach/testscript b/sqlite/attach/testscript deleted file mode 100644 index db5089d..0000000 --- a/sqlite/attach/testscript +++ /dev/null @@ -1,9 +0,0 @@ -# file : sqlite/attach/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../sqlite.testscript - -: basics -: -$* diff --git a/sqlite/auto/buildfile b/sqlite/auto/buildfile deleted file mode 100644 index 2c70b7c..0000000 --- a/sqlite/auto/buildfile +++ /dev/null @@ -1,32 +0,0 @@ -# file : sqlite/auto/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ -"sqlite should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-sqlite%lib{odb-sqlite} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix sqlitex_auto_ \ - --generate-schema \ - --default-database common \ - --generate-query \ - --sqlite-lax-auto-id - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/sqlite/auto/driver.cxx b/sqlite/auto/driver.cxx deleted file mode 100644 index bcd42c1..0000000 --- a/sqlite/auto/driver.cxx +++ /dev/null @@ -1,76 +0,0 @@ -// file : sqlite/auto/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test manual/automatic id assignment. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace sqlite = odb::sqlite; -using namespace sqlite; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_specific_database (argc, argv)); - - // object - // - { - unsigned long id1, id2, id3; - { - object o1 (1, "one"); - object o2 ("two"); - object o3 (3, "three"); - - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - - id1 = *o1.id_; - id2 = *o2.id_; - id3 = *o3.id_; - - assert (id1 == 1); - assert (id3 == 3); - - assert (id2 != id1); - assert (id2 != id3); - } - - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (id1)); - unique_ptr o2 (db->load (id2)); - unique_ptr o3 (db->load (id3)); - t.commit (); - - assert (*o1->id_ == id1 && o1->str_ == "one"); - assert (*o2->id_ == id2 && o2->str_ == "two"); - assert (*o3->id_ == id3 && o3->str_ == "three"); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/sqlite/auto/test.hxx b/sqlite/auto/test.hxx deleted file mode 100644 index 9905182..0000000 --- a/sqlite/auto/test.hxx +++ /dev/null @@ -1,32 +0,0 @@ -// file : sqlite/auto/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -#include - -#pragma db object -struct object -{ - explicit - object (const std::string& str): str_ (str) {} - object (unsigned long id, const std::string& str): id_ (id), str_ (str) {} - - #pragma db auto id - odb::nullable id_; - - std::string str_; - -private: - object () {} - - friend class odb::access; -}; - -#endif // TEST_HXX diff --git a/sqlite/auto/testscript b/sqlite/auto/testscript deleted file mode 100644 index a5a7da5..0000000 --- a/sqlite/auto/testscript +++ /dev/null @@ -1,9 +0,0 @@ -# file : sqlite/auto/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../sqlite.testscript - -: basics -: -$* diff --git a/sqlite/custom/buildfile b/sqlite/custom/buildfile deleted file mode 100644 index 3325762..0000000 --- a/sqlite/custom/buildfile +++ /dev/null @@ -1,31 +0,0 @@ -# file : sqlite/custom/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ -"sqlite should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-sqlite%lib{odb-sqlite} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix sqlitex_custom_ \ - --generate-schema \ - --default-database common \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/sqlite/custom/driver.cxx b/sqlite/custom/driver.cxx deleted file mode 100644 index 0627708..0000000 --- a/sqlite/custom/driver.cxx +++ /dev/null @@ -1,78 +0,0 @@ -// file : sqlite/custom/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test custom database type mapping in SQLite. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace sqlite = odb::sqlite; -using namespace sqlite; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_specific_database (argc, argv)); - - object o (1); - o.nv.push_back ("123"); // INTEGER - o.nv.push_back ("1.23"); // REAL - o.nv.push_back ("abc"); // TEXT - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - - // Update. - // - o.nv[1] += "4"; - - { - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/sqlite/custom/test.hxx b/sqlite/custom/test.hxx deleted file mode 100644 index 54a2ba3..0000000 --- a/sqlite/custom/test.hxx +++ /dev/null @@ -1,39 +0,0 @@ -// file : sqlite/custom/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#include - -// Map NUMERIC SQLite type to std::string (or any other type that -// provides the value_traits specialization). By -// default ODB treats NUMERIC as REAL. Note also that we don't -// need to specify to/from conversions since SQLite will convert -// implicitly. -// -#pragma db map type("NUMERIC") as("TEXT") - -#pragma db object -struct object -{ - object () {} - object (unsigned long id_): id (id_) {} - - #pragma db id - unsigned long id; - - #pragma db value_type("NUMERIC") - std::vector nv; - - bool - operator== (const object& y) const - { - return id == y.id && nv == y.nv; - } -}; - -#endif // TEST_HXX diff --git a/sqlite/custom/testscript b/sqlite/custom/testscript deleted file mode 100644 index 53561ae..0000000 --- a/sqlite/custom/testscript +++ /dev/null @@ -1,9 +0,0 @@ -# file : sqlite/custom/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../sqlite.testscript - -: basics -: -$* diff --git a/sqlite/database/buildfile b/sqlite/database/buildfile deleted file mode 100644 index e74ab1a..0000000 --- a/sqlite/database/buildfile +++ /dev/null @@ -1,11 +0,0 @@ -# file : sqlite/database/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ -"sqlite should be configured via config.odb_tests.database variable as a single database" - -import libs = libodb-sqlite%lib{odb-sqlite} - -exe{driver}: {hxx cxx}{*} $libs testscript - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/sqlite/database/driver.cxx b/sqlite/database/driver.cxx deleted file mode 100644 index 5e16653..0000000 --- a/sqlite/database/driver.cxx +++ /dev/null @@ -1,40 +0,0 @@ -// file : sqlite/database/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test that database constructors are unambiguous and some other things. -// - -#include - -#undef NDEBUG -#include - -namespace sqlite = odb::sqlite; -using namespace sqlite; - -int -main (int argc, char* argv[]) -{ - // Test UTF-16 to UTF-8 conversion. - // -#ifdef _WIN32 - { - database d (L"t\x00C8st"); - assert (d.name () == "t\xC3\x88st"); - } -#endif - - // This code should not execute. - // - if (argc != 0) - return 0; - - { - database d1 ("db1"); - } - - { - database d1 (argc, argv); - database d2 (argc, argv, false); - } -} diff --git a/sqlite/database/testscript b/sqlite/database/testscript deleted file mode 100644 index b9c0f5f..0000000 --- a/sqlite/database/testscript +++ /dev/null @@ -1,6 +0,0 @@ -# file : sqlite/database/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -: basics -: -$* diff --git a/sqlite/native/buildfile b/sqlite/native/buildfile deleted file mode 100644 index 49aa05b..0000000 --- a/sqlite/native/buildfile +++ /dev/null @@ -1,12 +0,0 @@ -# file : sqlite/native/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ -"sqlite should be configured via config.odb_tests.database variable as a single database" - -import libs = libodb-sqlite%lib{odb-sqlite} -import libs += lib{common} - -exe{driver}: {hxx cxx}{*} $libs testscript - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/sqlite/native/driver.cxx b/sqlite/native/driver.cxx deleted file mode 100644 index c87aa5d..0000000 --- a/sqlite/native/driver.cxx +++ /dev/null @@ -1,74 +0,0 @@ -// file : sqlite/native/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test native SQL execution. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#undef NDEBUG -#include - -using namespace std; -namespace sqlite = odb::sqlite; -using namespace sqlite; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db ( - create_specific_database (argc, argv, false)); - - // Create the database schema. - // - { - transaction t (db->begin ()); - - db->execute ("DROP TABLE IF EXISTS sqlitex_native_test"); - db->execute ("CREATE TABLE sqlitex_native_test (n INTEGER PRIMARY KEY)"); - - t.commit (); - } - - // Insert a few rows. - // - { - transaction t (db->begin ()); - - assert ( - db->execute ("INSERT INTO sqlitex_native_test (n) VALUES (1)") == 1); - - assert ( - db->execute ("INSERT INTO sqlitex_native_test (n) VALUES (2)") == 1); - - t.commit (); - } - - // Select a few rows. - // - { - transaction t (db->begin ()); - - assert ( - db->execute ("SELECT n FROM sqlitex_native_test WHERE n < 3") == 2); - - assert ( - db->execute ("SELECT n FROM sqlitex_native_test WHERE n > 3") == 0); - - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/sqlite/native/testscript b/sqlite/native/testscript deleted file mode 100644 index 16f05e0..0000000 --- a/sqlite/native/testscript +++ /dev/null @@ -1,9 +0,0 @@ -# file : sqlite/native/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../sqlite.testscript - -: basics -: -$* diff --git a/sqlite/stream/buildfile b/sqlite/stream/buildfile deleted file mode 100644 index fb8f605..0000000 --- a/sqlite/stream/buildfile +++ /dev/null @@ -1,31 +0,0 @@ -# file : sqlite/stream/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ -"sqlite should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} -import libodb_sqlite = libodb-sqlite%lib{odb-sqlite} -import libs = lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb and -# libodb-sqlite libraries are resolved for the odb_compile ad hoc rule (see -# build/root.build for details). -# -libue{test-meta}: $libodb $libodb_sqlite - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix sqlitex_stream_ \ - --generate-schema \ - --default-database common \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/sqlite/stream/driver.cxx b/sqlite/stream/driver.cxx deleted file mode 100644 index 86522ec..0000000 --- a/sqlite/stream/driver.cxx +++ /dev/null @@ -1,281 +0,0 @@ -// file : sqlite/stream/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test SQLite BLOB/TEXT incremental I/O. -// - -#include -#include // std::unique_ptr -#include - -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace sqlite = odb::sqlite; -using namespace sqlite; - -template -void -print (const S&) -{ - /* - cerr << s.db () << '.' - << s.table () << '.' - << s.column () << '#' - << s.rowid () << endl; - */ -} - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_specific_database (argc, argv)); - - string txt (1024 * 1024, 't'); - vector blb (1024 * 1024, 'b'); - - object o; - - { - transaction tx (db->begin ()); - - o.t.size (txt.size ()); - o.b.size (blb.size ()); - o.bv.push_back (blob (blb.size ())); - o.bv.push_back (blob (blb.size ())); - - db->persist (o); - - print (o.t); - print (o.b); - print (o.bv[0]); - print (o.bv[1]); - - blob_stream bs (o.b, true); - bs.write (blb.data (), blb.size ()); - - text_stream ts (o.t, true); - ts.write (txt.data (), txt.size ()); - - for (vector::iterator i (o.bv.begin ()); i != o.bv.end (); ++i) - { - blob_stream bs (*i, true); - bs.write (blb.data (), blb.size ()); - } - - tx.commit (); - } - - { - transaction tx (db->begin ()); - unique_ptr p (db->load (o.id)); - - print (p->t); - print (p->b); - print (p->bv[0]); - print (p->bv[1]); - - text_stream ts (p->t, false); - string t (ts.size (), '*'); - ts.read (const_cast (t.c_str ()), t.size ()); - assert (t == txt); - - blob_stream bs (p->b, false); - vector b (bs.size (), '\0'); - bs.read (b.data (), b.size ()); - assert (b == blb); - - for (vector::iterator i (p->bv.begin ()); i != p->bv.end (); ++i) - { - blob_stream bs (*i, false); - vector b (bs.size (), '\0'); - bs.read (b.data (), b.size ()); - assert (b == blb); - } - - assert (p->nb.null ()); - - tx.commit (); - } - - txt.resize (txt.size () + 1, 't'); - txt[0] = 'A'; - txt[txt.size () - 1] = 'Z'; - - blb.resize (blb.size () - 1); - blb.front () = 'A'; - blb.back () = 'Z'; - - { - transaction tx (db->begin ()); - - o.t.clear (); - o.t.size (txt.size ()); - - o.b.clear (); - o.b.size (blb.size ()); - - o.bv[0].clear (); - o.bv[0].size (blb.size ()); - - o.bv[1].clear (); - o.bv[1].size (blb.size ()); - - o.nb = blob (blb.size ()); - - db->update (o); - - print (o.t); - print (o.b); - print (o.bv[0]); - print (o.bv[1]); - print (*o.nb); - - { - text_stream ts (o.t, true); - ts.write (txt.data (), txt.size ()); - } - - { - blob_stream bs (o.b, true); - bs.write (blb.data (), blb.size ()); - } - - for (vector::iterator i (o.bv.begin ()); i != o.bv.end (); ++i) - { - blob_stream bs (*i, true); - bs.write (blb.data (), blb.size ()); - } - - { - blob_stream bs (*o.nb, true); - bs.write (blb.data (), blb.size ()); - } - - tx.commit (); - } - - { - transaction tx (db->begin ()); - unique_ptr p (db->load (o.id)); - - print (p->t); - print (p->b); - print (p->bv[0]); - print (p->bv[1]); - print (*p->nb); - - text_stream ts (p->t, false); - string t (ts.size (), '*'); - ts.read (const_cast (t.c_str ()), t.size ()); - assert (t == txt); - - blob_stream bs (p->b, false); - vector b (bs.size (), '\0'); - bs.read (b.data (), b.size ()); - assert (b == blb); - - for (vector::iterator i (p->bv.begin ()); i != p->bv.end (); ++i) - { - blob_stream bs (*i, false); - vector b (bs.size (), '\0'); - bs.read (b.data (), b.size ()); - assert (b == blb); - } - - { - blob_stream bs (*p->nb, false); - vector b (bs.size (), '\0'); - bs.read (b.data (), b.size ()); - assert (b == blb); - } - - tx.commit (); - } - - // Test query. - // - - txt.resize (32); - blb.resize (64); - - { - transaction tx (db->begin ()); - - o.t.size (txt.size ()); - o.b.size (blb.size ()); - o.bv.clear (); - o.nb.reset (); - - db->update (o); - - text_stream ts (o.t, true); - ts.write (txt.data (), txt.size ()); - - blob_stream bs (o.b, true); - bs.write (blb.data (), blb.size ()); - - tx.commit (); - } - - { - typedef sqlite::query query; - transaction tx (db->begin ()); - - { - object o1 (db->query_value (query::t == txt)); - - blob_stream bs (o1.b, false); - vector b (bs.size (), '\0'); - bs.read (b.data (), b.size ()); - assert (b == blb); - } - - { - object o1 (db->query_value (query::b == blb)); - - text_stream ts (o1.t, false); - string t (ts.size (), '*'); - ts.read (const_cast (t.c_str ()), t.size ()); - assert (t == txt); - } - - tx.commit (); - } - - // Test view. - // - { - typedef sqlite::query query; - transaction tx (db->begin ()); - - view v (db->query_value (query::t == txt)); - - blob_stream bs (v.b, false); - vector b (bs.size (), '\0'); - bs.read (b.data (), b.size ()); - assert (b == blb); - - tx.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/sqlite/stream/test.hxx b/sqlite/stream/test.hxx deleted file mode 100644 index 9189a87..0000000 --- a/sqlite/stream/test.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// file : sqlite/stream/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#include -#include - -#include -#include - -#pragma db object -struct object -{ - #pragma db id auto - unsigned long id; - - odb::sqlite::text t; - - #pragma db column("_123foo_bar") - odb::sqlite::blob b; - - std::vector bv; - - odb::nullable nb; -}; - -#pragma db view object(object) -struct view -{ - odb::sqlite::blob b; -}; - -#endif // TEST_HXX diff --git a/sqlite/stream/testscript b/sqlite/stream/testscript deleted file mode 100644 index 2b9f019..0000000 --- a/sqlite/stream/testscript +++ /dev/null @@ -1,9 +0,0 @@ -# file : sqlite/stream/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../sqlite.testscript - -: basics -: -$* diff --git a/sqlite/transaction/buildfile b/sqlite/transaction/buildfile deleted file mode 100644 index e29092d..0000000 --- a/sqlite/transaction/buildfile +++ /dev/null @@ -1,30 +0,0 @@ -# file : sqlite/transaction/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ -"sqlite should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-sqlite%lib{odb-sqlite} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix sqlitex_transaction_ \ - --generate-schema \ - --default-database common - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/sqlite/transaction/driver.cxx b/sqlite/transaction/driver.cxx deleted file mode 100644 index 80a0804..0000000 --- a/sqlite/transaction/driver.cxx +++ /dev/null @@ -1,61 +0,0 @@ -// file : sqlite/transaction/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test esoteric SQLite transaction semantics aspects. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace sqlite = odb::sqlite; -using namespace sqlite; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_specific_database (argc, argv)); - - // In SQLite, when a commit fails because of the deferred foreign - // key constraint violation, the transaction is not automatically - // rolled back. Make sure we compensate for that. - // - try - { - object o; - o.p = odb::lazy_ptr (*db, 0); - - transaction t (db->begin ()); - db->persist(o); - t.commit (); - } - catch (const odb::exception&) - { - } - - // Make sure we can start a new transaction. - // - { - transaction t (db->begin ()); - t.commit (); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/sqlite/transaction/test.hxx b/sqlite/transaction/test.hxx deleted file mode 100644 index bfb981b..0000000 --- a/sqlite/transaction/test.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// file : sqlite/transaction/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object -struct object1 -{ - #pragma db id - unsigned long id_; -}; - -#pragma db object -struct object -{ - #pragma db id auto - unsigned long id_; - - odb::lazy_ptr p; -}; - -#endif // TEST_HXX diff --git a/sqlite/transaction/testscript b/sqlite/transaction/testscript deleted file mode 100644 index c3388cb..0000000 --- a/sqlite/transaction/testscript +++ /dev/null @@ -1,9 +0,0 @@ -# file : sqlite/transaction/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../sqlite.testscript - -: basics -: -$* diff --git a/sqlite/truncation/buildfile b/sqlite/truncation/buildfile deleted file mode 100644 index 9a014e6..0000000 --- a/sqlite/truncation/buildfile +++ /dev/null @@ -1,31 +0,0 @@ -# file : sqlite/truncation/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ -"sqlite should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-sqlite%lib{odb-sqlite} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix sqlitex_truncation_ \ - --generate-schema \ - --default-database common \ - --generate-query - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/sqlite/truncation/driver.cxx b/sqlite/truncation/driver.cxx deleted file mode 100644 index a2f6d66..0000000 --- a/sqlite/truncation/driver.cxx +++ /dev/null @@ -1,163 +0,0 @@ -// file : sqlite/truncation/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test insufficient buffer/truncation handling. -// - -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace sqlite = odb::sqlite; -using namespace sqlite; - -int -main (int argc, char* argv[]) -{ - // The default pre-allocated buffer is 512 bytes long. - // - string long_str (640, 'c'); // This will get the buffer to 1024 - string longer_str (1025, 'b'); - - try - { - // Test basic operations. - // - { - unique_ptr db (create_specific_database (argc, argv)); - - // Run persist/load so that the initial bindings are established - // (version == 0). - // - { - object1 o (1); - o.str_ = "test string"; - - transaction t (db->begin ()); - db->persist (o); - db->load (1, o); - t.commit (); - } - - { - object2 o (2); - o.str_ = "test string"; - - transaction t (db->begin ()); - db->persist (o); - db->load (2, o); - t.commit (); - } - - // Store/load the long string which should trigger buffer growth. - // - { - object1 o (3); - o.str_ = long_str; - - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (3)); - assert (o->str_ == long_str); - t.commit (); - } - - // Store/load longer string. - // - { - object1 o (3); - o.str_ = longer_str; - - transaction t (db->begin ()); - db->update (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o (db->load (3)); - assert (o->str_ == longer_str); - t.commit (); - } - } - - // Test query. - // - { - unique_ptr db (create_specific_database (argc, argv)); - - typedef sqlite::query query; - typedef odb::result result; - - // Run persist/query so that the initial bindings are established - // (version == 0). - // - { - object1 o (20); - o.str_ = "test string"; - - transaction t (db->begin ()); - db->persist (o); - o.id_++; - db->persist (o); - o.id_++; - db->persist (o); - - result r (db->query (query::id == 20)); - assert (r.begin ()->id_ == 20); - t.commit (); - } - - // Test buffer growth with cached result. - // - { - object1 o; - - transaction t (db->begin ()); - - result r (db->query (query::id >= 20)); - result::iterator i (r.begin ()); - - o.id_ = i->id_; - o.str_ = long_str; - - // This forces buffer growth in the middle of result iteration. - // - db->update (o); - - ++i; - assert (i->str_ == "test string"); - - o.id_ = i->id_; - o.str_ = longer_str; - db->update (o); - - ++i; - assert (i->str_ == "test string"); - - t.commit (); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/sqlite/truncation/test.hxx b/sqlite/truncation/test.hxx deleted file mode 100644 index 8ca44ea..0000000 --- a/sqlite/truncation/test.hxx +++ /dev/null @@ -1,46 +0,0 @@ -// file : sqlite/truncation/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include - -#pragma db object table ("test") -struct object1 -{ - object1 (unsigned long id) - : id_ (id) - { - } - - object1 () - { - } - - #pragma db id - unsigned long id_; - - std::string str_; -}; - -#pragma db object table ("test") -struct object2 -{ - object2 (unsigned long id) - : id_ (id) - { - } - - object2 () - { - } - - #pragma db id - unsigned long id_; - - std::string str_; -}; - -#endif // TEST_HXX diff --git a/sqlite/truncation/testscript b/sqlite/truncation/testscript deleted file mode 100644 index 97e04f7..0000000 --- a/sqlite/truncation/testscript +++ /dev/null @@ -1,9 +0,0 @@ -# file : sqlite/truncation/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../sqlite.testscript - -: basics -: -$* diff --git a/sqlite/types/buildfile b/sqlite/types/buildfile deleted file mode 100644 index 1bf719d..0000000 --- a/sqlite/types/buildfile +++ /dev/null @@ -1,32 +0,0 @@ -# file : sqlite/types/buildfile -# license : GNU GPL v2; see accompanying LICENSE file - -assert ($sqlite && !$multi || $build.meta_operation == 'dist') \ -"sqlite should be configured via config.odb_tests.database variable as a single database" - -import libodb = libodb%lib{odb} - -import libs = libodb-sqlite%lib{odb-sqlite} -import libs += lib{common} - -exe{driver}: {hxx cxx}{* -*-odb} {hxx ixx cxx}{test-odb} testscript - -# Introduce the metadata library target to make sure the libodb library is -# resolved for the odb_compile ad hoc rule (see build/root.build for details). -# -libue{test-meta}: $libodb - -<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} - -exe{driver}: libue{test-meta} $libs - -# Specify the ODB custom options to be used by the odb_compile ad hoc rule -# (see build/root.build for details). -# -odb_options = --table-prefix sqlitex_types_ \ - --generate-schema \ - --default-database common \ - --generate-query \ - --cxx-prologue '#include "traits.hxx"' - -cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/sqlite/types/driver.cxx b/sqlite/types/driver.cxx deleted file mode 100644 index b444d94..0000000 --- a/sqlite/types/driver.cxx +++ /dev/null @@ -1,113 +0,0 @@ -// file : sqlite/types/driver.cxx -// license : GNU GPL v2; see accompanying LICENSE file - -// Test SQLite type conversion. -// - -#include // std::numeric_limits -#include // std::unique_ptr -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -#undef NDEBUG -#include - -using namespace std; -namespace sqlite = odb::sqlite; -using namespace sqlite; - -int -main (int argc, char* argv[]) -{ - try - { - unique_ptr db (create_specific_database (argc, argv)); - - object o (1); - - o.bool_ = true; - o.integer_ = -123456; - o.real_ = 1.123; - o.nan_ = numeric_limits::quiet_NaN (); - - string long_str (2040, 'l'); - - o.text_ = long_str; -#ifdef _WIN32 - o.wtext_ = L"t\x00C8st string"; -#endif - o.blob_.assign (long_str.c_str (), long_str.c_str () + long_str.size ()); - - { - transaction t (db->begin ()); - db->persist (o); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr o1 (db->load (1)); - t.commit (); - - assert (o == *o1); - } - -#ifdef _WIN32 - { - typedef sqlite::query query; - typedef odb::result result; - - transaction t (db->begin ()); - result r (db->query (query::wtext == L"t\x00C8st string")); - assert (!r.empty ()); - t.commit (); - } -#endif - - // Test char/wchar_t arrays - // - { -#ifndef _WIN32 - char_array o1 (1, ""); - char_array o2 (2, "1234567890"); - char_array o3 (3, "12345678901234567"); -#else - char_array o1 (1, "", L""); - char_array o2 (2, "1234567890", L"123456789\x00C8"); - char_array o3 (3, "12345678901234567", L"1234567890123456\x00C8"); -#endif - - { - transaction t (db->begin ()); - db->persist (o1); - db->persist (o2); - db->persist (o3); - t.commit (); - } - - { - transaction t (db->begin ()); - unique_ptr p1 (db->load (1)); - unique_ptr p2 (db->load (2)); - unique_ptr p3 (db->load (3)); - t.commit (); - - assert (o1 == *p1); - assert (o2 == *p2); - assert (o3 == *p3); - } - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/sqlite/types/test.hxx b/sqlite/types/test.hxx deleted file mode 100644 index fe0b274..0000000 --- a/sqlite/types/test.hxx +++ /dev/null @@ -1,125 +0,0 @@ -// file : sqlite/types/test.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include -#include -#include -#include // std::unique_ptr -#include // std::memcpy, std::str[n]cmp, std::strlen - -#ifdef _WIN32 -# include // std::wcslen, std::wcs[n]cmp -#endif - -#include - -typedef std::unique_ptr string_ptr; - -#pragma db object -struct object -{ - object () {} - object (unsigned long id): id_ (id) {} - - #pragma db id - unsigned long id_; - - #pragma db type("BOOL") - bool bool_; - - #pragma db type("INTEGER") - int integer_; - - #pragma db type("REAL") - double real_; - - double nan_; // Represented in SQLite as NULL. - - #pragma db type("TEXT") - std::string text_; - -#ifdef _WIN32 - std::wstring wtext_; -#endif - - #pragma db type("BLOB") - std::vector blob_; - - // Test NULL value. - // - #pragma db type("TEXT") null - string_ptr null_; - - bool - operator== (const object& y) const - { - return id_ == y.id_ - && bool_ == y.bool_ - && integer_ == y.integer_ - && real_ == y.real_ - && nan_ != nan_ - && text_ == y.text_ -#ifdef _WIN32 - && wtext_ == y.wtext_ -#endif - && blob_ == y.blob_ - && ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_); - } -}; - -// Test char/wchar_t arrays. -// -#pragma db object -struct char_array -{ - char_array () {} - char_array (unsigned long id - , const char* s -#ifdef _WIN32 - , const wchar_t* ws -#endif - ) - : id_ (id) - { - std::memcpy (s1, s, std::strlen (s) + 1); // VC++ strncpy deprecation. - s2[0] = c1 = *s; - -#ifdef _WIN32 - std::memcpy (ws1, ws, (std::wcslen (ws) + 1) * sizeof (wchar_t)); - ws2[0] = wc1 = *ws; -#endif - } - - #pragma db id - unsigned long id_; - - char s1[17]; - char s2[1]; - char c1; - -#ifdef _WIN32 - wchar_t ws1[17]; - wchar_t ws2[1]; - wchar_t wc1; -#endif - - bool - operator== (const char_array& y) const - { - return id_ == y.id_ - && std::strncmp (s1, y.s1, sizeof (s1)) == 0 - && s2[0] == y.s2[0] - && c1 == y.c1 -#ifdef _WIN32 - && std::wcsncmp (ws1, y.ws1, sizeof (ws1) / 2) == 0 - && ws2[0] == y.ws2[0] - && wc1 == y.wc1 -#endif - ; - } -}; - -#endif // TEST_HXX diff --git a/sqlite/types/testscript b/sqlite/types/testscript deleted file mode 100644 index 5e50d32..0000000 --- a/sqlite/types/testscript +++ /dev/null @@ -1,9 +0,0 @@ -# file : sqlite/types/testscript -# license : GNU GPL v2; see accompanying LICENSE file - -.include ../../database-options.testscript -.include ../../sqlite.testscript - -: basics -: -$* diff --git a/sqlite/types/traits.hxx b/sqlite/types/traits.hxx deleted file mode 100644 index 9483f58..0000000 --- a/sqlite/types/traits.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// file : sqlite/types/traits.hxx -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TRAITS_HXX -#define TRAITS_HXX - -#include // std::memcpy, std::memset - -#include - -#include "test.hxx" // string_ptr - -namespace odb -{ - namespace sqlite - { - template <> - class value_traits - { - public: - typedef string_ptr value_type; - typedef std::string query_type; - typedef details::buffer image_type; - - static void - set_value (string_ptr& v, - const details::buffer& b, - std::size_t n, - bool is_null) - { - v.reset (is_null ? 0 : new std::string (b.data (), n)); - } - - static void - set_image (details::buffer& b, - std::size_t& n, - bool& is_null, - const string_ptr& v) - { - is_null = v.get () == 0; - - if (!is_null) - { - n = v->size (); - - if (n > b.capacity ()) - b.capacity (n); - - if (n != 0) - std::memcpy (b.data (), v->c_str (), n); - } - } - }; - } -} - -#endif // TRAITS_HXX -- cgit v1.1