From boris at codesynthesis.com Mon Mar 2 08:19:53 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 2 08:30:24 2015 Subject: [odb-users] odb::result does not contain members "const_iterator" and "end () const". In-Reply-To: References: <57104e618f4c282fda0f9f214e502ca3.squirrel@webmail.xs4all.nl> Message-ID: Hi Jeroen, Jeroen N. Witmond [Bahco] writes: > inline std::ostream& operator<<(std::ostream& out, const result& val) > { > for (result::const_iterator i (val.begin ()); i != val.end (); ++i) > out << *i << std::endl; > return out; > } As I explained in my previous email, iterating changes query result. Therefore it doesn't make sense to try to iterate over const result. Boris From bbourke-martin at darkfield.com Tue Mar 3 08:30:48 2015 From: bbourke-martin at darkfield.com (Bourke-Martin, Brian) Date: Tue Mar 3 08:30:56 2015 Subject: [odb-users] ODB and QAbstractItemModel Message-ID: Hello all, I am currently using ODB for a project and I have also been looking to display some of the data objects in a Qt table. Qt has a data model system by which you inherit from QAbstractItemModel but in the process you need to use "Qt"-ify the code using the CMake function QT4_WRAP_CPP. Before I just down the rabbit hole attempting to run the odb and Qt function on the same code, I just was wondering if anyone else had attempted to do this. Thanks! Brian -- Brian Bourke-Martin Manager of Operations and Software Dark Field Technologies 70 Robinson Boulevard Orange, CT. 06477 www.darkfield.com 203.298.0731 ext. 212 From christian at gsvitec.com Wed Mar 4 05:09:58 2015 From: christian at gsvitec.com (Christian Sell) Date: Wed Mar 4 05:09:59 2015 Subject: [odb-users] wrong Qt include path Message-ID: <002201d05663$5f0ad1c0$1d207540$@gsvitec.com> Hello, Just started to integrate the Qt profile into my app to make use of the datetime mappings, and promptly stumbled across the error below. The Qt documentation says that "#include " is the correct path, which also works in QtCreator. However, ODB seems to work with different assumptions. What gives? In file included from :1:0: C:/local/libodb-qt-2.3.1/odb/qt/date-time/sqlite/default-mapping.hxx:8:24: fatal error: QtCore/QDate: No such file or directory Thanks Christian From christian at gsvitec.com Wed Mar 4 05:38:44 2015 From: christian at gsvitec.com (Christian Sell) Date: Wed Mar 4 05:38:43 2015 Subject: AW: [odb-users] wrong Qt include path In-Reply-To: <002201d05663$5f0ad1c0$1d207540$@gsvitec.com> References: <002201d05663$5f0ad1c0$1d207540$@gsvitec.com> Message-ID: <002f01d05667$63742280$2a5c6780$@gsvitec.com> Never mind. Had to add ${Qt5Core_INCLUDE_DIRS} to the INCLUDE option of the odb_compile CMake command, and all was well. I did not realize that this variable holds all paths, including the root Qt include path, so that "" and "" both work. -----Urspr?ngliche Nachricht----- Von: odb-users-bounces@codesynthesis.com [mailto:odb-users-bounces@codesynthesis.com] Im Auftrag von Christian Sell Gesendet: Mittwoch, 4. M?rz 2015 11:10 An: 'ODB Users Mailing List' Betreff: [odb-users] wrong Qt include path Hello, Just started to integrate the Qt profile into my app to make use of the datetime mappings, and promptly stumbled across the error below. The Qt documentation says that "#include " is the correct path, which also works in QtCreator. However, ODB seems to work with different assumptions. What gives? In file included from :1:0: C:/local/libodb-qt-2.3.1/odb/qt/date-time/sqlite/default-mapping.hxx:8:24: fatal error: QtCore/QDate: No such file or directory Thanks Christian From finjulhich at gmail.com Wed Mar 4 15:02:11 2015 From: finjulhich at gmail.com (MM) Date: Wed Mar 4 15:02:18 2015 Subject: [odb-users] column order in sqlite table Message-ID: Hi, I have tables that have been generated by odb in sqlite3. Am I able to create a new table with a different order of the same columns to replace my existing table and C++ code would still be ok with that? Rds, From boris at codesynthesis.com Thu Mar 5 05:58:11 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 5 06:08:41 2015 Subject: [odb-users] column order in sqlite table In-Reply-To: References: Message-ID: Hi, MM writes: > I have tables that have been generated by odb in sqlite3. Am I able > to create a new table with a different order of the same columns > to replace my existing table and C++ code would still be ok with > that? ODB doesn't rely on the order of columns in the tables. As long as you haven't defined native views that use something like "SELECT *", you will be fine. Boris From boris at codesynthesis.com Thu Mar 5 06:38:06 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 5 06:48:37 2015 Subject: [odb-users] ODB and QAbstractItemModel In-Reply-To: References: Message-ID: Hi Brian, Bourke-Martin, Brian writes: > I am currently using ODB for a project and I have also been looking to > display some of the data objects in a Qt table. Qt has a data model system > by which you inherit from QAbstractItemModel but in the process you need to > use "Qt"-ify the code using the CMake function QT4_WRAP_CPP. Before I just > down the rabbit hole attempting to run the odb and Qt function on the same > code, I just was wondering if anyone else had attempted to do this. I am not familiar with QAbstractItemModel or QT4_WRAP_CPP bit seeing that nobody more knowledgable is pitching in, my suggestion is this: Keep your object model (that is, the persistent classes) as simple and any framework-free as possible. I would just keep them pure C++11 but in Qt that may prove difficult to interact with the rest of the framework, so maybe I would use the fundamental types from QtCore (e.g., QString, QSharedPointer, etc) but that's it. Boris From nicholas.cremonesi at gmail.com Mon Mar 9 05:51:26 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Mon Mar 9 05:51:34 2015 Subject: [odb-users] Declaring db connection in reading query Message-ID: Hello everyone, I'm trying to execute queries on an already populated database. If I declare the db connection like this "auto_ptr db (create_database (argc, argv));" I notice that, executing the query, the target table is cleared. How can I declare the connection properly? From boris at codesynthesis.com Mon Mar 9 07:21:58 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 9 07:32:29 2015 Subject: [odb-users] Declaring db connection in reading query In-Reply-To: References: Message-ID: Hi Nicholas, Nicholas Cremonesi writes: > I'm trying to execute queries on an already populated database. If I > declare the db connection like this "auto_ptr db (create_database > (argc, argv));" I notice that, executing the query, the target table is > cleared. You copied the create_database() function from one of the examples. If you looked into its implementation, you would have seen that, for SQLite, it re-creates the database schema. This is the desired behavior for examples (we want them to start from the clean slate every time) but not necessarily for your application. Boris From nicholas.cremonesi at gmail.com Mon Mar 9 07:35:33 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Mon Mar 9 07:35:40 2015 Subject: [odb-users] Declaring db connection in reading query In-Reply-To: References: Message-ID: Thank you for your reply, I thinked it was so.. so, in my case, how can I connect to the db whithout the create_database() function? 2015-03-09 12:21 GMT+01:00 Boris Kolpackov : > Hi Nicholas, > > Nicholas Cremonesi writes: > > > I'm trying to execute queries on an already populated database. If I > > declare the db connection like this "auto_ptr db > (create_database > > (argc, argv));" I notice that, executing the query, the target table is > > cleared. > > You copied the create_database() function from one of the examples. > If you looked into its implementation, you would have seen that, > for SQLite, it re-creates the database schema. This is the desired > behavior for examples (we want them to start from the clean slate > every time) but not necessarily for your application. > > Boris > From boris at codesynthesis.com Mon Mar 9 07:28:42 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 9 07:39:12 2015 Subject: [odb-users] Declaring db connection in reading query In-Reply-To: References: Message-ID: Hi Nicholas, Nicholas Cremonesi writes: > so, in my case, how can I connect to the db whithout the create_database() > function? By reading the documentation. Specifically, Section 8.2, "SQLite Database Class". Boris From nicholas.cremonesi at gmail.com Tue Mar 10 06:11:54 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Tue Mar 10 06:12:03 2015 Subject: [odb-users] (no subject) Message-ID: A little question, do I have to define relationships between tables in .hxx files to make joined queries between classes, or there is another simple method? From nicholas.cremonesi at gmail.com Tue Mar 10 06:38:18 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Tue Mar 10 06:38:27 2015 Subject: [odb-users] Joined queries Message-ID: A little question, do I have to define relationships between tables in .hxx files to make joined queries between classes, or there is another simple method? From nicholas.cremonesi at gmail.com Tue Mar 10 08:01:48 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Tue Mar 10 08:03:54 2015 Subject: [odb-users] Re: Joined queries In-Reply-To: References: Message-ID: I supposed to use views. But my question is: can I define a view directly in my main.cxx when I need them, or I have to all possible views before hxx compilation? 2015-03-10 11:38 GMT+01:00 Nicholas Cremonesi : > A little question, > > do I have to define relationships between tables in .hxx files to make > joined queries between classes, or there is another simple method? > From boris at codesynthesis.com Tue Mar 10 08:01:01 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Mar 10 08:11:40 2015 Subject: [odb-users] Re: Joined queries In-Reply-To: References: Message-ID: Hi Nicholas, Nicholas Cremonesi writes: > I supposed to use views. Yes, views are probably what you need. > But my question is: can I define a view directly in my main.cxx when > I need them, or I have to all possible views before hxx compilation? A view has to be compiled by the ODB compiler so it has to be defined in the header. But, if you have multiple queries that have the same result (i.e., number, type, and order of columns), then you can reuse a single view and specify the actual query at runtime. See Section 10.6, "Native Views" for details. Boris From nicholas.cremonesi at gmail.com Tue Mar 10 09:19:29 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Tue Mar 10 11:52:10 2015 Subject: [odb-users] Re: Joined queries In-Reply-To: References: Message-ID: Hello Boris, thanks for reply, I'll explain you my situation, so maybe you can help me choose the best practice to follow. My database consists of over a hundred tables and I cannot know before compilation all possible 'join' queries I'll need. How do you advise me to proceed? 2015-03-10 13:01 GMT+01:00 Boris Kolpackov : > Hi Nicholas, > > Nicholas Cremonesi writes: > > > I supposed to use views. > > Yes, views are probably what you need. > > > > But my question is: can I define a view directly in my main.cxx when > > I need them, or I have to all possible views before hxx compilation? > > A view has to be compiled by the ODB compiler so it has to be defined > in the header. But, if you have multiple queries that have the same > result (i.e., number, type, and order of columns), then you can reuse > a single view and specify the actual query at runtime. See Section > 10.6, "Native Views" for details. > > Boris > From boris at codesynthesis.com Tue Mar 10 11:48:36 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Mar 10 11:59:05 2015 Subject: [odb-users] Re: Joined queries In-Reply-To: References: Message-ID: Hi Nicholas, Nicholas Cremonesi writes: > My database consists of over a hundred tables and I cannot know before > compilation all possible 'join' queries I'll need. How do you advise me > to proceed? Can you know before compilation all possible "result sets" (i.e., number, type, and order of columns) that you will need? If the answer is "yes", then you can use native views with complete queries specified at runtime as text. Not going to be pretty or convenient, but possible. If the answer if "no", then you should probably use something other than ODB. Generally, ODB, is best suited for situations where you know before runtime what you are going to do. Then the ODB compiler can "implement" a lot of it for you. Boris From nicholas.cremonesi at gmail.com Thu Mar 12 04:58:20 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Thu Mar 12 10:09:31 2015 Subject: [odb-users] About references Message-ID: Hello, I finally maked relationships to work for my joined queries. Now my question is: if I have three tables called A, B and C, where A references to B, and B to C, is there any way to access C data directly from A, passing through B? From nicholas.cremonesi at gmail.com Thu Mar 12 09:01:43 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Thu Mar 12 10:09:31 2015 Subject: [odb-users] Nested pointers in relationship Message-ID: I founded an old request like mine: "Hi, I have a problem using ODB in a particular situation: I have this sort of code: *class A* *{* *std::string valuea;* *}* *class B* *{* *std::string valueb* *shared_ptr obja;* *}* *class C* *{* *shared_ptr objb;* *}* All these objects are build using odb without any problems. But my final source file fail with such type of code: *odb::query qry(odb::query::objb->obja->valuea == "Test");* It declares an error saying that "odb::query::objb->obja" is not a pointer type. Does ODB support multiple nesting like this? (tables creation goes correctly and the whole architecture seems ok) Is there an error in my syntax? Here is the exact error. *..*/../*../../build/gen/odb/classes/OTCaracteristiqueCharge-query.cpp:9:63: error: base operand of ?->? has non-pointer type ?const Support_*type*_ {aka const odb::mysql::query_column}?* * q_OTCaracteristiqueCharge::Identifiant->Support->Reference == "ABCD"* *q_OTCaracteristiqueCharge *is a typedef to odb::query The complete architecture is the same as described as example. -- Deldycke Quentin" From boris at codesynthesis.com Thu Mar 12 10:16:18 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 12 10:26:47 2015 Subject: [odb-users] About references In-Reply-To: References: Message-ID: Hi Nicholas, Nicholas Cremonesi writes: > Now my question is: if I have three tables called A, B and C, where A > references to B, and B to C, is there any way to access C data directly > from A, passing through B? Yes, with ODB views. Boris From boris at codesynthesis.com Thu Mar 12 10:19:33 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 12 10:30:02 2015 Subject: [odb-users] Nested pointers in relationship In-Reply-To: References: Message-ID: Hi Nicholas, Nicholas Cremonesi writes: > odb::query qry(odb::query::objb->obja->valuea == "Test"); In object queries ODB only supports one level of relationships for performance reasons. If you need to go further, as in the example above, then you will need to use a view. In 2.4.0 we have added Object Loading Views with the main use-case being exactly this. See the manual for details. Boris From alexandre.pretyman at gmail.com Fri Mar 13 00:35:01 2015 From: alexandre.pretyman at gmail.com (Alexandre Pretyman) Date: Fri Mar 13 00:35:40 2015 Subject: [odb-users] Curiously recurring template and odb Message-ID: Hello Boris! I have a little simple dynamically configurable state machine framework, which would be nice to persist in odb. However in my transitions, to avoid boiler plate code, I resorted to the curiously recurring template pattern (CRTP) and I don't seem to find a solution for persisting this template code in the manual or in the mailing list. My states have a list of associated transitions, of base type: #pragma db object polymorphic struct abstract_transition { virtual ~abstract_transition() {} virtual bool triggered(event const & e) const = 0; #pragma db id auto long long id; state * source; state * destination = {nullptr}; }; Since my events (unfortunately) inherit from base class event, I test their type to see if it what is expected by the transition, casting them to their derived type, and use the CRTP to cast the transition to its derived type, calling a method with the derived event. yielding the following code: template < typename TransitionType, typename EventType > struct transition : abstract_transition { bool triggered(event const & ev) const { if (typeid(ev) == typeid(EventType)) { return static_cast(this)-> trigger_on(dynamic_cast(ev)); } else { return false; } } }; So if I have a struct switch_event : event { bool on; }; as my event of turning the switch of a lamp on or off, and would like to create a transition to enter the light on state of my state machine, I would define a switch_on_transition as: struct switch_on_transition : transition { bool trigger_on(switch_event const & ev) const { return ev.on == true; } }; #pragma db object (switch_on_transition) However compiling through odb compiler gives me: error: no data member designated as an object id Is there a solution for this? Or am I miss-using odb? Best regards, -- Alexandre Pretyman From axel50397 at gmail.com Fri Mar 13 05:36:22 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Fri Mar 13 05:45:44 2015 Subject: [odb-users] Homebrew package 2.4.0 Message-ID: Hi there! I saw that some of you were interested in the homebrew packages, here are the updates for 2.4.0. I?ve updated: libcutl (to 1.9) odb (2.4.0) libodb (2.4.0) libodb-sqlite (2.4.0) libodb-qt (2.4.0) Basically, there was nothing to change except removing some patches. I will submit them to homebrew to make all of it easier. While waiting, here are the new files (they will overwrite the previous) (/usr/local/Library/Formula), personally I make a symlink there. I will keep you updated about the homebrew process. -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). -------------- next part -------------- A non-text attachment was scrubbed... Name: libcutl.rb Type: application/octet-stream Size: 711 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20150313/51ca1036/libcutl.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: libodb-qt.rb Type: application/octet-stream Size: 2068 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20150313/51ca1036/libodb-qt.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: libodb-sqlite.rb Type: application/octet-stream Size: 1337 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20150313/51ca1036/libodb-sqlite.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: libodb.rb Type: application/octet-stream Size: 1183 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20150313/51ca1036/libodb.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: odb.rb Type: application/octet-stream Size: 1874 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20150313/51ca1036/odb.obj From axel50397 at gmail.com Fri Mar 13 05:46:31 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Fri Mar 13 05:59:29 2015 Subject: [odb-users] Querying entity's container Message-ID: I need to find an entity based of one of it?s container?s data. Let me explain, I?m on a CashRegister app. I have the Product entity, which contains a Containers of String (QSet, unique in the table) to store the barcodes. I have an Offer entity, which stores a Product and a Price. I need to be able to find an Offer, using a barcode. So basically, except if it?s easily possible, I think I need to find a Product based on a barcode but I don?t see how to build the ?odb::query? to find the Product which contains ?barcode? in its container. Is there a way, or do I need a workaround? Or suggestions? Thanks -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From mne at qosmotec.com Fri Mar 13 06:13:53 2015 From: mne at qosmotec.com (Marcel Nehring) Date: Fri Mar 13 06:15:05 2015 Subject: AW: [odb-users] Curiously recurring template and odb In-Reply-To: References: Message-ID: Hi Alexandre, ODB does not support persisting of template classes at the moment. However, there exists a workaround by making persistent objects out of class templates instantiations. For more information on how it works (and the limitations) you can read these topics: http://codesynthesis.com/pipermail/odb-users/2014-July/001987.html http://codesynthesis.com/pipermail/odb-users/2014-August/001994.html Regards, Marcel From nicholas.cremonesi at gmail.com Thu Mar 12 10:50:01 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Fri Mar 13 09:08:20 2015 Subject: [odb-users] Nested pointers in relationship In-Reply-To: References: Message-ID: Thanks for your reply! My issue is that I cannot perform ALL possible views before compiling the headers. So, is this the only way, or is there any "workaround"? Another question: is there any way to perform a query like this? "SELECT * FROM TBL_A T1, TBL_A T2, TBL_B T3 ecc...", that is give different "aliases" to the same table? Many thanks 2015-03-12 15:19 GMT+01:00 Boris Kolpackov : > Hi Nicholas, > > Nicholas Cremonesi writes: > > > odb::query qry(odb::query::objb->obja->valuea == "Test"); > > In object queries ODB only supports one level of relationships > for performance reasons. If you need to go further, as in the > example above, then you will need to use a view. In 2.4.0 we > have added Object Loading Views with the main use-case being > exactly this. See the manual for details. > > Boris > From boris at codesynthesis.com Fri Mar 13 09:13:04 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Mar 13 09:23:33 2015 Subject: [odb-users] Curiously recurring template and odb In-Reply-To: References: Message-ID: Hi Alexandre, Alexandre Pretyman writes: > Since my events (unfortunately) inherit from base class event, I test their > type to see if it what is expected by the transition, casting them to their > derived type, and use the CRTP to cast the transition to its derived type, > calling a method with the derived event. Ok, you lost me here. In any case, check Section 15.2, "Persistent Class Template Instantiations" in the ODB manual. Essentially, you cannot store C++ class templates in the database but you can class templates instantiations. Once the dust settles after all your CRTP exploits, you have a set of template instantiations. So all you have to do is map all of them with ODB pragmas to persistent classes. Admittedly, CRTP may make untangling all this challenging, but it is definitely should be possible. Boris From boris at codesynthesis.com Fri Mar 13 09:18:13 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Mar 13 09:28:43 2015 Subject: [odb-users] Nested pointers in relationship In-Reply-To: References: Message-ID: Hi Nicholas, Nicholas Cremonesi writes: > My issue is that I cannot perform ALL possible views before compiling the > headers. So, is this the only way, or is there any "workaround"? I unswered this question already: http://codesynthesis.com/pipermail/odb-users/2015-March/002436.html And, no, there is no other workaround. > Another question: is there any way to perform a query like this? > "SELECT * FROM TBL_A T1, TBL_A T2, TBL_B T3 ecc...", that is give > different "aliases" to the same table? Yes, again, you can do this with native views and runtime queries as long as you know what to expect for '*'. Please read the part of the manual on native views before asking any more questions. I am tired of answering like a parrot "yes, this is possible with a native view". Boris From boris at codesynthesis.com Fri Mar 13 10:55:47 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Mar 13 11:06:17 2015 Subject: [odb-users] Querying entity's container In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > I need to find an entity based of one of it?s container?s data. > > I have the Product entity, which contains a Containers of String > (QSet, unique in the table) to store the barcodes. Support for containers in queries is the next major feature on the TODO list. In the meantime: If we are talking about containers of object pointers (not your case, I know), then a fairly straightforward workaround is to use an object loading view (Section 10.2, "Object Loading Views" in the ODB manual has an example of this specifically). If it is a container of values (like your case), then things are a bit harder and we have to resort to a fairly hackish workaround. In a nutshell, the idea is to define a class that is an "image" of the container table and then JOIN it into an object loading view, just like in the above case. Here is an example. Say we have this product class: #pragma db object struct product { public: #pragma db id auto unsigned long id_; std::set barcodes_; }; If we generate the database schema for it, the container table will look like this (using SQLite): CREATE TABLE "product_barcodes" ( "object_id" INTEGER NOT NULL, "value" TEXT NOT NULL, CONSTRAINT ...); Next we create a special "image" object that matches this table: #pragma db object table("product_barcodes") no_id abstract struct product_barcode { person* object_id; std::string value; }; A couple of things to note about this object: 1. It uses the same table name as the container table (product_barcodes). In a way, we are overlaying this object on the container table. 2. object_id and value member names are not arbitrary, they should match the table columns (or you can use db column() pragma to assign them explicitly). Once this is done, we create an object loading view that JOIN's product and its container: #pragma db view object(product) object(product_barcode = barcode) \ query(distinct) struct product_view { std::chared_ptr p; }; Now we can use this view to load a product that matches a barcode: typedef odb::query query; db.query (query::barcode::value == "123456"); Boris From alexandre.pretyman at gmail.com Fri Mar 13 12:45:22 2015 From: alexandre.pretyman at gmail.com (Alexandre Pretyman) Date: Fri Mar 13 12:46:00 2015 Subject: [odb-users] Curiously recurring template and odb In-Reply-To: References: Message-ID: I am very sorry for the bad explanation - it was late at night, and I did not revise before sending. Thank you for your feedback. The aim of the CRTP was to write shorter code. The code generation I required was so simple I substituted the CRTP for pre-processor macros. And odb seems to have accepted the code so far. So the solution for the simple example of having a transition to take a lamp to the light on state, given a switch on event, I ended up inheriting directly from my polymorphic base class, skipping the CRTP: struct switch_on_transition : abstract_transition { TRIGGER_ON(switch_event) bool trigger_on(switch_event const & ev) const { return ev.on == true; } }; #pragma db object (switch_on_transition) What was to be generated by CRTP is now a #define directive: #define TRIGGER_ON(EventType) bool triggered(::statemachine::event const & ev) const { \ if (typeid(ev) == typeid(EventType)) { \ return trigger_on(dynamic_cast(ev)); \ } \ else { \ return false; \ } \ } I hope this can be useful for others in the future. Kind regards, On 13 March 2015 at 09:13, Boris Kolpackov wrote: > Hi Alexandre, > > Alexandre Pretyman writes: > > > Since my events (unfortunately) inherit from base class event, I test > their > > type to see if it what is expected by the transition, casting them to > their > > derived type, and use the CRTP to cast the transition to its derived > type, > > calling a method with the derived event. > > Ok, you lost me here. > > In any case, check Section 15.2, "Persistent Class Template > Instantiations" in the ODB manual. > > Essentially, you cannot store C++ class templates in the database but > you can class templates instantiations. Once the dust settles after > all your CRTP exploits, you have a set of template instantiations. So > all you have to do is map all of them with ODB pragmas to persistent > classes. Admittedly, CRTP may make untangling all this challenging, > but it is definitely should be possible. > > Boris > -- Alexandre Pretyman From alexandre.pretyman at gmail.com Sun Mar 15 10:47:20 2015 From: alexandre.pretyman at gmail.com (Alexandre Pretyman) Date: Sun Mar 15 10:47:59 2015 Subject: [odb-users] Composite pattern (not composite value) with extra pointer to a child Message-ID: Hello list, This is just a heads up from a current experience with persisting the composite pattern with ODB, where the child has a pointer to the parent and the parent has also a pointer to a "chosen child". I present the problem I ran into and what I did to work around it at the end. I would populate the object and when I tried to persist it, I was getting a Foreign Key constraint violation. Here are the class definitions for this scenario: #pragma db object polymorphic struct simple_object { virtual ~simple_object() {} #pragma db id auto unsigned long id = {0}; simple_object * parent; std::string name; }; #pragma db object struct composite_object : simple_object { simple_object * chosen_child; #pragma db not_null inverse(parent) std::vector> children; simple_object * add_child() { std::unique_ptr child(new simple_object); child->parent = this; simple_object * ptr_to_return = child.get(); children.push_back(std::move(child)); return ptr_to_return; } }; I would populate the objects and then try to persist them after being populated with ODB: { odb::session s; odb::transaction t (db->begin ()); composite_object comp_obj; comp_obj.name = "I am the parent"; auto child = comp_obj.add_child(); child->name = "I am the child"; comp_obj.chosen_child = child; db->persist(comp_obj); db->persist(child); t.commit (); } However this gives me a Foreign Key constraint on sqlite: sqlite3_trace - INSERT INTO "simple_object" ("id", "typeid", "parent", "name") VALUES (NULL, 'composite_object', NULL, 'I am the parent') sqlite3_trace - INSERT INTO "composite_object" ("id", "chosen_child") VALUES (1, 0) sqlite3_trace - INSERT INTO "simple_object" ("id", "typeid", "parent", "name") VALUES (NULL, 'simple_object', 1, 'I am the child') sqlite3_trace - COMMIT Exception: 19 (787): FOREIGN KEY constraint failed Because as the parent object was being persisted, it tried to persist the child which had an invalid id, with INSERT INTO "composite_object" ("id", "chosen_child") VALUES (1, 0) where 0 should have been a valid foreign key. Trying to persist the child before the parent also resulted also with a foreign key violation, because it tried to refer to a parent which had an invalid id, as the parent had not been persisted yet. The solution was to persist the objects before they were wired together and update the parent at the end to reflect the changes: { odb::session s; odb::transaction t (db->begin ()); composite_object comp_obj; db->persist(comp_obj); comp_obj.name = "I am the parent"; auto child = comp_obj.add_child(); child->name = "I am the child"; comp_obj.chosen_child = child; db->persist(child); db->update(comp_obj); t.commit (); } Where this resulted in a successful commit: sqlite3_trace - INSERT INTO "simple_object" ("id", "typeid", "parent", "name") VALUES (NULL, 'composite_object', NULL, '') sqlite3_trace - INSERT INTO "composite_object" ("id", "chosen_child") VALUES (1, NULL) sqlite3_trace - INSERT INTO "simple_object" ("id", "typeid", "parent", "name") VALUES (NULL, 'simple_object', 1, 'I am the child') sqlite3_trace - UPDATE "simple_object" SET "parent"=NULL, "name"='I am the parent' WHERE "id"=1 sqlite3_trace - UPDATE "composite_object" SET "chosen_child"=2 WHERE "id"=1 sqlite3_trace - COMMIT So it seems that for this scenario odb must be part of wiring of the object pointers. Regards, -- Alexandre Pretyman From axel50397 at gmail.com Sun Mar 15 11:05:55 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Sun Mar 15 11:06:20 2015 Subject: [odb-users] Simple libodb-sqlite test Message-ID: Hi there, Still on ODB homebrew packages, I?m making simple tests, but I?m not able to compile any of the ?odb-example?s, plus I?m not even able to compile the simplest test I?ve made for libodb-sqlite: > #include > #include > #include > #include > #include > > int main (int argc, char* argv[]) > { > std::auto_ptr db(new odb::sqlite::database( > std::string("test.sqlite"), SQLITE_OPEN_READWRITE > )); > > return 0; > } Here is how I compile it: > clang++ test.cpp -lodb-sqlite -lodb Here is the error: > Undefined symbols for architecture x86_64: > "odb::sqlite::database::database(std::__1::basic_string, std::__1::allocator > const&, int, bool, std::__1::basic_string, std::__1::allocator > const&, odb::details::transfer_ptr)", referenced from: > _main in test-0f6c5b.o > ld: symbol(s) not found for architecture x86_64 I?ve also tried to compile the cpp file THEN link it, I?ve also tried to add ?-L? and ?-I?, the error is still the same. I don?t get it, because I?m on my cash register app since few month and it uses libodb-sqlite, it correctly compiled (using clang, libs compiled with clang). Any idea? Thank you ! -- Cordialement, Adnan RIHAN. GPG : 5675-62BA (https://keybase.io/max13/key.asc ) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr? : (https://encrypt.to/0x567562BA ). From boris at codesynthesis.com Mon Mar 16 09:23:55 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 16 09:34:25 2015 Subject: [odb-users] Composite pattern (not composite value) with extra pointer to a child In-Reply-To: References: Message-ID: Hi Alexandre, Alexandre Pretyman writes: > So it seems that for this scenario odb must be part of wiring of > the object pointers. Quoting from Chapter 6, "Relationships": "When persisting or updating an object containing a pointer to another object, the pointed-to object must have a valid object id. This, however, may not always be easy to achieve in complex relationships that involve objects with automatically assigned identifiers. In such cases it may be necessary to first persist an object with a pointer set to NULL and then, once the pointed-to object is made persistent and its identifier assigned, set the pointer to the correct value and update the object in the database." Boris From boris at codesynthesis.com Mon Mar 16 09:27:25 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 16 09:37:54 2015 Subject: [odb-users] Simple libodb-sqlite test In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > I don?t get it [...] See if this helps: http://codesynthesis.com/products/odb/doc/install-macosx.xhtml Particularly, the "Installing the Runtime Libraries" section. Boris From axel50397 at gmail.com Mon Mar 16 12:41:55 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Mon Mar 16 12:47:35 2015 Subject: [odb-users] Simple libodb-sqlite test In-Reply-To: References: Message-ID: You?re right, thanks T_T I?ve solved that few hours ago, when using std::string, I need to add ?-lstdc++?. So I?ve removed that from my tests and I now only test exceptions. On 16 mars 2015 at 14:37:53, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > Hi Adnan, > > Adnan RIHAN writes: > > > I don?t get it [...] > > See if this helps: > > http://codesynthesis.com/products/odb/doc/install-macosx.xhtml > > Particularly, the "Installing the Runtime Libraries" section. > > Boris -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From alexandre.pretyman at gmail.com Mon Mar 16 23:04:07 2015 From: alexandre.pretyman at gmail.com (Alexandre Pretyman) Date: Mon Mar 16 23:04:45 2015 Subject: [odb-users] Composite pattern (not composite value) with extra pointer to a child In-Reply-To: References: Message-ID: Thank you Boris and sorry about the noise. On 16 March 2015 at 09:23, Boris Kolpackov wrote: > Hi Alexandre, > > Alexandre Pretyman writes: > > > So it seems that for this scenario odb must be part of wiring of > > the object pointers. > > Quoting from Chapter 6, "Relationships": > > "When persisting or updating an object containing a pointer to another > object, > the pointed-to object must have a valid object id. This, however, may not > always be easy to achieve in complex relationships that involve objects > with > automatically assigned identifiers. In such cases it may be necessary to > first persist an object with a pointer set to NULL and then, once the > pointed-to object is made persistent and its identifier assigned, set the > pointer to the correct value and update the object in the database." > > Boris > -- Alexandre Pretyman From nicholas.cremonesi at gmail.com Tue Mar 17 05:01:21 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Tue Mar 17 06:26:14 2015 Subject: [odb-users] Multiple PKs Message-ID: I have a very important question: is it possible to define multiple primary keys in a table with ODB? From tiankongcc1991 at qq.com Tue Mar 17 11:29:18 2015 From: tiankongcc1991 at qq.com (=?gb18030?B?zOy/1c2s0ac=?=) Date: Tue Mar 17 11:29:29 2015 Subject: [odb-users] Re:odb-users Digest, Vol 55, Issue 11 In-Reply-To: <201503161600.t2GG0pAa010546@codesynthesis.com> References: <201503161600.t2GG0pAa010546@codesynthesis.com> Message-ID: hi, I got a problem: I defined a class Employee with a member boost::shared_ptr , then the odb tell me a error in generate the xx-odb.hxx file: "unable to map c++ type ::boost::shared_ptr ...", so who can tell me why? Thank you? ------------------ Original ------------------ From: "odb-users-request"; Date: 2015?3?17?(???) ??0:00 To: "odb-users"; Subject: odb-users Digest, Vol 55, Issue 11 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: Composite pattern (not composite value) with extra pointer to a child (Boris Kolpackov) 2. Re: Simple libodb-sqlite test (Boris Kolpackov) ---------------------------------------------------------------------- Message: 1 Date: Mon, 16 Mar 2015 15:23:55 +0200 From: Boris Kolpackov Subject: Re: [odb-users] Composite pattern (not composite value) with extra pointer to a child To: Alexandre Pretyman Cc: odb-users@codesynthesis.com Message-ID: Content-Type: text/plain; charset=us-ascii Hi Alexandre, Alexandre Pretyman writes: > So it seems that for this scenario odb must be part of wiring of > the object pointers. Quoting from Chapter 6, "Relationships": "When persisting or updating an object containing a pointer to another object, the pointed-to object must have a valid object id. This, however, may not always be easy to achieve in complex relationships that involve objects with automatically assigned identifiers. In such cases it may be necessary to first persist an object with a pointer set to NULL and then, once the pointed-to object is made persistent and its identifier assigned, set the pointer to the correct value and update the object in the database." Boris ------------------------------ Message: 2 Date: Mon, 16 Mar 2015 15:27:25 +0200 From: Boris Kolpackov Subject: Re: [odb-users] Simple libodb-sqlite test To: Adnan RIHAN Cc: "odb-users@codesynthesis.com" Message-ID: Content-Type: text/plain; charset=utf-8 Hi Adnan, Adnan RIHAN writes: > I don?t get it [...] See if this helps: http://codesynthesis.com/products/odb/doc/install-macosx.xhtml Particularly, the "Installing the Runtime Libraries" section. Boris ------------------------------ _______________________________________________ odb-users mailing list odb-users@codesynthesis.com http://codesynthesis.com/mailman/listinfo/odb-users End of odb-users Digest, Vol 55, Issue 11 ***************************************** From nicholas.cremonesi at gmail.com Tue Mar 17 07:53:33 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Wed Mar 18 05:37:52 2015 Subject: [odb-users] Issue using Object Loading Views Message-ID: Hello, I have an issue using Object Loading Views. This is my piece of code: = BEGIN == int test(auto_ptr db) { typedef odb::query query; typedef odb::result result; { session s; transaction t (db->begin ()); result r (db->query ( (query::T_AREA::AREA == "NNAP") )); for (result::iterator i (r.begin ()); i != r.end (); ++i) { cout << " " << i->tt_area->ANAM() << endl; } t.commit (); } return 0; } == END == When I execute the above code it returns to me only one result, and then I receive this error: "Error in `./main': double free or corruption (fasttop): 0x00000000007b5760" Any idea? Many thanks! From boris at codesynthesis.com Wed Mar 18 08:48:17 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 18 08:58:47 2015 Subject: [odb-users] Multiple PKs In-Reply-To: References: Message-ID: Hi Nicholas, Nicholas Cremonesi writes: > is it possible to define multiple primary keys in a table with ODB? There is by definition can only be one primary key in any table. What you are maybe after is a composite (multi-column) primary key? If so, then the answer is, as always, in the documentation, specifically, Section 7.2.1, "Composite Object Ids". Boris From boris at codesynthesis.com Wed Mar 18 08:55:12 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 18 09:05:42 2015 Subject: [odb-users] Issue using Object Loading Views In-Reply-To: References: Message-ID: Hi Nicholas, Nicholas Cremonesi writes: > I have an issue using Object Loading Views. This is my piece > of code: The transaction looks ok. What is the definition of the view and the object(s) that it is based on? Boris From boris at codesynthesis.com Wed Mar 18 09:12:03 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 18 09:22:34 2015 Subject: [odb-users] Re: shared_ptr as object data member In-Reply-To: References: <201503161600.t2GG0pAa010546@codesynthesis.com> Message-ID: Hi, In the future please don't ask a question by replying to the digest (or by replying to any other unrelated post, for that matter). Instead, start a new thread with a descriptive subject, as discussed in the posting guidelines: http://codesynthesis.com/support/posting-guidelines.xhtml ???? writes: > I defined a class Employee with a member boost::shared_ptr, > then the odb tell me a error in generate the xx-odb.hxx file: > "unable to map c++ type ::boost::shared_ptr ..." There are too many "semantics" that one can prescribe to this construct for ODB to make any specific assumption. For example, when loading the value from the database, and the pointer is not NULL, should we assign to the existing value (and thus modify it for every other shared_ptr that points to it) or should we allocate a new value? You can, however, use the virtual data member feature (Section 14.4.13, "virtual") to implement the logic that you want. For example, below is one way to do it. Here we assume the pointer cannot be NULL when we get the value and we always allocate a new value when we set it. #pragma db object class object { #pragma db transient boost::shared_ptr i_; #pragma db member(i) virtual(int) \ get(*this.i_) \ set(this.i_.reset (new int (?))) }; Boris From axel50397 at gmail.com Wed Mar 18 13:13:48 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Wed Mar 18 13:13:31 2015 Subject: [odb-users] Error using ODB on OS X 10.10.2 Message-ID: Hi there, Apparently, the GCC-ODB-Yosemite-gate isn?t finished yet. I have a strange error with gcc when I start odb: > ? ?homebrew-odb git:(master) ? odb -d sqlite test.cpp > cc1plus(19044,0x7fff74fc7300) malloc: *** error for object 0x142bf2720: pointer being freed was not allocated > *** set a breakpoint in malloc_error_break to debug > *** WARNING *** there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins. > Event ? ? ? ? ? ? ? ? ? ? ? ? ? ?| Plugins > PLUGIN_START_UNIT ? ? ? ? ? ? ? ?| odb > PLUGIN_PRAGMAS ? ? ? ? ? ? ? ? ? | odb > PLUGIN_OVERRIDE_GATE ? ? ? ? ? ? | odb > test.cpp: In function 'int main()': > test.cpp:1:5: internal compiler error: Abort trap: 6 > ?int main(){return 0;} > ? ? ?^ > g++-4.9: internal compiler error: Abort trap: 6 (program cc1plus) Is it known? Boris, I?m back (:evil:) ! -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From finjulhich at gmail.com Wed Mar 18 16:11:06 2015 From: finjulhich at gmail.com (MM) Date: Wed Mar 18 16:11:14 2015 Subject: [odb-users] naming first and second columns of std::pair Message-ID: hello, I have this struct: /// main header file typedef std::pair possizethresh_df_t; typedef std::vector< possizethresh_df_t > dftiers_t; struct S { ... dftiers_t dftiers; ... }; /// odb-specific header file #pragma db object(S) #pragma db value(possizethresh_df_t) Is there a way to give a name to the columns resulting from the 2 doubles in the pair? Rds, From David.Sarrut at creatis.insa-lyon.fr Thu Mar 19 05:55:20 2015 From: David.Sarrut at creatis.insa-lyon.fr (David Sarrut) Date: Thu Mar 19 05:55:48 2015 Subject: [odb-users] How to retrieve schema name ? Message-ID: Hello, when create a db with a schema name, there is an additional table "schema_version" that is created. When reading a database, say from a file with sqlite, is there a way to access this table content and retrieve the value for the name ? thanks, David -- David Sarrut, Phd Directeur de recherche CNRS CREATIS, UMR CNRS 5220, Inserm U 1044 Centre de lutte contre le cancer L?on B?rard 28 rue La?nnec, 69373 Lyon cedex 08 Tel : 04 78 78 51 51 / 06 74 72 05 42 http://www.creatis.insa-lyon.fr/~dsarrut _________________________________ "2 + 2 = 5, for extremely large values of 2" _________________________________ From info at peredin.com Thu Mar 19 06:09:11 2015 From: info at peredin.com (Per Edin) Date: Thu Mar 19 06:09:19 2015 Subject: [odb-users] How to retrieve schema name ? In-Reply-To: References: Message-ID: Hi David! Maybe I have misunderstood your problem, but wouldn't a simple SELECT name FROM schema_version GROUP BY name work? To get all unique schema names in any database. /Per On Thu, Mar 19, 2015 at 10:55 AM, David Sarrut wrote: > Hello, > > when create a db with a schema name, there is an additional table > "schema_version" that is created. When reading a database, say from a file > with sqlite, is there a way to access this table content and retrieve the > value for the name ? > > thanks, > David > > -- > David Sarrut, Phd > Directeur de recherche CNRS > CREATIS, UMR CNRS 5220, Inserm U 1044 > Centre de lutte contre le cancer L?on B?rard > 28 rue La?nnec, 69373 Lyon cedex 08 > Tel : 04 78 78 51 51 / 06 74 72 05 42 > http://www.creatis.insa-lyon.fr/~dsarrut > _________________________________ > "2 + 2 = 5, for extremely large values of 2" > _________________________________ From David.Sarrut at creatis.insa-lyon.fr Thu Mar 19 06:20:12 2015 From: David.Sarrut at creatis.insa-lyon.fr (David Sarrut) Date: Thu Mar 19 06:20:40 2015 Subject: [odb-users] How to retrieve schema name ? In-Reply-To: References: Message-ID: yes Per, sure ! Sorry I was not enough precise: I need to do this query within odb, in C++. I usually use things such as : typedef odb::query query; typedef odb::result result; etc ... but I need to know the type of this schema_version table to do that. Or maybe with native SQL query ? but in this case, it is not clear for me how to get the result. thanks, David On Thu, Mar 19, 2015 at 11:09 AM, Per Edin wrote: > Hi David! > > Maybe I have misunderstood your problem, but wouldn't a simple > > SELECT name FROM schema_version GROUP BY name > > work? To get all unique schema names in any database. > > /Per > > On Thu, Mar 19, 2015 at 10:55 AM, David Sarrut > wrote: > > Hello, > > > > when create a db with a schema name, there is an additional table > > "schema_version" that is created. When reading a database, say from a > file > > with sqlite, is there a way to access this table content and retrieve the > > value for the name ? > > > > thanks, > > David > > > > -- > > David Sarrut, Phd > > Directeur de recherche CNRS > > CREATIS, UMR CNRS 5220, Inserm U 1044 > > Centre de lutte contre le cancer L?on B?rard > > 28 rue La?nnec, 69373 Lyon cedex 08 > > Tel : 04 78 78 51 51 / 06 74 72 05 42 > > http://www.creatis.insa-lyon.fr/~dsarrut > > _________________________________ > > "2 + 2 = 5, for extremely large values of 2" > > _________________________________ > -- David Sarrut, Phd Directeur de recherche CNRS CREATIS, UMR CNRS 5220, Inserm U 1044 Centre de lutte contre le cancer L?on B?rard 28 rue La?nnec, 69373 Lyon cedex 08 Tel : 04 78 78 51 51 / 06 74 72 05 42 http://www.creatis.insa-lyon.fr/~dsarrut _________________________________ "2 + 2 = 5, for extremely large values of 2" _________________________________ From info at peredin.com Thu Mar 19 06:45:56 2015 From: info at peredin.com (Per Edin) Date: Thu Mar 19 06:46:03 2015 Subject: [odb-users] How to retrieve schema name ? In-Reply-To: References: Message-ID: Ah! I see. I'm sure native views can help you with that, untested example from the top of my head: #pragma db view query("SELECT name FROM schema_version GROUP BY name") struct schema_name { std::string name; }; odb::result< schema_name > r(db.query< schema_name >()); Section 10.6 Native Views of the ODB manual should provide more details. :) /Per On Thu, Mar 19, 2015 at 11:20 AM, David Sarrut wrote: > > yes Per, sure ! Sorry I was not enough precise: I need to do this query > within odb, in C++. > > I usually use things such as : > typedef odb::query query; > typedef odb::result result; > etc ... > > but I need to know the type of this schema_version table to do that. Or > maybe with native SQL query ? but in this case, it is not clear for me how > to get the result. > > thanks, > David > > > On Thu, Mar 19, 2015 at 11:09 AM, Per Edin wrote: >> >> Hi David! >> >> Maybe I have misunderstood your problem, but wouldn't a simple >> >> SELECT name FROM schema_version GROUP BY name >> >> work? To get all unique schema names in any database. >> >> /Per >> >> On Thu, Mar 19, 2015 at 10:55 AM, David Sarrut >> wrote: >> > Hello, >> > >> > when create a db with a schema name, there is an additional table >> > "schema_version" that is created. When reading a database, say from a >> > file >> > with sqlite, is there a way to access this table content and retrieve >> > the >> > value for the name ? >> > >> > thanks, >> > David >> > >> > -- >> > David Sarrut, Phd >> > Directeur de recherche CNRS >> > CREATIS, UMR CNRS 5220, Inserm U 1044 >> > Centre de lutte contre le cancer L?on B?rard >> > 28 rue La?nnec, 69373 Lyon cedex 08 >> > Tel : 04 78 78 51 51 / 06 74 72 05 42 >> > http://www.creatis.insa-lyon.fr/~dsarrut >> > _________________________________ >> > "2 + 2 = 5, for extremely large values of 2" >> > _________________________________ > > > > > -- > David Sarrut, Phd > Directeur de recherche CNRS > CREATIS, UMR CNRS 5220, Inserm U 1044 > Centre de lutte contre le cancer L?on B?rard > 28 rue La?nnec, 69373 Lyon cedex 08 > Tel : 04 78 78 51 51 / 06 74 72 05 42 > http://www.creatis.insa-lyon.fr/~dsarrut > _________________________________ > "2 + 2 = 5, for extremely large values of 2" > _________________________________ From David.Sarrut at creatis.insa-lyon.fr Thu Mar 19 07:14:07 2015 From: David.Sarrut at creatis.insa-lyon.fr (David Sarrut) Date: Thu Mar 19 07:14:35 2015 Subject: [odb-users] How to retrieve schema name ? In-Reply-To: References: Message-ID: many thanks Per, I did as suggested, and it works. thanks again David On Thu, Mar 19, 2015 at 11:45 AM, Per Edin wrote: > Ah! I see. I'm sure native views can help you with that, untested > example from the top of my head: > > #pragma db view query("SELECT name FROM schema_version GROUP BY name") > struct schema_name > { > std::string name; > }; > > odb::result< schema_name > r(db.query< schema_name >()); > > Section 10.6 Native Views of the ODB manual should provide more details. :) > > /Per > > > On Thu, Mar 19, 2015 at 11:20 AM, David Sarrut > wrote: > > > > yes Per, sure ! Sorry I was not enough precise: I need to do this query > > within odb, in C++. > > > > I usually use things such as : > > typedef odb::query query; > > typedef odb::result result; > > etc ... > > > > but I need to know the type of this schema_version table to do that. Or > > maybe with native SQL query ? but in this case, it is not clear for me > how > > to get the result. > > > > thanks, > > David > > > > > > On Thu, Mar 19, 2015 at 11:09 AM, Per Edin wrote: > >> > >> Hi David! > >> > >> Maybe I have misunderstood your problem, but wouldn't a simple > >> > >> SELECT name FROM schema_version GROUP BY name > >> > >> work? To get all unique schema names in any database. > >> > >> /Per > >> > >> On Thu, Mar 19, 2015 at 10:55 AM, David Sarrut > >> wrote: > >> > Hello, > >> > > >> > when create a db with a schema name, there is an additional table > >> > "schema_version" that is created. When reading a database, say from a > >> > file > >> > with sqlite, is there a way to access this table content and retrieve > >> > the > >> > value for the name ? > >> > > >> > thanks, > >> > David > >> > > >> > -- > >> > David Sarrut, Phd > >> > Directeur de recherche CNRS > >> > CREATIS, UMR CNRS 5220, Inserm U 1044 > >> > Centre de lutte contre le cancer L?on B?rard > >> > 28 rue La?nnec, 69373 Lyon cedex 08 > >> > Tel : 04 78 78 51 51 / 06 74 72 05 42 > >> > http://www.creatis.insa-lyon.fr/~dsarrut > >> > _________________________________ > >> > "2 + 2 = 5, for extremely large values of 2" > >> > _________________________________ > > > > > > > > > > -- > > David Sarrut, Phd > > Directeur de recherche CNRS > > CREATIS, UMR CNRS 5220, Inserm U 1044 > > Centre de lutte contre le cancer L?on B?rard > > 28 rue La?nnec, 69373 Lyon cedex 08 > > Tel : 04 78 78 51 51 / 06 74 72 05 42 > > http://www.creatis.insa-lyon.fr/~dsarrut > > _________________________________ > > "2 + 2 = 5, for extremely large values of 2" > > _________________________________ > -- David Sarrut, Phd Directeur de recherche CNRS CREATIS, UMR CNRS 5220, Inserm U 1044 Centre de lutte contre le cancer L?on B?rard 28 rue La?nnec, 69373 Lyon cedex 08 Tel : 04 78 78 51 51 / 06 74 72 05 42 http://www.creatis.insa-lyon.fr/~dsarrut _________________________________ "2 + 2 = 5, for extremely large values of 2" _________________________________ From finjulhich at gmail.com Thu Mar 19 08:47:13 2015 From: finjulhich at gmail.com (MM) Date: Thu Mar 19 08:47:20 2015 Subject: [odb-users] Re: naming first and second columns of std::pair In-Reply-To: References: Message-ID: On 18 March 2015 at 20:11, MM wrote: > hello, > > I have this struct: > > /// main header file > typedef std::pair possizethresh_df_t; > typedef std::vector< possizethresh_df_t > dftiers_t; > struct S { > ... > dftiers_t dftiers; > ... > }; > > > /// odb-specific header file > #pragma db object(S) > #pragma db value(possizethresh_df_t) > > Is there a way to give a name to the columns resulting from the 2 doubles > in the pair? > > Rds, > I've got it: #pragma db value(possizethresh_df_t) definition #pragma db member(possizethresh_df_t::first) column("possizeuplmt") #pragma db member(possizethresh_df_t::second) column("depfactor") I thought the "member" was just for object types, not for value types also, Rds, From boris at codesynthesis.com Thu Mar 19 10:11:18 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 19 10:21:49 2015 Subject: [odb-users] How to retrieve schema name ? In-Reply-To: References: Message-ID: Hi David, Yes, Per got it right, the easiest way to get this information is to use a view. Section 13.2, "Schema Migration" has the description of this table: "... By default, when schema evolution is enabled, ODB maintains this information in a special table called schema_version that has the following (or equivalent, depending on the database used) definition:" CREATE TABLE "schema_version" ( "name" TEXT NOT NULL PRIMARY KEY, "version" BIGINT NOT NULL, "migration" BOOLEAN NOT NULL); "The name column is the schema name as specified with the --schema-name option. It is empty for the default schema. The version column contains the current database version. And, finally, the migration flag indicates whether we are in the process of migrating the database, that is, between the pre and post-migration stages." One improvement on Per's suggestion would be to use a table view rather than a native view. A bit less raw SQL: #pragma db view table("schema_version") struct schema_name { #pragma db column("name") std::string name; }; Boris From boris at codesynthesis.com Thu Mar 19 10:14:05 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 19 10:24:35 2015 Subject: [odb-users] Error using ODB on OS X 10.10.2 In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > Apparently, the GCC-ODB-Yosemite-gate isn?t finished yet. Can you try the official ODB binary for Mac OS? If it doesn't have the same problem, then something is messed up with your build. Maybe different runtimes again? Boris From finjulhich at gmail.com Thu Mar 19 10:27:08 2015 From: finjulhich at gmail.com (MM) Date: Thu Mar 19 10:27:16 2015 Subject: [odb-users] 2 virtual members mapping to 1 transient member Message-ID: struct Base; /// c++ abstract and odb abstract struct A : public Base {...}; struct B : public Base {...}; struct C : public Base {...}; struct S : public Base { const Base* linked; /// can be either A B or C }; #pragma db object(S) definition #pragma db member(igindex_dfb::linked) transient #pragma db member(igindex_dfb::linkedtype) virtual(std::string) get() set() #pragma db member(igindex_dfb::linkedid) virtual(std::uint32_t) get() set() 2 columns from the database, linkedtype and linkedid. the linkedtype is either "A" or "B" or "C" the linkedid identifies which instance of A is linked to by S. How can I make it atomic to have 'linked' map to both 'linkedtype' and 'linkedid' at the same time? From boris at codesynthesis.com Thu Mar 19 10:23:17 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 19 10:33:47 2015 Subject: [odb-users] 2 virtual members mapping to 1 transient member In-Reply-To: References: Message-ID: Hi, MM writes: > How can I make it atomic to have 'linked' map to both 'linkedtype' and > 'linkedid' at the same time? Using a composite value? #pragma db value struct linked_type { std::string type; std::uint32_t id; }; #pragma db member(igindex_dfb::linked) virtual(linked_type) get(...) set(...) Boris From nicholas.cremonesi at gmail.com Thu Mar 19 10:48:51 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Fri Mar 20 07:36:11 2015 Subject: [odb-users] PKs and FKs at the same time Message-ID: Hello, I have to define a column (let's call it 'col_B') which is both Primary Key of 'Class_B' and Foreign Key referencing 'Class_A', so I tried to define it this way: #pragma db id shared_ptr col_B_; but compiling with ODB give me a lot of errors. Is this implementation unable to do? From boris at codesynthesis.com Fri Mar 20 07:30:41 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Mar 20 07:42:06 2015 Subject: [odb-users] PKs and FKs at the same time In-Reply-To: References: Message-ID: Hi Nicholas, Nicholas Cremonesi writes: > I have to define a column (let's call it 'col_B') which is both Primary Key > of 'Class_B' and Foreign Key referencing 'Class_A', so I tried to define it > this way: > > #pragma db id > shared_ptr col_B_; > > but compiling with ODB give me a lot of errors. Is this implementation > unable to do? No, ODB does not support using object pointers as object ids. However, you can quite easily emulate this behavior as described in this earlier post: http://www.codesynthesis.com/pipermail/odb-users/2015-January/002335.html Boris From David.Sarrut at creatis.insa-lyon.fr Fri Mar 20 08:47:40 2015 From: David.Sarrut at creatis.insa-lyon.fr (David Sarrut) Date: Fri Mar 20 08:48:08 2015 Subject: [odb-users] How to retrieve schema name ? In-Reply-To: References: Message-ID: even simpler, thanks ! David On Thu, Mar 19, 2015 at 3:11 PM, Boris Kolpackov wrote: > Hi David, > > Yes, Per got it right, the easiest way to get this information is > to use a view. Section 13.2, "Schema Migration" has the description > of this table: > > "... By default, when schema evolution is enabled, ODB maintains this > information in a special table called schema_version that has the > following (or equivalent, depending on the database used) definition:" > > > CREATE TABLE "schema_version" ( > "name" TEXT NOT NULL PRIMARY KEY, > "version" BIGINT NOT NULL, > "migration" BOOLEAN NOT NULL); > > > "The name column is the schema name as specified with the --schema-name > option. It is empty for the default schema. The version column contains > the > current database version. And, finally, the migration flag indicates > whether > we are in the process of migrating the database, that is, between the pre > and > post-migration stages." > > One improvement on Per's suggestion would be to use a table view rather > than a native view. A bit less raw SQL: > > #pragma db view table("schema_version") > struct schema_name > { > #pragma db column("name") > std::string name; > }; > > Boris > -- David Sarrut, Phd Directeur de recherche CNRS CREATIS, UMR CNRS 5220, Inserm U 1044 Centre de lutte contre le cancer L?on B?rard 28 rue La?nnec, 69373 Lyon cedex 08 Tel : 04 78 78 51 51 / 06 74 72 05 42 http://www.creatis.insa-lyon.fr/~dsarrut _________________________________ "2 + 2 = 5, for extremely large values of 2" _________________________________ From axel50397 at gmail.com Fri Mar 20 14:41:58 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Fri Mar 20 14:42:28 2015 Subject: [odb-users] Error using ODB on OS X 10.10.2 In-Reply-To: References: Message-ID: Hi Boris, On 19 mars 2015 at 15:24:34, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > Maybe?different runtimes again? GRRR ! I?ve compiled 34 times this morning with plenty of configuration... And guess what I missed?! Yes runtimes... But not libc++/stdlibc++. I didn?t realized that I was linking with Apple's libstdc++ and not GCC?s libstdc++ ... So much pain, but now it works ! I will send you a mail through the ML to announce the homebrew packages tap address (because it?s so custom that they advised me to do a tap...) Thank you ! -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From nicholas.cremonesi at gmail.com Fri Mar 20 11:31:49 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Mon Mar 23 08:11:59 2015 Subject: [odb-users] PKs and FKs at the same time In-Reply-To: References: Message-ID: Hello Boris, I tried to define the callback as in the example you gave me, but I encountered some troubles. This is my code: ========== class Table_A { private: ... #pragma db id int pk_tblA_; #pragma db transient shared_ptr FK_TableA_TableB_; void init (odb::callback_event e, odb::database& db) { if (e == odb::callback_event::post_load) FK_TableA_TableB_ = db.load (pk_tblA_); } }; ========== And this is the error odb compiler returns to me: >> odb -d sqlite --generate-query --generate-schema --generate-session *.hxx >> cannot convert ?((Table_A*)this)->Table_A::pk_tblA_? (type ?int?) to type ?const odb::access::object_traits::id_type&? FK_TableA_TableB_ = db.load (pk_tblA_); 2015-03-20 13:56 GMT+01:00 Nicholas Cremonesi : > Thanks Boris, > > I'm going to read carefully the documentation about callbacks. > My question is, how can I perform queries once defined the callbacks? > > 2015-03-20 12:30 GMT+01:00 Boris Kolpackov : > >> Hi Nicholas, >> >> Nicholas Cremonesi writes: >> >> > I have to define a column (let's call it 'col_B') which is both Primary >> Key >> > of 'Class_B' and Foreign Key referencing 'Class_A', so I tried to >> define it >> > this way: >> > >> > #pragma db id >> > shared_ptr col_B_; >> > >> > but compiling with ODB give me a lot of errors. Is this implementation >> > unable to do? >> >> No, ODB does not support using object pointers as object ids. However, >> you can quite easily emulate this behavior as described in this earlier >> post: >> >> http://www.codesynthesis.com/pipermail/odb-users/2015-January/002335.html >> >> Boris >> > > From boris at codesynthesis.com Mon Mar 23 08:03:46 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 23 08:15:12 2015 Subject: [odb-users] PKs and FKs at the same time In-Reply-To: References: Message-ID: Hi Nicholas, Nicholas Cremonesi writes: > void init (odb::callback_event e, odb::database& db) > { > if (e == odb::callback_event::post_load) > FK_TableA_TableB_ = db.load (pk_tblA_); > } Move the callback definition to the source file and make sure you include the *-odb header file for Table_B. Boris From axel50397 at gmail.com Mon Mar 23 09:12:20 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Mon Mar 23 09:12:37 2015 Subject: [odb-users] Option -x ignored in profile.options file Message-ID: Hi ! It seems that ?-x? options are ignored in profile .options files. For instance, on my system, Qt?s directory is in: /home/me/Qt/lib So when I install ODB, I need to specify some ?-x? options to make ODB find my Qt?s lib directory. Basically, I need to add these lines to default.options: > -x -F/Users/Max13/Qt/5.4/clang_64/lib > -x -I/Users/Max13/Qt/5.4/clang_64/lib/QtCore.framework/Headers > -x -I/Users/Max13/Qt/5.4/clang_64/lib/QtGui.framework/Headers > -x -I/Users/Max13/Qt/5.4/clang_64/lib/QtWidgets.framework/Headers So I tried to move them from ?default.options? to ?qt.options? where it?s expected to belong. When I start ODB, it complains: > In file included from :1:0: > /usr/local/include/odb/qt/basic/sqlite/default-mapping.hxx:8:26: fatal error: QtCore/QString: No such file or directory > #include > ^ > compilation terminated. I?ve tried to clean the qt.options file to make sure odb reads it, and it fails (so it reads and interprets the file). And of course, ?odb -v ...? doesn?t show the -x options I wanted to pass. Am I right to expect ODB to read qt.options and interpret ?-x? options? -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From boris at codesynthesis.com Mon Mar 23 09:37:47 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Mar 23 09:49:12 2015 Subject: [odb-users] Option -x ignored in profile.options file In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > It seems that ?-x? options are ignored in profile .options files. Correct. -x, -I, etc. are only recognized on the command line and in the default.options file. In your case, default.options is where you should add your include paths. Adding them to the profile is the wrong way to do it. Boris From axel50397 at gmail.com Mon Mar 23 11:40:50 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Mon Mar 23 11:41:07 2015 Subject: [odb-users] Option -x ignored in profile.options file In-Reply-To: References: Message-ID: On 23 mars 2015 at 14:49:11, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > In your case, default.options is where > you should add your include paths. Adding them to the profile is > the wrong way to do it. Considering that is also expected. But here is where I have my issue with the homebrew packages: You can install all the libodb-* without installing the ODB compiler, because it?s not a build dependency, and you always use the precompiled binaries. But my libodb-qt package is writing to the default.options file placed in the default homebrews directory (where libodb-qt installation expects it to be if you have installed odb with homebrew). If it?s not found, nothing happen. If it?s found, it adds the -x options inside. So, the problem is that if you install odb AFTER installing a libodb-*, the options file won?t contain the corresponding ?-x?. What would be the best way to do what?s expected ? :S -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From axel50397 at gmail.com Mon Mar 23 18:53:43 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Mon Mar 23 18:54:09 2015 Subject: [odb-users] Re: Homebrew package 2.4.0 In-Reply-To: References: Message-ID: Hello ! After few days of work, it?s FINALLY THERE: The homebrew-odb tap ! (https://github.com/Max13/homebrew-odb(https://github.com/Max13/homebrew-odb/blob/master/README.md)) After few discussion about the package submission with the homebrew team (https://github.com/Homebrew/homebrew/pulls?utf8=?&q=is%3Apr+author%3AMax13), the best was to make my own tap and push my packages on it directly. First of all, READ the README. Then have fun, read issues, report issues, send your pull requests and else. And above all, please try them and send me your feedbacks please. Thank you ! PS: Boris, if everything is OK, would you add it as ?non-official? on the ODB download page? -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From boris at codesynthesis.com Tue Mar 24 11:01:25 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Mar 24 11:12:50 2015 Subject: [odb-users] Re: Homebrew package 2.4.0 In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > Boris, if everything is OK, would you add it as ?non-official? on > the ODB download page? Hm, "if everything is OK" is the key phrase here. Dealing with Mac OS has been a royal pain and a giant waste of my time. It is worse than Windows. I am serious. So I am very reluctant to advertise any way to use ODB on Mac OS other than the official binary that I have tested. So I think we will need to wait and see. Boris From boris at codesynthesis.com Tue Mar 24 11:04:16 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Mar 24 11:15:40 2015 Subject: [odb-users] Option -x ignored in profile.options file In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > So, the problem is that if you install odb AFTER installing > a libodb-*, the options file won?t contain the corresponding > ?-x?. What would be the best way to do what?s expected? Add the Qt paths to the default.options file in the ODB package. Strictly speaking, someone may want to include Qt headers into their ODB-compiled files without enabling the Qt profile. There is no reason why this shouldn't be possible. Boris From info at peredin.com Tue Mar 24 11:38:40 2015 From: info at peredin.com (Per Edin) Date: Tue Mar 24 11:38:47 2015 Subject: [odb-users] ODB on Mac OS X (was: Homebrew package 2.4.0) Message-ID: Hi! Regarding ODB on Mac OS, the other day I had to upgrade to 2.4 from 2.3 while at the same time going from GCC 4.8 to GCC 4.9. I installed GCC 4.9 using homebrew and then manually upgraded odb by executing the following commands: export CXX=g++-4.9 cd /code/libodb-2.4.0 ./configure --prefix=/usr/local make make install cd /code/libodb-pgsql-2.4.0 ./configure --prefix=/usr/local --with-libodb=/code/libodb-2.4.0 make make install cd /code/libcutl-1.8.1 ./configure --prefix=/usr/local make make install I couldn't get the ODB compiler to compile with GCC 4.9 so I used 4.8 for that. cd /code/odb-2.4.0 export CXX=g++-4.8 ./configure --prefix=/usr/local --with-libcutl=/code/libcutl-1.8.1 make make install Worked like a charm. /Per On Tue, Mar 24, 2015 at 4:01 PM, Boris Kolpackov wrote: > Hi Adnan, > > Adnan RIHAN writes: > >> Boris, if everything is OK, would you add it as ?non-official? on >> the ODB download page? > > Hm, "if everything is OK" is the key phrase here. Dealing with Mac OS > has been a royal pain and a giant waste of my time. It is worse than > Windows. I am serious. So I am very reluctant to advertise any way > to use ODB on Mac OS other than the official binary that I have > tested. So I think we will need to wait and see. > > Boris > From axel50397 at gmail.com Tue Mar 24 11:46:54 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Tue Mar 24 11:47:21 2015 Subject: [odb-users] Re: ODB on Mac OS X (was: Homebrew package 2.4.0) In-Reply-To: References: Message-ID: Hi Per Edin, On 24 mars 2015 at 16:38:40, Per Edin (info@peredin.com(mailto:info@peredin.com)) wrote: > I couldn't get the ODB compiler to compile with GCC 4.9 so I used 4.8 for that. What about using the homebrew packages? When using mine, you will have odb compiled with the last gcc available on homebrew (currently 4.9.1) and it?s working like a charm on my system. As I need some feedbacks, can I ask you to try them please?? It seems you only use GCC, so it will be easy: > brew install libodb odb --with-gcc If your homebrew is up to date, these 2 packages (including libcutl) will be compiled with gcc-4.9 If it doesn?t work, I would be interested in a ?brew install -dv ...? and send me the log please. Thank you ! -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From info at peredin.com Tue Mar 24 12:06:45 2015 From: info at peredin.com (Per Edin) Date: Tue Mar 24 12:06:52 2015 Subject: [odb-users] Re: ODB on Mac OS X (was: Homebrew package 2.4.0) In-Reply-To: References: Message-ID: Hi Adnan! I will gladly try your homebrew packages. They weren't available when I upgraded to ODB 2.4 and GCC 4.9. I'll get back to you as soon as I'm done (which may take a day or two). My main point was to tell Boris that I haven't experience any non-trivial problems using ODB on Mac OS X (except compiling the compiler with 4.9 that is, which was a minor problem for me). :) /Per On Tue, Mar 24, 2015 at 4:46 PM, Adnan RIHAN wrote: > Hi Per Edin, > > > On 24 mars 2015 at 16:38:40, Per Edin (info@peredin.com(mailto:info@peredin.com)) wrote: > >> I couldn't get the ODB compiler to compile with GCC 4.9 so I used 4.8 for that. > > What about using the homebrew packages? When using mine, you will have odb compiled with the last gcc available on homebrew (currently 4.9.1) and it?s working like a charm on my system. > > As I need some feedbacks, can I ask you to try them please? > > It seems you only use GCC, so it will be easy: >> brew install libodb odb --with-gcc > > If your homebrew is up to date, these 2 packages (including libcutl) will be compiled with gcc-4.9 > > If it doesn?t work, I would be interested in a ?brew install -dv ...? and send me the log please. Thank you ! > -- > Cordialement, Adnan RIHAN. > Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. > > GPG: 5675-62BA (https://keybase.io/max13/key.asc) > -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From axel50397 at gmail.com Wed Mar 25 03:26:07 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Wed Mar 25 03:26:32 2015 Subject: [odb-users] Re: Homebrew package 2.4.0 In-Reply-To: References: Message-ID: Hi Boris, On 24 mars 2015 at 16:12:49, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > Dealing with Mac OS?has been a royal pain and a giant waste of my time. > It is worse than?Windows. I am serious. So I am very reluctant to advertise any way > to use ODB on Mac OS other than the official binary that I have > tested. So I think we will need to wait and see. I agree, at the beginning, Yosemite was on beta and I wasn?t aware of some issues. I was also less experimented using different C++ standard libs (usually, either I dev in pure C, pure C++ or Qt, everything is automatically handled). It?s not a problem for me to wait for more feedbacks and fix some things, but it?s hard to get feedbacks on something only mailing-list users will know. You?re also right, it?s a bad image if the homebrew package doesn?t work well. --? Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From axel50397 at gmail.com Wed Mar 25 03:44:48 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Wed Mar 25 03:45:12 2015 Subject: [odb-users] Option -x ignored in profile.options file In-Reply-To: References: Message-ID: Hi Boris, On 24 mars 2015 at 16:15:40, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > Add the Qt paths to the default.options file in the ODB package. > Strictly speaking, someone may want to include Qt headers into > their ODB-compiled files without enabling the Qt profile. There > is no reason why this shouldn't be possible. As I said, it?s the qt package which writes the Qt headers to the default.options But if you install the libodb-qt without the odb compiler, libodb-qt will have nowhere to write, right? What about creating this file (or appending corresponding conf) for every libodb-* even if odb isn?t installed? I think it may be better than nothing ^ -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From axel50397 at gmail.com Wed Mar 25 06:06:26 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Wed Mar 25 06:06:54 2015 Subject: [odb-users] Querying entity's container In-Reply-To: References: Message-ID: Hi Boris, On 13 mars 2015 at 16:06:16, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > Now we can use this view to load a product that matches a barcode: > > typedef odb::query query; > > db.query (query::barcode::value == "123456"); Thanks a lot for that help. But I had compiler issues. Here is how I had to implement it (I only show what seems relevant): Product.cpp // *SP means: QSharedPointer<*> class Product : public BaseModel { ? ? private: ? ? ? ? CategorySP ? ? ?m_category; ? ? ? ? QSet ? m_barcodes; }; typedef QSharedPointer ProductSP; struct product_barcode { ? ? ProductSP ? product_id; # <-- shared_ptr instead of ptr directly ? ? QString ? ? barcode; }; struct product_view { ? ? ProductSP ? p; }; # ifdef ? ? ODB_COMPILER # ? pragma ?db ?model ? ? ? ? ? ? ? ? ? ? ? ? ? version(1, 1, open) # ? pragma ?db ?object(Product) ? ? ? ? ? ? ? ? table("products") # ? pragma ?db ?member(Product::m_category) ? ? not_null ? ? ? ? ? ? ? ? ? ?column("category_id") # ? pragma ?db ?member(Product::m_barcodes) ? ? table("product_barcodes") ? id_column("product_id") value_column("barcode") # ? pragma ?db ?object(product_barcode) ? ? ? ? table("product_barcodes") ? no_id ? abstract # ? pragma ?db ?member(product_barcode::product_id) column("product_id") # ? pragma ?db ?member(product_barcode::barcode) ? ?column("barcode") # ? pragma ?db ?view(product_view) ? ? ? ? ? ? ?object(Product) object(product_barcode = barcode) ? query(distinct) # endif // END And this is the compiler error I had: /Users/Max13/Dev/System/LGC/Desktop/apps/LGC/src/Models/Product/Product-odb.cxx:1790:13: error: cannot cast from type 'typename object_traits::pointer_type' (aka 'QSharedPointer< ::Product>') to pointer type 'ptr_traits::pointer_type' (aka 'Product *') ? ? ? ? v = ptr_traits::pointer_type ( ? ? ? ? ? ? ^~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. So I thought it was just a typo. It?s good thanks. =================== I was using ? query() ? before 2.4.0 update. Now I know query_one exists, I wanted to give a try. But then, I have a more complicated compiler issue: In file included from /Users/Max13/Dev/System/LGC/Desktop/apps/LGC/src/CashRegister/CashRegisterWidget.cpp:5: In file included from /usr/local/include/odb/qt/list.hxx:8: In file included from /usr/local/include/odb/qt/containers/list.hxx:22: In file included from /usr/local/include/odb/vector-impl.hxx:14: In file included from /usr/local/include/odb/transaction.hxx:263: In file included from /usr/local/include/odb/transaction.ixx:5: In file included from /usr/local/include/odb/connection.hxx:19: In file included from /usr/local/include/odb/prepared-query.hxx:12: In file included from /usr/local/include/odb/result.hxx:242: /usr/local/include/odb/result.txx:19:20: error: no viable conversion from 'typename view_traits::pointer_type' (aka 'QSharedPointer< ::product_view>') to 'pointer_type' (aka 'product_view *') ? ? ? pointer_type o (i.load ()); ? ? ? ? ? ? ? ? ? ?^ ?~~~~~~~~~ /usr/local/include/odb/database.ixx:837:14: note: in instantiation of member function 'odb::result::one' requested here ? ? return r.one (); ? ? ? ? ? ? ?^ /usr/local/include/odb/database.ixx:647:12: note: in instantiation of function template specialization 'odb::database::query_one_ >' requested here ? ? return query_one_ (q); ? ? ? ? ? ?^ /Users/Max13/Dev/System/LGC/Desktop/apps/LGC/src/Controllers/EntityManager/EntityManager.hpp:247:39: note: in instantiation of function template specialization 'odb::database::query_one' requested here ? ? ? ? ? ? ? ? one.reset(this->m_db->query_one(query)); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^ /Users/Max13/Dev/System/LGC/Desktop/apps/LGC/src/CashRegister/CashRegisterWidget.cpp:156:72: note: in instantiation of function template specialization 'EntityManager::findOne2' requested here ? ? QSharedPointer ? ?pv(MasterController::inst()->em()->findOne2(odb::query::barcode::barcode == scan)); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^ /Users/Max13/Qt/5.4/clang_64/lib/QtCore.framework/Headers/qsharedpointer_impl.h:299:12: note: candidate function ? ? inline operator RestrictedBool() const { return isNull() ? 0 : &QSharedPointer::value; } ? ? ? ? ? ?^ 1 error generated. It may be another thread, but I didn?t try it with another call. It seems that ??query_one?? returns a raw pointer, while it tries to assign it from a shared_ptr. The error doesn?t change if I set the product_view::p to raw pointer. Is it a bug? -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From info at peredin.com Wed Mar 25 07:26:36 2015 From: info at peredin.com (Per Edin) Date: Wed Mar 25 07:26:44 2015 Subject: [odb-users] Is running odb really a build-time task? Message-ID: Hi! Is running odb really a build-time task? I know some tasks are, such as running the Qt meta-object compiler. Qt moc generates code for functionality which is similar to functionality already generated by the C++ compiler, such as default constructors and destructors, calling destructors, etc. The odb compiler is quite different though, as it generates code that is typically used directly by others parts of the program and this code is tightly coupled to the C++ models. If an ORM had not been used one would probably write the SQL mapping code first, then write code that use it and finally attempt to build and test the whole thing. ODB just automates the process of implementing the SQL mapping code and is thus not a build-time task. 1. Implement models 2. Implement SQL-mapping code (or run odb) 3. Update business logic to use models and database CRUD functions 4. Build My approach is now to run odb manually (using a script of course) once I've made a change to my models, update the business logic if necessary, and finally build. If everything worked, my model changes and the odb output (source, sql and changelog) would be added to VCS. This also removes the odb compiler from the list of requirements to build my program. To put this another way, all output of odb is (IMHO) supposed to be version controlled and thus belongs in the source directory, the output of Qt's moc is not and thus belongs in the build directory. What are your thoughts on this? /Per From boris at codesynthesis.com Wed Mar 25 09:23:52 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 25 09:35:16 2015 Subject: [odb-users] Querying entity's container In-Reply-To: References: Message-ID: Hi Adnan, Both issues that you are observing stem from incompatible pointers. If you make all your objects/view use QSharedPointer (e.g., by enabling the Qt profile), then you should use QSharedPointer in relationships (the first issue) or when getting a result from calls like query_one() (second issue). Boris From boris at codesynthesis.com Wed Mar 25 09:27:38 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 25 09:39:03 2015 Subject: [odb-users] Option -x ignored in profile.options file In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > > Add the Qt paths to the default.options file in the ODB package. > > Strictly speaking, someone may want to include Qt headers into > > their ODB-compiled files without enabling the Qt profile. There > > is no reason why this shouldn't be possible. > > As I said, it?s the qt package which writes the Qt headers to the > default.options [...] And, as I said, don't do this. Instead, add the Qt headers to the default.options file that is installed by the ODB compiler (odb package). In other words, make the default.options that is installed by the ODB compiler already contain these paths. Boris From boris at codesynthesis.com Wed Mar 25 09:32:48 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 25 09:44:13 2015 Subject: [odb-users] Re: ODB on Mac OS X (was: Homebrew package 2.4.0) In-Reply-To: References: Message-ID: Hi Per, Per Edin writes: > My main point was to tell Boris that I haven't experience any > non-trivial problems using ODB on Mac OS X Uh, I would be very cautious making a statement like this... ;-) > except compiling the compiler with 4.9 that is, which was a > minor problem for me). :) You are probably hitting the GCC's devirtualization bug. Adding -fno-devirtualize when compiling ODB should help. Boris From boris at codesynthesis.com Wed Mar 25 09:42:10 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Mar 25 09:53:35 2015 Subject: [odb-users] Is running odb really a build-time task? In-Reply-To: References: Message-ID: Hi Per, Per Edin writes: > What are your thoughts on this? My general suggestion is, do what works for you. And keep it simple ;-). I, personally, probably wouldn't keep ODB-generated C++ source code in the repository. But adding it to the release distribution of your software is not a bad idea (this way users who don't modify your object model don't need to install the ODB compiler). On the other hand, if you distribute your software by making people clone your repository, then checking in the generated code would make a lot of sense. Boris From info at peredin.com Wed Mar 25 10:06:26 2015 From: info at peredin.com (Per Edin) Date: Wed Mar 25 10:06:34 2015 Subject: [odb-users] Is running odb really a build-time task? In-Reply-To: References: Message-ID: At first I did not include the ODB-generated C++ source code in my repository. When schema versioning was introduced I realized that the changelog (which was placed in the build directory) must be stored in the repository. And if the changelog goes into the repository then so do all other files generated at the same time. It also made my CMakeLists.txt-files much cleaner, keeping it simple. ;-) /Per On Wed, Mar 25, 2015 at 2:42 PM, Boris Kolpackov wrote: > Hi Per, > > Per Edin writes: > >> What are your thoughts on this? > > My general suggestion is, do what works for you. And keep it simple ;-). > > I, personally, probably wouldn't keep ODB-generated C++ source code > in the repository. But adding it to the release distribution of your > software is not a bad idea (this way users who don't modify your > object model don't need to install the ODB compiler). On the other > hand, if you distribute your software by making people clone your > repository, then checking in the generated code would make a lot > of sense. > > Boris From axel50397 at gmail.com Wed Mar 25 12:41:47 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Wed Mar 25 12:42:16 2015 Subject: [odb-users] Querying entity's container In-Reply-To: References: Message-ID: Hi, On 25 mars 2015 at 14:35:17, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > then you should use QSharedPointer in > relationships (the first issue) or when getting a result from > calls like query_one() (second issue). This is what I do. But the issue seems not being the return of my function, but the return inside result.cxx /usr/local/include/odb/result.txx:19:20: error: no viable conversion from 'typename view_traits::pointer_type' (aka 'QSharedPointer< ::product_view>') to 'pointer_type' (aka 'product_view *')? ? ? ? pointer_type o (i.load ()); ? ? ? ? ? ? ? ? ? ?^ ?~~~~~~~~~ In my methods, I always use QSharedPointer. The thing is that I?m trying with query_one() but the same call with query() is working (then I return the first result if it?s not null). This works: > QSharedPointer ? one(new product_view); >?try { >?? ? odb::result ? r(this->m_db->query( >?? ? ? ? odb::query::barcode::barcode == scan >?? ? )); >?? ? typename odb::result::iterator ? i(r.begin()); >? >?? ? if (i != r.end()) { >?? ? ? ? *one = *i; >?? ? } >?} catch (const odb::exception &e) {} >?return (one); But this, doesn?t and produce the error: >?QSharedPointer ? one; >?try { >?? ? one.reset(this->m_db->query_one( >?? ? ? ? odb::query::barcode::barcode == scan >?? ? )); >?} catch (const odb::exception &e) {} >?return (one); In the two functions, the template is ??product_view?? and the return type is a QSharedPointer -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From axel50397 at gmail.com Wed Mar 25 12:49:22 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Wed Mar 25 12:49:49 2015 Subject: [odb-users] Option -x ignored in profile.options file In-Reply-To: References: Message-ID: On 25 mars 2015 at 14:39:03, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > In other words, make the default.options that is installed > by the ODB compiler already contain these paths. Ah ok, I didn?t get it that way. Yes, this is a good way to do it. Thanks. --? Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From axel50397 at gmail.com Wed Mar 25 12:51:14 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Wed Mar 25 12:51:39 2015 Subject: [odb-users] Re: ODB on Mac OS X (was: Homebrew package 2.4.0) In-Reply-To: References: Message-ID: On 25 mars 2015 at 14:44:13, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > You are probably hitting the GCC's devirtualization bug. Adding > -fno-devirtualize when compiling ODB should help. ** Whispering: Already done in the homebrew package ** -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From samuel.littley at toastwaffle.com Wed Mar 25 13:32:16 2015 From: samuel.littley at toastwaffle.com (Samuel Littley) Date: Thu Mar 26 02:16:13 2015 Subject: [odb-users] Using ODB with Bazel Message-ID: <5512F120.8060004@toastwaffle.com> I've been trying to work out how to use ODB with Bazel (Google's open source release of their internal build system). I've been trying to define a rule which runs the ODB compiler to produce the -odb.{cc,h,i} files, but keep hitting errors, namely "odb: error: unable to resolve ODB driver path" and "/usr/bin/odb: error: unable to obtain GCC plugin directory". I think these errors are mostly to do with how Bazel alters the environment in an attempt to make builds reproducible. For the first error, I assume it's referring to the libodb-xxx database drivers (sqlite in my case), however manually adding the correct include path (-I/usr/include/odb/sqlite) seems to have no effect. The second error appears only when I call the binary as /usr/bin/odb as opposed to just calling odb and letting it be resolved from the path, but I can't see any options for odb that would let me specify where it should look for the plugin. Can anybody help with this? I know that Bazel is still in Alpha, and this is all purely out of academic interest, but it would be lovely to get this working! Best Wishes, Samuel Littley samuel.littley@toastwaffle.com Web: http://www.toastwaffle.com Tel: 07724205781 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: OpenPGP digital signature Url : http://codesynthesis.com/pipermail/odb-users/attachments/20150325/47a95d71/signature.pgp From boris at codesynthesis.com Thu Mar 26 08:44:30 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 26 08:56:08 2015 Subject: [odb-users] Using ODB with Bazel In-Reply-To: <5512F120.8060004@toastwaffle.com> References: <5512F120.8060004@toastwaffle.com> Message-ID: Hi Samuel, Samuel Littley writes: > "odb: error: unable to resolve ODB driver path" and "/usr/bin/odb: > error: unable to obtain GCC plugin directory". [...] > > For the first error, I assume it's referring to the libodb-xxx database > drivers [...] No, this error refers to the 'odb' executable. It is the compiler driver for ODB (implemented as a GCC plugin) just like, say, g++ is a driver for cc1plus, which is the actual C++ compiler. The 'odb' driver needs to find its location since it uses it as a base to search for the plugin to load. In your case, it looks for it in PATH which doesn't work, for some reason. > The second error appears only when I call the binary as /usr/bin/odb as > opposed to just calling odb and letting it be resolved from the path, > but I can't see any options for odb that would let me specify where it > should look for the plugin. The plugin will be looked for in a directory that is relative to /usr/bin. You didn't say what package of ODB you are using (e.g., pre-built binary from the website, from your distribution repository, or built it yourself). Generally, you shouldn't move the 'odb' binary around. Here is a warning from the pre-built binary README file: "Note also that while you can move the ODB compiler directory around, you cannot move individual sub-directories or files inside it. For example, copying or linking the ODB compiler executable to /usr/local/bin/ will not work." Boris From boris at codesynthesis.com Thu Mar 26 10:01:06 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Mar 26 10:12:42 2015 Subject: [odb-users] Querying entity's container In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > /usr/local/include/odb/result.txx:19:20: error: no viable conversion > from 'typename view_traits::pointer_type' (aka > 'QSharedPointer< ::product_view>') to 'pointer_type' (aka 'product_view *') Ok, this is a bug and here is the fix: http://scm.codesynthesis.com/?p=odb/libodb.git;a=commit;h=b119086e8c5835695cd851da8ad1393218aa29df Could you try it and let me know if there are any issues? Boris From axel50397 at gmail.com Thu Mar 26 11:03:19 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Thu Mar 26 11:03:46 2015 Subject: [odb-users] Querying entity's container In-Reply-To: References: Message-ID: Hi Boris, On 26 mars 2015 at 15:12:42, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > Could you try it and let me know if there are any issues? Almost good (now it?s in database.hxx): In file included from /usr/local/include/odb/database.hxx:631: /usr/local/include/odb/database.ixx:837:12: error: no viable conversion from 'pointer_type' (aka 'QSharedPointer< ::offer_view>') to 'typename object_traits::pointer_type' (aka 'offer_view *') ? ? return r.one (); ? ? ? ? ? ?^~~~~~~~ /usr/local/include/odb/database.ixx:647:12: note: in instantiation of function template specialization 'odb::database::query_one_ >' requested here ? ? return query_one_ (q); ? ? ? ? ? ?^ /Users/Max13/Dev/System/LGC/Desktop/apps/LGC/src/Controllers/EntityManager/EntityManager.hpp:247:39: note: in instantiation of function template specialization 'odb::database::query_one' requested here ? ? ? ? ? ? ? ? one.reset(this->m_db->query_one(query)); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^ /Users/Max13/Dev/System/LGC/Desktop/apps/LGC/src/CashRegister/CashRegisterWidget.cpp:162:42: note: in instantiation of function template specialization 'EntityManager::findOne2' requested here ? ? ov = MasterController::inst()->em()->findOne2( ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^ -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From samuel.littley at toastwaffle.com Thu Mar 26 19:10:47 2015 From: samuel.littley at toastwaffle.com (Samuel Littley) Date: Thu Mar 26 19:11:00 2015 Subject: [odb-users] Using ODB with Bazel In-Reply-To: References: <5512F120.8060004@toastwaffle.com> Message-ID: <551491F7.7070509@toastwaffle.com> Boris, Apologies for not saying before, I'm using packages built from the Arch Linux user repository (https://aur.archlinux.org/packages/odb). I think the more correct approach for Bazel would actually be to compile odb and its extensions from source with Bazel, but that would require converting autoconf/Makefiles to Bazel BUILD files which is obviously not ideal (or rather, not something I want to commit to immediately). It appears Bazel completely clears the path, exporting the original path (/usr/local/bin:/usr/bin:/usr/local/sbin) before running the odb command makes it work perfectly. Thanks for the hints! Best Wishes, Samuel On 26/03/15 12:44, Boris Kolpackov wrote: > Hi Samuel, > > Samuel Littley writes: > >> "odb: error: unable to resolve ODB driver path" and "/usr/bin/odb: >> error: unable to obtain GCC plugin directory". [...] >> >> For the first error, I assume it's referring to the libodb-xxx database >> drivers [...] > > No, this error refers to the 'odb' executable. It is the compiler driver > for ODB (implemented as a GCC plugin) just like, say, g++ is a driver > for cc1plus, which is the actual C++ compiler. > > The 'odb' driver needs to find its location since it uses it as a > base to search for the plugin to load. In your case, it looks for > it in PATH which doesn't work, for some reason. > > >> The second error appears only when I call the binary as /usr/bin/odb as >> opposed to just calling odb and letting it be resolved from the path, >> but I can't see any options for odb that would let me specify where it >> should look for the plugin. > > The plugin will be looked for in a directory that is relative to /usr/bin. > You didn't say what package of ODB you are using (e.g., pre-built binary > from the website, from your distribution repository, or built it yourself). > Generally, you shouldn't move the 'odb' binary around. Here is a warning > from the pre-built binary README file: > > "Note also that while you can move the ODB compiler directory around, you > cannot move individual sub-directories or files inside it. For example, > copying or linking the ODB compiler executable to /usr/local/bin/ will > not work." > > Boris > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: OpenPGP digital signature Url : http://codesynthesis.com/pipermail/odb-users/attachments/20150326/db316534/signature.pgp From nicholas.cremonesi at gmail.com Fri Mar 27 05:11:38 2015 From: nicholas.cremonesi at gmail.com (Nicholas Cremonesi) Date: Fri Mar 27 10:29:16 2015 Subject: [odb-users] Error version mismatch with ODB 2.4.0 Message-ID: Hello, I compiled ODB 2.4.0 under MingW but when I compile my project the compiler returns to me "ODB version mismatch". If I comment out in my "TEST-odb.hxx" the lines for the version check, compiling my project it returns to me a lot of errors like "/opt/lib/libodbclasses.a(TEST-odb.o):TEST-odb.cxx:(.text+0x1110): undefined reference to `_imp___ZN3odb6sqlite11transaction7currentEv'" What's the matter?? From boris at codesynthesis.com Fri Mar 27 10:32:06 2015 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Mar 27 10:43:44 2015 Subject: [odb-users] Querying entity's container In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > Almost good (now it?s in database.hxx): Uh, oh: http://scm.codesynthesis.com/?p=odb/libodb.git;a=commit;h=ee4d942916d347ac65f53969941b0fb100760611 http://scm.codesynthesis.com/?p=odb/libodb-sqlite.git;a=commit;h=27a578709046a81bb0efc0027bfc74318615447e Let me know if it still doesn't work. Thanks, Boris From axel50397 at gmail.com Fri Mar 27 13:00:27 2015 From: axel50397 at gmail.com (Adnan RIHAN) Date: Fri Mar 27 13:00:52 2015 Subject: [odb-users] Querying entity's container In-Reply-To: References: Message-ID: Hi Boris, On 27 mars 2015 at 15:43:43, Boris Kolpackov (boris@codesynthesis.com(mailto:boris@codesynthesis.com)) wrote: > Let me know if it still doesn't work. YOU DID IT ! It works. I?ve also updated the homebrew packages, added the patches and pushed. -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. GPG: 5675-62BA (https://keybase.io/max13/key.asc) -> Si vous n'utilisez pas GPG mais souhaitez quand m?me m?envoyer un e-mail chiffr?: (https://encrypt.to/0x567562BA). From mne at qosmotec.com Tue Mar 31 08:08:15 2015 From: mne at qosmotec.com (Marcel Nehring) Date: Tue Mar 31 08:09:25 2015 Subject: [odb-users] abstract objects and the data member pragma 'table' Message-ID: <15ad6efd2b5f40bdb5025957005e20b2@QEX.qosmotec.com> Hi all, in my code I have an ODB abstract class with a data member of a container type. PRAGMA_DB(unordered table("CUSTOM_NAME") id_column("FOO_ID") value_column("BAR_ID")) std::vector m_bars; When I try to specify a custom table name for the table that should be used to store the contents of the container member, this results in an ODB error when generating the schema (note the identical line numbers). Foo.h:156:26: error: table name 'CUSTOM_NAME' conflicts with an already defined table name Foo.h:156:26: info: conflicting table is defined here Foo.h:156:26: info: use #pragma db table to change its name Is there a way to avoid this? For example when I don't specify a custom name ODB generates the table name from the class name of the derived, non-abstract class and the member's name. What I would like is to have my custom name prefixed with the non-abstract class' name, for example. I would like to avoid the need to specify the custom name in each derived class. Regards, Marcel