1-1 Relationships

Forum for posting problems using QxEntityEditor

1-1 Relationships

Postby Kasuax » Mon Jun 20, 2016 6:48 pm

I can't find any examples on how to create 2 tables with a 1-1 relationship. It sounds simple but I can't figure out what combination of settings in the EntityEditor makes both the C++ generated code happy and the postgres sql generator happy. I can modify either side after generating these output files but I feel as though I shouldn't have to... Help, Tutorial, Example? Do they share the same key name?
Kasuax
 
Posts: 62
Joined: Mon Jun 20, 2016 6:42 pm

Re: 1-1 Relationships

Postby qxorm » Mon Jun 20, 2016 7:50 pm

Hello,

In most cases, you should use a n-1 relationship instead of a 1-1 relationship.
A 1-1 relationship is a very specific case where 2 tables share the same id : for example, imagine a person table and a user table and you want that these 2 tables share the same id, then you can use a 1-1 relationship.

I can't figure out what combination of settings in the EntityEditor makes both the C++ generated code happy and the postgres sql generator happy. I can modify either side after generating these output files but I feel as though I shouldn't have to...

What is your error exactly ?
What do you have to change after exporting your project ?
qxorm
Site Admin
 
Posts: 477
Joined: Mon Apr 12, 2010 7:45 am

Re: 1-1 Relationships

Postby Kasuax » Tue Jun 21, 2016 3:00 am

Ok good, I'm on the right track.

I did use the same key name across objects. The problem is, what should the relationship name be called? If I re-use the key name as the relationship name with the other table then the sql is happy and the foreign keys are correct too. For some reason the primary key name is not included in the {field name|relationship name} validation so it can be reused to make sql happy at the expense of the C++ code becoming invalid. Reusing that field name causes obvious naming issues with the generated class objects.

I think what the UI needs is a way to specify what the foreign key field name is in a 1-1 relationship.

For reference, I'm using the postgres exporter.

At the moment I think my solution will be to make the C++ generated code settled and fix up the foreign keys myself.
Kasuax
 
Posts: 62
Joined: Mon Jun 20, 2016 6:42 pm

Re: 1-1 Relationships

Postby qxorm » Tue Jun 21, 2016 10:27 am

For some reason the primary key name is not included in the {field name|relationship name} validation so it can be reused to make sql happy at the expense of the C++ code becoming invalid. Reusing that field name causes obvious naming issues with the generated class objects.

I will try to reproduce the issue to fix it for the next release.
qxorm
Site Admin
 
Posts: 477
Joined: Mon Apr 12, 2010 7:45 am

Re: 1-1 Relationships

Postby qxorm » Mon Dec 12, 2016 9:39 am

Should be fixed with QxEntityEditor 1.2.1 : for changes log and download, please go to QxOrm download web page : https://www.qxorm.com/qxorm_en/download.html.
qxorm
Site Admin
 
Posts: 477
Joined: Mon Apr 12, 2010 7:45 am


Return to QxEntityEditor - Help

Who is online

Users browsing this forum: No registered users and 2 guests

cron