From asnagni at yahoo.com Mon Jan 1 04:39:37 2018 From: asnagni at yahoo.com (Alain-SergeNagni) Date: Mon Jan 1 04:39:59 2018 Subject: [odb-users] Issue with Section Message-ID: <8BEC309C-8A54-4212-ADDE-B3652E5F6E25@yahoo.com> Hi Boris, We are having some issues with section. We experiencing some random crashes. Would you have a beta release that we can download to fix the issue? Thank you, Alain-Serge Sent from my iPad From boris at codesynthesis.com Mon Jan 1 06:39:42 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jan 1 06:39:54 2018 Subject: [odb-users] Issue with Section In-Reply-To: <8BEC309C-8A54-4212-ADDE-B3652E5F6E25@yahoo.com> References: <8BEC309C-8A54-4212-ADDE-B3652E5F6E25@yahoo.com> Message-ID: Alain-SergeNagni writes: > We are having some issues with section. We experiencing some random > crashes. Would you have a beta release that we can download to fix > the issue? Please try the latest pre-release: https://codesynthesis.com/~boris/tmp/odb/pre-release/b.3/ Boris From asnagni at yahoo.com Mon Jan 1 07:17:54 2018 From: asnagni at yahoo.com (Alain-Serge Nagni) Date: Mon Jan 1 07:18:16 2018 Subject: [odb-users] Issue with Section In-Reply-To: References: <8BEC309C-8A54-4212-ADDE-B3652E5F6E25@yahoo.com> Message-ID: <9ED262D5-C132-4D1D-A16A-7DDD500656CC@yahoo.com> Hi Boris, Thank you for this quick reply. I do appreciate that. Thank you, Alain-Serge > On Jan 1, 2018, at 6:39 AM, Boris Kolpackov wrote: > > Alain-SergeNagni writes: > >> We are having some issues with section. We experiencing some random >> crashes. Would you have a beta release that we can download to fix >> the issue? > > Please try the latest pre-release: > > https://codesynthesis.com/~boris/tmp/odb/pre-release/b.3/ > > Boris From asnagni at yahoo.com Mon Jan 1 12:14:23 2018 From: asnagni at yahoo.com (Alain-SergeNagni) Date: Mon Jan 1 12:14:45 2018 Subject: [odb-users] New Release 2.5.0 features Message-ID: <759D198A-8CEF-4C9E-B7E5-A24945701A81@yahoo.com> Hi Boris, Do you have a list of the new features you are planing for the next release 2.5 .0 ? Where could we have that list? Will it be possible to query containers as data members (e.g.: vector) ? Would you have additional containers change-tracking for performance improvement ? Thank you, Alain-Serge Sent from my iPad From boris at codesynthesis.com Fri Jan 5 08:35:36 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 5 08:35:54 2018 Subject: [odb-users] New Release 2.5.0 features In-Reply-To: <759D198A-8CEF-4C9E-B7E5-A24945701A81@yahoo.com> References: <759D198A-8CEF-4C9E-B7E5-A24945701A81@yahoo.com> Message-ID: Alain-SergeNagni writes: > Do you have a list of the new features you are planing for the next > release 2.5 .0 ? Where could we have that list? It's in the usual place, the NEWS file in the ODB compiler: https://git.codesynthesis.com/cgit/odb/odb/tree/NEWS > Will it be possible to query containers as data members (e.g.: vector) ? This feature is on our TODO though it is very complex so I don't think it will make it into this release. > Would you have additional containers change-tracking for performance > improvement? Not likely. Change-tracking containers are not exactly trivial to implement, especially if you want to do this efficiently. On the other hand, if you make some application-specific assumptions (e.g., elements are never removed) or accept some inefficiency, then an application- specific implementation can be provided relatively easily. I suggest that you study the ODB's implementation of vector to get a sense. Boris From vladimir.yelnikov at gmail.com Fri Jan 12 12:54:49 2018 From: vladimir.yelnikov at gmail.com (Vladimir Yelnikov) Date: Sat Jan 13 01:27:48 2018 Subject: [odb-users] How to define odb::section for a member defined in base class Message-ID: Hi All, I would like to declare a derived class demo2 with section tied with base member data but ODB compiler can't generate proper code with error pointing last pragma: error: ')' expected at the end of db pragma section Everything works if section and member defined in the same class. struct demo { std::deque data; }; struct demo2 : public demo { int id; odb::section dataSection; }; #pragma db object(demo) definition abstract #pragma db object(demo2) #pragma db member(demo2::id) id #pragma db member(demo2::dataSection) load(lazy) #pragma db member(demo2::data) type("BLOB") section(demo2::dataSection) Is it possible to make things work? -- Best Wishes, Vladimir Yelnikov From boris at codesynthesis.com Sat Jan 13 08:03:38 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sat Jan 13 08:03:59 2018 Subject: [odb-users] How to define odb::section for a member defined in base class In-Reply-To: References: Message-ID: Vladimir Yelnikov writes: > I would like to declare a derived class demo2 with section tied with > base member data but ODB compiler can't generate proper code with > error pointing last pragma: > > error: ')' expected at the end of db pragma section > > [...] > > #pragma db member(demo2::data) type("BLOB") section(demo2::dataSection) Quoting the manual (emphasis added): "The section specifier indicates that a data member of a persistent class belongs to an object section. The single required argument to this specifier is the name of the section data member. This specifier can only be used on *direct data members* of a persistent class." > Is it possible to make things work? You can use a virtual data member: #include #include struct demo { typedef std::deque data_type; data_type data; int dummy; }; struct demo2 : public demo { int id; odb::section dataSection; }; #pragma db object(demo) definition abstract #pragma db member(demo::data) transient #pragma db object(demo2) #pragma db member(demo2::id) id #pragma db member(demo2::dataSection) load(lazy) #pragma db member(demo2::data_) virtual(demo::data_type) access(data) type("BLOB") section(dataSection) Note that I've added a dummy non-transient data member to demo. If it only needs to contain data, then you can make the whole demo class a transient base (i.e., simply don't declare it as persistent). Boris From vladimir.yelnikov at gmail.com Sat Jan 13 10:17:59 2018 From: vladimir.yelnikov at gmail.com (Vladimir Yelnikov) Date: Sun Jan 14 04:21:01 2018 Subject: [odb-users] How to define odb::section for a member defined in base class In-Reply-To: References: Message-ID: Thank you, works like a charm. 2018-01-13 15:03 GMT+02:00 Boris Kolpackov : > Vladimir Yelnikov writes: > > > I would like to declare a derived class demo2 with section tied with > > base member data but ODB compiler can't generate proper code with > > error pointing last pragma: > > > > error: ')' expected at the end of db pragma section > > > > [...] > > > > #pragma db member(demo2::data) type("BLOB") section(demo2::dataSection) > > Quoting the manual (emphasis added): > > "The section specifier indicates that a data member of a persistent class > belongs to an object section. The single required argument to this > specifier > is the name of the section data member. This specifier can only be used on > *direct data members* of a persistent class." > > > > Is it possible to make things work? > > You can use a virtual data member: > > #include > #include > > struct demo > { > typedef std::deque data_type; > data_type data; > > int dummy; > }; > > struct demo2 : public demo > { > > int id; > odb::section dataSection; > }; > > #pragma db object(demo) definition abstract > #pragma db member(demo::data) transient > > #pragma db object(demo2) > #pragma db member(demo2::id) id > #pragma db member(demo2::dataSection) load(lazy) > #pragma db member(demo2::data_) virtual(demo::data_type) access(data) > type("BLOB") section(dataSection) > > Note that I've added a dummy non-transient data member to demo. If it > only needs to contain data, then you can make the whole demo class a > transient base (i.e., simply don't declare it as persistent). > > Boris > -- Best Wishes, Vladimir Yelnikov From franchouze at gmail.com Mon Jan 15 05:05:33 2018 From: franchouze at gmail.com (Fanch Fanch) Date: Mon Jan 15 05:06:06 2018 Subject: [odb-users] How to handle column based rights in ODB Message-ID: Hi All, I have a table in my DB that handles rights at the column level.Therefore, for users who do not have read rights on all coumns, when querying with ODB I get a "permission denied" error which is expected. So I woiuld like to perform something like SELECT my_col FROM my_table .... ; instead of SELECT * FROM my_table ...; What is the best way to handle this using odb ? Thanks for your help, Fran?ois From boris at codesynthesis.com Tue Jan 16 07:21:02 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 16 07:21:33 2018 Subject: [odb-users] How to handle column based rights in ODB In-Reply-To: References: Message-ID: Fanch Fanch writes: > I have a table in my DB that handles rights at the column level.Therefore, > for users who do not have read rights on all coumns, when querying with ODB > I get a "permission denied" error which is expected. > > So I woiuld like to perform something like > > SELECT my_col FROM my_table .... ; instead of SELECT * FROM my_table ...; > > What is the best way to handle this using odb ? ODB views. Boris From franchouze at gmail.com Wed Jan 17 04:19:50 2018 From: franchouze at gmail.com (=?UTF-8?B?RnJhbsOnb2lz?=) Date: Wed Jan 17 04:20:35 2018 Subject: [odb-users] How to handle column based rights in ODB In-Reply-To: References: Message-ID: Hi Boris, Thank you for your answer. My question was not precise enough because I may have to also update those fields. Whereas some postgreSQL views (under some conditions) can be updated, in the ODB documentation, it is written that ODB views are read only. I think I may need to change the design of my table and share columns into several tables. Each table will have different read/write user rights. 2018-01-16 13:21 GMT+01:00 Boris Kolpackov : > Fanch Fanch writes: > > > I have a table in my DB that handles rights at the column > level.Therefore, > > for users who do not have read rights on all coumns, when querying with > ODB > > I get a "permission denied" error which is expected. > > > > So I woiuld like to perform something like > > > > SELECT my_col FROM my_table .... ; instead of SELECT * FROM my_table > ...; > > > > What is the best way to handle this using odb ? > > ODB views. > > Boris > From liort at checkpoint.com Thu Jan 18 11:40:29 2018 From: liort at checkpoint.com (Lior Tamim) Date: Fri Jan 19 02:03:00 2018 Subject: [odb-users] Table view with inner join Message-ID: Hi, I'm trying to generate a table view with inner join, and cannot compile it (probably wrong syntax, cannot understand where the 'inner' keyword should fit). Where can I find an example of table view (#pragma db table view) that contains an inner join condition? Thanks, Lior From liorta at gmail.com Fri Jan 19 06:36:52 2018 From: liorta at gmail.com (Lior Tamim) Date: Fri Jan 19 07:18:34 2018 Subject: [odb-users] Defining a table view with inner join Message-ID: Suppose I have 2 database tables: CREATE TABLE developers( employee_id INTEGER, employee_name TEXT) CREATE TABLE new_employees( id INTEGER, age INTEGER) I wish to define a table view that contains all the *new developers*. With simple SQL query this can be achieved easily by using inner join: "select * from developers inner join new_employees on developers.employee_id == new_employees.id" What's the best way to achieve this with table view pragma? #pragma db view table("developers" ...) // not sure how to continue this statement struct new_developers { #pragma db column("employee_name") type("TEXT") std::string employee_name; } Thanks, Lior From boris at codesynthesis.com Fri Jan 19 07:26:52 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 19 07:27:04 2018 Subject: [odb-users] Defining a table view with inner join In-Reply-To: References: Message-ID: Lior Tamim writes: > Suppose I have 2 database tables: > > CREATE TABLE developers( > employee_id INTEGER, > employee_name TEXT) > > CREATE TABLE new_employees( > id INTEGER, > age INTEGER) > > I wish to define a table view that contains all the *new developers*. > > With simple SQL query this can be achieved easily by using inner join: > "select * from developers inner join new_employees on > developers.employee_id == new_employees.id" > > What's the best way to achieve this with table view pragma? > > #pragma db view table("developers" ...) // not sure how to continue this Section 10.3, "Table Views" in the manual deals with this pretty comprehensively, including an example that does pretty much exactly this (sans the inner join, but it should be fairly clear where to put it from the general format discussed a couple of paragraphs above). From liorta at gmail.com Sun Jan 21 01:40:18 2018 From: liorta at gmail.com (Lior Tamim) Date: Sun Jan 21 09:34:05 2018 Subject: [odb-users] Defining a table view with inner join In-Reply-To: References: Message-ID: I followed the manual and ended up with this: #pragma db view table("developers") table("new_employees" inner: "developers.employee_id" == "new_employees.id") But odb compilation fails on the 'inner' keyword: error: ')' expected at the end of db pragma table I'm not sure why, because this statement follows the same rules as this one (from the manual): #pragma db view object(employer) object(country inner: employer::name == country::name) What am I missing? On Fri, Jan 19, 2018 at 2:26 PM, Boris Kolpackov wrote: > Lior Tamim writes: > > > Suppose I have 2 database tables: > > > > CREATE TABLE developers( > > employee_id INTEGER, > > employee_name TEXT) > > > > CREATE TABLE new_employees( > > id INTEGER, > > age INTEGER) > > > > I wish to define a table view that contains all the *new developers*. > > > > With simple SQL query this can be achieved easily by using inner join: > > "select * from developers inner join new_employees on > > developers.employee_id == new_employees.id" > > > > What's the best way to achieve this with table view pragma? > > > > #pragma db view table("developers" ...) // not sure how to continue this > > Section 10.3, "Table Views" in the manual deals with this pretty > comprehensively, including an example that does pretty much > exactly this (sans the inner join, but it should be fairly > clear where to put it from the general format discussed a > couple of paragraphs above). > From boris at codesynthesis.com Sun Jan 21 09:36:53 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Sun Jan 21 09:37:12 2018 Subject: [odb-users] Defining a table view with inner join In-Reply-To: References: Message-ID: Lior Tamim writes: > #pragma db view table("developers") table("new_employees" inner: > "developers.employee_id" == "new_employees.id") > > But odb compilation fails on the 'inner' keyword: > error: ')' expected at the end of db pragma table What version of ODB are you using? The join types were added in 2.4.0. Boris From liorta at gmail.com Sun Jan 21 09:51:31 2018 From: liorta at gmail.com (Lior Tamim) Date: Mon Jan 22 07:14:06 2018 Subject: [odb-users] Defining a table view with inner join In-Reply-To: References: Message-ID: I see. I'm using 2.1.1, I'll upgrade. Thanks a lot. On Sun, Jan 21, 2018 at 4:36 PM, Boris Kolpackov wrote: > Lior Tamim writes: > > > #pragma db view table("developers") table("new_employees" inner: > > "developers.employee_id" == "new_employees.id") > > > > But odb compilation fails on the 'inner' keyword: > > error: ')' expected at the end of db pragma table > > What version of ODB are you using? The join types were added in 2.4.0. > > Boris > From javier.gutierrez at web.de Thu Jan 25 07:06:20 2018 From: javier.gutierrez at web.de (Javier Gutierrez) Date: Thu Jan 25 07:06:59 2018 Subject: [odb-users] Unit-testing odb::result Message-ID: <3a3eb004-90e2-712c-3277-01a160f016c9@web.de> Hi there, first of all thank you very much for the great job. I am in the process of unit-testing a function that calls a method that returns odb::result. So basically what I want is to mock that method and to return instead my own version of an odb::result object pointing to a couple of made-up MyClassTable objects. I have tried to create my own version of odb::result by inheriting from the template odb::view_result_impl, but can't figure out how to go further. I analyzed the possibility to return std::vector instead of odb::result and to convert from odb::result to std::vector in the real method, but obviously that's an overkill.. Would you mind giving me any hints that points me to the right direction ? Thanks a lot in advance, Javier From boris at codesynthesis.com Fri Jan 26 08:53:21 2018 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jan 26 08:53:57 2018 Subject: [odb-users] Unit-testing odb::result In-Reply-To: <3a3eb004-90e2-712c-3277-01a160f016c9@web.de> References: <3a3eb004-90e2-712c-3277-01a160f016c9@web.de> Message-ID: Javier Gutierrez writes: > first of all thank you very much for the great job. Thanks, I am glad you are enjoying it. > I am in the process of unit-testing a function that calls a method that > returns odb::result. > So basically what I want is to mock that method and to return instead my own > version of an odb::result object pointing to a couple of made-up > MyClassTable objects. > I have tried to create my own version of odb::result by inheriting from the > template odb::view_result_impl, but can't figure out how to go further. You would need to implement its virtual interface to load objects from, say, a vector instead of the database: virtual void load (object_type&, bool fetch = true) = 0; virtual id_type load_id () = 0; virtual void next () = 0; virtual void cache () = 0; virtual std::size_t size () = 0; > I analyzed the possibility to return std::vector instead of odb::result and > to convert from odb::result to std::vector in the real method, but obviously > that's an overkill.. Yes, if I were to go this direction, then I would make my code accept a container template rather than odb::result<> so that I can call it either with that or std::vector<>. The iteration interface in odb::result<> is intentionally std-compatible to allow such generic code. Boris