From finjulhich at gmail.com Mon Jun 2 04:45:23 2014 From: finjulhich at gmail.com (MM) Date: Mon Jun 2 04:45:31 2014 Subject: [odb-users] composite value type Message-ID: Hi, Even after reading parts of the extremely well written manual, I am still unclear how to go about this: I have an odb object C struct C { std::string s1, ..., s5; V v; }; where V has 2 persistent members, a container and a string. class V { private: std::vector< std::tuple< boost::gregorian::year_based_generator*, boost::gregorian::year_based_generator**,* boost::posix_time::time_period[5u] > > data_; std::string x_; }; For a non-intrusive change of V. I would add accessors to data_ and to x_; Now for data_, I am not too sure what this maps to. I would have a table of Cs. Each row being a C instance. But the V part of the row cannot map simply as a couple of columns. In practice, I know my data_ vector will have at most 3/4 entries, and most of the time just 1 entry. How would you go about this? Secondly, for the boost profile, I cannot see any mappings for the types I use here (time_period, year_based_generator). What kind of solution can I go for? Your help is appreciated immensely, you provide the best I have ever seen in any forum:-) Regards, From finjulhich at gmail.com Mon Jun 2 08:01:33 2014 From: finjulhich at gmail.com (MM) Date: Mon Jun 2 08:01:41 2014 Subject: [odb-users] design questions: c++ / python / sqlite In-Reply-To: References: Message-ID: On 22 May 2014 19:47, Boris Kolpackov wrote: > Hi, > > MM writes: > > > I just meant that a given class is defined in C++. I would expose that > > class in python with boost.python perhaps, and then use those classes in > > python to access the sqlite db through python.sqlite > > This doesn't make much sense to me. You have C++ classes that you > can persist in the database with ODB. You expose them to python via > Boost.Python. You then use these classes and SQLite support in Python > to access their state in database? Why? That is already handled by ODB > on the C++ side. > > > > Is there a way to make this map to a single table that holds 10 rows > where > > the primary key is name, and the other things are other columns, and yet > on > > loading back from the table, that the correct concrete instances are > > created? > > What you are looking for is the table-per-hierarchy mapping for > inheritance. This is currently not supported by ODB. See Section > 8.2, "Polymorphism Inheritance" in the ODB manual for details. > > > > If not, how to change my simple class hierarchy? > > You don't really have to change anything. Just use the > *table-per- difference mapping supported by ODB*. You will end up with > some > extra tables that (seemingly) are not necessary, but other than > that, everything will work as expected. In fact, the root table > will look as if you were using the table-per-hierarchy mapping > so if your Python code only needs to read the data, then you > can treat it in Python as such. > > Boris > I have managed to generate the sql for this. As a reminder here: class ABClass { public: virtual ~ABClass(); // other virtuals // 2 pairs of getters/setter for name and hols protected: ABClass() private: const std::string* name_; std::vector hols_; }; class D1 .... D10 : public ABClass { ... }; All Ds are singletons. Their name_ points to a static list of strings, so D1's name_ points to "D1" So the names themselves and the single instances D1...D10 currently are statics in the C++ code, and I intend to have the hols data in the database. Now, I'll get rid of the statics and have everything stored in the db. There are indeed the ABClass table + all the D tables. I assume a query like result r (db->query()); would just work and load up all the Ds instances in 1 go? From finjulhich at gmail.com Mon Jun 2 09:49:49 2014 From: finjulhich at gmail.com (MM) Date: Mon Jun 2 09:49:58 2014 Subject: [odb-users] path of include headers Message-ID: The call to odb compiler has this form: odb [options] header_file_to_process I use -I to specify the dirs where to find headers, and the -o to specify where to generate the 3 ?xx files and the sql file. I have a cmake driven directory structure. trunk contains source, and i have a release and debug build dirs e.g. odb -o outdir \C-odb <...>\trunk\C-odb\C.hpp /// nonintrusive header The generated C.hxx has: #include "C.hpp" // this is wrong, should "C-odb/C.hpp" in a driver cpp file, I include the odb generated file "C.hxx", but this fails to find the C-odb\C.hpp file. Is there a way to tell odb compiler my intention? Rds, From boris at codesynthesis.com Mon Jun 2 09:56:43 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 2 09:54:02 2014 Subject: [odb-users] design questions: c++ / python / sqlite In-Reply-To: References: Message-ID: Hi, MM writes: > I assume a query like > > result r (db->query()); > > would just work and load up all the Ds instances in 1 go? If you mark ABClass polymorphic, yes. Boris From boris at codesynthesis.com Mon Jun 2 10:00:26 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 2 09:57:47 2014 Subject: [odb-users] path of include headers In-Reply-To: References: Message-ID: Hi, MM writes: > Is there a way to tell odb compiler my intention? Yes, as always, the documentation has the answer to your question! See the --include-prefix and, if that's not sufficient, --include-regex options in the ODB Compiler Manual (man pages). Boris From boris at codesynthesis.com Mon Jun 2 10:19:25 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 2 10:16:44 2014 Subject: [odb-users] composite value type In-Reply-To: References: Message-ID: Hi, MM writes: > std::vector< > std::tuple< boost::gregorian::year_based_generator*, > boost::gregorian::year_based_generator**,* > boost::posix_time::time_period[5u] > > > > data_; > > Now for data_, I am not too sure what this maps to. Me neither. I don't even understand the semantics of this let alone what a sensible representation for it might be in the database. > But the V part of the row cannot map simply as a couple of columns. Normally, std::vector (and other containers) is mapped to a separate table (container table) that stores the entries for all the objects (See Chapter 5). > Secondly, for the boost profile, I cannot see any mappings for the types I > use here (time_period, year_based_generator). What kind of solution can > I go for? You cannot store a pointer to year_based_generator in a database. In fact, to me, it seems like year_based_generator is not something that would be stored in the database at all. So if I were you I would first try to understand what it is this data describes semantically and what a sensible persistent representation for it might be (ODB cannot auto-magically do it for you). Using a random number generator as an example (no idea if year_based_generator is anything even remotely similar; I could not find any documentation on it). There is no "direct" way to store it in the database. Instead, you need to come up with something that would describe it that you can persist. And what that representation might be depends on your application logic. Maybe it is the seed and the last returned value (so that, for example, you can continue from where you left off). Maybe it is just the seed. Maybe some other internal state. And for some applications it may not even make sense to store anything at all. You could just create a fresh generator seeded, say, with current time. Boris From finjulhich at gmail.com Mon Jun 2 10:47:50 2014 From: finjulhich at gmail.com (MM) Date: Mon Jun 2 10:47:58 2014 Subject: [odb-users] composite value type In-Reply-To: References: Message-ID: On 2 June 2014 15:19, Boris Kolpackov wrote: > Hi, > > MM writes: > > > std::vector< > > std::tuple< boost::gregorian::year_based_generator*, > > boost::gregorian::year_based_generator**,* > > boost::posix_time::time_period[5u] > > > > > > data_; > > > > Now for data_, I am not too sure what this maps to. > > Me neither. I don't even understand the semantics of this let alone > what a sensible representation for it might be in the database. > > > > But the V part of the row cannot map simply as a couple of columns. > > Normally, std::vector (and other containers) is mapped to a separate > table (container table) that stores the entries for all the objects (See > Chapter 5). > > > > Secondly, for the boost profile, I cannot see any mappings for the types > I > > use here (time_period, year_based_generator). What kind of solution can > > I go for? > > You cannot store a pointer to year_based_generator in a database. In fact, > to me, it seems like year_based_generator is not something that would > be stored in the database at all. > > So if I were you I would first try to understand what it is this data > describes semantically and what a sensible persistent representation > for it might be (ODB cannot auto-magically do it for you). Thanks for taking the time to answer. Apologies that I I haven't described well enough. The type boost::gregorian::year_based_generator comes from the date_time library, and is the base class of all date generators. For eg., 1 of the concrete types lets you say: 1st monday of April An object of type boost::gregorian::first_day_of_the_week_in_month (which derives from boost::gregorian::year_based_generator) can hold this value. You then pass the year say 2014, and it gives you the exact date that matches this. My vector encodes a list of periods through the year < 1st monday of jan, 2nd tuesday of apr, array of 5 timeperiods > < 2nd tuesday of apr, 1rd friday of aug, array of 5 timeperiods > a timeperiod is say 8am to 5pm I can come up with some encoding from these date_time types to std::string, to store and load, which i can then store to db. I was hoping the date_time profile included a direct representation of this. Would you advise to try to extend the odb boost profile to add more types from date_time, or rather pass by std::string? Thanks again, From boris at codesynthesis.com Mon Jun 2 11:19:07 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 2 11:16:26 2014 Subject: [odb-users] composite value type In-Reply-To: References: Message-ID: Hi, MM writes: > I can come up with some encoding from these date_time types to std::string, > to store and load, which i can then store to db. It doesn't have to be a string. You could encode it as a number of columns that capture the state using convenient data types, etc. In other words, think of a struct that would capture the state of your tuple using basic types like strings, integers, date-time types from the Boost profile, etc. > I was hoping the date_time profile included a direct representation of this. Even if it did, it wouldn't help you much since in your case you have pointers of an abstract year_based_generator that point to the concrete generator implementations with their own states. In fact, who manages the lifetime of these generators? If there is some fixed "registry" of them, then maybe you could store a "key" to this registry instead of the state and type of the generator. Boris From finjulhich at gmail.com Tue Jun 3 04:44:57 2014 From: finjulhich at gmail.com (MM) Date: Tue Jun 3 04:45:04 2014 Subject: [odb-users] composite value type In-Reply-To: References: Message-ID: On 2 June 2014 16:19, Boris Kolpackov wrote: > Hi, > > MM writes: > > > I can come up with some encoding from these date_time types to > std::string, > > to store and load, which i can then store to db. > > It doesn't have to be a string. You could encode it as a number of > columns that capture the state using convenient data types, etc. In > other words, think of a struct that would capture the state of your > tuple using basic types like strings, integers, date-time types > from the Boost profile, etc. > > > I was hoping the date_time profile included a direct representation of > this. > > Even if it did, it wouldn't help you much since in your case you have > pointers of an abstract year_based_generator that point to the concrete > generator implementations with their own states. > > In fact, who manages the lifetime of these generators? If there is > some fixed "registry" of them, then maybe you could store a "key" > to this registry instead of the state and type of the generator. > > Boris > Trying here according to your response yesterday: class period_s_hours { public: const year_based_generator& from() const; const year_based_generator& to() const; const time_period* tperiods() const; void tperiods(const time_period[]); private: std::shared_ptr from_; std::shared_ptr to_; std::array tperiods_; /// start/end times for Mon..Fri }; 1) period_s_hours is the element type of std::vector that is a member of another class. I understand I am not allowed to have containers of containers, which would be the case here. In fact, I don't want the tperiods_ member to be treated as a container by odb, but it's probably cleaner to have it map to 5 columns. Can I keep it as the std::array<...,5> and have get/set so that odb loads/stores that from 5 columns? I assume I need a separate struct of 5 members that is directly convertible by odb? Or perhaps 5 virtual members of type time_period (i have valuetyped time_period) with get/set 2) For year_based_generator, if I think of a struct S that captures with basic types, a virtual member of type S would then be used in period_s_hours with get/set to translate from the S type to year_based_generator Thanks, From finjulhich at gmail.com Tue Jun 3 05:14:58 2014 From: finjulhich at gmail.com (MM) Date: Tue Jun 3 05:15:06 2014 Subject: [odb-users] no modifiers found Message-ID: I have tried to define the type found here: http://www.boost.org/doc/libs/1_54_0/doc/html/date_time/posix_time.html#date_time.posix_time.time_period as a value type with #pragma db value(boost::posix_time::time_period) transient definition #pragma db member(boost::posix_time::time_period::begin) virtual(boost::posix_time::ptime) #pragma db member(boost::posix_time::time_period::end) virtual(boost::posix_time::ptime) However, modifiers are indeed not found in that type definition. The doc lists only some accessors. The type doesn't have a def ctor, provides a user ctor and a copy ctor, but no assignment operator, nor setter for begin/end. I assume the only solution is some wrapper type? Hicham From boris at codesynthesis.com Tue Jun 3 08:10:45 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 3 08:16:33 2014 Subject: [odb-users] composite value type In-Reply-To: References: Message-ID: Hi, MM writes: > Can I keep it as the std::array<...,5> and have get/set so that odb > loads/stores that from 5 columns? I assume I need a separate struct of 5 > members that is directly convertible by odb? > Or perhaps 5 virtual members of type time_period (i have valuetyped > time_period) with get/set Yes, I would go for virtual members. It should be as simple as: #pragma db member(p0) virtual (...) access (tperiods_[0]) #pragma db member(p1) virtual (...) access (tperiods_[1]) ... > 2) For year_based_generator, if I think of a struct S that captures with > basic types, a virtual member of type S would then be used in > period_s_hours with get/set to translate from the S type to > year_based_generator You could make the year_based_generator an object and then store it as a polymorphic object hierarchy. But to me this feels like an overkill and doesn't really fit in well (e.g., what would the object id be? maybe a year?). So, yes, I would probably just encode the type and state using some simple struct and then store that in the database, using a virtual data member with custom accessor/modifier to seamlesly translate between this database representation and the actual type. Boris From boris at codesynthesis.com Tue Jun 3 08:27:49 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 3 08:30:33 2014 Subject: [odb-users] no modifiers found In-Reply-To: References: Message-ID: Hi, MM writes: > However, modifiers are indeed not found in that type definition. The doc > lists only some accessors. The type doesn't have a def ctor, provides a > user ctor and a copy ctor, but no assignment operator, nor setter for > begin/end. Lack of modifiers is a bit of challenge but you could use constructor and assignment to work around that: #pragma db member(boost::posix_time::time_period::begin) \ virtual(boost::posix_time::ptime) \ get (begin ()) \ set (this = boost::posix_time::time_period ((?), this.end ())) #pragma db member(boost::posix_time::time_period::end) \ virtual(boost::posix_time::ptime) \ get (end ()) \ set (this = boost::posix_time::time_period (this.begin (), (?))) The trick here is not to violate some type constraints that would cause the constructor to throw or not to store the data we want it to store. If that causes problems, then one can assume that simple value data members are initialized in the order of declaration (we don't specify this anywhere but I don't see a reason why this will ever not hold). Boris From lidia at lemur-soft.com Tue Jun 3 12:36:44 2014 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Tue Jun 3 12:36:51 2014 Subject: [odb-users] Lazy pointers question Message-ID: Hello all, I have 2 persistent classes : A and B. B contains vector of As. I would like them to be lazy_ptr and load at once only when required. Should I fetch myself ( by some query using native view ) their's db ids, load one-by-one and push to m_As vector ? Is there some another "magic" way to do this ? Any other suggestions are very appreciated. Thanks. Lidia. class A { }; class B { std::vector > m_As; }; //// //some id ; std::shared_ptr a = db.load(id); // need to get all As. // here m_As vector is empty -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From boris at codesynthesis.com Wed Jun 4 04:53:58 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 4 04:51:25 2014 Subject: [odb-users] Lazy pointers question In-Reply-To: References: Message-ID: Hi Lidia, Lidia Kalinovsky writes: > Is there some another "magic" way to do this ? Yes, it is called object sections (Chapter 9 in the ODB manual). You can have two-level "laziness" here: firstly you can load the vector (i.e., the ids of pointed-to objects) on demand, only when needed, using object sections. Then you can lazily load individual pointed-to objects using the lazy pointer mechanism. Boris From lidia at lemur-soft.com Wed Jun 4 05:08:56 2014 From: lidia at lemur-soft.com (Lidia Kalinovsky) Date: Wed Jun 4 05:09:03 2014 Subject: [odb-users] Lazy pointers question In-Reply-To: References: Message-ID: thanks a lot On Wed, Jun 4, 2014 at 11:53 AM, Boris Kolpackov wrote: > Hi Lidia, > > Lidia Kalinovsky writes: > > > Is there some another "magic" way to do this ? > > Yes, it is called object sections (Chapter 9 in the ODB manual). You > can have two-level "laziness" here: firstly you can load the vector > (i.e., the ids of pointed-to objects) on demand, only when needed, > using object sections. Then you can lazily load individual pointed-to > objects using the lazy pointer mechanism. > > Boris > -- Software integration and outsourcing services, Lemur-Soft, Giv'at Nili Israel, 37825 Phone : (+972) 545748325 Fax : (+972) 775345383 Email : lidia@lemur-soft.com Web: www.lemur-soft.com From finjulhich at gmail.com Thu Jun 5 13:17:48 2014 From: finjulhich at gmail.com (MM) Date: Thu Jun 5 13:17:55 2014 Subject: [odb-users] design questions: c++ / python / sqlite In-Reply-To: References: Message-ID: The sql generated looks like: CREATE TABLE "ABClass" ( "name" TEXT NOT NULL PRIMARY KEY, "typeid" TEXT NOT NULL); 10 other CREATE TABLE, 1 for each derived class. CREATE TABLE "d1" ( "name" TEXT NOT NULL PRIMARY KEY, CONSTRAINT "name_fk" FOREIGN KEY ("name") REFERENCES "ABClass" ("name") ON DELETE CASCADE); Is the value of typeid col the name of the derived class? I am gonna populate this table from python. would I run for each derived class INSERT INTO ABClass VALUES( "d1", "d1" ) ? Do I also need a single row in each derived table? These tables will be created oneoff and very rarely added to On 2 June 2014 14:56, Boris Kolpackov wrote: > Hi, > > MM writes: > > > I assume a query like > > > > result r (db->query()); > > > > would just work and load up all the Ds instances in 1 go? > > If you mark ABClass polymorphic, yes. > > Boris > > From boris at codesynthesis.com Fri Jun 6 05:14:07 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jun 6 05:12:01 2014 Subject: [odb-users] design questions: c++ / python / sqlite In-Reply-To: References: Message-ID: Hi, MM writes: > Is the value of typeid col the name of the derived class? Yes, the fully-qualified class name. > Do I also need a single row in each derived table? Yes. You could try to persist one of the derived classes from C++ and inspect the resulting content in the database. That should give you a pretty good idea on what needs to be done in Python. Boris From finjulhich at gmail.com Fri Jun 6 06:46:21 2014 From: finjulhich at gmail.com (MM) Date: Fri Jun 6 06:46:30 2014 Subject: [odb-users] Headers organisation and include prefix Message-ID: Hello, As non-intrusive odb is important to me, I have the following headers under src trunk (src dir) |--- dir1--- *f.hpp* (defines struct F) #include "dir1/g.hpp" struct F { G g; ... }; --- *g.hpp* (defines class G) class G { ... }; | |--- dir1_odb --- *f.hpp* (contains odb pragmas for struct F: object ) #include #include "dir1/f.hpp" #include "dir1_odb/g.hpp" // correct namespace #pragma db object(F) definition --- *g.hpp* (contains odb pragmas for class G: value type) #include #include "dir1/g.hpp" // correct namespace #pragma db value(G) definition I use cmake and have the following out of src build dir trunk-build-debug (build dir) |----dir1 (objects for sources under dir1) |----dir1_odb (this is where the output of odb compiler goes) ----- f.hxx f.cxx f.ixx ----- g.hxx g.cxx g.ixx This is the odb command line: odb -d sqlite --std c++11 --profile boost --generate-query -I -IC:/boost/1_54 --include-prefix dir1_odb /dir1_odb/f.hpp odb -d sqlite --std c++11 --profile boost --generate-query -I -IC:/boost/1_54 --include-prefix dir1_odb /dir1_odb/g.hpp This generates: 1) f-odb.hxx under trunk-build-debug/dir1_odb with this bit right after the End prologue #include "dir1_odb/f.hpp" // correct, this comes from the --include-prefix argument. but also #include "dir1/g-odb.hxx" //// wrong, this doesn't exist all. #include "dir1_odb/g-odb.hxx" //// Ok, it's the result of other odb compiler run 2) g-odb.hxx under trunk-build-debug/dir1_odb with this bit right after the End prologue #include "dir1_odb/g.hpp" // correct, this comes from the --include-prefix argument. but also #include "dir1/g-odb.hxx" //// wrong, this doesn't exist all. I am a little confused as to what happens, and would appreciate advise on reorg of headers if needed, Thanks MM From boris at codesynthesis.com Fri Jun 6 10:20:29 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jun 6 10:17:51 2014 Subject: [odb-users] Headers organisation and include prefix In-Reply-To: References: Message-ID: <20140606142029.GA3569@codesynthesis.com> Hi, MM writes: > #include "dir1/g-odb.hxx" //// wrong, this doesn't exist all. ODB would add the *-odb.hxx include if this header contains definitions of some persistent objects or value types. You have all the pragmas in a separate file (dir1_odb/h.hxx) which is what you actually want to compile with the ODB compiler. What you also need to make sure is that this file is marked as the definition file of all the persistent entities found in dir1/g.hxx ('db definition' pragma). If that doesn't help, then that would indicate there is a bug in ODB. In that case, can you send me an archive with all the files you have mentioned placed in their relevant directories so that I can try to reproduce this? Boris From finjulhich at gmail.com Fri Jun 6 13:00:28 2014 From: finjulhich at gmail.com (MM) Date: Fri Jun 6 13:00:36 2014 Subject: [odb-users] Headers organisation and include prefix In-Reply-To: <20140606142029.GA3569@codesynthesis.com> References: <20140606142029.GA3569@codesynthesis.com> Message-ID: On 6 June 2014 15:20, Boris Kolpackov wrote: > Hi, > > MM writes: > > > #include "dir1/g-odb.hxx" //// wrong, this doesn't exist > all. > > ODB would add the *-odb.hxx include if this header contains definitions > of some persistent objects or value types. You have all the pragmas in a > separate file (dir1_odb/h.hxx) which is what you actually want to compile > with the ODB compiler. What you also need to make sure is that this file > is marked as the definition file of all the persistent entities found in > dir1/g.hxx ('db definition' pragma). > Indeed, 1 of the value pragma did not have the definition qualifier. Thank you immensely for your help, > If that doesn't help, then that would indicate there is a bug in ODB. > In that case, can you send me an archive with all the files you have > mentioned placed in their relevant directories so that I can try to > reproduce this? > Boris > From steve.xu.cd at gmail.com Fri Jun 6 23:37:22 2014 From: steve.xu.cd at gmail.com (steve xu) Date: Fri Jun 6 23:37:28 2014 Subject: [odb-users] unsubcribe Message-ID: From finjulhich at gmail.com Sun Jun 8 08:03:43 2014 From: finjulhich at gmail.com (MM) Date: Sun Jun 8 08:03:51 2014 Subject: [odb-users] sqlite schema evolution and unsupported drop column Message-ID: hello, I have now a setup where i specify the version of my schema that matches my svn commit version. I have made a change to the object model and it resulted in a sql change. On running odb to update the changelog and the new sql file (single), I get this error: 1>EXEC : error : SQLite does not support dropping of columns 1> info: first dropped column is 'days_before_fnd' in table 'cfmarkets' 1> info: could have perform logical drop if the column allowed NULL values The columns that are dropped have at the moment INTEGER 0. Looking at the changelog, it hasn't been changed at all due to the failure of the odb compiler run. How do I go about making changes and keep the changelog and everything else in sync? MM From adnan at rihan.fr Sun Jun 8 20:59:48 2014 From: adnan at rihan.fr (Adnan RIHAN) Date: Sun Jun 8 21:00:24 2014 Subject: [odb-users] First project: can't find QtCore/QString on OSX Message-ID: Hi there, It?s the first time I?m using ODB, and while reading the documentation, I wanted to add it on an existing project. Here is my command line: > odb -d sqlite -p qt --generate-query Category.hpp The error is: > In file included from :1:0: > /Users/Max13/Dev/System/ODB/Compiler/odb-2.3.0-i686-macosx/lib/odb/i686-apple-darwin8/lib/gcc/../../include/odb/qt/basic/sqlite/default-mapping.hxx:8:26: fatal error: QtCore/QString: No such file or directory > compilation terminated. So I?ve tried many combinations, including: http://codesynthesis.com/pipermail/odb-users/2014-May/001862.html, adding -I to the lib dir or to the Headers? framework dir, but nothing is working, QtCore/QString isn?t found. What am I missing ? -- Cordialement, Adnan RIHAN. GPG: 0x2FBD3D25 From boris at codesynthesis.com Mon Jun 9 07:23:40 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 9 07:21:02 2014 Subject: [odb-users] First project: can't find QtCore/QString on OSX In-Reply-To: Message-ID: Hi Adnan, Adnan RIHAN writes: > odb -d sqlite -p qt --generate-query Category.hpp > > /Users/Max13/Dev/System/ODB/Compiler/odb-2.3.0-i686-macosx/lib/odb/i686-apple-darwin8/lib/gcc/../../include/odb/qt/basic/sqlite/default-mapping.hxx:8:26: fatal error: QtCore/QString: No such file or directory > > So I?ve tried many combinations, including: > http://codesynthesis.com/pipermail/odb-users/2014-May/001862.html, > adding -I to the lib dir or to the Headers? framework dir, but nothing > is working, QtCore/QString isn?t found. Ok, the problem here is that the private copy of GCC that is used by the ODB compiler is not built with support for frameworks (so we cannot use -F or -framework). This is something that I am hoping to try and address in the future. So in the meantime we need to try to come up with the equivalent -I options (ODB compiler only needs headers so we don't need to worry about libraries). Based on my understanding of the framework layout that you have showed earlier, you will need to make a symlink in order to re-create the standard Qt header hierarchy. Since it will only be used by ODB, a good place to create this symlink is in the ODB compiler's etc/ subdirectory: cd /Users/Max13/Dev/System/ODB/Compiler/odb-2.3.0-i686-macosx/etc ln -s /Users/Max13/Qt/5.2.1/clang_64/lib/QtCore.framework/Headers ./QtCore Then open the 'default.options' file in this directory and add these two lines: -I /Users/Max13/Dev/System/ODB/Compiler/odb-2.3.0-i686-macosx/etc -I /Users/Max13/Dev/System/ODB/Compiler/odb-2.3.0-i686-macosx/etc/QtCore With these two changes your original command line should work fine. Boris From boris at codesynthesis.com Mon Jun 9 07:50:03 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 9 07:47:26 2014 Subject: [odb-users] sqlite schema evolution and unsupported drop column In-Reply-To: References: Message-ID: Hi, MM writes: > error : SQLite does not support dropping of columns > > How do I go about making changes and keep the changelog and everything else > in sync? I bet you haven't read sub-Section 18.5.7, "Database Schema Evolution" in the SQLite limitations section. If so, then that would be a really good place to start. Boris From finjulhich at gmail.com Mon Jun 9 08:04:45 2014 From: finjulhich at gmail.com (MM) Date: Mon Jun 9 08:04:54 2014 Subject: [odb-users] sqlite schema evolution and unsupported drop column In-Reply-To: References: Message-ID: On 9 June 2014 12:50, Boris Kolpackov wrote: > Hi, > > MM writes: > > > error : SQLite does not support dropping of columns > > > > How do I go about making changes and keep the changelog and everything > else > > in sync? > > I bet you haven't read sub-Section 18.5.7, "Database Schema Evolution" in > the SQLite limitations section. If so, then that would be a really good > place to start. > "In particular, you cannot add the --sqlite-override-null option when you realize you need to delete a data member. At this point it is too late since the column has already been added as NOT NULL in existing databases" Yes, it is too late. At this point, I can start the whole thing from scratch (new changelog file...), put the sqlite override option in the odb calls, and refill the new db once generated from the old db, manually. From adnan at rihan.fr Mon Jun 9 13:18:18 2014 From: adnan at rihan.fr (Adnan RIHAN) Date: Mon Jun 9 13:19:30 2014 Subject: [odb-users] First project: can't find QtCore/QString on OSX In-Reply-To: References: Message-ID: It?s working, thank you. Do you need anything from me to work/understand/test something about framework directory structures ? Le 9 juin 2014 ? 12:21:04, Boris Kolpackov (boris@codesynthesis.com) a ?crit: > Hi Adnan, > > Adnan RIHAN writes: > > > odb -d sqlite -p qt --generate-query Category.hpp > > > > /Users/Max13/Dev/System/ODB/Compiler/odb-2.3.0-i686-macosx/lib/odb/i686-apple-darwin8/lib/gcc/../../include/odb/qt/basic/sqlite/default-mapping.hxx:8:26: > fatal error: QtCore/QString: No such file or directory > > > > So I?ve tried many combinations, including: > > http://codesynthesis.com/pipermail/odb-users/2014-May/001862.html, > > adding -I to the lib dir or to the Headers? framework dir, but nothing > > is working, QtCore/QString isn?t found. > > Ok, the problem here is that the private copy of GCC that is used by > the ODB compiler is not built with support for frameworks (so we > cannot use -F or -framework). This is something that I am hoping to > try and address in the future. > > So in the meantime we need to try to come up with the equivalent -I > options (ODB compiler only needs headers so we don't need to worry > about libraries). Based on my understanding of the framework layout > that you have showed earlier, you will need to make a symlink in > order to re-create the standard Qt header hierarchy. Since it will > only be used by ODB, a good place to create this symlink is in the > ODB compiler's etc/ subdirectory: > > cd /Users/Max13/Dev/System/ODB/Compiler/odb-2.3.0-i686-macosx/etc > ln -s /Users/Max13/Qt/5.2.1/clang_64/lib/QtCore.framework/Headers ./QtCore > > Then open the 'default.options' file in this directory and add these > two lines: > > -I /Users/Max13/Dev/System/ODB/Compiler/odb-2.3.0-i686-macosx/etc > -I /Users/Max13/Dev/System/ODB/Compiler/odb-2.3.0-i686-macosx/etc/QtCore > > With these two changes your original command line should work fine. > > Boris > -- Cordialement, Adnan RIHAN. Directeur-G?rant de Eolis-Software, soci?t? de services informatiques. $this->set("Mobile", "+33 (0) 6 78 62 26 20"); GPG: 0x2FBD3D25 From boris at codesynthesis.com Tue Jun 10 04:46:52 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 10 04:44:16 2014 Subject: [odb-users] First project: can't find QtCore/QString on OSX In-Reply-To: References: Message-ID: Hi Adnan, Adnan RIHAN writes: > It?s working, thank you. Great! This is actually a fairly clean workaround. The purpose of the etc/default.options file is exactly these kind of site-wide adjustments that once made are not visible to the end-user (i.e., one doesn't have to keep adding the Qt -I options to every ODB compiler command line in every project). > Do you need anything from me to work/understand/test something about > framework directory structures ? No, I think I have pretty much everything I need right now. If I need to test anything OS X and Qt-related in the future, I will let you know. Thanks for the offer and let me know if there are any other issues. Boris From cresanta at me.com Wed Jun 11 00:12:09 2014 From: cresanta at me.com (Bruce Cresanta) Date: Wed Jun 11 01:05:18 2014 Subject: [odb-users] Hand coded schema Message-ID: <810E531C-FB1B-4172-A35D-5070AD274CA3@me.com> Boris, I?m getting closer to giving ODB a test run. I like to write my schemas by hand. What is the best way to do this with ODB? I have a rather large system that I?m designing and would like to prove it outbefore I worry about mappings and things of that nature. Any recommendations on how to learn? Bruce From boris at codesynthesis.com Wed Jun 11 09:21:24 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 11 09:18:47 2014 Subject: [odb-users] Hand coded schema In-Reply-To: <810E531C-FB1B-4172-A35D-5070AD274CA3@me.com> References: <810E531C-FB1B-4172-A35D-5070AD274CA3@me.com> Message-ID: Hi Bruce, Bruce Cresanta writes: > I like to write my schemas by hand. You realize you will then have to do schema migration by hand as well (which is a real PITA)? > What is the best way to do this with ODB? I have a rather large system > that I?m designing and would like to prove it out before I worry about > mappings and things of that nature. Any recommendations on how to learn? I actually would strongly suggest that you start with automatic schema generation, at least initially. This will allow you to iterate/prove your system out much faster since you only need to focus on one thing (object model design) instead of three things (object model, relational model, and mapping between the two). You can always keep an eye on the generate database schema to see if it satisfies your requirements (always a good idea). Though ODB generates pretty idiomatic SQL (one guy from a big shop told me their Oracle DBA was quite impressed after seeing ODB- generated database schema). This way you will also learn how ODB maps various C++ constructs (containers, pointers to objects, class hierarchies, etc) to SQL so when/if you decide to go the manual schema route, you will have a pretty good idea how to map it back to C++ classes (I assume that's what you meant by "leaning"). Boris From cresanta at me.com Wed Jun 11 17:55:37 2014 From: cresanta at me.com (Bruce Cresanta) Date: Thu Jun 12 04:26:31 2014 Subject: [odb-users] Hand coded schema In-Reply-To: References: <810E531C-FB1B-4172-A35D-5070AD274CA3@me.com> Message-ID: Boris, Hi. Thanks for the reply. I?m just old school. I have a rigorous requirement for any relational system and might need to have a good degree of control. I haven?t totally read-up yet, so I?ll wait to share the specifics later. Thanks, Bruce On Jun 11, 2014, at 6:21 AM, Boris Kolpackov wrote: > Hi Bruce, > > Bruce Cresanta writes: > >> I like to write my schemas by hand. > > You realize you will then have to do schema migration by hand as well > (which is a real PITA)? > > >> What is the best way to do this with ODB? I have a rather large system >> that I?m designing and would like to prove it out before I worry about >> mappings and things of that nature. Any recommendations on how to learn? > > I actually would strongly suggest that you start with automatic schema > generation, at least initially. This will allow you to iterate/prove > your system out much faster since you only need to focus on one thing > (object model design) instead of three things (object model, relational > model, and mapping between the two). You can always keep an eye on the > generate database schema to see if it satisfies your requirements (always > a good idea). Though ODB generates pretty idiomatic SQL (one guy from a > big shop told me their Oracle DBA was quite impressed after seeing ODB- > generated database schema). > > This way you will also learn how ODB maps various C++ constructs > (containers, pointers to objects, class hierarchies, etc) to SQL so > when/if you decide to go the manual schema route, you will have a pretty > good idea how to map it back to C++ classes (I assume that's what you > meant by "leaning"). > > Boris From finjulhich at gmail.com Thu Jun 12 05:19:50 2014 From: finjulhich at gmail.com (MM) Date: Thu Jun 12 05:19:57 2014 Subject: [odb-users] dates and times in sqlite3 Message-ID: Hi, I create a sqlite database through ODB in the C++ world. I use the boost::date_time library. By default, *date* converts to extended iso string like so YYYY-MM-DD, and *time_duration* converts to HH:MM:SS.fffffffff were fff is fractional seconds that are only included if non-zero. For both, the default column type is TEXT. 1. for date, is this compatible with the default pysqlite3 converter for datetime.date ? 2. Is there a pysqlite3 default converter for datetime.time? not datetime.datetime? If so, is it compatible with the time_duration string format above? If not, how do I assign a converter for this database for datetime.time? Rds, From christian.lichtenberger at etm.at Thu Jun 12 05:12:31 2014 From: christian.lichtenberger at etm.at (Lichtenberger, Christian) Date: Thu Jun 12 05:50:17 2014 Subject: [odb-users] Object Model based on Interfaces Message-ID: <6C48D395FE34B94FA716D062240DAB8A272E4652@ATNETS9912TMSX.ww300.siemens.net> Hi I have following class construct: #pragma db object polymorphic class Base { //some base functionality } class IDerived { //define pure virtual functions } #pragma db object class Derived : public Base, public IDerived { //implements virtual functions } How can I archive that following is possible: main() { QSharedPointer db; IDerived derived = new Derived; db->persist(derived); } Thanks! Regards Christian From boris at codesynthesis.com Thu Jun 12 06:02:20 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jun 12 05:59:43 2014 Subject: [odb-users] Object Model based on Interfaces In-Reply-To: <6C48D395FE34B94FA716D062240DAB8A272E4652@ATNETS9912TMSX.ww300.siemens.net> References: <6C48D395FE34B94FA716D062240DAB8A272E4652@ATNETS9912TMSX.ww300.siemens.net> Message-ID: Hi Christian, Lichtenberger, Christian writes: > #pragma db object polymorphic > class Base > { > //some base functionality > } > > class IDerived > { > //define pure virtual functions > } > > #pragma db object > class Derived : public Base, public IDerived > { > //implements virtual functions > } > > How can I archive that following is possible: > > main() > { > QSharedPointer db; > IDerived derived = new Derived; > db->persist(derived); > } To persist via IDerived you would have to make it a persistent object. But ODB does not support multiple inheritance. So the only way is to simplify this somehow into a single inheritance chain (e.g., derive Base from IDerived or the other way around). Boris From boris at codesynthesis.com Thu Jun 12 06:08:42 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jun 12 06:06:03 2014 Subject: [odb-users] dates and times in sqlite3 In-Reply-To: References: Message-ID: Hi, MM writes: > By default, *date* converts to extended iso string like so YYYY-MM-DD, > and *time_duration* converts to HH:MM:SS.fffffffff were fff is fractional > seconds that are only included if non-zero. > > For both, the default column type is TEXT. Yes, SQLite does not have date-time data types. These representations, however, are pretty standard. See this page, for example: http://www.sqlite.org/lang_datefunc.html > 1. for date, is this compatible with the default pysqlite3 converter for > datetime.date? Maybe someone else on the mailing list will be able to answer this, but generally, this mailing list is a wrong place to ask what a Python default converter might do. The relevant Python mailing list would be a much more sensible place. Boris From finjulhich at gmail.com Thu Jun 12 08:19:40 2014 From: finjulhich at gmail.com (MM) Date: Thu Jun 12 08:19:49 2014 Subject: [odb-users] dates and times in sqlite3 In-Reply-To: References: Message-ID: On 12 June 2014 11:08, Boris Kolpackov wrote: > Hi, > > MM writes: > > > By default, *date* converts to extended iso string like so YYYY-MM-DD, > > and *time_duration* converts to HH:MM:SS.fffffffff were fff is fractional > > seconds that are only included if non-zero. > > > > For both, the default column type is TEXT. > > Yes, SQLite does not have date-time data types. These representations, > however, are pretty standard. See this page, for example: > > http://www.sqlite.org/lang_datefunc.html > > > > 1. for date, is this compatible with the default pysqlite3 converter for > > datetime.date? > > Maybe someone else on the mailing list will be able to answer this, > but generally, this mailing list is a wrong place to ask what a Python > default converter might do. The relevant Python mailing list would be a > much more sensible place. > > Boris > I'm sorry I put odb's mailing list in CC rather than in To just for the benefits of others. The email was sent To the author of pysqlite. MM From christian.lichtenberger at etm.at Thu Jun 12 10:23:16 2014 From: christian.lichtenberger at etm.at (Lichtenberger, Christian) Date: Fri Jun 13 04:16:38 2014 Subject: AW: [odb-users] Object Model based on Interfaces In-Reply-To: References: <6C48D395FE34B94FA716D062240DAB8A272E4652@ATNETS9912TMSX.ww300.siemens.net> Message-ID: <6C48D395FE34B94FA716D062240DAB8A272E4840@ATNETS9912TMSX.ww300.siemens.net> I think this should be relatively easy to implement in ODB. All you need is a own object_traits: template <> class WBE_REPOSITORY_EXPORT access::object_traits< ::IDerived > : public access::object_traits< ::Derived > { }; And a cast in the object_traits_impl, which depends on the pointer type First one I have tried, but second is not possible without modifying generated code. One open question is how get the odb compiler the necessary information? #pragma db object #pragma db interface IDerived Class Derived : Base, IDerived { } Or #pragma db interface Class IDerived { } Christian -----Urspr?ngliche Nachricht----- Von: Boris Kolpackov [mailto:boris@codesynthesis.com] Gesendet: Donnerstag, 12. Juni 2014 12:02 An: Lichtenberger, Christian Cc: odb-users@codesynthesis.com Betreff: Re: [odb-users] Object Model based on Interfaces Hi Christian, Lichtenberger, Christian writes: > #pragma db object polymorphic > class Base > { > //some base functionality > } > > class IDerived > { > //define pure virtual functions > } > > #pragma db object > class Derived : public Base, public IDerived { > //implements virtual functions > } > > How can I archive that following is possible: > > main() > { > QSharedPointer db; > IDerived derived = new Derived; > db->persist(derived); > } To persist via IDerived you would have to make it a persistent object. But ODB does not support multiple inheritance. So the only way is to simplify this somehow into a single inheritance chain (e.g., derive Base from IDerived or the other way around). Boris From boris at codesynthesis.com Fri Jun 13 04:55:41 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jun 13 04:53:03 2014 Subject: [odb-users] Object Model based on Interfaces In-Reply-To: <6C48D395FE34B94FA716D062240DAB8A272E4840@ATNETS9912TMSX.ww300.siemens.net> References: <6C48D395FE34B94FA716D062240DAB8A272E4652@ATNETS9912TMSX.ww300.siemens.net> <6C48D395FE34B94FA716D062240DAB8A272E4840@ATNETS9912TMSX.ww300.siemens.net> Message-ID: Hi Christian, Lichtenberger, Christian writes: > I think this should be relatively easy to implement in ODB. It is not. Trust me, I've implemented the single inheritance support ;-). > class WBE_REPOSITORY_EXPORT access::object_traits< ::IDerived > : > public access::object_traits< ::Derived > > > And a cast in the object_traits_impl, which depends on the pointer type Normally, the idea of having something like IDerived is to have multiple implementations. What if you have AnotherDerived? How will this work? Boris From sba at list.ru Wed Jun 18 09:30:15 2014 From: sba at list.ru (=?UTF-8?B?c2JhIHNiYQ==?=) Date: Wed Jun 18 09:30:28 2014 Subject: [odb-users] Status of other ODB Change-Tracking Containers? Message-ID: <1403098215.954302719@f311.i.mail.ru> Hi, Boris! Can you tell the supposed release date of all other Change-Tracking?Tracking containers? I'm mostly interested in odb::map. Thanks. -- sba From boris at codesynthesis.com Thu Jun 19 06:54:53 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jun 19 06:59:15 2014 Subject: [odb-users] Status of other ODB Change-Tracking Containers? In-Reply-To: <1403098215.954302719@f311.i.mail.ru> References: <1403098215.954302719@f311.i.mail.ru> Message-ID: Hi, sba@list.ru writes: > Can you tell the supposed release date of all other Change-Tracking > Tracking containers? I'm mostly interested in odb::map. Generally, we implement support based on demand so there is no firm date for supporting all other change-tracking containers. I could try adding support for odb::map for the next release. Are you willing to beta-test the pre-release? Boris From sba at list.ru Thu Jun 19 08:31:52 2014 From: sba at list.ru (=?UTF-8?B?c2JhIHNiYQ==?=) Date: Thu Jun 19 08:32:00 2014 Subject: =?UTF-8?B?UmVbMl06IFtvZGItdXNlcnNdIFN0YXR1cyBvZiBvdGhlciBPREIgQ2hhbmdl?= =?UTF-8?B?LVRyYWNraW5nIENvbnRhaW5lcnM/?= In-Reply-To: References: <1403098215.954302719@f311.i.mail.ru> Message-ID: <1403181112.511278678@f293.i.mail.ru> Hi! > I could try?adding support for odb::map for the next release. Thanks you. >Are you willing to?beta-test the pre-release? Ok, i'm ready for beta-test. -- sba From abellina at gmail.com Mon Jun 23 00:32:39 2014 From: abellina at gmail.com (Alessandro Bellina) Date: Mon Jun 23 00:32:46 2014 Subject: [odb-users] Custom session example code (in test project) Message-ID: Hello Boris In odb-test, you have a custom session example. I wanted to ask you if you could explain the significance of the flush function, and the mark function. >From the test.hxx code I can see that there is special change tracking code performed to see if an object has changed state (updated() function). From the driver.cxx, I believe that the flush will translate changes detected using updated(), into an .update operation altering the state of the objects. On a commit, you then execute a hook to mark the objects "changed". My question is, if I just want a session that stores objects for me, such that I can find them by key later on... and I don't care about the change tracking, do I need to worry about flushing? Thanks Alessandro From mpendse90 at gmail.com Sun Jun 22 20:42:33 2014 From: mpendse90 at gmail.com (Mihir Pendse) Date: Mon Jun 23 02:42:05 2014 Subject: [odb-users] Strange crash when inheriting a composite id from a polymorphic base class Message-ID: Hi, I have a polymorphic base class which has a composite id; the code snippet is: #pragma db value struct shape_key { double tau; double pi; bool operator==(const shape_key& rhs) const { return ((tau == rhs.tau) && (pi == rhs.pi)); } bool operator<(const shape_key& rhs) const { return ((tau < rhs.tau) && (pi < rhs.pi)); } }; #pragma db object abstract struct shape { int vertices; }; #pragma db object polymorphic pointer(std::shared_ptr) struct parallelogram : public shape { #pragma db id column("") shape_key key; virtual ~parallelogram() {} }; #pragma db value struct triangle { int angles; int sides; }; #pragma db object struct square : public parallelogram { odb::vector triangles; }; On compilation, the compiler crashes with this error: terminate called after throwing an instance of 'cutl::compiler::context::no_entry' what(): N4cutl8compiler7context8no_entryE *** 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 :8:0: /net/binlib/ubuntu/sandy/gcc/lib/odb/odb-2.3/libodb-2.3.0_gcc-4.7.2/include/odb/tr1/pointer-traits.hxx: In member function ?virtual const char* __gnu_cxx::__concurrence_lock_error::what() const?: /net/binlib/ubuntu/sandy/gcc/lib/odb/odb-2.3/libodb-2.3.0_gcc-4.7.2/include/odb/tr1/pointer-traits.hxx:116:1: internal compiler error: Aborted Please submit a full bug report, with preprocessed source if appropriate. See for instructions. The code works if I use a basic data type as the key. I am running the ODB compiler 2.3.0, g++ 4.7.2 on Ubuntu 12.04 x86_64. How do I solve this problem? Regards, Mihir Pendse From boris at codesynthesis.com Mon Jun 23 03:09:10 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 23 03:13:32 2014 Subject: [odb-users] Custom session example code (in test project) In-Reply-To: References: Message-ID: Hi Alessandro, Alessandro Bellina writes: > My question is, if I just want a session that stores objects for me, such > that I can find them by key later on... and I don't care about the change > tracking, do I need to worry about flushing? No, you don't. The interface that should be provided by a custom session is described in Section 11.2, "Custom Sessions". In particular: "The notification functions are called after an object has been persisted, loaded, updated, or erased, respectively. If your session implementation does not need some of the notifications, you still have to provide their functions, however, you can leave their implementations empty." You can also use the default odb::session implementation from libodb as a guide. It only implements the object cache functionality and, as you will see, has most of the notification functions do nothing. BTW, this implementation allows low-level access to the cache (see the "Low-level object cache access (iteration, etc)." section of the class) so maybe you could reuse this implementation. Boris From boris at codesynthesis.com Mon Jun 23 06:03:40 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 23 06:08:02 2014 Subject: [odb-users] Strange crash when inheriting a composite id from a polymorphic base class In-Reply-To: References: Message-ID: Hi Mihir, Mihir Pendse writes: > On compilation, the compiler crashes with this error: That was a bug in the ODB compiler which I have fixed: http://scm.codesynthesis.com/?p=odb/odb.git;a=commit;h=c3cb4c76130950bf461e9f8d802f45e97d4113a1 Thanks for the report and the test case! If you are building the ODB compiler yourself, then you can just apply the above patch, it is quite small. Otherwise, if you would like, I can build you a pre-release binary. Boris From quentindeldycke at gmail.com Tue Jun 24 07:52:50 2014 From: quentindeldycke at gmail.com (Quentin Deldycke) Date: Tue Jun 24 07:52:57 2014 Subject: [odb-users] Problem building query with multiple shared objects Message-ID: 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 Tue Jun 24 08:33:27 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jun 24 08:37:50 2014 Subject: [odb-users] Problem building query with multiple shared objects In-Reply-To: References: Message-ID: Hi Quentin, Quentin Deldycke writes: > odb::query qry(odb::query::objb->obja->valuea == "Test"); ODB only supports one level of indirection in object queries. If you need to do several levels, then you will have to use a view. Views allow you to create an arbitrary-long custom JOIN chain based on object relationships: #pragma db view object(C) object(B) object(A) struct C_View { ... }; odb::query qry(odb::query::A::valuea == "Test"); Boris From quentindeldycke at gmail.com Tue Jun 24 09:08:32 2014 From: quentindeldycke at gmail.com (Quentin Deldycke) Date: Tue Jun 24 09:08:40 2014 Subject: [odb-users] Problem building query with multiple shared objects In-Reply-To: References: Message-ID: Hi Boris, Firstly, thanks for your fast and helpfull answer. Sadly, this solution is not the best for me, but i think it will be ok. I will create a view containing only the members of my query (3-4 out of 25+ fields) + the id of the "root" object. Then, I will be able to use this id to regenerate a complete object if needed. Thanks for your help! -- Deldycke Quentin On 24 June 2014 14:33, Boris Kolpackov wrote: > Hi Quentin, > > Quentin Deldycke writes: > > > odb::query qry(odb::query::objb->obja->valuea == "Test"); > > ODB only supports one level of indirection in object queries. If > you need to do several levels, then you will have to use a view. > Views allow you to create an arbitrary-long custom JOIN chain > based on object relationships: > > #pragma db view object(C) object(B) object(A) > struct C_View > { > ... > }; > > odb::query qry(odb::query::A::valuea == "Test"); > > Boris > From boris at codesynthesis.com Wed Jun 25 03:33:43 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jun 25 03:38:06 2014 Subject: [odb-users] Problem building query with multiple shared objects In-Reply-To: References: Message-ID: Hi Quentin, Quentin Deldycke writes: > Sadly, this solution is not the best for me, but i think it will be ok. > > I will create a view containing only the members of my query (3-4 out of > 25+ fields) + the id of the "root" object. Then, I will be able to use this > id to regenerate a complete object if needed. Firstly, you don't need to have members in the view in order to be able to use them in the query -- all the members from all the associated objects can always be used. Secondly, yes, I agree, if you need the object then this solution is not ideal. In fact, there is a plan to add support for "object-loading views" that instead of loading specific members will load the whole object. Boris From cresanta at me.com Sun Jun 29 23:48:12 2014 From: cresanta at me.com (Bruce Cresanta) Date: Mon Jun 30 03:54:05 2014 Subject: [odb-users] Dumping Persistent Objects Message-ID: <754CE4E9-8D76-42A2-8EEE-1D446858FA0F@me.com> Boris, I have a project for ODB and I need to erase, not truncate, persistent objects like tables and views and regenerate them on the fly with key calculations changed. Also read that you can base a view on a database view. I need to do this too to get a firehose cursor of several views. I could do a select into and write the views as persistent objects, but I have 12 million records. Wondered how ODB handles indexes? Bruce From boris at codesynthesis.com Mon Jun 30 05:38:57 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 30 05:43:44 2014 Subject: [odb-users] Dumping Persistent Objects In-Reply-To: <754CE4E9-8D76-42A2-8EEE-1D446858FA0F@me.com> References: <754CE4E9-8D76-42A2-8EEE-1D446858FA0F@me.com> Message-ID: Hi Bruce, Bruce Cresanta writes: > I have a project for ODB and I need to erase, not truncate, persistent > objects like tables and views and regenerate them on the fly with key > calculations changed. You mean you need to re-create the database schema? This is possible, see Section 3.4, "Database" and Chapter 13, "Database Schema Evolution". > Also read that you can base a view on a database view. I need to do > this too to get a firehose cursor of several views. I could do a > select into and write the views as persistent objects, but I have > 12 million records. Not sure what the question is here. To base an ODB view on a database view you would use the ODB Table Views (Section 10.2). > Wondered how ODB handles indexes? Section 14.7, "Index Definition Pragmas". Boris From frankiegp at libero.it Mon Jun 30 13:23:30 2014 From: frankiegp at libero.it (frankiegp@libero.it) Date: Mon Jul 14 09:27:17 2014 Subject: [odb-users] ODB without persistent objects? Message-ID: <652564741.2762121404149010724.JavaMail.defaultUser@defaultHost> Hi to everybody, I would like to know whether I could exploit ODB Query functionalities without creating any C++ classes to be mapped to the tables of a database. I mean: - I have an existent database managed by a hypothetical DBMS (one among PostgreSQL, MySQL, Oracle, SQLServer and so on); - I would like to query my database without taking care of the specific dialect of the DBMS. In other words, I would like to write my queries in some high-level languages (pseudo-sql) and then I would like that my query would be rewritten by ODB in the SQL-dialect of the specific DBMS. Is it possible? Thank you for your consideration, looking forward to your kind reply. Best, Pierfrancesco