From yohuang at nvidia.com Tue Jan 5 06:59:44 2021 From: yohuang at nvidia.com (Justin Huang) Date: Tue Jan 5 07:26:10 2021 Subject: [odb-users] Load old DB after adding new class data member Message-ID: Hi, I added a new boolean data member (with default value false) for a class, but I want to load a DB generated before adding this new data member. I got '1: no such column' error when I tried to load old DB after updating the class. Is there a way that ODB can load this old db? I tried the 'default value pragma' which did not work. Thanks, Justin From boris at codesynthesis.com Tue Jan 5 08:21:59 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Jan 5 08:25:19 2021 Subject: [odb-users] Load old DB after adding new class data member In-Reply-To: References: Message-ID: Justin Huang writes: > I added a new boolean data member (with default value false) for a class, > but I want to load a DB generated before adding this new data member. I > got '1: no such column' error when I tried to load old DB after updating > the class. > > Is there a way that ODB can load this old db? I think the soft object model changes support should allow you to achieve this, see "Soft Object Model Changes" for details: https://codesynthesis.com/products/odb/doc/manual.xhtml#13.4 From yohuang at nvidia.com Tue Jan 5 09:03:55 2021 From: yohuang at nvidia.com (Justin Huang) Date: Wed Jan 6 09:03:24 2021 Subject: [odb-users] Load old DB after adding new class data member In-Reply-To: References: Message-ID: Hi Boris, I added a new line '#pragma db model version(1, 2)' at the top of class header file, and added '#pragma db added(2)' before the newly added bool data member in class definition, then the old db can be loaded successfully. I see a new table named by 'schema_version' is created in newly created db. Thanks a lot for quick suggestion. thanks, Justin -----Original Message----- From: Boris Kolpackov Sent: Tuesday, January 5, 2021 9:22 PM To: Justin Huang Cc: odb-users@codesynthesis.com Subject: Re: [odb-users] Load old DB after adding new class data member External email: Use caution opening links or attachments Justin Huang writes: > I added a new boolean data member (with default value false) for a > class, but I want to load a DB generated before adding this new data > member. I got '1: no such column' error when I tried to load old DB > after updating the class. > > Is there a way that ODB can load this old db? I think the soft object model changes support should allow you to achieve this, see "Soft Object Model Changes" for details: https://codesynthesis.com/products/odb/doc/manual.xhtml#13.4 From andrea at pappacoda.it Sun Jan 31 10:21:23 2021 From: andrea at pappacoda.it (Andrea Pappacoda) Date: Mon Feb 1 05:23:01 2021 Subject: [odb-users] One-to-many relationship in composite primary key Message-ID: <20210131152123.Horde.I4b4sJgqRZclnWwKe1_RN1w@cloud.pappacoda.it> I have two entities, school and class. School has a simple primary key (id), while class has a primary key composed by a name and a reference to its school. In SQL terms: CREATE TABLE school ( id BIGINT NOT NULL PRIMARY KEY ); CREATE TABLE class ( school_fk BIGINT NOT NULL REFERENCES school (id), name VARCHAR (30) NOT NULL, PRIMARY KEY (school_fk, name) ); How can I implement this with ODB? Section 7.2.1 of the manual states that a composite value type cannot have any object pointers, is this a thing that ODB can't do? Thanks for the help.