Avanade/NTangle

Duplication of models when generating code

wborowiecki opened this issue · 4 comments

In my master table, I have 2 columns that point to the same column, two times 1:1

I defined join as:
{name: RecentPOC, table: NAC_Contacts, joinCardinality: OneToOne, model: Contact, property: RecentPOC, joinTo: NAC_Vendors,
on: [
{name: CN_ContactID, toColumn: VE_RecentPOCID}
]
},
{name: BookingContact, table: NAC_Contacts, joinCardinality: OneToOne, model: Contact, property: BookingContact, joinTo: NAC_Vendors,
on: [
{name: CN_ContactID, toColumn: VE_BookingContactID}
]
}

Model "Contact" will be generated twice and the code will not compile.

Hi @wborowiecki - you will need to have two different models as they are not always guaranteed to be the same, as different columns (with different names) could be selected resulting in different set of properties. From a publishing perspective they will result in same JSON assuming same columns with same names.

Let me know if there are any issues related to the use of the two models.

@chullybun please consider a scenario in which table "Order" has references to table "User" twice: "CreatedById" and "UpdatedById". It would be desired to have a single model for User that is referenced twice.

Yeah ok, that makes sense. But developers will need to be cognizant that the definition must be the same. Looking forward to your pull request.

thank you for accepting the pull request, let me close it