From whisperity at gmail.com Mon Aug 1 11:19:23 2016 From: whisperity at gmail.com (Whisperity) Date: Mon Aug 1 11:45:02 2016 Subject: [odb-users] Using CTEs in ODB queries Message-ID: Dear Mailing List, We are using ODB as an ORM in our software. A new feature has required us to use complex queries which are too time-consuming and unneccessary to implement as persistent objects. For this end, we have developed native queries, but we have ran into a problem when we wished to execute it as a native query. Consider the following code example: WITH "Query1" AS ( > SELECT * FROM "SomeTable" WHERE "SomeField" = 'SomeValue' > ), "Query2" AS ( > SELECT "id" FROM "SomeIDTable" WHERE "id_field" IS IN (SELECT ...) > ), ... > > SELECT "id", "QueryX"."other_id" FROM "QueryX" WHERE "id" > 500 AND ... > This query is to return pairs of values, obviously. I am trying to map it to the following struct and use the query as follows: > #pragma db view > struct MyView > { > ::types::someIDType id; > ::types::someIDType other_id; > }; > However, when executing the query, the query string is prepended with WHERE, making the query a huge syntax error. I'm using PostgreSQL as our database backend. I have seen a similar issue on the list (back from July 2014) about using EXEC and a fix for it, but using stored procedures are not available to us because sometimes we have to use sqlite. But using a similar approach, the issue was "fixed", so I am requesting a review for this little patch, maybe it will help other users in the next release: s.compare (0, (n = 4), "WITH") == 0 || s.compare (0, (n = 4), "with") == 0 ---- Along with this issue, I have another one. It is not trivial at first glance, but where we are using this query is actually a link table defining one-to-many relationships, or at least considering a view of this calculated relationship. If I try to use std::vector<::types::someIDtype> other_id as my second field (or any other collection), the ODB compiler throws an error. Is it possible to make ODB believe that it should give me a "list of IDs grouped by another column"? Or should I do this grouping in my program on a sorted result? Whisperity From boris at codesynthesis.com Mon Aug 1 12:31:20 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 1 12:31:53 2016 Subject: [odb-users] ODB compiler support for variable templates? In-Reply-To: References: Message-ID: Hi Steve, Hales, Steve writes: > Does the 2.4.0 compiler support C++ 14 variable templates? The 2.4.0 ODB compiler binary for Mac OS was built with GCC 4.9.3. Variable templates are supported from GCC 5. We will upgrade GCC in the next release of ODB. In the meantime, I believe excluding these definitions from the ODB compilation should be a fairly simple workaround: #ifndef ODB_COMPILER ... #endif Boris From odb at a-cunningham.com Mon Aug 1 12:47:32 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Mon Aug 1 12:48:33 2016 Subject: [odb-users] ODB compiler support for variable templates? In-Reply-To: References: Message-ID: Just put an #ifndef ODB_COMPILER around code the compiler can't understand. The compiler is only interested in #pragma db statements. On Fri, Jul 29, 2016 at 6:01 PM, Hales, Steve wrote: > The ODB 2.4.0 compiler on Mac OS fails to compile the code below: > > // Begin code > #include > > > template > > static const auto theGuidRegexStr = std::basic_string{}; > > > template <> > > static const auto theGuidRegexStr = std::basic_string > > { > > > "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" > > }; > > > template <> > > static const auto theGuidRegexStr = std::basic_string > > { > > > L"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" > > }; > > // End code > > Does the 2.4.0 compiler support C++ 14 variable templates? > > Thanks, > Steve > > > ________________________________ > > CONFIDENTIALITY NOTICE: This email and any attachments are for the sole > use of the intended recipient(s) and contain information that may be Garmin > confidential and/or Garmin legally privileged. If you have received this > email in error, please notify the sender by reply email and delete the > message. Any disclosure, copying, distribution or use of this communication > (including attachments) by someone other than the intended recipient is > prohibited. Thank you. > From luisagiacomini.eu at gmail.com Wed Aug 3 10:30:19 2016 From: luisagiacomini.eu at gmail.com (Luisa Giacomini) Date: Wed Aug 3 10:56:46 2016 Subject: [odb-users] odb queries on osx 10.8 mountain lion Message-ID: Dear Boris, I am using odb 2.3 (with sqlite) on a mac os x 10.8 Mountain Lion and I am compiling my code with clang. The problem is that the queries are not working Here is my code typedef odb::query queryTerminal; typedef odb::result resultTerminal; resultTerminal resTerminal (db->query( queryTerminal::idConductingEquipment == sart.get_voltn())); after the query line the program crashes saying malloc: *** error for object .... : pointer being freed is not allocated The same code works on windows and linux. We started guessing about a possible solution. Change to odb 2.4? Trying to install a recent version of gcc (the one in the system does not support c+11 and this is compulsary for us). Change osx version? Or maybe I made some mistake in the process of installing odb? Thanks in advance, Luisa From boris at codesynthesis.com Wed Aug 3 10:59:51 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Aug 3 11:00:37 2016 Subject: [odb-users] ODB compiler support for variable templates? In-Reply-To: References: Message-ID: Hi Andrew, Andrew Cunningham writes: > The compiler is only interested in #pragma db statements. Well, not exactly. The ODB compiler needs to see "definitions" (persistent classes, non-static data members, etc) that will be "saved" to the database. Boris From boris at codesynthesis.com Wed Aug 3 11:21:33 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Aug 3 11:21:54 2016 Subject: [odb-users] odb queries on osx 10.8 mountain lion In-Reply-To: References: Message-ID: Hi Luisa, Luisa Giacomini writes: > malloc: *** error for object .... : pointer being freed is not allocated > > The same code works on windows and linux. We started guessing about a > possible solution. Change to odb 2.4? Good idea. > Trying to install a recent version of gcc (the one in the system does > not support c+11 and this is compulsory for us). I would suggest sticking with Clang since that's the default compiler on Mac OS. > Change osx version? Don't think that will help. > Or maybe I made some mistake in the process of installing odb? Yes, that's unfortunately very likely on Mac OS. Please see these instructions for possible pitfalls: http://codesynthesis.com/products/odb/doc/install-macosx.xhtml Another thing that is helpful when tracing memory management issues is to try to isolate the problem to the minimum possible amount of code. I.e., try to comment out blocks of your application until you make the problem disappear. Boris From boris at codesynthesis.com Wed Aug 3 11:45:41 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Aug 3 11:46:02 2016 Subject: [odb-users] Using CTEs in ODB queries In-Reply-To: References: Message-ID: Hi, Whisperity writes: > [...] so I am requesting a review for this little patch, maybe it will help > other users in the next release: > > s.compare (0, (n = 4), "WITH") == 0 || s.compare (0, (n = 4), "with") == 0 Thanks, committed for the next release: http://scm.codesynthesis.com/?p=odb/libodb-pgsql.git;a=commit;h=fa085bca16a685b768e091c7c352e97677b4d8ff > Along with this issue, I have another one. It is not trivial at first > glance, but where we are using this query is actually a link table defining > one-to-many relationships, or at least considering a view of this > calculated relationship. If I try to use std::vector<::types::someIDtype> > other_id as my second field (or any other collection), the ODB compiler > throws an error. Is it possible to make ODB believe that it should give me > a "list of IDs grouped by another column"? Or should I do this grouping in > my program on a sorted result? I am not sure I understand what you are trying to achieve. A small example might help. Generally, you cannot load containers in views thought you could load a container as a view (i.e., view representing each element). Boris From ellav at checkpoint.com Thu Aug 4 06:47:33 2016 From: ellav at checkpoint.com (Ella Vishnevsky) Date: Thu Aug 4 06:51:41 2016 Subject: [odb-users] Failure after upgrading from 2.1.1 to 2.3.0 version Message-ID: <4E3D0839F36EF04D988AECF0CA558E15012C57CF44@DAG-EX10.ad.checkpoint.com> Hey, I'm running the same code using version 2.1.1 and 2.3.0 : odb::database *db = new odb::sqlite::database("TEST", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); odb::transaction t (db->begin()); domains *domain_to_add = new domains("TESTER"); domains *domain_to_add1 = new domains("TESTER1"); domains *domain_to_add2 = new domains("TESTER2"); db->persist(domain_to_add); db->persist(domain_to_add1); db->persist(domain_to_add2); t.commit(); typedef odb::query query; typedef odb::result result; odb::transaction tt (db->begin ()); result r = db->query (query::domain=="TESTER"); std::string test; std::vector hell; for (result::iterator i (r.begin ()); i != r.end (); ++i) { test = i->domain(); hell.push_back(test); } tt.commit(); When running version 2.1.1 everything works as expected, but the moment I upgrade to 2.3.0 I get the following errors: [Expert@gw-32b051:0]# *** glibc detected *** /opt/CPsuite-R77/fw1/teCurrentPack/temain: double free or corruption (out): 0x0bba98c8 *** ======= Backtrace: ========= /lib/libc.so.6[0xf7bf1aa6] /lib/libc.so.6(cfree+0x90)[0xf7bf4fe0] /usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xf7d88fd1] /usr/lib/libstdc++.so.6(_ZNSs4_Rep10_M_destroyERKSaIcE+0x1d)[0xf7d65b9d] /opt/CPsuite-R77/fw1/teCurrentPack/temain(_ZN3odb6sqlite9statementD1Ev+0x105)[0x94c7be5] /opt/CPsuite-R77/fw1/teCurrentPack/temain(_ZN3odb6sqlite16select_statementD0Ev+0x18)[0x94c1f48] /opt/CPsuite-R77/fw1/teCurrentPack/temain(_ZN3odb6sqlite18object_result_implIN2te7domainsEE10invalidateEv+0xf4)[0x864d3f4] /opt/CPsuite-R77/fw1/teCurrentPack/temain(_ZN3odb10connection18invalidate_resultsEv+0x20)[0x94d0720] /opt/CPsuite-R77/fw1/teCurrentPack/temain(_ZN3odb6sqlite16transaction_impl6commitEv+0x16)[0x94c8ff6] /opt/CPsuite-R77/fw1/teCurrentPack/temain(_ZN3odb11transaction6commitEv+0x37)[0x94d7057] /opt/CPsuite-R77/fw1/teCurrentPack/temain(_ZN2te6Daemon25StartApplicationSpecificsEv+0x2ea7)[0x84fb767] /opt/CPsuite-R77/fw1/teCurrentPack/temain(_ZN3NAC2IS22BasicDaemonApplication10InitializeEv+0x3db)[0x9055fcb] /opt/CPsuite-R77/fw1/teCurrentPack/temain(_ZN3NAC2IS16BasicApplication9MainStartEv+0x17)[0x84be157] /opt/CPsuite-R77/fw1/teCurrentPack/temain(_Z8main_tediPPKc+0xf63)[0x847fc93] /opt/CPsuite-R77/fw1/teCurrentPack/temain(_Z8main_cmdiPPcRi+0x1e0)[0x8433c50] /opt/CPsuite-R77/fw1/teCurrentPack/temain(main+0x37)[0x8433cd7] /lib/libc.so.6(__libc_start_main+0xdc)[0xf7ba0dec] /opt/CPsuite-R77/fw1/teCurrentPack/temain[0x84339b1] ======= Memory map: ======== 08048000-09a44000 r-xp 00000000 fd:03 16908333 /var/log/files_repository/Raw_Files/D100C612-9D05-48AA-9F2A-F8C42528F100/47086/temain 09a44000-09aeb000 rwxp 019fc000 fd:03 16908333 /var/log/files_repository/Raw_Files/D100C612-9D05-48AA-9F2A-F8C42528F100/47086/temain 09aeb000-0ad0c000 rwxp 09aeb000 00:00 0 0b1d2000-0bc47000 rwxp 0b1d2000 00:00 0 ed23f000-ed247000 rwxs 00000000 fd:00 7573953 /var/opt/CPsuite-R77/fw1/conf/te_tcsi_db-shm ed247000-ed248000 ---p ed247000 00:00 0 ed248000-edc48000 rwxp ed248000 00:00 0 edc48000-edc49000 ---p edc48000 00:00 0 edc49000-ee649000 rwxp edc49000 00:00 0 ee64b000-ee64c000 ---p ee64b000 00:00 0 ee64c000-ee68c000 rwxp ee64c000 00:00 0 ee68c000-ee68d000 ---p ee68c000 00:00 0 ee68d000-ef08d000 rwxp ee68d000 00:00 0 ef08d000-ef08e000 ---p ef08d000 00:00 0 ef08e000-efa8e000 rwxp ef08e000 00:00 0 efa8e000-f7a91000 rwxs 00000000 fd:00 7576456 /var/opt/CPsuite-R77/fw1/database/fwauth.NDB f7a91000-f7b12000 rwxp f7a91000 00:00 0 f7b12000-f7b1b000 r-xp 00000000 fd:00 8258025 /lib/libnss_files-2.5.so f7b1b000-f7b1c000 r-xp 00008000 fd:00 8258025 /lib/libnss_files-2.5.so f7b1c000-f7b1d000 rwxp 00009000 fd:00 8258025 /lib/libnss_files-2.5.so f7b23000-f7b64000 rwxp f7b23000 00:00 0 f7b64000-f7b76000 r-xp 00000000 fd:00 8258046 /lib/libaudit.so.0.0.0 f7b76000-f7b78000 rwxp 00011000 fd:00 8258046 /lib/libaudit.so.0.0.0 f7b78000-f7b8a000 r-xp 00000000 fd:00 6096584 /usr/lib/libz.so.1.2.3 f7b8a000-f7b8b000 rwxp 00011000 fd:00 6096584 /usr/lib/libz.so.1.2.3 f7b8b000-f7cc5000 r-xp 00000000 fd:00 8258009 /lib/libc-2.5.so f7cc5000-f7cc7000 r-xp 0013a000 fd:00 8258009 /lib/libc-2.5.so f7cc7000-f7cc8000 rwxp 0013c000 fd:00 8258009 /lib/libc-2.5.so f7cc8000-f7ccc000 rwxp f7cc8000 00:00 0 f7ccc000-f7cd7000 r-xp 00000000 fd:00 8257999 /lib/libgcc_s-4.1.2-20080825.so.1 f7cd7000-f7cd8000 rwxp 0000a000 fd:00 8257999 /lib/libgcc_s-4.1.2-20080825.so.1 f7cd8000-f7db6000 r-xp 00000000 fd:00 6096580 /usr/lib/libstdc++.so.6.0.8 f7db6000-f7db9000 r-xp 000dd000 fd:00 6096580 /usr/lib/libstdc++.so.6.0.8 f7db9000-f7dbb000 rwxp 000e0000 fd:00 6096580 /usr/lib/libstdc++.so.6.0.8 f7dbb000-f7dc1000 rwxp f7dbb000 00:00 0 f7dc1000-f7de6000 r-xp 00000000 fd:00 8258017 /lib/libm-2.5.so f7de6000-f7de7000 r-xp 00024000 fd:00 8258017 /lib/libm-2.5.so f7de7000-f7de8000 rwxp 00025000 fd:00 8258017 /lib/libm-2.5.so f7de8000-f7dfb000 r-xp 00000000 fd:00 8258019 /lib/libnsl-2.5.so f7dfb000-f7dfc000 r-xp 00012000 fd:00 8258019 /lib/libnsl-2.5.so f7dfc000-f7dfd000 rwxp 00013000 fd:00 8258019 /lib/libnsl-2.5.so f7dfd000-f7dff000 rwxp f7dfd000 00:00 0 f7dff000-f7e09000 r-xp 00000000 fd:00 8258092 /lib/libpam.so.0.81.5 f7e09000-f7e0a000 rwxp 0000a000 fd:00 8258092 /lib/libpam.so.0.81.5 f7e0a000-f7e0c000 r-xp 00000000 fd:00 8258015 /lib/libdl-2.5.so f7e0c000-f7e0d000 r-xp 00001000 fd:00 8258015 /lib/libdl-2.5.so f7e0d000-f7e0e000 rwxp 00002000 fd:00 8258015 /lib/libdl-2.5.so f7e0e000-f7e0f000 rwxp f7e0e000 00:00 0 f7e0f000-f7e1e000 r-xp 00000000 fd:00 8258035 /lib/libresolv-2.5.so f7e1e000-f7e1f000 r-xp 0000e000 fd:00 8258035 /lib/libresolv-2.5.so f7e1f000-f7e20000 rwxp 0000f000 fd:00 8258035 /lib/libresolv-2.5.so f7e20000-f7e22000 rwxp f7e20000 00:00 0 f7e22000-f7e35000 r-xp 00000000 fd:00 8258033 /lib/libpthread-2.5.so f7e35000-f7e36000 r-xp 00012000 fd:00 8258033 /lib/libpthread-2.5.so f7e36000-f7e37000 rwxp 00013000 fd:00 8258033 /lib/libpthread-2.5.so f7e37000-f7e39000 rwxp f7e37000 00:00 0 f7e3d000-f7e3f000 rwxp f7e3d000 00:00 0 f7e3f000-f7f5a000 r-xp 00000000 fd:00 1736849 /opt/CPshrd-R77/lib/libxml2.so.2 f7f5a000-f7f61000 rwxp 0011a000 fd:00 1736849 /opt/CPshrd-R77/lib/libxml2.so.2 f7f61000-f7f62000 rwxp f7f61000 00:00 0 f7f62000-f7f7b000 r-xp 00000000 fd:00 8258002 /lib/ld-2.5.so f7f7b000-f7f7c000 r-xp 00019000 fd:00 8258002 /lib/ld-2.5.so f7f7c000-f7f7d000 rwxp 0001a000 fd:00 8258002 /lib/ld-2.5.so ffcbe000-ffea2000 rwxp ffcbe000 00:00 0 [stack] and another error I saw: Program received signal SIGABRT, Aborted. 0xffffe410 in __kernel_vsyscall () (gdb) bt #0 0xffffe410 in __kernel_vsyscall () #1 0xf7b6eba0 in raise () from /lib/libc.so.6 #2 0xf7b704b1 in abort () from /lib/libc.so.6 #3 0xf7ba4dfb in __libc_message () from /lib/libc.so.6 #4 0xf7bacaa6 in _int_free () from /lib/libc.so.6 #5 0xf7baffe0 in free () from /lib/libc.so.6 #6 0xf7d43fd1 in operator delete(void*) () from /usr/lib/libstdc++.so.6 #7 0x08ada5d5 in dec (p=0xd9f84e78, this=0xd9c44bdc) at /local_ckp/xl/odb/2_3_E/include/odb/details/shared-ptr/base.txx:172 #8 ~shared_ptr (this=0xd9c44bdc, __in_chrg=) at /local_ckp/xl/odb/2_3_E/include/odb/details/shared-ptr.hxx:26 #9 odb::sqlite::object_result_impl::~object_result_impl (this=0xd9c44bb0, __in_chrg=) at /local_ckp/xl/odb_sqlite/2_3_E_2/include/odb/sqlite/simple-object-result.txx:21 #10 0x08ada812 in odb::sqlite::object_result_impl::~object_result_impl (this=0xd9c44bb0, __in_chrg=) at /local_ckp/xl/odb_sqlite/2_3_E_2/include/odb/sqlite/simple-object-result.txx:22 #11 0x0865a9d2 in dec (p=0xd9c44bb0, this=0xffab05d8) at /local_ckp/xl/odb/odb_2_3_0/include/odb/details/shared-ptr/base.txx:172 #12 ~shared_ptr (this=0xffab05d8, __in_chrg=) at /local_ckp/xl/odb/odb_2_3_0/include/odb/details/shared-ptr.hxx:26 #13 ~result (this=0xffab05d8, __in_chrg=) at /local_ckp/xl/odb/odb_2_3_0/include/odb/result.hxx:76 #14 te::OdbDatabase::OdbQuery (this=0xc3bcd58, _vect=std::vector of length 0, capacity 0, _max=1) Can you please advise? What it the difference between the two versions, I can't seem to understand why I fail =\ From whisperity at gmail.com Wed Aug 3 15:47:57 2016 From: whisperity at gmail.com (Whisperity) Date: Thu Aug 4 10:54:28 2016 Subject: [odb-users] Using CTEs in ODB queries In-Reply-To: References: Message-ID: Dear Boris, Thank you for your reply. I assume the same patch has been added to libodb-sqlite as well? ----- What I was trying to achieve is this. I have a RESULT table (so there is no persistent type for it) of two columns which are two IDs calculated by the query. But actually this table defines a relationship of an object having the ID from the first column to many objects having IDs from the second column. So instead of doing "SELECT id1, id2 FROM cte;" and loading them as just pairs of IDs, I thought I could let ODB do the grouping job for me and my code would only get struct which contains an int and a vector(/set) of ints. So #prama db view > struct MyStruct > { > int id1; > int id2; > }; > > ... > > std::multimap grouped; > result res = db->query(...); > for (auto it = res.begin(); it != res.end(); ++it) > { > grouped.insert(std::make_pair(it->id1, it->id2)); > } > I could just do #pragma db view > struct MyStruct > { > int id1; > std::vector id2s; > }; > > ... > > result res = db->query(...); > // And now all the "second" IDs for the same "first" ID is grouped at this > point. > But seeing your last sentence and the fact that doing the grouping myself is maybe marginally worse (if it is worse at all) than ODB doing it, we just scrapped this idea. 2016-08-03 17:45 GMT+02:00 Boris Kolpackov : > Hi, > > Whisperity writes: > > > [...] so I am requesting a review for this little patch, maybe it will > help > > other users in the next release: > > > > s.compare (0, (n = 4), "WITH") == 0 || s.compare (0, (n = 4), "with") == > 0 > > Thanks, committed for the next release: > > > http://scm.codesynthesis.com/?p=odb/libodb-pgsql.git;a=commit;h=fa085bca16a685b768e091c7c352e97677b4d8ff > > > > Along with this issue, I have another one. It is not trivial at first > > glance, but where we are using this query is actually a link table > defining > > one-to-many relationships, or at least considering a view of this > > calculated relationship. If I try to use std::vector<::types::someIDtype> > > other_id as my second field (or any other collection), the ODB compiler > > throws an error. Is it possible to make ODB believe that it should give > me > > a "list of IDs grouped by another column"? Or should I do this grouping > in > > my program on a sorted result? > > I am not sure I understand what you are trying to achieve. A small > example might help. > > Generally, you cannot load containers in views thought you could load > a container as a view (i.e., view representing each element). > > Boris > > From boris at codesynthesis.com Thu Aug 4 11:06:33 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Aug 4 11:07:04 2016 Subject: [odb-users] Failure after upgrading from 2.1.1 to 2.3.0 version In-Reply-To: <4E3D0839F36EF04D988AECF0CA558E15012C57CF44@DAG-EX10.ad.checkpoint.com> References: <4E3D0839F36EF04D988AECF0CA558E15012C57CF44@DAG-EX10.ad.checkpoint.com> Message-ID: Hi Ella, Ella Vishnevsky writes: > I'm running the same code using version 2.1.1 and 2.3.0: If upgrading, why not to the latest (2.4.0)? If that still doesn't help, can you send a minimal but complete (i.e., a header with the class, test driver with main(), and the ODB comman line) test case that reproduces the problem. While you showed a small fragment, from the stack traces I can see that you are running something a lot more elaborate. Boris From harriev9 at gmail.com Thu Aug 4 11:53:09 2016 From: harriev9 at gmail.com (harriev9) Date: Thu Aug 4 11:53:48 2016 Subject: [odb-users] Problem compiling with QT Message-ID: <1470325989.2169.2.camel@gmail.com> Hello, When I compile my program (it is using QT 5.6) then i get an error message: /usr/include/QtCore/qglobal.h:1087:4: error: #error "You must build your code with position independent code if Qt was built with -reduce- relocations. " "Compile your code with -fPIC (-fPIE is not enough)." Is it possible to compile with -fPIC and if so how do i instruct the odb compiler to do so? Greetings, Harrie Versteden. From boris at codesynthesis.com Fri Aug 5 12:13:19 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Aug 5 12:13:40 2016 Subject: [odb-users] Problem compiling with QT In-Reply-To: <1470325989.2169.2.camel@gmail.com> References: <1470325989.2169.2.camel@gmail.com> Message-ID: Hi Harrie, harriev9 writes: > When I compile my program (it is using QT 5.6) then i get an error > message: > > /usr/include/QtCore/qglobal.h:1087:4: error: #error "You must build > your code with position independent code if Qt was built with -reduce- > relocations. " "Compile your code with -fPIC (-fPIE is not enough)." > > Is it possible to compile with -fPIC and if so how do i instruct the > odb compiler to do so? This should not be necessary if you are using the Qt profile (-p qt). If not, then, yes, you can pass -fPIC like this: odb -x -fPIC ... Here is also the relevant comment from libodb-qt/odb/qt/default/config.hxx: // Qt5 may complain if we are building without -fPIC or -fPIE. Instead of // asking the user to pass one of these options to the ODB compiler (which // can, BTW, be done with -x -fPIE, for example, if one is not using the // Qt profile), we are going to define __PIE__ ourselves just to silence // Qt. [...] Boris From asnagni at yahoo.com Fri Aug 5 12:58:24 2016 From: asnagni at yahoo.com (Alain-Serge Nagni) Date: Fri Aug 5 12:59:01 2016 Subject: [odb-users] Need Help for compiling ODB for iOS Message-ID: Hi, I would like to know if someone has experience building ODB for iOS (iPhone). If yes, it would be nice to share your experience and share the steps that you went trough to achieve that. 1) I was wondering if to do that we could use Xcode to create the library from the source file. 2) Or I we need to use the command line Thank you sharing your procedure. I have Xcode version 7.3.1 and I?m on OS X El Capitan Thank you, Alain-Serge From boris at codesynthesis.com Mon Aug 8 11:53:17 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 8 11:53:36 2016 Subject: [odb-users] Using CTEs in ODB queries In-Reply-To: References: Message-ID: Hi, Whisperity writes: > I assume the same patch has been added to libodb-sqlite as well? Now it has. Thanks for checking. > What I was trying to achieve is this. I have a RESULT table (so there is no > persistent type for it) of two columns which are two IDs calculated by the > query. But actually this table defines a relationship of an object having > the ID from the first column to many objects having IDs from the second > column. > > So instead of doing "SELECT id1, id2 FROM cte;" and loading them as just > pairs of IDs, I thought I could let ODB do the grouping job for me and my > code would only get struct which contains an int and a vector(/set) of ints. No, you cannot currently do this. The closest would probably be a view that contains both IDs and you return them ORDER'ed BY the first ID. So you get ranges of view objects that correspond to the same first ID. Boris From boris at codesynthesis.com Mon Aug 8 12:06:04 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 8 12:06:23 2016 Subject: [odb-users] Need Help for compiling ODB for iOS In-Reply-To: References: Message-ID: Hi Folks, We have a number of guides on using ODB with various platforms, IDEs, etc: http://wiki.codesynthesis.com/ODB In particular, we have the general guide on cross-compiling (based on the Raspberry Pi target) as well as for the Android NDK. What we do miss is an iOS guide. At the same time I know quite a few of you are using ODB on iOS. So if someone can post an even rough guide/steps as an email, it will be much appreciated. And I volunteer to turn it into a guide on the Wiki (with proper attribution, of course). Thanks, Boris From asnagni at yahoo.com Sat Aug 13 18:51:50 2016 From: asnagni at yahoo.com (Alain-Serge Nagni) Date: Sat Aug 13 18:52:29 2016 Subject: [odb-users] Cannot cross compile libodb-sqlite for iOS Message-ID: <4C0778CD-1107-498D-93C8-7991CE8208A3@yahoo.com> Hi guys, I have been trying for several days now to compile ODB for iOS (I?m on MAC OS X "El Capitan? ) following the guide line publish by Code Syntesis here (http://wiki.codesynthesis.com/Using_ODB_on_Mobile_and_Embedded_Systems ) . But I?m facing a problem with their libodb-sqlite package. When I try the build and install that package for some reason it cannot find the SQLite package that was cross compiled. Maybe someone someoneelse faced this issue, some help will be appreciated. So based on the Wiki page these are the steps that I?m performing to cross compile the library: 1) This is how I cross compile and install the libodb package (it works with out any problem): ./configure --host=arm-apple-darwin CPPFLAGS="-I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/" CXXFLAGS="-arch arm64 -std=c++14 -stdlib=libc++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk" CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" CXX="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" LD="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" AR="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar" --prefix=`pwd`/../install --disable-shared make make install 2) This is how I cross compile the sqlite package (it works with out any problem): ./configure --host=arm-apple-darwin CXXFLAGS="?Os -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 -arch arm64 -std=c++14 -stdlib=libc++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk" CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" CXX="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" LD="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" AR="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar" --prefix=`pwd`/../install --disable-shared make make install 3) This is how I cross compile the libodb-sqlite package (It doesn?t work, it cannot find libsqlite ) ./configure --host=arm-apple-darwin CFLAGS="-I`pwd`/../install/include" CPPFLAGS="-I`pwd`/../install/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/" LDFLAGS="-L`pwd`/../install/lib" CXXFLAGS="?Os -arch arm64 -std=c++14 -stdlib=libc++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk" CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" CXX="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" LD="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" AR="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar" --prefix=`pwd`/../install --disable-shared --disable-threads make make install This is the error that I have when I cross compile libodb-sqlite : checking whether /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ accepts -g... yes checking dependency style of /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++... gcc3 checking how to run the C++ preprocessor... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -E checking whether the /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... no libtool.m4: error: problem compiling CXX test program checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ option to produce PIC... -DPIC checking if /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ PIC flag -DPIC works... no checking if /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ static flag works... no checking if /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ supports -c -o file.o... no checking if /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ supports -c -o file.o... (cached) no checking whether the /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... no checking dynamic linker characteristics... darwin dyld checking how to hardcode library paths into programs... immediate configure: creating ./config.lt config.lt: creating libtool checking for libsqlite3... no configure: error: libsqlite3 is not found; consider using CPPFLAGS/LDFLAGS to specify its location make: *** No targets specified and no makefile found. Stop. make: Nothing to be done for `install'. Alain-Serges-iMac:libodb-sqlite asnagni$ Thank you for your help, Alain-Serge From albert.gu at ringcentral.com Sun Aug 14 23:16:34 2016 From: albert.gu at ringcentral.com (Albert Gu) Date: Mon Aug 15 05:56:28 2016 Subject: [odb-users] A lot dependent ODB header files are included when we include the header file "odb::lazy_shared_ptr" Message-ID: Hi All, When we try to include to use template class odb::lazy_shared_ptr, it will cause a lot dependent ODB header files are included. This will cause the compile time very slow. We would like to know is there any method to reduce this dependencies? We tried to forward the template class odd::lazy_shared_ptr in header and include in cpp file, but it didn't compile well. Any comment is appreciated. Thanks a lot for your help. - Regards, Albert From boris at codesynthesis.com Mon Aug 15 06:04:05 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 15 06:04:18 2016 Subject: [odb-users] Cannot cross compile libodb-sqlite for iOS In-Reply-To: <4C0778CD-1107-498D-93C8-7991CE8208A3@yahoo.com> References: <4C0778CD-1107-498D-93C8-7991CE8208A3@yahoo.com> Message-ID: Hi Alain-Serge, Alain-Serge Nagni writes: > configure: error: libsqlite3 is not found; consider using CPPFLAGS/LDFLAGS > to specify its location I took a look at the config.log file (that you sent me off-list) and here is what I saw: clang: error: no such file or directory: '?Os' Then looking at your configure command line: > ./configure [...] CXXFLAGS="?Os -arch arm64 [...] Notice that the dash before 'Os' looks like a Unicode n-dash, not the standard 'minus' that is used with options. Try replacing it with '-'. Boris From boris at codesynthesis.com Mon Aug 15 10:29:22 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 15 10:29:44 2016 Subject: [odb-users] A lot dependent ODB header files are included when we include the header file "odb::lazy_shared_ptr" In-Reply-To: References: Message-ID: Hi Albert, Albert Gu writes: > When we try to include to use template class > odb::lazy_shared_ptr, it will cause a lot dependent ODB header > files are included. This will cause the compile time very slow. Can you try to comment out inclusion of in libodb/odb/lazy-ptr-impl.txx and see if that helps? The consequence of this change is that you will now have to make sure is included in source files that initialize persistent lazy_ptr instances. But that is probably acceptable (and is probably already the case anyway most of the times). Boris From asnagni at yahoo.com Mon Aug 15 11:06:48 2016 From: asnagni at yahoo.com (Alain-Serge Nagni) Date: Mon Aug 15 11:07:26 2016 Subject: [odb-users] Cannot cross compile libodb-sqlite for iOS In-Reply-To: References: <4C0778CD-1107-498D-93C8-7991CE8208A3@yahoo.com> Message-ID: <404A914D-E656-4BFE-A452-D7EF5A7B15CD@yahoo.com> Hi Boris, Wow, ok I will make the change and give it a try. Thank you, Alain-Serge > On Aug 15, 2016, at 6:04 AM, Boris Kolpackov wrote: > > Hi Alain-Serge, > > Alain-Serge Nagni writes: > >> configure: error: libsqlite3 is not found; consider using CPPFLAGS/LDFLAGS >> to specify its location > > I took a look at the config.log file (that you sent me off-list) and here > is what I saw: > > clang: error: no such file or directory: '?Os' > > Then looking at your configure command line: > >> ./configure [...] CXXFLAGS="?Os -arch arm64 [...] > > Notice that the dash before 'Os' looks like a Unicode n-dash, not the > standard 'minus' that is used with options. Try replacing it with '-'. > > Boris From odb at a-cunningham.com Wed Aug 17 18:30:28 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Wed Aug 17 18:31:14 2016 Subject: [odb-users] Containers of containers Message-ID: HI Boris, I just got bitten badly by a containers of containers issue. I had unintentionally used an object with a std::array member variable in the "value" type of a std::map. e.g. #pragma db value class XYZ { std::array xyz_; }; ... #pragma db object class D { std::map mapxyz_; <---oops, container of container } I would like that the ODB compiler detect this issue and fail with an error. At the moment, the compiler runs without error and generates 'working' ODB code. The objects can be persisted without apparent error, but after opening the database and loading the objects , one will find that the std::map is loaded with value objects having a std::array full of 0.0 data. On a related issue, I also would like the ODB compiler to be enhanced to deal with fixed sized arrays of 'simple' data types (other than char) not as containers - put them in the object as members/columns. For example float xyz_[3]; or std::array xyz_; At the moment, this type of member data has to be spelled out as, say, float x_; float y_; float z_; if you ever intend the owning class to be used in a container. Andrew From alexandr.tver at gmail.com Wed Aug 17 20:25:37 2016 From: alexandr.tver at gmail.com (=?UTF-8?B?0JDQu9C10LrRgdCw0L3QtNGAINCRLg==?=) Date: Thu Aug 18 09:51:57 2016 Subject: [odb-users] statement-regex Message-ID: <8635b0b2-332d-8ea7-6418-51c642bcfd07@gmail.com> Hello. I have a problem with message "warning: prepared statement name 'insert_[some_class_name]_[other_class_name]' is longer than the default PostgreSQL name limit of 63 characters and may be truncated" I'm trying to shorten the name with option "--statement-regex", but I can not replace all occurrences of expression. Example: 'insert_long_class_name_other_long_class_name' The expression should be reduced to 'insert_short_name_other_short_name'. Is it possible? Thank you very much. Alexandr. B. From gdejian at 126.com Thu Aug 18 04:44:19 2016 From: gdejian at 126.com (=?GBK?B?uN+1wr2h?=) Date: Thu Aug 18 09:51:57 2016 Subject: [odb-users] segmentation fault on linux while operating Mysql database Message-ID: <386c7679.968d.1569cd28b60.Coremail.gdejian@126.com> Dear Boris, I run the example "hello" on linux, and I got segmentation faults all the time. There is no problem connecting to mysql server, I can use db->execute() to execute some native sql statements. BUT, when i use db->persist() or result(db->query(id == id)), it crashes with a segmentation fault. In the core file, it points to : #0 0x0000000000407c11 in odb::object_traits_impl::statements_type& odb::mysql::statement_cache::find_object() () #1 0x0000000000404fc9 in odb::access::object_traits_impl::persist(odb::database&, person&) () #2 0x00000000004036e6 in main () I tried the same example on windows, it worked well. How can I solve this? Thanks, Gao Dejian -- ??? ?????????37? ???????? ??gdejian@126.com ??13041129171 From boris at codesynthesis.com Thu Aug 18 10:33:33 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Aug 18 10:33:44 2016 Subject: [odb-users] statement-regex In-Reply-To: <8635b0b2-332d-8ea7-6418-51c642bcfd07@gmail.com> References: <8635b0b2-332d-8ea7-6418-51c642bcfd07@gmail.com> Message-ID: Hi Alexandr, ????????? ?. writes: > "warning: prepared statement name > 'insert_[some_class_name]_[other_class_name]' is longer than the default > PostgreSQL name limit of 63 characters and may be truncated" > > I'm trying to shorten the name with option "--statement-regex", but I > can not replace all occurrences of expression. Can you send a test header file and the regex you use that fails to "replace all occurrences of expression"? Boris From boris at codesynthesis.com Thu Aug 18 10:36:12 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Aug 18 10:36:31 2016 Subject: [odb-users] segmentation fault on linux while operating Mysql database In-Reply-To: <386c7679.968d.1569cd28b60.Coremail.gdejian@126.com> References: <386c7679.968d.1569cd28b60.Coremail.gdejian@126.com> Message-ID: Hi Gao, ??? writes: > In the core file, it points to : > #0 0x0000000000407c11 in odb::object_traits_impl::statements_type& odb::mysql::statement_cache::find_object() () > #1 0x0000000000404fc9 in odb::access::object_traits_impl::persist(odb::database&, person&) () > #2 0x00000000004036e6 in main () Try to rebuild the example with debug information (-g) so that we can see the line numbers in the above stack trace. Boris From boris at codesynthesis.com Thu Aug 18 11:43:17 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Aug 18 11:43:36 2016 Subject: [odb-users] Containers of containers In-Reply-To: References: Message-ID: Hi Andrew, > I would like that the ODB compiler detect this issue and fail with an > error. At the moment, the compiler runs without error and generates > 'working' ODB code. I've implemented this diagnostics. Will send you a binary shortly. > On a related issue, I also would like the ODB compiler to be enhanced to > deal with fixed sized arrays of 'simple' data types (other than char) not > as containers - put them in the object as members/columns. > > For example > > float xyz_[3]; > or > std::array xyz_; This sounds simple on the surface but it is a can of worms. Just to start, what should be the names of those members? What if they conflict with existing members? What if you want to customize their types or column names? Should we invent special syntax for such members, e.g.: #pragma db member(xyz_[0]) type("DECIMAL") column("xyz_first") If we support simple types, why not composite? And object pointers? Inverse? What about using those members in queries, should we support that? So I don't think we will implement this any time soon. > At the moment, this type of member data has to be spelled out as, say, > float x_; > float y_; > float z_; > > if you ever intend the owning class to be used in a container. You can actually map std::array as a composite value type and it can be used "as if" it was a container. For example: #include #include using float3 = std::array; #pragma db value(float3) transient #pragma db member(float3::e1) virtual(float) get(this[0]) set(this[0]) #pragma db member(float3::e2) virtual(float) get(this[1]) set(this[1]) #pragma db member(float3::e3) virtual(float) get(this[2]) set(this[2]) #pragma db object struct object { #pragma db id int id; std::vector vf3; }; Note how with this approach you can easily customize column name/type, use members in queries, etc. Boris From odb at a-cunningham.com Thu Aug 18 13:50:34 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Thu Aug 18 13:51:20 2016 Subject: [odb-users] containers of containers Message-ID: > > You can actually map std::array as a composite value type and it > can be used "as if" it was a container. For example: > > > > #include > > #include > > > > using float3 = std::array; > > > > #pragma db value(float3) transient > > #pragma db member(float3::e1) virtual(float) get(this[0]) set(this[0]) > #pragma db member(float3::e2) virtual(float) get(this[1]) set(this[1]) > #pragma db member(float3::e3) virtual(float) get(this[2]) set(this[2]) > > > > #pragma db object > > struct object > > { > > #pragma db id > > int id; > > > > std::vector vf3; > > }; > > > > Note how with this approach you can easily customize column name/type, use > members in queries, etc. > OK, i see how that can work... I think....could get painful for larger array sizes. From jnw at xs4all.nl Thu Aug 18 14:40:44 2016 From: jnw at xs4all.nl (Jeroen N. Witmond) Date: Thu Aug 18 14:41:38 2016 Subject: [odb-users] containers of containers In-Reply-To: References: Message-ID: On 2016-08-18 19:50, Andrew Cunningham wrote: >> >> You can actually map std::array as a composite value type >> and it >> can be used "as if" it was a container. For example: >> >> >> >> #include >> >> #include >> >> >> >> using float3 = std::array; >> >> >> >> #pragma db value(float3) transient >> >> #pragma db member(float3::e1) virtual(float) get(this[0]) set(this[0]) >> #pragma db member(float3::e2) virtual(float) get(this[1]) set(this[1]) >> #pragma db member(float3::e3) virtual(float) get(this[2]) set(this[2]) >> >> >> >> #pragma db object >> >> struct object >> >> { >> >> #pragma db id >> >> int id; >> >> >> >> std::vector vf3; >> >> }; >> >> >> >> Note how with this approach you can easily customize column name/type, >> use >> members in queries, etc. >> > > OK, i see how that can work... I think....could get painful for larger > array sizes. You could write a simple program (or even a shell script) to generate all "#pragma db member" statements required ... From odb at a-cunningham.com Thu Aug 18 15:27:44 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Thu Aug 18 15:28:38 2016 Subject: [odb-users] containers of containers In-Reply-To: References: Message-ID: I see how that is a workaround, but I would like ODB to do that work for me :) I still think maybe a "#pragma db array" or similar would be very useful, despite Boris's misgivings. It could be restricted to "simple SQL types" - int,float, double with some default naming convention for the columns. Forgetting about issues with containers of containers for the moment, currently using a std::array "as is" in any object is very inefficient in time and space vs, say, float x,y,z;. The ODB compiler generates another table to store the array data, along with associated "SELECT" when loading the parent object. On Thu, Aug 18, 2016 at 11:40 AM, Jeroen N. Witmond wrote: > On 2016-08-18 19:50, Andrew Cunningham wrote: > >> >>> You can actually map std::array as a composite value type and >>> it >>> can be used "as if" it was a container. For example: >>> >>> >>> >>> #include >>> >>> #include >>> >>> >>> >>> using float3 = std::array; >>> >>> >>> >>> #pragma db value(float3) transient >>> >>> #pragma db member(float3::e1) virtual(float) get(this[0]) set(this[0]) >>> #pragma db member(float3::e2) virtual(float) get(this[1]) set(this[1]) >>> #pragma db member(float3::e3) virtual(float) get(this[2]) set(this[2]) >>> >>> >>> >>> #pragma db object >>> >>> struct object >>> >>> { >>> >>> #pragma db id >>> >>> int id; >>> >>> >>> >>> std::vector vf3; >>> >>> }; >>> >>> >>> >>> Note how with this approach you can easily customize column name/type, >>> use >>> members in queries, etc. >>> >>> >> OK, i see how that can work... I think....could get painful for larger >> array sizes. >> > > You could write a simple program (or even a shell script) to generate all > "#pragma db member" statements required ... > > From gdejian at 126.com Thu Aug 18 21:35:38 2016 From: gdejian at 126.com (=?GBK?B?uN+1wr2h?=) Date: Fri Aug 19 11:07:04 2016 Subject: [odb-users] segmentation fault on linux while operating Mysql database Message-ID: <32f59d4b.1e71.156a07070a4.Coremail.gdejian@126.com> Hi Boris, In debug mode: #0 0x00000000004079ec in odb::mysql::statement_cache::find_object (this=0x0) at ../hello/libodb-mysql-2.4.0/odb/mysql/statement-cache.txx:24 #1 0x0000000000404dd6 in object_traits_impl::persist (db=..., obj=...) at ../hello/person-odb.cxx:403 #2 0x000000000040445d in odb::database::persist_ (this=0x9a7ce0, obj=...) at ../hello/libodb-2.4.0/odb/database.txx:38 #3 0x000000000040433d in odb::database::persist (this=0x9a7ce0, obj=...) at ../hello/libodb-2.4.0/odb/database.ixx:160 Thanks, Gao From boris at codesynthesis.com Fri Aug 19 11:52:07 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Aug 19 11:52:25 2016 Subject: [odb-users] Re: segmentation fault on linux while operating Mysql database In-Reply-To: <32f59d4b.1e71.156a07070a4.Coremail.gdejian@126.com> References: <32f59d4b.1e71.156a07070a4.Coremail.gdejian@126.com> Message-ID: Hi Gao, ??? writes: > #0 0x00000000004079ec in odb::mysql::statement_cache::find_object > (this=0x0) at ../hello/libodb-mysql-2.4.0/odb/mysql/statement-cache.txx:24 Well, this=0x0 should tell you something is not right. > #1 0x0000000000404dd6 in object_traits_impl:: > persist (db=..., obj=...) at ../hello/person-odb.cxx:403 Looks like mysql::transaction::current ().connection () call returns NULL as current connection. Which is quite strange: if there was no current transaction, the you should have gotten an exception. And if there is a transaction, then there should be a connection. Something strange is going on. Looks like a skew/mis-configured build or some such. You will have to investigate on your own. Boris From tom at touchsurgery.com Sat Aug 20 05:44:06 2016 From: tom at touchsurgery.com (Tom Stoffer) Date: Sat Aug 20 10:09:25 2016 Subject: [odb-users] Self join WHERE value IS NULL Message-ID: <6A00FF63-D454-4DCB-9CF3-C3ADCC7FAFA3@touchsurgery.com> Hi Boris, I have a question regarding querying using views. Here is my object structure: #pragma db object class employee { friend class odb::access; public: employee(){}; employee(std::string name){ name_ = name; } #pragma db id std::string name_; #pragma db value_not_null inverse(down) std::vector> up; #pragma db value_not_null unordered std::vector> down; }; The query I am trying to perform is to get all the employees who do not have any up relations. I have attempted using Views for this but have struggled to get the correct query for checking if up is null. Especially seeing as though it is an inverse relation, hence not appearing in the DB. After reading chapter 10 and the mailing list, still no luck. I have managed to accomplish what I need using a native view as below, although I would like to avoid using native views if possible. #pragma db view query("SELECT employee.name FROM employee LEFT JOIN employee_down ON employee.name = employee_down.value WHERE employee_down.value IS NULL") struct NativeEmployeeView { #pragma db column(employee::name_) std::string name_; }; Much thanks for all your work on this project! Tom From odb at a-cunningham.com Sat Aug 20 12:11:03 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Sat Aug 20 12:11:49 2016 Subject: [odb-users] Need Help for compiling ODB for iOS Message-ID: Hi Boris, Do you mean compiling "libodb" and "libodb-sqlite" for iOS? Or the ODB compiler itself? Obviously it would be nice to be able to build/use the ODB compiler directly within XCode but I am not sure if that is possible given GCC is not supported on MacOS anymore as far as I understand. Maybe someone else can suggest an option there. Of course it would be easy to ODB-compile the headers via a Windows/Linux VM or something similar. As far as compiling libodb/libodb-sqlite as iOS static libraries, this is very easy. It may be possible to do this entirely via some tricky command-line use, but that's outside of my experience base. Extract the archives into a directory on OS X ./configure ./make as per any Linux platform. This of course builds the x86 versions. Start Xcode Create a new project ( libodb, libodb-sqlite) targeting iOS Static Library Set the preprocessor macro HAVE_CONFIG_H Add the ODB search #include paths Set "always search user include paths" to yes Add the source code files from the ODB libraries Build. Andrew From boris at codesynthesis.com Mon Aug 22 12:36:32 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 22 12:37:13 2016 Subject: [odb-users] Self join WHERE value IS NULL In-Reply-To: <6A00FF63-D454-4DCB-9CF3-C3ADCC7FAFA3@touchsurgery.com> References: <6A00FF63-D454-4DCB-9CF3-C3ADCC7FAFA3@touchsurgery.com> Message-ID: Hi Tom, Tom Stoffer writes: > #pragma db view query("SELECT employee.name FROM employee LEFT > JOIN employee_down ON employee.name = employee_down.value WHERE > employee_down.value IS NULL") If you need to test container entries for NULL, then this is the only way since there is no support for using container elements in query conditions, yet. In this particular case it is not clear what the benefit of having NULL pointers in the container when you could just remove the entry altogether. In this case I think you would have been able to test this (i.e., no related objects) using a non-native view. Boris From xiang.zhao at gamegou.com Tue Aug 23 08:04:48 2016 From: xiang.zhao at gamegou.com (=?utf-8?B?WmhhbyBYaWFuZw==?=) Date: Tue Aug 23 12:08:08 2016 Subject: [odb-users] Two namespace in one header file cause generation error Message-ID: Dear odb support: I've noticed a possible bug in sql generation if there were two namespaces in one file. I'm using odb 2.4.0 on windows. My input file is: #pragma once #include #include #include #include #pragma db namespace schema("abcd") namespace abcd { #pragma db object struct a { #pragma db id uint32_t id; }; } #pragma db namespace schema("abcdef") namespace abcdef { #pragma db object struct a { #pragma db id uint32_t id; }; #pragma db object struct b { #pragma db id uint32_t id; }; } The command I used was? ..\..\..\..\..\tools\odb-i686-windows\bin\odb -I../../../../../lib/odb/libodb -I../../../../../lib/ -I../../../common/ -I../../../../../lib/protobuf/src -d mysql --generate-query --generate-schema --std c++11 --profile boost/date-time --profile boost/optional %1 The output sql file I got is: /* This file was generated by ODB, object-relational mapping (ORM) * compiler for C++. */ DROP TABLE IF EXISTS `abcd`.`b`; DROP TABLE IF EXISTS `abcd`.`a`; CREATE TABLE `abcd`.`a` ( `id` INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE `abcd`.`b` ( `id` INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=InnoDB; As you can see, table `abcdef`.`a` is missing from the file, and table `b` appeared in schema `abcd`, which should be in `abcdef`. Would you please kindly check it out? Thanks Zhao Xiang From luisagiacomini.eu at gmail.com Tue Aug 23 11:30:00 2016 From: luisagiacomini.eu at gmail.com (Luisa Giacomini) Date: Tue Aug 23 12:08:08 2016 Subject: [odb-users] schema not found in odb2.4 project compiled on osx Message-ID: Dear Boris, I am really struggling with osx mountain lion. After a short "break" I am again trying to use odb on an osx platform. In my previous email the problem was odb 2.3. I do not know if it was 2.3 or the way it was compiled, but I stated that also odb test check did not work so I switched to odb 2.4. Now the test check work but 2.4 cannot make something odb 2.3 was able to: create the db with the schema_catalog::create_schema call. The exe says "unknown schema". I read in the forum that this can happen if I use static libraries, but I use only dynamic libraries. I am compiling my project from inside QtCreator with qt 5.4.1, maybe I have to configure something special for these projects? Thanks in advance, Luisa From odb at a-cunningham.com Wed Aug 24 02:28:28 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Wed Aug 24 02:29:12 2016 Subject: [odb-users] ODB porting Message-ID: I managed to get the ODB compiler built on OS-X 10.11 El Cap. - Install "MacPorts" from https://www.macports.org - Install GCC 4.8 from MacPorts (Not the latest, but it's good enough to build ODB) - sudo port install gcc48 - download libcutl from codesynthesis Then basically build everything (libodb, libodb-sqlite, libcutl, odb) like you would on any linux except using the gcc 4.8 compiler, for example... ./configure CXX=x86_64-apple-darwin15-c++-mp-4.8 PS I tried GCC 4.9 from MacPorts, but it crashed with an ICE. From axel50397 at gmail.com Wed Aug 24 03:37:19 2016 From: axel50397 at gmail.com (Adnan RIHAN) Date: Wed Aug 24 03:38:14 2016 Subject: [odb-users] ODB porting In-Reply-To: References: Message-ID: <2521AD83F4DE74FC.578013AB-595F-4D1A-BCF9-5D7AC9739EE8@mail.outlook.com> Hey ! If you have homebrew, check this out: https://github.com/max13/homebrew-odb -- Cordialement, Adnan RIHAN GPG: 5675-62BA (https://keybase.io/max13/key.asc) ? If you are not using GPG/PGP but want to send me an encrypted e-mail: https://encrypt.to/0x567562BA. On Wed, Aug 24, 2016 at 8:47 AM +0200, "Andrew Cunningham" wrote: I managed to get the ODB compiler built on OS-X 10.11 El Cap. - Install "MacPorts" from https://www.macports.org - Install GCC 4.8 from MacPorts (Not the latest, but it's good enough to build ODB) - sudo port install gcc48 - download libcutl from codesynthesis Then basically build everything (libodb, libodb-sqlite, libcutl, odb) like you would on any linux except using the gcc 4.8 compiler, for example... ./configure CXX=x86_64-apple-darwin15-c++-mp-4.8 PS I tried GCC 4.9 from MacPorts, but it crashed with an ICE. From tom at touchsurgery.com Wed Aug 24 11:37:10 2016 From: tom at touchsurgery.com (Tom Stoffer) Date: Wed Aug 24 12:28:39 2016 Subject: [odb-users] Self join WHERE value IS NULL In-Reply-To: References: <6A00FF63-D454-4DCB-9CF3-C3ADCC7FAFA3@touchsurgery.com> Message-ID: Thanks for the reply Boris, Please could you elaborate on your second suggestion. How would you go about defining a view which checks for no related objects. Please note that the object I am looking for is inverse, meaning it is not in the database. So far as I have seen it is not possible to use inverse values in queries? Maybe I have missed something. Tom On Mon, Aug 22, 2016 at 5:36 PM, Boris Kolpackov wrote: > Hi Tom, > > Tom Stoffer writes: > > > #pragma db view query("SELECT employee.name FROM employee LEFT > > JOIN employee_down ON employee.name = employee_down.value WHERE > > employee_down.value IS NULL") > > If you need to test container entries for NULL, then this is the only > way since there is no support for using container elements in query > conditions, yet. > > In this particular case it is not clear what the benefit of having > NULL pointers in the container when you could just remove the entry > altogether. In this case I think you would have been able to test > this (i.e., no related objects) using a non-native view. > > Boris > From boris at codesynthesis.com Wed Aug 24 12:46:00 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Aug 24 12:46:39 2016 Subject: [odb-users] ODB porting In-Reply-To: References: Message-ID: Hi Andrew, Thanks for sharing the steps, always appreciated. Andrew Cunningham writes: > PS I tried GCC 4.9 from MacPorts, but it crashed with an ICE. This is a bug in GCC 4.9-series that has just been finally fixed a few days ago. You can also work around it by passing -fno-devirtualize CXXFLAGS option. Boris From boris at codesynthesis.com Wed Aug 24 12:50:11 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Aug 24 12:50:42 2016 Subject: [odb-users] schema not found in odb2.4 project compiled on osx In-Reply-To: References: Message-ID: Hi Luisa, Luisa Giacomini writes: > Now the test check work but 2.4 cannot make something odb 2.3 was able > to: create the db with the schema_catalog::create_schema call. The exe > says "unknown schema". Try to create a simple application, for example, based on the hello example, that uses an embedded schema, similar to your application and see if it still does not work. If it works, then try to figure out what's different compared to your application. If it doesn't work, then send over so that we can take a look. Boris From boris at codesynthesis.com Wed Aug 24 12:55:50 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Aug 24 12:56:28 2016 Subject: [odb-users] Two namespace in one header file cause generation error In-Reply-To: References: Message-ID: Hi Zhao, Zhao Xiang writes: > As you can see, table `abcdef`.`a` is missing from the file, and > table `b` appeared in schema `abcd`, which should be in `abcdef`. I think this has been already fixed for the next release, but thanks for reporting it and providing a test case. With ODB build from master I get: CREATE TABLE `abcd`.`a` [...] CREATE TABLE `abcdef`.`a` [...] CREATE TABLE `abcdef`.`b` [...] You can try the latest pre-release: http://codesynthesis.com/~boris/tmp/odb/pre-release/a9/ Boris From boris at codesynthesis.com Wed Aug 24 13:09:19 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Aug 24 13:09:58 2016 Subject: [odb-users] Self join WHERE value IS NULL In-Reply-To: References: <6A00FF63-D454-4DCB-9CF3-C3ADCC7FAFA3@touchsurgery.com> Message-ID: Hi Tom, Tom Stoffer writes: > Please could you elaborate on your second suggestion. How would you go > about defining a view which checks for no related objects. Please note that > the object I am looking for is inverse, meaning it is not in the database. > So far as I have seen it is not possible to use inverse values in queries? You can use inverse pointers in queries. What you cannot do is use containers in queries. But you can use container-based relationships in view JOIN's. So the idea in a nutshell is this: > #pragma db object > class employee > { > #pragma db id > std::string name_; > > #pragma db value_not_null inverse(down) > std::vector> up; > > #pragma db value_not_null unordered > std::vector> down; > }; #pragma db view \ object(employee) \ object(employee = up: employee::up) \ query(distinct) struct employee_up { #pragma db column (employee::name_) std::string name }; using eu_query = odb::query db.query (eu_query::up::name.is_no_null ()); This will return all the employees that have non empty 'up' containers. Now, thinking about it, I believe this will also omit employees that have 'up' containers with only NULL pointers. Boris From odb at a-cunningham.com Wed Aug 24 14:17:22 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Wed Aug 24 14:18:14 2016 Subject: [odb-users] ODB porting In-Reply-To: <2521AD83F4DE74FC.578013AB-595F-4D1A-BCF9-5D7AC9739EE8@mail.outlook.com> References: <2521AD83F4DE74FC.578013AB-595F-4D1A-BCF9-5D7AC9739EE8@mail.outlook.com> Message-ID: Adnan, Thanks, that looks even easier. I looked at homebrew, but since I had MacPorts already installed and I wanted to build the 2.5.0a9 pre-release , I went that route. I also gather homebrew and MacPorts don't play too well together when installed on the same machine. Andrew On Wed, Aug 24, 2016 at 12:37 AM, Adnan RIHAN wrote: > Hey ! > > If you have homebrew, check this out: https://github.com/max13/ > homebrew-odb > > On Wed, Aug 24, 2016 at 8:47 AM +0200, "Andrew Cunningham" < > odb@a-cunningham.com> wrote: > > I managed to get the ODB compiler built on OS-X 10.11 El Cap. >> >> >> - Install "MacPorts" from https://www.macports.org >> - Install GCC 4.8 from MacPorts (Not the latest, but it's good enough to >> build ODB) >> - sudo port install gcc48 >> - download libcutl from codesynthesis >> >> Then basically build everything (libodb, libodb-sqlite, libcutl, odb) like >> you would on any linux except using the gcc 4.8 compiler, for example... >> >> ./configure CXX=x86_64-apple-darwin15-c++-mp-4.8 >> >> >> PS I tried GCC 4.9 from MacPorts, but it crashed with an ICE. >> >> From odb at a-cunningham.com Wed Aug 24 14:30:44 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Wed Aug 24 14:32:35 2016 Subject: [odb-users] Two namespace in one header file cause generation error In-Reply-To: References: Message-ID: And the 2.5.0a9 release fixes a couple of things as well - The ODB compiler will now return an error if you violate the "container of containers" restriction - A bug fixed which prevented containers being loaded when.... You have multiple containers in the same odb::section The containing object was derived from a persistent base class that contained the "db id" The objects in the containers were also derived from the same persistent base class The bug would cause the second and subsequent containers in the section to not be loaded on "load" of the section. Thanks again to Boris for fixing! On Wed, Aug 24, 2016 at 9:55 AM, Boris Kolpackov wrote: > Hi Zhao, > > Zhao Xiang writes: > > > As you can see, table `abcdef`.`a` is missing from the file, and > > table `b` appeared in schema `abcd`, which should be in `abcdef`. > > I think this has been already fixed for the next release, but thanks > for reporting it and providing a test case. > > With ODB build from master I get: > > CREATE TABLE `abcd`.`a` [...] > > CREATE TABLE `abcdef`.`a` [...] > > CREATE TABLE `abcdef`.`b` [...] > > You can try the latest pre-release: > > http://codesynthesis.com/~boris/tmp/odb/pre-release/a9/ > > Boris > > From tomstoffer at gmail.com Thu Aug 25 05:22:00 2016 From: tomstoffer at gmail.com (Tom Stoffer) Date: Thu Aug 25 05:23:08 2016 Subject: [odb-users] Re: odb-users Digest, Vol 72, Issue 14 In-Reply-To: <201608231601.u7NG0Jh4014575@codesynthesis.com> References: <201608231601.u7NG0Jh4014575@codesynthesis.com> Message-ID: Hi Boris, Thanks for the reply, I think we are getting close! There is still an issue with your above suggestion however. When executing the query you specify, the database throws an error: "thrown: 1: no such table:" After looking into the sql that the view generates, it seems it is trying to join on the employee_up table. As mentioned in my last post, up is an is inverse relation so does not have a corresponding table. I am not sure how the odb compiler works but I would have thought that this should be handled there? Is there some sort of flag that needs to be specified in the view to tell the odb compiler to switch the tables when generating the sql? Here is the generated sql: query_base_type r ( "SELECT DISTINCT " "\"up\".\"name\" "); r += "FROM \"employee\""; r += " LEFT JOIN \"employee_up\" ON"; r += "\"employee_up\".\"object_id\"=\"employee\".\"name\""; r += " LEFT JOIN \"employee\" AS \"up\" ON"; r += "\"employee_up\".\"value\"=\"up\".\"name\""; Cheers Tom On Tue, Aug 23, 2016 at 5:01 PM, wrote: > Send odb-users mailing list submissions to > odb-users@codesynthesis.com > > To subscribe or unsubscribe via the World Wide Web, visit > http://codesynthesis.com/mailman/listinfo/odb-users > or, via email, send a message with subject or body 'help' to > odb-users-request@codesynthesis.com > > You can reach the person managing the list at > odb-users-owner@codesynthesis.com > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of odb-users digest..." > > > Today's Topics: > > 1. Re: Self join WHERE value IS NULL (Boris Kolpackov) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 22 Aug 2016 18:36:32 +0200 > From: Boris Kolpackov > Subject: Re: [odb-users] Self join WHERE value IS NULL > To: Tom Stoffer > Cc: odb-users@codesynthesis.com > Message-ID: > Content-Type: text/plain; charset=us-ascii > > Hi Tom, > > Tom Stoffer writes: > > > #pragma db view query("SELECT employee.name FROM employee LEFT > > JOIN employee_down ON employee.name = employee_down.value WHERE > > employee_down.value IS NULL") > > If you need to test container entries for NULL, then this is the only > way since there is no support for using container elements in query > conditions, yet. > > In this particular case it is not clear what the benefit of having > NULL pointers in the container when you could just remove the entry > altogether. In this case I think you would have been able to test > this (i.e., no related objects) using a non-native view. > > Boris > > > > ------------------------------ > > _______________________________________________ > odb-users mailing list > odb-users@codesynthesis.com > http://codesynthesis.com/mailman/listinfo/odb-users > > > End of odb-users Digest, Vol 72, Issue 14 > ***************************************** > From axel50397 at gmail.com Thu Aug 25 06:27:34 2016 From: axel50397 at gmail.com (Adnan RIHAN) Date: Thu Aug 25 06:28:59 2016 Subject: [odb-users] ODB porting In-Reply-To: References: <2521AD83F4DE74FC.578013AB-595F-4D1A-BCF9-5D7AC9739EE8@mail.outlook.com> Message-ID: Well? I don?t really know, I had ports, and when brew came I preferred it?s way. If you needed a special command compiling the pre-release, send it to me please, if I have time I can include it to my homebrew package. Thx On 24 ao?t 2016 at 20:17:23, Andrew Cunningham (odb@a-cunningham.com) wrote: Adnan, Thanks, that looks even easier. I looked at homebrew, but since I had MacPorts already installed and I wanted to build the 2.5.0a9 pre-release , I went that route. I also gather homebrew and MacPorts don't play too well together when installed on the same machine. Andrew On Wed, Aug 24, 2016 at 12:37 AM, Adnan RIHAN wrote: Hey ! If you have homebrew, check this out: https://github.com/max13/homebrew-odb On Wed, Aug 24, 2016 at 8:47 AM +0200, "Andrew Cunningham" wrote: I managed to get the ODB compiler built on OS-X 10.11 El Cap. - Install "MacPorts" from https://www.macports.org - Install GCC 4.8 from MacPorts (Not the latest, but it's good enough to build ODB) - sudo port install gcc48 - download libcutl from codesynthesis Then basically build everything (libodb, libodb-sqlite, libcutl, odb) like you would on any linux except using the gcc 4.8 compiler, for example... ./configure CXX=x86_64-apple-darwin15-c++-mp-4.8 PS I tried GCC 4.9 from MacPorts, but it crashed with an ICE. --? Cordialement, Adnan RIHAN Ing?nieur-Syst?me chez Clawi S.A. GPG: 5675-62BA (https://keybase.io/max13/key.asc) ??If you are not using GPG/PGP but want to send me an encrypted e-mail: https://encrypt.to/0x567562BA. From xiang.zhao at gamegou.com Wed Aug 24 20:53:44 2016 From: xiang.zhao at gamegou.com (=?utf-8?B?WmhhbyBYaWFuZw==?=) Date: Thu Aug 25 12:29:57 2016 Subject: [odb-users] Two namespace in one header file cause generationerror In-Reply-To: References: Message-ID: Hi Boris, Thanks for your kind reply. However it feels unreliable to use a pre release version in production. As far as I can tell, the current stable version, odb-2.4.0-i686-windows.zip, was released on 10-Feb-2015, which has been 18 months. I'd be appreciated to have a new stable version of odb. It's a great ORM system for C++, I'm using it in my game server which supports thousands of online users every second. Thanks Zhao Xiang ------------------ Original ------------------ From: "Boris Kolpackov"; Date: Thu, Aug 25, 2016 00:55 AM To: "Zhao Xiang"; Cc: "odb-users"; Subject: Re: [odb-users] Two namespace in one header file cause generationerror Hi Zhao, Zhao Xiang writes: > As you can see, table `abcdef`.`a` is missing from the file, and > table `b` appeared in schema `abcd`, which should be in `abcdef`. I think this has been already fixed for the next release, but thanks for reporting it and providing a test case. With ODB build from master I get: CREATE TABLE `abcd`.`a` [...] CREATE TABLE `abcdef`.`a` [...] CREATE TABLE `abcdef`.`b` [...] You can try the latest pre-release: http://codesynthesis.com/~boris/tmp/odb/pre-release/a9/ Boris From odb at a-cunningham.com Fri Aug 26 00:06:49 2016 From: odb at a-cunningham.com (Andrew Cunningham) Date: Fri Aug 26 00:07:36 2016 Subject: [odb-users] Custom ODB compiler build rule on OSX Message-ID: I am trying to create a custom build rule for the header files in my Xcode project to call the odb compiler. I know how to create custom build rule for a target - but it seems creating one to actually process a subset of the headers is somehow eluding me. As a test, I created a build rule for a specific header, but this build rule is never call on "Build". ideas? From alexandre.pretyman at gmail.com Fri Aug 26 09:22:10 2016 From: alexandre.pretyman at gmail.com (Alexandre Pretyman) Date: Fri Aug 26 09:23:41 2016 Subject: [odb-users] Custom ODB compiler build rule on OSX Message-ID: Hi Andrew (and Boris!) If you don't mind using CMake on your project, as it could generate Xcode project files, I've contributed the unix friendly odb libraries to the hunter package manager [ https://github.com/ruslo/hunter ]. CMake will manage the build rule for you. hunter is a kick-ass-CMake-based package manager for C++/C run by Ruslan Baratov. It will download the sources for odb-* and compile them - only once per toolchain (except for odb-compiler, where it downloads the binaries directly). The odb compiler CMake integration is based on the work of Timo Rothenpieler and Per Edin except for the crucial change that the odb_compile(...) function has to be called AFTER defining the CMake target for your executable/library: list(APPEND headers-to-run-the-odb-compiler-on header1.hpp header2.hpp ...) add_executable(MyGreatestApp ...) odb_compile( MyGreatestApp FILES ${headers-to-run-the-odb-compiler-on} DB mysql GENERATE_QUERY GENERATE_SESSION GENERATE_SCHEMA ) To use hunter you will add https://github.com/hunter-packages/gate/blob/master/cmake/HunterGate.cmake to the cmake directory next to the CMakeLists.txt file, and before your project(MyGreatesProject) you will put: include("cmake/HunterGate.cmake") HunterGate( URL "https://github.com/ruslo/hunter/archive/v0.15.20.tar.gz" SHA1 "1771b5509cf8645bdb1c7ac12bc5d29a35465d12" ) project(MyGreatesProject) ... hunter_add_package(odb-compiler) hunter_add_package(odb-mysql) find_package(odb COMPONENTS compiler mysql) ... [repeated from above for clarity] list(APPEND headers-to-run-the-odb-compiler-on header1.hpp header2.hpp ...) add_executable(MyGreatestApp ...) odb_compile( MyGreatestApp FILES ${headers-to-run-the-odb-compiler-on} DB mysql GENERATE_QUERY GENERATE_SESSION GENERATE_SCHEMA ) target_link_libraries(MyGreatestApp odb::mysql) This is from an example at: https://github.com/ruslo/hunter/blob/master/examples/odb-mysql Arguments to the odb_compile function can be found at: https://github.com/ruslo/hunter/blob/master/cmake/find/Findodb-compiler.cmake (I has not yet updated the hunter wiki for the odb library, sorry!) At the moment hunter has version 2.4.0 of odb, which I don't know if will suite you. iOS integration was working with a few manual hacks, but there is an issue open to fix it, which I will do *soon*. Hope you find this useful, Alexandre Pretyman On 26 August 2016 at 01:06, Andrew Cunningham wrote: > I am trying to create a custom build rule for the header files in my Xcode > project to call the odb compiler. > I know how to create custom build rule for a target - but it seems creating > one to actually process a subset of the headers is somehow eluding me. > As a test, I created a build rule for a specific header, but this build > rule is never call on "Build". > ideas? > -- Alexandre Pretyman From boris at codesynthesis.com Fri Aug 26 12:45:00 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Aug 26 12:45:38 2016 Subject: [odb-users] Two namespace in one header file cause generationerror In-Reply-To: References: Message-ID: Hi Zhao, Zhao Xiang writes: > However it feels unreliable to use a pre release version in production. > As far as I can tell, the current stable version, odb-2.4.0-i686-windows.zip, > was released on 10-Feb-2015, which has been 18 months. Yes, the release is overdue and we are working on something[1] that will allow us to have much more frequent/convenient releases. However, the pre-release is generally fairly reliable. Quite a few of ODB users (including ourselves in other projects) are using the pre-release. > It's a great ORM system for C++, I'm using it in my game server which > supports thousands of online users every second. Great, I am glad to hear you are enjoying ODB. [1] https://build2.org/ Boris From boris at codesynthesis.com Fri Aug 26 12:59:15 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Aug 26 12:59:44 2016 Subject: [odb-users] Re: incorrect view JOIN for inverse container relationship In-Reply-To: References: <201608231601.u7NG0Jh4014575@codesynthesis.com> Message-ID: Hi Tom, In the future please don't reply to the digest since it makes email subject and threading pretty useless. Please see Posting Guidelines (specifically #2 and #3) for details: http://codesynthesis.com/support/posting-guidelines.xhtml Tom Stoffer writes: > After looking into the sql that the view generates, it seems it is trying > to join on the employee_up table. As mentioned in my last post, up is an is > inverse relation so does not have a corresponding table. > I am not sure how the odb compiler works but I would have thought that this > should be handled there? Is there some sort of flag that needs to be > specified in the view to tell the odb compiler to switch the tables when > generating the sql? Yes, this should be handled auto-magically but the code that handles it is not-trivial, to put it mildly. Can you send a minimal but complete header that reproduces this issue? Boris From boris at codesynthesis.com Fri Aug 26 13:05:07 2016 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Aug 26 13:06:31 2016 Subject: [odb-users] Custom ODB compiler build rule on OSX In-Reply-To: References: Message-ID: Hi Alexandre, Alexandre Pretyman writes: > kick-ass-CMake-based package manager Thanks for sharing. I happen to be working on a kick-ass but non-CMake-based package manager (and a build system, while at it) for C++: https://build2.org We've already packaged a few base ODB libraries and you are welcome to take a look, if interested: https://queue.cppget.org Boris From alexandre.pretyman at gmail.com Sun Aug 28 21:59:52 2016 From: alexandre.pretyman at gmail.com (Alexandre Pretyman) Date: Sun Aug 28 22:00:59 2016 Subject: [odb-users] Custom ODB compiler build rule on OSX In-Reply-To: References: Message-ID: Hi Boris, Pretty cool effort! I have not found a odb example which runs the odb compiler on a project's headers, so please announce it to the list when there one. [ as constructive feedback, I found hard to find the version of libpq which is available in your repository ]. I'm not a biggest fan of CMake, but I don't see it going away any time soon :-) I guess us CMakers will have to integrate build2. All the best! On 26 August 2016 at 14:05, Boris Kolpackov wrote: > Hi Alexandre, > > Alexandre Pretyman writes: > > > kick-ass-CMake-based package manager > > Thanks for sharing. > > I happen to be working on a kick-ass but non-CMake-based package > manager (and a build system, while at it) for C++: > > https://build2.org > > We've already packaged a few base ODB libraries and you are welcome > to take a look, if interested: > > https://queue.cppget.org > > Boris > -- Alexandre Pretyman From andrew at a-cunningham.com Sat Aug 27 01:40:31 2016 From: andrew at a-cunningham.com (Andrew Cunningham) Date: Mon Aug 29 13:11:35 2016 Subject: [odb-users] ODB Build rules for XCode Message-ID: > > > On Aug 26, 2016, at 6:22 AM, Alexandre Pretyman < > alexandre.pretyman@gmail.com> wrote: > Hi Andrew (and Boris!) > If you don't mind using CMake on your project, as it could generate Xcode > project files, I've contributed the unix friendly odb libraries to the > hunter package manager [ https://github.com/ruslo/hunter ]. CMake will > manage the build rule for you. > hunter is a kick-ass-CMake-based package manager for C++/C run by Ruslan > Baratov. It will download the sources for odb-* and compile them - only > once per toolchain (except for odb-compiler, where it downloads the > binaries directly). > That's great, but I already have my Xcode project ( and have built all the ODB tools and libraries), and I am simply trying to add an ODB build rule for some headers. Some "Steps for Xcode Dummies" on how to set that up would be great appreciated ! From albert.gu at ringcentral.com Wed Aug 31 10:59:15 2016 From: albert.gu at ringcentral.com (Albert Gu) Date: Thu Sep 1 05:13:45 2016 Subject: [odb-users] Does ODB support partial update? If not, how can we improve the performance? Message-ID: Hi guys, I am using ODB currently, just want to know how can I improve the update/insert/delete performance? Let's say, I have to insert 1000 new records, update 1000 old records, delete 1000 records, after getting the response from server. These records are mixed together. Is there any good performance practice for this kind of issue? Thank you very much! - Regards, Albert