From icewill9999 at vip.qq.com Mon Jul 5 22:24:06 2021 From: icewill9999 at vip.qq.com (=?gb18030?B?srvD99Xmz+A=?=) Date: Tue Jul 6 08:33:19 2021 Subject: [odb-users] field 'extra_' has incomplete type 'odb::section' Message-ID: Hi all, I was trying to migrate my project from odb 2.4.0 to odb 2.5.0, when I use the odb compiler I got the error message: odb -d mysql -q --std c++11 --default-pointer std::shared_ptr  -p "boost/date-time" -I "E:\newsdbdev\include\boost\boost1630" -I "C:\odb\release\include"    baseinfo.hxx baseinfo.hxx:564:18: error: field 'extras_' has incomplete type 'odb::section'   564 |     odb::section extras_;       |                  ^~~~~~~ In file included from C:\odb\release\include/odb/core.hxx:16,                  from baseinfo.hxx:19: C:\odb\release\include/odb/forward.hxx:38:9: note: forward declaration of 'class odb::section'    38 |   class section; the section is defined just as the ODB manual described , and it works fine in ODB 2.4.0.  const odb::section& extras_section() const { return extras_; }     odb::section& extras_section() { return extras_; }     const odb::nullable References: Message-ID: writes: > baseinfo.hxx:564:18: error: field 'extras_' has incomplete type > 'odb::section' Does baseinfo.hxx #include ? From icewill9999 at vip.qq.com Wed Jul 7 01:49:54 2021 From: icewill9999 at vip.qq.com (=?gb18030?B?srvD99Xmz+A=?=) Date: Thu Jul 8 09:26:45 2021 Subject: [odb-users] field 'extra_' has incomplete type 'odb::section' In-Reply-To: References: Message-ID: thx Boris, the inclusion fix the problem. The migration to odb 2.5.0 makes a bunch of problems that i have to fix, right now  the problem that i am trying to solve is below: link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /DLL /SUBSYSTEM:WINDOWS /MANIFEST:embed /OUT:..\..\..\newsdbdev\bin\news_ndbbase_vc2015d_64.dll @E:\newsdbdev\bin\news_ndbbase_vc2015d_64.dll.3304.70969.jom   ????? ..\..\..\newsdbdev\bin\news_ndbbase_vc2015d_64.lib ??? ..\..\..\newsdbdev\bin\news_ndbbase_vc2015d_64.exp odb.lib(statement-processing.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb.lib(connection.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb.lib(prepared-query.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb-mysql.lib(exceptions.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb-mysql.lib(options.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb-mysql.lib(error.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb-boost.lib(exceptions.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb-mysql.lib(statement.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb-mysql.lib(transaction-impl.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb-mysql.lib(connection.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb-mysql.lib(connection-factory.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb.lib(base.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb.lib(result.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb-mysql.lib(query.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb-mysql.lib(database.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb.lib(transaction.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb.lib(exceptions.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb.lib(database.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb.lib(tracer.lib.obj) : error LNK2001: ????????? __CxxFrameHandler4 odb.lib(connection.lib.obj) : error LNK2001: ????????? __GSHandlerCheck_EH4 odb-mysql.lib(connection-factory.lib.obj) : error LNK2001: ????????? __GSHandlerCheck_EH4 odb-mysql.lib(exceptions.lib.obj) : error LNK2001: ????????? __GSHandlerCheck_EH4 odb-mysql.lib(options.lib.obj) : error LNK2001: ????????? __GSHandlerCheck_EH4 odb-mysql.lib(error.lib.obj) : error LNK2001: ????????? __GSHandlerCheck_EH4 odb.lib(exceptions.lib.obj) : error LNK2001: ????????? __GSHandlerCheck_EH4 odb-mysql.lib(query.lib.obj) : error LNK2001: ????????? __GSHandlerCheck_EH4 odb-mysql.lib(database.lib.obj) : error LNK2001: ????????? __GSHandlerCheck_EH4 odb-mysql.lib(connection.lib.obj) : error LNK2001: ????????? __GSHandlerCheck_EH4 odb-mysql.lib(connection-factory.lib.obj) : error LNK2019: ????????? __dyn_tls_on_demand_init??????? "public: virtual class odb::details::shared_ptr Hi, At my company I'm in charge of writing a payment processor in C++. One of the things I have to do is use ODB to store a list of Exchange (financial store of value) entities in the database. We have Exchange entity defined as an "id" std::string, a "type" int, a "lastpingtime" string, and we have a map container that maps the string UUID of a PaymentMethod (aka. "Coin") to a boolean to indicate whether the Exchange supports it, like so: class ExchangeSchema: public Schema { public: ExchangeSchema(); const std::string& get_id() const; void set_id(const std::string&); const unsigned short get_type() const; void set_type(const unsigned short); const std::string& get_lastpingtime() const; void set_lastpingtime(const std::string&); private: std::string id_; unsigned short type_; std::string lastpingtime_; std::map coin_supported_map_; }; #pragma db object(ExchangeSchema) #pragma db member(ExchangeSchema::id_) id We need the ability to query the database for Exchanges by whether they are supported by a PaymentMethod by checking the UUID string key against its boolean value. However, I am not quite sure how to accomplish this. According to an old post https://odb-users.codesynthesis.narkive.com/CPkFAOWx/querying-entity-s-container , ODB's query language doesn't support container members. Is this still the case? So a query like the below, for example, won't work? typedef odb::query ExchangeQuery; ... q = ExchangeQuery(ExchangeQuery::coin_supported()[uuid_string] == true); I am trying to follow the resolution in the linked post, which is to make an "image" object followed by an object loading view. Is the following image object correct syntax? Mainly, I am concerned that I'm using the wrong type for the custom (string) key of this entity. #pragma db object table("exchange_coinsupport") no_id abstract struct exchange_coinsupport { std::string id; unsigned short type; std::string lastpingtime; }; Also, the following object loading view corresponds to it? #pragma db view object(ExchangeSchema) object(exchange_coinsupport = coin_support) \ query(distinct) struct exchange_view // I would use this in odb::query { std::chared_ptr p; }; Thanks for your time. - Ali From boris at codesynthesis.com Thu Jul 15 08:12:37 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 15 08:11:39 2021 Subject: [odb-users] How to query entity by map container member? In-Reply-To: References: Message-ID: Ali Sherief writes: > class ExchangeSchema: public Schema { > > [...] > > std::string id_; > unsigned short type_; > std::string lastpingtime_; > std::map coin_supported_map_; > }; > > #pragma db object(ExchangeSchema) > #pragma db member(ExchangeSchema::id_) id > > We need the ability to query the database for Exchanges by whether they > are supported by a PaymentMethod by checking the UUID string key against > its boolean value. > > According to an old post [...] , ODB's query language doesn't support > container members. Is this still the case? Yes, that's still the case. > So a query like the below, for example, won't work? > > typedef odb::query ExchangeQuery; > ... > q = ExchangeQuery(ExchangeQuery::coin_supported()[uuid_string] == true); No, there is no such syntax in the ODB query language. > I am trying to follow the resolution in the linked post, which is to > make an "image" object followed by an object loading view. That's one way to do it. In this case I would personally change the data model a bit so that I could express such queries directly with views. Specifically, I would make various supported payment methods a persistent object and then would replace the map with a vector of pointers to supported payment methods: class Coin { std::string uuid; }; class ExchangeSchema: public Schema { ... std::vector> coin_supported_; }; Then you should be able to create a view over these two object that will allow you to express the above query condition without image objects. > Is the following image object correct syntax? Mainly, I am concerned that > I'm using the wrong type for the custom (string) key of this entity. Check the resulting database schema of the two objects -- if they match, then you are using compatible types. From icewill9999 at vip.qq.com Wed Jul 21 04:12:36 2021 From: icewill9999 at vip.qq.com (=?gb18030?B?srvD99Xmz+A=?=) Date: Wed Jul 21 07:16:29 2021 Subject: [odb-users] constuct lazy_ptr with a given id Message-ID: Hi, From the ODB manual, the lazy_ptr could be constructed using the given id // Initialization with a persistent unloaded object. // template References: Message-ID: icewill9999@vip.qq.com writes: > // Initialization with a persistent unloaded object. > // template lazy_ptr (database&, const ID&); > > I tried the code below, > odb::database* db = /////; > int aid = ////; > lazy_shared_ptr aodbPtr(db, aid); > But the compiler reports the error messages: > > [...] > > Did I call this function a wrong way? Yes, most likely. In particular, the constructor expects a reference to database while you are passing a pointer. You need to start paying attention instead of using this mailing list as an easy way (for you) to fix your programming errors. In fact, I will no longer be answering such queries from you. From awalters at spsy.com Mon Jul 26 20:46:45 2021 From: awalters at spsy.com (Adam Walters) Date: Tue Jul 27 04:50:53 2021 Subject: [odb-users] Encapsulating ODB Message-ID: Hi, I am looking at using ODB in a Windows application that has multiple projects. I would like to create a database layer that encapsulates the database 'magic' and thus hides the implementation from the projects that consume the services. Although ODB encapsulates the database code, the classes used for persistence have to reference the ODB includes so that the pragmas and other references compile. I looked at the polymorphic options but there doesn't seem to be a way to (for example) derive the persisted class from a non-persisted one. This would allow me to create the persisted entities as pointers to base class objects that did not reference any ODB code and thus consume the objects in other projects without having to reference the ODB code. This is obviously better than having a parallel set of business objects and copying the data between these and the persisted class objects. Does anyone have a suggestion as to how I can achieve this or am I stuck with referencing ODB include paths in all of the projects that use the database classes? Thanks, Adam From boris at codesynthesis.com Tue Jul 27 09:38:47 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jul 27 09:37:41 2021 Subject: [odb-users] Encapsulating ODB In-Reply-To: References: Message-ID: Adam Walters writes: > Although ODB encapsulates the database code, the classes used for > persistence have to reference the ODB includes so that the pragmas > and other references compile. You can move the pragmas (and any ODB #include's that they require) to a separate file or #ifdef them out using the ODB_COMPILER macro. The introduction to Chapter 14, "ODB Pragma Language" has all the details: https://codesynthesis.com/products/odb/doc/manual.xhtml#14 Of course that also means you persistent classes won't be able to use some of the ODB feature that depend on types (and thus headers) provided by ODB, such as lazy pointers, change-tracking contains, and sections. From awalters at spsy.com Tue Jul 27 12:23:03 2021 From: awalters at spsy.com (Adam Walters) Date: Tue Jul 27 12:35:23 2021 Subject: [odb-users] Encapsulating ODB In-Reply-To: References: Message-ID: Thanks Boris, After some playing around with your 'Hello World" sample, I was able to accomplish what I needed (I had tried this originally but had failed to change one of the references to the original class and assumed that the reams of obscure compiler errors meant it wasn't possible). I ended up creating an abstract base class from which the persistent class derives. The base class has accessor methods for the data members of interest and these are overridden in the derived class to provide the access. Users of the data access layer can instantiate a persistent object through a static factory method in the base class and obtain it as a pointer to the base class (thus avoiding any need to include any of the ODB headers). Once the object has been filled in, it can be persisted by a call to an overloaded method in the base class that calls the database code in the derived class. I haven't fully implemented this yet but I am confident from the test application I have written that it should work. Best regards, Adam Walters -----Original Message----- From: Boris Kolpackov Sent: Tuesday, July 27, 2021 6:39 AM To: Adam Walters Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Encapsulating ODB CAUTION: This email originated from outside your organization. Exercise caution when opening attachments or clicking links, especially from unknown senders. Adam Walters writes: > Although ODB encapsulates the database code, the classes used for > persistence have to reference the ODB includes so that the pragmas and > other references compile. You can move the pragmas (and any ODB #include's that they require) to a separate file or #ifdef them out using the ODB_COMPILER macro. The introduction to Chapter 14, "ODB Pragma Language" has all the details: https://codesynthesis.com/products/odb/doc/manual.xhtml#14 Of course that also means you persistent classes won't be able to use some of the ODB feature that depend on types (and thus headers) provided by ODB, such as lazy pointers, change-tracking contains, and sections. From bibhudutta_barik at baxter.com Wed Jul 28 10:09:05 2021 From: bibhudutta_barik at baxter.com (Barik, Bibhudutta) Date: Wed Jul 28 10:26:46 2021 Subject: [odb-users] Getting error while generating database support code using ODB. Message-ID: Hello, I am getting error while generating database support code using ODB. Below is the error after putting this command. Need support to resolve this error. [cid:image001.jpg@01D783E8.370D7880] Thanks -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 51527 bytes Desc: image001.jpg Url : https://codesynthesis.com/pipermail/odb-users/attachments/20210728/2c67bb3b/image001-0001.jpg From boris at codesynthesis.com Wed Jul 28 10:44:34 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Jul 28 10:43:27 2021 Subject: [odb-users] Getting error while generating database support code using ODB. In-Reply-To: References: Message-ID: Barik, Bibhudutta writes: > I am getting error while generating database support code using ODB. > Below is the error after putting this command. > [cid:image001.jpg@01D783E8.370D7880] Please don't send error messages as images (or any other attachments). Rather, include the text of the error in the email directly. See Posting Guidelines for details: https://codesynthesis.com/support/posting-guidelines.xhtml The error you are getting has to do with the (old) GCC that is bundled with the ODB 2.4.0 release being no longer compatible with your (newer) OS. In the upcoming release of ODB we are moving away from bundling GCC with ODB instead using the system- provided version. Could you try the following setup instructions for the 2.5.0 pre-release and see if it helps: https://codesynthesis.com/products/odb/doc/install-build2.xhtml From Carsten.Behling at wiesheu.de Thu Jul 29 09:55:57 2021 From: Carsten.Behling at wiesheu.de (Behling Carsten) Date: Thu Jul 29 11:01:11 2021 Subject: [odb-users] C++11 To-Many Relationship using std::shared_ptr>> Message-ID: <1627566957198.72356@Wiesheu.de> Hi, I'm having a To-Many Relationship : OvenData ----*>ProgramData using C++11 containers and smart pointers This worked fine until I changed the relationship using a std::shared_ptr to the std::vetor: std::vector> programs_; to std::shared_ptr>> programs_; Persistent data file excerpt: ... namespace dal { #pragma db object pointer(std::shared_ptr) session #pragma db object table("programs") class ProgramData { ... std::string program_name_; ... } ... #pragma db object pointer(std::shared_ptr) session #pragma db object table("ovens") class OvenData { ... #pragma db value_not_null unordered std::shared_ptr>> programs_; }; ... and ODB compiler crashes: ... ocbe@debian:~/projects/5446/bakingsystem/src/dal$ cd /home/kocbe/projects/5446/bakingsystem/src/dal && /usr/bin/odb -x -dH -d sqlite --generate-query --generate-session --generate-schema --std c++11 --output-dir /home/kocbe/projects/5446/build-bakingsystem-Desktop_Qt_5_12_8_GCC_64bit-Debug/src/dal/odb_gen --hxx-suffix .h --ixx-suffix _inline.h --cxx-suffix .cpp --odb-file-suffix _odb -I/usr/include BakingSystemData.h *** 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 /usr/include/odb/container-traits.hxx:217:0, from :9: /usr/include/odb/std-unordered-set-traits.hxx:122:1: internal compiler error: Segmentation fault } ^ g++: internal compiler error: Aborted (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See for instructions. ... Backtrace: ... Program terminated with signal SIGABRT, Aborted. #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 #1 0x00007fdc37c3142a in __GI_abort () at abort.c:89 #2 0x000000000113ba8b in diagnostic_action_after_output(diagnostic_context*, diagnostic_t) () #3 0x000000000113bd0e in diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) () #4 0x000000000113d20e in internal_error(char const*, ...) () #5 0x0000000000ad3fb0 in ?? () #6 #7 0x00000000011aa60d in __dynamic_cast () #8 0x00007fdc370c2358 in ?? () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #9 0x00007fdc37076a66 in cutl::compiler::dispatcher::dispatch(semantics::node&) () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #10 0x00007fdc37077586 in cutl::compiler::dispatcher::dispatch(semantics::edge&) () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #11 0x00007fdc370702e6 in traversal::scope_template::names(semantics::class_&, cutl::compiler::dispatcher&) () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #12 0x00007fdc370c9a1f in ?? () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #13 0x00007fdc37076a66 in cutl::compiler::dispatcher::dispatch(semantics::node&) () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #14 0x00007fdc37077586 in cutl::compiler::dispatcher::dispatch(semantics::edge&) () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #15 0x00007fdc370989c6 in traversal::scope_template::names(semantics::namespace_&, cutl::compiler::dispatcher&) () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #16 0x00007fdc37076a66 in cutl::compiler::dispatcher::dispatch(semantics::node&) () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #17 0x00007fdc37077586 in cutl::compiler::dispatcher::dispatch(semantics::edge&) () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #18 0x00007fdc37098966 in traversal::scope_template::names(semantics::unit&, cutl::compiler::dispatcher&) () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #19 0x00007fdc37076a66 in cutl::compiler::dispatcher::dispatch(semantics::node&) () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #20 0x00007fdc370c7667 in process(options const&, features&, semantics::unit&, cutl::fs::basic_path const&) () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #21 0x00007fdc370f6595 in gate_callback () from /usr/lib/gcc/x86_64-linux-gnu/6/plugin/odb.so #22 0x0000000000a2fb12 in invoke_plugin_callbacks_full(int, void*) () #23 0x0000000000a25f17 in execute_one_pass(opt_pass*) () #24 0x0000000000a26c12 in execute_ipa_pass_list(opt_pass*) () #25 0x00000000007c6b05 in ?? () #26 0x00000000007c8815 in symbol_table::finalize_compilation_unit() () #27 0x0000000000ad422a in ?? () ---Type to continue, or q to quit--- #28 0x00000000005cae04 in toplev::main(int, char**) () #29 0x00000000005cd05b in main () ... I'm on Deian Stretch using quite old ODB 2.4.0. Is it possible to use std::shared_ptr>> as 'To-Many Relationship'? Anyway ODB compiler should not crash. Best regards Carsten WIESHEU GmbH Schleifwiesenstr.27 71723 Gro?bottwar / Deutschland Gesch?ftsf?hrer / Managing Director: Marcus Gansloser HRB-Nr. 310389 Informationspflicht nach Art 13 DSGVO https://www.wiesheu.de/informationspflicht -------------- next part -------------- A non-text attachment was scrubbed... Name: fb-1.jpg.gif Type: image/gif Size: 1261 bytes Desc: not available Url : https://codesynthesis.com/pipermail/odb-users/attachments/20210729/4ce4b387/fb-1.jpg.gif -------------- next part -------------- A non-text attachment was scrubbed... Name: youtube.jpg.gif Type: image/gif Size: 711 bytes Desc: not available Url : https://codesynthesis.com/pipermail/odb-users/attachments/20210729/4ce4b387/youtube.jpg.gif -------------- next part -------------- A non-text attachment was scrubbed... Name: link.gif Type: image/gif Size: 818 bytes Desc: not available Url : https://codesynthesis.com/pipermail/odb-users/attachments/20210729/4ce4b387/link.gif -------------- next part -------------- A non-text attachment was scrubbed... Name: insta.gif Type: image/gif Size: 1467 bytes Desc: not available Url : https://codesynthesis.com/pipermail/odb-users/attachments/20210729/4ce4b387/insta.gif -------------- next part -------------- A non-text attachment was scrubbed... Name: WIESHEU_4c__002_.gif Type: image/gif Size: 6141 bytes Desc: not available Url : https://codesynthesis.com/pipermail/odb-users/attachments/20210729/4ce4b387/WIESHEU_4c__002_.gif From boris at codesynthesis.com Thu Jul 29 11:21:28 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Jul 29 11:20:20 2021 Subject: [odb-users] C++11 To-Many Relationship using std::shared_ptr>> In-Reply-To: <1627566957198.72356@Wiesheu.de> References: <1627566957198.72356@Wiesheu.de> Message-ID: Behling Carsten writes: > std::vector> programs_; > > to > > std::shared_ptr>> programs_; What is the intended semantics of the outer shared_ptr? Is it just for storage (a "wrapper" in the ODB terminology) or do you expect it to play some relationship role? > I'm on Deian Stretch using quite old ODB 2.4.0. > > Anyway ODB compiler should not crash. Could you try the latest pre-release and see if it makes any difference: https://codesynthesis.com/products/odb/doc/install-build2.xhtml