From boris at codesynthesis.com Mon Aug 1 08:02:26 2022 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Aug 1 07:57:31 2022 Subject: [odb-users] Attempt to refer to a dbvalue inside another dbvalue - "invalid data member in db pragma column" In-Reply-To: <522621658478087@mail.yandex.ru> References: <522621658478087@mail.yandex.ru> Message-ID: ????? ?????? writes: > #include > #pragma db value > struct Val_1 { int a; }; > #pragma db value > struct Val_2 { Val_1 val1; }; > > #pragma db object > class Object { > friend odb::access; > #pragma db id auto > int id; > Val_2 value; > }; > > #pragma db view object(Object) > struct ObjectView > { > #pragma db column(Object::value) ///< OK > Val_2 val2; > #pragma db column(Object::value.val1.a) ///< OK > int a; > #pragma db column(Object::value.val1) ///< DONT WORK: "invalid data member in db pragma column" > Val_1 val1; > }; Yes, can confirm this still fails in the development version. Not sure when we will get to fixing this seeing that it's a fairly obscure case. But if you want to try to fix it, patches are welcome. You can also probably work around this by "decomposing" Object::value using virtual data members. From boris at codesynthesis.com Tue Aug 2 01:32:28 2022 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 2 01:27:34 2022 Subject: [odb-users] ODB 2.5.0-b.23 published Message-ID: We've published ODB 2.5.0-b.23 to cppget.org which adds support for GCC 12. Besides that, this beta also adds support for the --std c++20 option value and includes a number of bug fixes. To install or upgrade to ODB 2.5.0-b.23 see the installation instructions: https://codesynthesis.com/products/odb/doc/install-build2.xhtml A notes to Mac OS users: There is an issue with newer versions of GCC (11.3, 12.1) on Intel (but not M1) Mac OS: https://github.com/Homebrew/homebrew-core/issues/106394 Older versions of GCC (10.x, 11.2) seem to work. We are still investigating this. From jed.wu at ringcentral.com Tue Aug 16 02:09:55 2022 From: jed.wu at ringcentral.com (Jed Wu) Date: Tue Aug 16 07:08:53 2022 Subject: [odb-users] how to generate two db files with different schemas and embedded into an application Message-ID: ls -d -1 *.h* | grep -v odb | tr '\n' ' '| xargs odb -I./ --ixx-suffix .ipp -d sqlite --generate-schema --at-once --std c++11 --generate-query --generate-session --input-name contact --show-sloc ls -d -1 *.h* | grep -v odb | tr '\n' ' '| xargs odb -I./ --ixx-suffix .ipp -d sqlite --generate-schema --at-once --std c++11 --generate-query --generate-session --input-name phonenumber --show-sloc By the commands above, the ODB compiler would generate contact-odb.cxx and phonenumber-odb.cxx, both of cxx files have static create_schema() function. namespace odb { static bool create_schema (database& db, unsigned short pass, bool drop) { ODB_POTENTIALLY_UNUSED (db); ODB_POTENTIALLY_UNUSED (pass); ODB_POTENTIALLY_UNUSED (drop); if (drop) ... } When calling odb::schema_catalog::create_schema(*db);it always debug into call create_schema() in contact-odb.cxx. How can I call create_schema() in contact-odb.cxx for contact.db and create_schema in phonenumber-odb.cxx for phonenumber.db? Hope to hear from you very soon! Thank you! From boris at codesynthesis.com Tue Aug 16 07:19:09 2022 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Aug 16 07:14:05 2022 Subject: [odb-users] how to generate two db files with different schemas and embedded into an application In-Reply-To: References: Message-ID: Jed Wu writes: > How can I call create_schema() in contact-odb.cxx for contact.db and > create_schema in phonenumber-odb.cxx for phonenumber.db? The ODB compiler has the --schema-name option that allows you to assign names to your database schemas. This name can then be passed as the second argument to odb::schema_catalog::create_schema(). This is covered in Section 3.4, "Database" in the ODB manual: https://codesynthesis.com/products/odb/doc/manual.xhtml#3.4 From jed.wu at ringcentral.com Thu Aug 18 12:23:37 2022 From: jed.wu at ringcentral.com (Jed Wu) Date: Fri Aug 19 01:06:04 2022 Subject: [odb-users] how to generate two db files with different schemas and embedded into an application In-Reply-To: References: Message-ID: <6BB9002F-CA90-462A-9129-1B885CC4E96A@ringcentral.com> Hi, per my test, if I define and use more then one schema(default or custom), it will throw out an exception like "unknown database schema ?myschema??. Do you have an example that can work well with multiple schema names? On Aug 16, 2022, at 19:19, Boris Kolpackov > wrote: [EXTERNAL] Jed Wu > writes: How can I call create_schema() in contact-odb.cxx for contact.db and create_schema in phonenumber-odb.cxx for phonenumber.db? The ODB compiler has the --schema-name option that allows you to assign names to your database schemas. This name can then be passed as the second argument to odb::schema_catalog::create_schema(). This is covered in Section 3.4, "Database" in the ODB manual: https://urldefense.com/v3/__https://codesynthesis.com/products/odb/doc/manual.xhtml*3.4__;Iw!!J-1DKIBqn-Pi!FcMXX5sKCggEPUvS-CjiPGfSM3buQntFKNBz1dYZZfpVHwqsMfeU0jIagNbSF4SfRU5DB5pCK5Nji4touqRC$ From boris at codesynthesis.com Fri Aug 19 01:23:09 2022 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Aug 19 01:18:03 2022 Subject: [odb-users] how to generate two db files with different schemas and embedded into an application In-Reply-To: <6BB9002F-CA90-462A-9129-1B885CC4E96A@ringcentral.com> References: <6BB9002F-CA90-462A-9129-1B885CC4E96A@ringcentral.com> Message-ID: Jed Wu writes: > Hi, per my test, if I define and use more then one schema(default or > custom), it will throw out an exception like "unknown database schema > ?myschema??. This usually means that the *-odb.cxx file that contains myschema is not linked to your application. In particular, this can happen inadvertently when *-odb.cxx comes from a static library. > Do you have an example that can work well with multiple schema names? Overall, your usage should look along these lines odb ... --generate-schema --input-name contact --schema-name contact ... odb ... --generate-schema --input-name phonenumber --schema-name phonenumber ... c++ ... myapp.cxx contact-odb.cxx phonenumber-odb.cxx Then, in myapp.cxx, you should be able to do: odb::schema_catalog::create_schema (db1, "contact"); odb::schema_catalog::create_schema (db2, "phonenumber");