From p.staszewski90 at gmail.com Fri Oct 6 02:35:16 2017 From: p.staszewski90 at gmail.com (=?UTF-8?Q?Pawe=C5=82_Staszewski?=) Date: Fri Oct 6 04:16:26 2017 Subject: [odb-users] Problem with relatinships on Microsoft SQL Server database Message-ID: Hello, I've some problem with relationships (one to many) from odb library to Microsoft SQL Server. When I use yours examples from website then this implemantation that same not work, but relationship one to one is running very good. What can be wrong? Best regards, Pawe? Staszewski From boris at codesynthesis.com Fri Oct 6 05:31:01 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Oct 6 05:31:10 2017 Subject: [odb-users] Problem with relatinships on Microsoft SQL Server database In-Reply-To: References: Message-ID: Pawe? Staszewski writes: > I've some problem with relationships (one to many) from odb library to > Microsoft SQL Server. > When I use yours examples from website then this implemantation that same > not work, but relationship one to one is running very good. You will need to provide a lot more details than this. Specifically, show the object model (classes) involved in the relationship, what you are doing in your code (query, etc), and what exactly does not work. Boris From obermann.lukas at gmail.com Fri Oct 6 11:52:22 2017 From: obermann.lukas at gmail.com (Lukas Obermann) Date: Fri Oct 6 11:52:36 2017 Subject: [odb-users] Update multiple rows with an Object and/or View Message-ID: <6EC8308D-4598-4F73-B15F-5913F5690B2C@gmail.com> Hello, is it possible to update multiple rows via a object or view? I am migrating a query which looks like this: UPDATE table SET some_value = 0 WHERE path = ?something?; It can also be that there are multiple joins in there to determine which ones to update, those are set at runtime. I know I can do it without joins something like this: db.execute( "UPDATE "+odb::object_traits::table_name+ " SET "+ MyTable::m_myValue+" = 0 WHERE "+MyTable::m_path+? = ?something??); Can this be done directly with an object, similar to how delete works. And can this be done with a view, so I can handle the joins and where clauses? Thanks, Lukas From boris at codesynthesis.com Fri Oct 6 12:12:28 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Oct 6 12:12:39 2017 Subject: [odb-users] Update multiple rows with an Object and/or View In-Reply-To: <6EC8308D-4598-4F73-B15F-5913F5690B2C@gmail.com> References: <6EC8308D-4598-4F73-B15F-5913F5690B2C@gmail.com> Message-ID: Lukas Obermann writes: > I am migrating a query which looks like this: > UPDATE table SET some_value = 0 WHERE path = ?something?; > > It can also be that there are multiple joins in there to determine > which ones to update, those are set at runtime. > > I know I can do it without joins something like this: > db.execute( > "UPDATE "+odb::object_traits::table_name+ > " SET "+ MyTable::m_myValue+" = 0 WHERE "+MyTable::m_path+? = ?something??); > > Can this be done directly with an object, similar to how delete works. No, this is not yet supported, though this feature (we call it "mass update") is on the TODO list. So currently the two options are the manual statement as you have shown above or loading and updating one object at a time. While the latter will have worse performance, sometimes it could be an acceptable sacrifice to keep the code simple. Boris From obermann.lukas at gmail.com Mon Oct 9 01:17:22 2017 From: obermann.lukas at gmail.com (Lukas Obermann) Date: Mon Oct 9 01:17:39 2017 Subject: [odb-users] Update multiple rows with an Object and/or View In-Reply-To: References: <6EC8308D-4598-4F73-B15F-5913F5690B2C@gmail.com> Message-ID: Hi Boris, thank you for the info! Any rough plan on when it will be implemented? Also, is there also a date for the next official release? Thanks, Lukas > Am 06.10.2017 um 18:12 schrieb Boris Kolpackov : > > Lukas Obermann writes: > >> I am migrating a query which looks like this: >> UPDATE table SET some_value = 0 WHERE path = ?something?; >> >> It can also be that there are multiple joins in there to determine >> which ones to update, those are set at runtime. >> >> I know I can do it without joins something like this: >> db.execute( >> "UPDATE "+odb::object_traits::table_name+ >> " SET "+ MyTable::m_myValue+" = 0 WHERE "+MyTable::m_path+? = ?something??); >> >> Can this be done directly with an object, similar to how delete works. > > No, this is not yet supported, though this feature (we call it "mass > update") is on the TODO list. So currently the two options are the > manual statement as you have shown above or loading and updating > one object at a time. While the latter will have worse performance, > sometimes it could be an acceptable sacrifice to keep the code simple. > > Boris From boris at codesynthesis.com Mon Oct 9 11:26:15 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Oct 9 11:26:24 2017 Subject: [odb-users] Update multiple rows with an Object and/or View In-Reply-To: References: <6EC8308D-4598-4F73-B15F-5913F5690B2C@gmail.com> Message-ID: Lukas Obermann writes: > Any rough plan on when it will be implemented? No, currently no specific plans. While this feature is requested from time to time, it is also fairly complex, so it is not very high on our priority list. > Also, is there also a date for the next official release? No official date but we are working on it right now. Boris From obermann.lukas at gmail.com Tue Oct 10 08:39:03 2017 From: obermann.lukas at gmail.com (Lukas Obermann) Date: Tue Oct 10 08:39:18 2017 Subject: [odb-users] Update multiple rows with an Object and/or View In-Reply-To: References: <6EC8308D-4598-4F73-B15F-5913F5690B2C@gmail.com> Message-ID: Thank you! One last question, what is the correct way to get the column name in this situation? Because using "MyTable::m_path? gives me an ?Invalid use of non-static member ?? error. I see that the names are generated in the type query_columns, but I have difficulties accessing that. Could you give me a hint on that? Lukas > Am 09.10.2017 um 17:26 schrieb Boris Kolpackov : > > Lukas Obermann writes: > >> Any rough plan on when it will be implemented? > > No, currently no specific plans. While this feature is requested > from time to time, it is also fairly complex, so it is not very > high on our priority list. > > >> Also, is there also a date for the next official release? > > No official date but we are working on it right now. > > Boris > From boris at codesynthesis.com Wed Oct 11 14:17:20 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Oct 11 14:17:29 2017 Subject: [odb-users] Update multiple rows with an Object and/or View In-Reply-To: References: <6EC8308D-4598-4F73-B15F-5913F5690B2C@gmail.com> Message-ID: Lukas Obermann writes: > One last question, what is the correct way to get the column name in > this situation? > > I see that the names are generated in the type query_columns, but I > have difficulties accessing that. Could you give me a hint on that? There is no "official" support for getting the column names. They are available in the query_columns templates but you will have to figure out how to get them. Alternatively, simply hard-coding the names as strings might be a more straightforward option. Boris From p.staszewski90 at gmail.com Thu Oct 12 01:40:32 2017 From: p.staszewski90 at gmail.com (=?UTF-8?Q?Pawe=C5=82_Staszewski?=) Date: Fri Oct 13 06:51:11 2017 Subject: [odb-users] Problem with relatinships on Microsoft SQL Server database Message-ID: In this URL I describe all steps on images. https://drive.google.com/drive/folders/0B9krg4YUhC3VVFgtMklzWE1aZUE?usp=sharing When i try connect to database with relationship "one to one" then everything works good. Problem is only then when i try connect to database with relationship "one to many". Thanks for helping me! From topolewr at cooley.edu Mon Oct 23 19:31:19 2017 From: topolewr at cooley.edu (Richard Topolewski) Date: Mon Oct 23 19:31:33 2017 Subject: [odb-users] when running odb compiler get error "#error libodb-mysql header included in odb-compiled header" Message-ID: I got odb or myClass1 to create the myClass1-odb.hxx, myClass1.sql, myClass1-odb.cxx, myClass1-odb.ixx. I then modified useingClass to use persist my set of myClass1s, and also load the set of myClass1s from the database. Cool. Then I started working on myClass2. When I went to run the odb complier it has some errors because myClass2 depends on a number other packages. Ok, resolved all those errors but then end up with an error: In file included from /usr/include/odb/mysql/version.hxx:10:0, from myClass1-odb.hxx:83, from usingClass.h:24, from myClass2.h:10: :/usr/include/odb/mysql/details/config.hxx:15:4: error: #error libodb-mysql header included in odb-compiled header Turns out myClass2 includes a member pointer to usingClass which includes the member vector array of myClass1s then includes The odb complier command I am using is: odb -I/usr/include/odblib --std c++14 $(INCLUDES) -d mysql --generate-query myClass2.h What am I doing wrong? Do I need to not structure my classes this way? Should I not be creating the db object in usingClass? Is there some part of the odb manual I should be looking at? If there is any additional information I need to provide please let me know. Rich Topolewski From topolewr at cooley.edu Tue Oct 24 06:29:20 2017 From: topolewr at cooley.edu (Richard Topolewski) Date: Tue Oct 24 06:29:34 2017 Subject: [odb-users] Re: when running odb compiler get error "#error libodb-mysql header included in odb-compiled header" (Typos fixed) Message-ID: Fixed some typos: I got odb complier to work on myClass1 to create myClass1-odb.hxx, myClass1.sql, myClass1-odb.cxx, and myClass1-odb.ixx. I then modified useingClass to persist a vector of myClass1s, and also load the set of myClass1s from the database. All really cool. Then I started working on myClass2. When I went to run the odb complier on myClass2 it has some errors because myClass2 depends on a number other packages. Ok, resolved all those errors but then end up with this error: In file included from /usr/include/odb/mysql/version.hxx:10:0, from myClass1-odb.hxx:83, from usingClass.h:24, from myClass2.h:10: :/usr/include/odb/mysql/details/config.hxx:15:4: error: #error libodb-mysql header included in odb-compiled header Turns out myClass2 has a member variable that is a usingClass pointer that includes the member vector array of myClass1s. The odb complier command I am using is: odb -I/usr/include/odblib --std c++14 $(INCLUDES) -d mysql --generate-query myClass2.h What am I doing wrong? Do I need to structure my classes in a different way? Is there some pragma I should be using to fix this? Should I not be creating the db object in usingClass? Is there some part of the odb manual I should be looking at? If there is any additional information I need to provide please let me know. Rich Topolewski On Mon, Oct 23, 2017 at 7:31 PM, Richard Topolewski wrote: > > I got odb or myClass1 to create the myClass1-odb.hxx, myClass1.sql, > myClass1-odb.cxx, myClass1-odb.ixx. > > I then modified useingClass to use persist my set of myClass1s, and also > load the set of myClass1s from the database. Cool. > > Then I started working on myClass2. When I went to run the odb complier > it has some errors because myClass2 depends on a number other packages. > Ok, resolved all those errors but then end up with an error: > > In file included from /usr/include/odb/mysql/version.hxx:10:0, > from myClass1-odb.hxx:83, > from usingClass.h:24, > from myClass2.h:10: > :/usr/include/odb/mysql/details/config.hxx:15:4: error: #error > libodb-mysql header included in odb-compiled header > > Turns out myClass2 includes a member pointer to usingClass which includes > the member vector array of myClass1s then includes > > The odb complier command I am using is: > odb -I/usr/include/odblib --std c++14 $(INCLUDES) -d mysql > --generate-query myClass2.h > > What am I doing wrong? Do I need to not structure my classes this way? > Should I not be creating the db object in usingClass? Is there some part > of the odb manual I should be looking at? > > If there is any additional information I need to provide please let me > know. > > Rich Topolewski > From boris at codesynthesis.com Tue Oct 24 08:51:28 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Oct 24 08:51:38 2017 Subject: [odb-users] Re: when running odb compiler get error "#error libodb-mysql header included in odb-compiled header" (Typos fixed) In-Reply-To: References: Message-ID: Richard Topolewski writes: > In file included from /usr/include/odb/mysql/version.hxx:10:0, > from myClass1-odb.hxx:83, > from usingClass.h:24, > from myClass2.h:10: > :/usr/include/odb/mysql/details/config.hxx:15:4: error: #error libodb-mysql > header included in odb-compiled header You shouldn't include *-odb.hxx headers in your object model headers, at least not unconditionally: #ifndef ODB_COMPILER # include "myClass1-odb.hxx" #endif Boris From topolewr at cooley.edu Tue Oct 24 14:25:54 2017 From: topolewr at cooley.edu (Richard Topolewski) Date: Wed Oct 25 09:02:31 2017 Subject: [odb-users] Re: when running odb compiler get error "#error libodb-mysql header... THANKS, unfortunately now "internal compiler error: Bus error" Message-ID: Hi Boris, Thanks so much for the tip "#ifndef ODB_COMPILER". I was going down that route but didn't know if I was a better way. Now it "compiles" without error but it does not generate any real code, just stub code with no data members (aka fields). I turned on --trace and the compile end with the following: *** 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 In file included from ../Release/include/cpprest/http_client.h:34:0, from UsingClass.h:5, from MyClass2.h:10: ../Release/include/pplx/pplxtasks.h: In function ?void pplx::details::_ScheduleFuncWithAutoInline(const std::function&, pplx::details::_TaskInliningMode_t)?: ../Release/include/pplx/pplxtasks.h:564:17: internal compiler error: Bus error static void _ScheduleFuncWithAutoInline(const std::function & _Func, _TaskInliningMode_t _InliningMode) I am compiling with c++11, because the default(c++98) throws all kinds of compile errors on some of the packages (cpprest & pplx) that my code uses. Attached is the complete trace, but I expect to help me you would need the source for UsingClass, but before I go through the effort of trimming it down to the relevant code I thought I would ask you have any advice to get this to work on myClass2? Rich On Tue, Oct 24, 2017 at 8:51 AM, Boris Kolpackov wrote: > Richard Topolewski writes: > > > In file included from /usr/include/odb/mysql/version.hxx:10:0, > > from myClass1-odb.hxx:83, > > from usingClass.h:24, > > from myClass2.h:10: > > :/usr/include/odb/mysql/details/config.hxx:15:4: error: #error > libodb-mysql > > header included in odb-compiled header > > You shouldn't include *-odb.hxx headers in your object model headers, at > least not unconditionally: > > #ifndef ODB_COMPILER > # include "myClass1-odb.hxx" > #endif > > Boris > -------------- next part -------------- A non-text attachment was scrubbed... Name: myClass2_odb_trace.log Type: application/octet-stream Size: 209266 bytes Desc: not available Url : http://codesynthesis.com/pipermail/odb-users/attachments/20171024/fdcc07f7/myClass2_odb_trace-0001.obj From boris at codesynthesis.com Wed Oct 25 09:07:59 2017 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Oct 25 09:08:08 2017 Subject: [odb-users] Re: when running odb compiler get error "#error libodb-mysql header... THANKS, unfortunately now "internal compiler error: Bus error" In-Reply-To: References: Message-ID: Richard Topolewski writes: > Now it "compiles" without error but it does not generate any real code, > just stub code with no data members (aka fields). My first two ideas: 1. None or your classes are marked as persistent. 2. You are compiling a header that only included other headers (see the --at-once ODB compiler option). Generally, though, the approach I would recommend is to start with once of the example that come with ODB and see if you observe the same problem. If not, then try to understand what's different between your code and then example. Predictably, we cannot fix every mistake in your code for you. > I turned on --trace and the compile end with the following [...] This is an unrelated issue that we have already fixed. --trace is generally not useful for this kind of investigation. Boris From topolewr at cooley.edu Thu Oct 26 06:17:30 2017 From: topolewr at cooley.edu (Richard Topolewski) Date: Thu Oct 26 06:17:44 2017 Subject: [odb-users] Re: when running odb compiler get error "#error libodb-mysql header... THANKS, unfortunately now "internal compiler error: Bus error" In-Reply-To: References: Message-ID: Thanks Boris, I did negleted to complete marking class as persistent, my mistake. I really appreciat you assistance. Your awsome. Rich On Wed, Oct 25, 2017 at 9:07 AM, Boris Kolpackov wrote: > Richard Topolewski writes: > > > Now it "compiles" without error but it does not generate any real code, > > just stub code with no data members (aka fields). > > My first two ideas: > > 1. None or your classes are marked as persistent. > > 2. You are compiling a header that only included other headers (see > the --at-once ODB compiler option). > > Generally, though, the approach I would recommend is to start with > once of the example that come with ODB and see if you observe the > same problem. If not, then try to understand what's different > between your code and then example. Predictably, we cannot fix > every mistake in your code for you. > > > > I turned on --trace and the compile end with the following [...] > > This is an unrelated issue that we have already fixed. --trace is > generally not useful for this kind of investigation. > > Boris >