From shprotello at mail.ru Mon Dec 4 03:14:19 2017 From: shprotello at mail.ru (=?UTF-8?B?0KHQtdGA0LPQtdC5INCd0LjQutC+0L3QvtCy?=) Date: Mon Dec 4 03:14:39 2017 Subject: =?UTF-8?B?UmVbMl06IFtvZGItdXNlcnNdIHN0ZCBiYWQgYWxsb2NhdGlvbg==?= In-Reply-To: References: <1511865351.437739545@f487.i.mail.ru> Message-ID: <1512375259.362217113@f404.i.mail.ru> Hi Boris, Thank you for information. Does this version support composite object ids? Regards, Sergey >?????, 29 ?????? 2017, 11:22 +03:00 ?? Boris Kolpackov : > >Hi Sergey, > >Thanks for the report and analysis. I am pretty sure this has been >fixed in master by these two[1][2] commits. Could you try 2.5.0-b.3 >to confirm? > >https://codesynthesis.com/~boris/tmp/odb/pre-release/b.3/ > >[1] https://git.codesynthesis.com/cgit/odb/odb/commit/?id=5d969f916178eb5e223d658dd55f5f2bc9ab526d >[2] https://git.codesynthesis.com/cgit/odb/odb/commit/?id=7ebcc590a5ca302f35805a025545a8d10ce4cf5f > >Thanks, >Boris From k.cherenkov at gmail.com Sat Dec 2 13:56:11 2017 From: k.cherenkov at gmail.com (Konstantin Cherenkov) Date: Mon Dec 4 06:52:15 2017 Subject: [odb-users] Polymorphism with multiple header files Message-ID: Hi guys, I am trying to use odb with a polymorphic feature. An example https://git.codesynthesis.com/cgit/odb/odb-examples/tree/inheritance/polymorphism works fine. Unfortunately, when I am splitting classes into different header files I get an error `no_type_info`. For example, if I will extract `contractor` class into separate header file `contractor.hpp` then I will see this error. Is it possible to use polymorphic classes with multiple headers files? From boris at codesynthesis.com Mon Dec 4 07:58:28 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 4 07:58:40 2017 Subject: [odb-users] std bad allocation In-Reply-To: <1512375259.362217113@f404.i.mail.ru> References: <1511865351.437739545@f487.i.mail.ru> <1512375259.362217113@f404.i.mail.ru> Message-ID: ?????? ??????? writes: > Does this version support composite object ids? Yes, it is the latest version with all the features. Boris From boris at codesynthesis.com Mon Dec 4 08:04:18 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 4 08:04:29 2017 Subject: [odb-users] Polymorphism with multiple header files In-Reply-To: References: Message-ID: Konstantin Cherenkov writes: > Unfortunately, when I am splitting classes into different header files I > get an error `no_type_info`. > > For example, if I will extract `contractor` class into separate header file > `contractor.hpp` then I will see this error. > > Is it possible to use polymorphic classes with multiple headers files? Yes, of course. My guess would be: 1. You did not compile contractor.hpp with the ODB compiler. 2. You did not compile and link the resulting contractor-odb.cpp into your application. 3. You packaged contractor-odb.cpp into a static library and since you did not reference contractor in your application, it did not get linked. For (3), see: http://www.codesynthesis.com/pipermail/odb-users/2013-May/001286.html Boris From unusual.exception.thrown at gmail.com Fri Dec 8 11:07:13 2017 From: unusual.exception.thrown at gmail.com (Crispus Attucks) Date: Fri Dec 8 11:07:31 2017 Subject: [odb-users] Postgres comment feature via ODB Message-ID: Hi, I have been skimming the documentation and have been trying to figure out whether there is a way to take advantage of the "comment" feature[1] in Postgres. Is this possible in odb? (It would be nice to have the "--generate-schama" option generate the comments so I can attach metadata to columns.) If this is not a feature and not a development priority, perhaps you could point me to where I could begin investigating how to intercept the --generate-schema output for postgres (as well as the easiest way to tack on some new pragmas.) Moreover, some guidance on how to iterate over the fields and data types before the "create table" sql is generated would be helpful. In many cases, I want to be able to "plug in" to your system right before the schema for a database table is created. Thank you for a very nice product and thanks in advance for any response. [1] https://www.postgresql.org/docs/9.1/static/sql-comment.html From asnagni at yahoo.com Sat Dec 9 08:20:28 2017 From: asnagni at yahoo.com (Alain-Serge Nagni) Date: Sat Dec 9 08:20:49 2017 Subject: [odb-users] Help is need with odb::vector Binary Type for PostgreSQL Message-ID: <221B160E-CCFD-4F86-A968-2993DE1ACBD2@yahoo.com> Hi there, We have a Classe with a std::vector as a data member, std::vector , and for performance reason we would like to migrate to odb::::vector. Do anyone knows how to perform that switch? Per the documentation it should be a drop and replacement. We are using PostgreSQL database. We did try and we are having some issues at run time. This is the class and the data member declaration: #pragma db object Class CPhotos { ?. ?. ?. ?. #pragma db type (?BYTEA") std::vector m_imageBytes; } When we change std::vector m_imageBytes to : odb::vector m_imageBytes; At run time when we try to access the database we have an error. This is the error : 42P01: ERROR: relation "CPhotos_imageBytes" does not exist LINE 1: ...Bytes"."index", "CPhotos_imageBytes"."value" FROM "CPhotos_i? Thank you for your help, Alain-Serge From jnw at xs4all.nl Sun Dec 10 03:06:26 2017 From: jnw at xs4all.nl (Jeroen N. Witmond) Date: Sun Dec 10 03:06:44 2017 Subject: [odb-users] Combining ODB with CXX Tree Message-ID: <4716ec2c22fdb2522063ba402d600bb5@xs4all.nl> Greetings! I was thinking about combining ODB with CXX Tree, so I found this post https://codesynthesis.com/pipermail/xsd-users/2015-November/004714.html dated Thu Nov 5 03:40:20 EST 2015. I understand that in general, implementing this combination is not trivial, but I felt that should be able to get a trivial case to work, just for the fun of it. However, I've run into a problem that I do not understand. I started with: [bicycles.xsd] [/bicycles.xsd] and I created: [bicycle.odb] namespace test { #pragma db object(bicycle) #pragma db member(bicycle::id_) id get(id()) set(id(?)) #pragma db member(bicycle::name_) get(name()) set(name(?)) } [/bicycle.odb] This results in the following output: -*- mode: compilation; default-directory: "~/development/bahcowork/odb+xsd/" -*- Compilation started at Sun Dec 10 08:47:53 make -Wbicycles.xsd bicycles-odb.cxx xsdcxx cxx-tree --std c++11 --generate-wildcard --generate-ostream \ bicycles.xsd odb --database mysql --std c++11 --generate-query --generate-schema \ --odb-epilogue '#include "bicycle.odb"' bicycles.hxx bicycle.odb:4:46: error: modifier expression requires member type to be default-constructible Makefile:814: recipe for target 'bicycles-odb.cxx' failed make: *** [bicycles-odb.cxx] Error 1 Compilation exited abnormally with code 2 at Sun Dec 10 08:47:54 $ xsdcxx --version CodeSynthesis XSD XML Schema to C++ compiler 4.0.0 Copyright (c) 2005-2014 Code Synthesis Tools CC This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ odb --version ODB object-relational mapping (ORM) compiler for C++ 2.4.0 Copyright (c) 2009-2015 Code Synthesis Tools CC This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. I do not understand the "error: modifier expression requires member type to be default-constructible" because the following code compiles cleanly: [testing.cpp] #include #include "bicycles.hxx" int main() { typedef ::xml_schema::unsigned_int id_type; ::xsd::cxx::tree::one< id_type > id_(); typedef ::xml_schema::ncname name_type; ::xsd::cxx::tree::one< name_type > name_(); } #include [/testing.cpp] The post I referred to above is in the xsd-users mailing list. I've posted this in the odb-users mailing list because I guessed that this is a better place for this problem, but I may be wrong ... Can anybody help to get this trivial case to work? Thanks, Jeroen. From boris at codesynthesis.com Mon Dec 11 10:58:37 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 11 10:58:48 2017 Subject: [odb-users] Postgres comment feature via ODB In-Reply-To: References: Message-ID: Crispus Attucks writes: > Hi, I have been skimming the documentation and have been trying to figure > out whether there is a way to take advantage of the "comment" feature[1] in > Postgres. Is this possible in odb? If there were a way to specify comments as part of a column definition, then you could have used the 'options' pragma. But it looks like they can only be specified as separate statements. > If this is not a feature and not a development priority, Yes, its use seems rather limited so definitely not a priority. > perhaps you could point me to where I could begin investigating how > to intercept the --generate-schema output for postgres (as well as > the easiest way to tack on some new pragmas.) Moreover, some guidance > on how to iterate over the fields and data types before the "create > table" sql is generated would be helpful. The schema is first generated into the in-memory model described in odb/semantics/relational/. This is done by the relational::model::generate() function in odb/relational/model.cxx Then it is written as SQL by relational::schema::generate_{drop,create}() in odb/relational/schema.cxx. Pragmas are defined in odb/pragma.cxx. Boris From boris at codesynthesis.com Mon Dec 11 11:02:20 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 11 11:02:31 2017 Subject: [odb-users] Help is need with odb::vector Binary Type for PostgreSQL In-Reply-To: <221B160E-CCFD-4F86-A968-2993DE1ACBD2@yahoo.com> References: <221B160E-CCFD-4F86-A968-2993DE1ACBD2@yahoo.com> Message-ID: Alain-Serge Nagni writes: > We have a Classe with a std::vector as a data member, > std::vector , and for performance reason we would > like to migrate to odb::::vector. > > #pragma db type (?BYTEA") > std::vector m_imageBytes; odb::vector is a change-tracking implementation that is used for containers, not for storing BLOBs. See the documentation for details. Boris From boris at codesynthesis.com Mon Dec 11 11:11:14 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Dec 11 11:11:25 2017 Subject: [odb-users] Combining ODB with CXX Tree In-Reply-To: <4716ec2c22fdb2522063ba402d600bb5@xs4all.nl> References: <4716ec2c22fdb2522063ba402d600bb5@xs4all.nl> Message-ID: Jeroen N. Witmond writes: > > > > > > > > [...] > > namespace test > { > #pragma db object(bicycle) > #pragma db member(bicycle::id_) id get(id()) set(id(?)) > #pragma db member(bicycle::name_) get(name()) set(name(?)) > } > > [...] > > ::xsd::cxx::tree::one< id_type > id_(); This declares a function, its doesn't call the default constructor. xsd::cxx::tree::one<> is not default-constructible. The way you can work around it (you could make one<> an ODB wrapper if you wanted to do it "properly") is by using virtual data members. Something along these lines: #pragma db object(bicycle) transient #pragma db member(bicycle::id) virtual(bicycle::id_type) id get(id()) set(id(?)) Boris From asnagni at yahoo.com Mon Dec 11 14:07:50 2017 From: asnagni at yahoo.com (Alain-Serge Nagni) Date: Mon Dec 11 14:08:13 2017 Subject: [odb-users] Re: Help is need with odb::vector Binary Type for PostgreSQL In-Reply-To: <221B160E-CCFD-4F86-A968-2993DE1ACBD2@yahoo.com> References: <221B160E-CCFD-4F86-A968-2993DE1ACBD2@yahoo.com> Message-ID: <9CAFB85F-A96B-4393-B8E4-DA87944BCFCE@yahoo.com> Hi Bris, Thank you the info. I have a look. Tell me Boris, when we load the object from the database, is there a way to not load the BLOB? Thank you, Alain-Serge > On Dec 9, 2017, at 8:20 AM, Alain-Serge Nagni wrote: > > Hi there, > We have a Classe with a std::vector as a data member, std::vector , and for performance reason we would like to migrate to odb::::vector. Do anyone knows how to perform that switch? Per the documentation it should be a drop and replacement. We are using PostgreSQL database. We did try and we are having some issues at run time. This is the class and the data member declaration: > > > #pragma db object > Class CPhotos > { > ?. > ?. > ?. > ?. > > #pragma db type (?BYTEA") > std::vector m_imageBytes; > } > > > > When we change std::vector m_imageBytes to : odb::vector m_imageBytes; > > > At run time when we try to access the database we have an error. This is the error : > > 42P01: ERROR: relation "CPhotos_imageBytes" does not exist > LINE 1: ...Bytes"."index", "CPhotos_imageBytes"."value" FROM "CPhotos_i? > > > > Thank you for your help, > Alain-Serge From mruess at gmail.com Mon Dec 11 11:59:49 2017 From: mruess at gmail.com (Matthias Ruess) Date: Tue Dec 12 01:04:05 2017 Subject: [odb-users] VS2017 Message-ID: Hi odb-users, I want to update my VS2013 projects to 2017 and have two questions: Should ODB 2.4.0 compile with VS 2017 version 15.5? Will there be a new version of odb in the next 2 or 3 months or will it take longer? Is the next version of libodb-mysql part of the vcpkg ports like libodb-sqlite? Matt From boris at codesynthesis.com Tue Dec 12 02:17:36 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Dec 12 02:17:47 2017 Subject: [odb-users] VS2017 In-Reply-To: References: Message-ID: Matthias Ruess writes: > I want to update my VS2013 projects to 2017 and have two questions: > Should ODB 2.4.0 compile with VS 2017 version 15.5? Yes, though I would recommend that you use the latest pre-release (we use[1] it ourselves with VS 15): https://codesynthesis.com/~boris/tmp/odb/pre-release/b.3/ > Will there be a new version of odb in the next 2 or 3 months or will it > take longer? This is the timeframe (i.e., early next year) we are aiming for but it may take longer. > Is the next version of libodb-mysql part of the vcpkg ports like > libodb-sqlite? The vcpkg package of libodb-sqlite was not done by us (in fact, this is the first time I am hearing about it) so can't say anything about libodb-mysql. Both will be (in fact, already are[2]) packaged for bpkg. And libodb-mysql will be usable with both MySQL and MariaDB client libraries (and even on Windows). [1] https://build2.org/ [2] https://stage.build2.org/?q=mysql Boris From boris at codesynthesis.com Tue Dec 12 02:19:21 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Dec 12 02:19:32 2017 Subject: [odb-users] Re: Help is need with odb::vector Binary Type for PostgreSQL In-Reply-To: <9CAFB85F-A96B-4393-B8E4-DA87944BCFCE@yahoo.com> References: <221B160E-CCFD-4F86-A968-2993DE1ACBD2@yahoo.com> <9CAFB85F-A96B-4393-B8E4-DA87944BCFCE@yahoo.com> Message-ID: Alain-Serge Nagni writes: > Tell me Boris, when we load the object from the database, is there > a way to not load the BLOB? Yes, you can partition the object into separately-loaded/updated sections. See Chapter 9, "Sections" in the manual. Boris From mruess at gmail.com Tue Dec 12 03:56:34 2017 From: mruess at gmail.com (Matthias Ruess) Date: Tue Dec 12 04:59:44 2017 Subject: [odb-users] VS2017 In-Reply-To: References: Message-ID: Thank you very much for the detailled answers - then I will wait until spring 2018... Cheers, Matt On Tue, Dec 12, 2017 at 8:17 AM, Boris Kolpackov wrote: > Matthias Ruess writes: > > > I want to update my VS2013 projects to 2017 and have two questions: > > Should ODB 2.4.0 compile with VS 2017 version 15.5? > > Yes, though I would recommend that you use the latest pre-release (we > use[1] it ourselves with VS 15): > > https://codesynthesis.com/~boris/tmp/odb/pre-release/b.3/ > > > > Will there be a new version of odb in the next 2 or 3 months or will it > > take longer? > > This is the timeframe (i.e., early next year) we are aiming for but it > may take longer. > > > > Is the next version of libodb-mysql part of the vcpkg ports like > > libodb-sqlite? > > The vcpkg package of libodb-sqlite was not done by us (in fact, this > is the first time I am hearing about it) so can't say anything about > libodb-mysql. > > Both will be (in fact, already are[2]) packaged for bpkg. And > libodb-mysql will be usable with both MySQL and MariaDB client > libraries (and even on Windows). > > [1] https://build2.org/ > [2] https://stage.build2.org/?q=mysql > > Boris > From asnagni at yahoo.com Tue Dec 12 23:31:39 2017 From: asnagni at yahoo.com (Alain-SergeNagni) Date: Tue Dec 12 23:31:59 2017 Subject: [odb-users] Help is need with odb::vector Binary Type for PostgreSQL In-Reply-To: References: <221B160E-CCFD-4F86-A968-2993DE1ACBD2@yahoo.com> Message-ID: <1A4362BE-C4BF-407E-8236-CAA7CFBFCFBF@yahoo.com> Hi Boris, We read the sections of the document as you suggested. As always it has the information and solution to our issues: chapter 5.4 and chapter 9 Thank you again, Alain-Serge Sent from my iPad > On Dec 11, 2017, at 11:02 AM, Boris Kolpackov wrote: > > Alain-Serge Nagni writes: > >> We have a Classe with a std::vector as a data member, >> std::vector , and for performance reason we would >> like to migrate to odb::::vector. >> >> #pragma db type (?BYTEA") >> std::vector m_imageBytes; > > odb::vector is a change-tracking implementation that is used for > containers, not for storing BLOBs. See the documentation for > details. > > Boris From ps.georgiou at gmail.com Wed Dec 13 10:49:30 2017 From: ps.georgiou at gmail.com (Panayiotis Georgiou) Date: Wed Dec 13 10:49:49 2017 Subject: [odb-users] Exception handling and rollback() Message-ID: Hello According to ODB's manual, as well as this post [1], ODB is smart enough to rollback any non-finalised transactions. Is there a situation where ODB may throw an exception in which we need to manually call rollback ()? Below I have included a simple example of how I catch exceptions in my code (same approach is followed for calls to update(), load(), delete()). Is this a reasonable implementation and if we had to call rollback after an exception was thrown, what is the best way to do that? Thanks, Panayiotis. //========== unsigned long createRecord(T& newRecord) const { odb::database* db; odb::transaction transaction; unsigned long id; for (unsigned short retryCount(0); ; retryCount++) { try { db = dbManager.getDatabase(); transaction.reset(db->begin()); id = db->persist(newRecord); transaction.commit(); } catch (const odb::recoverable& e) { if (retryCount > maxRetries) throw kException("Retry limit exceeded: " + e.what()); else continue; } catch (const odb::exception& e) { throw kException("ODB critical exception: " + e.what()); } } return id; } //========== [1] https://www.codesynthesis.com/pipermail/odb-users/2013-May/001296.html From seshagiri.sandhya89 at gmail.com Wed Dec 13 12:57:12 2017 From: seshagiri.sandhya89 at gmail.com (Sandhya Seshagiri) Date: Thu Dec 14 02:11:38 2017 Subject: [odb-users] Fetch value from class A and update class B In-Reply-To: References: Message-ID: Hi Borris, I am new to ODB ORM and also to C++. I started learning from month back. For my application I need to fetch values from Column 1 in Table A and update Column 1 in Table B. Can you please provide me some example on how to do it. Thanks and Regards, Sandhya From boris at codesynthesis.com Thu Dec 14 08:40:29 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Dec 14 08:40:41 2017 Subject: [odb-users] Exception handling and rollback() In-Reply-To: References: Message-ID: Panayiotis Georgiou writes: > Is there a situation where ODB may throw an exception in which we need to > manually call rollback ()? If you catch it before the transaction's destructor is called (due to stack unwinding). > unsigned long createRecord(T& newRecord) const > { > odb::database* db; > odb::transaction transaction; I would move this ... > unsigned long id; > > for (unsigned short retryCount(0); ; retryCount++) > { > try > { > db = dbManager.getDatabase(); > transaction.reset(db->begin()); ... here: odb::transaction transaction (db->begin()); > id = db->persist(newRecord); > transaction.commit(); > } > catch (const odb::recoverable& e) > { > if (retryCount > maxRetries) > throw kException("Retry limit exceeded: " + e.what()); > else > continue; > } > catch (const odb::exception& e) > { > throw kException("ODB critical exception: " + e.what()); > } > } > > return id; > } From davejohansen at gmail.com Mon Dec 25 13:35:16 2017 From: davejohansen at gmail.com (Dave Johansen) Date: Mon Dec 25 13:35:38 2017 Subject: [odb-users] Update to MySQL Message-ID: Apparently, MySQL is being updated and libodb-mysql needs to be updated as well: https://bugzilla.redhat.com/show_bug.cgi?id=1494097 From boris at codesynthesis.com Wed Dec 27 08:25:22 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Dec 27 08:25:35 2017 Subject: [odb-users] Update to MySQL In-Reply-To: References: Message-ID: Dave Johansen writes: > Apparently, MySQL is being updated and libodb-mysql needs to be updated as > well: https://bugzilla.redhat.com/show_bug.cgi?id=1494097 Thanks for the heads up. I've added a comment to the bug report (in short, the needed updates are already in master). Boris