Many-to-Many through a Sub-Type Doesn't Include Discriminator Value in SQL

Posts   
 
    
shware
User
Posts: 23
Joined: 14-May-2007
# Posted on: 14-May-2007 23:27:19   

Hi,

I'm evaluating the product (so far I think it's great!). One thing that has come up is when trying to create a many-to-many relationship where the join table is actually a sub-type of the middle table.

Basic Table Defs:

Accounts Table (left table):

accounts.id
accounts.name ....

Project_Relation (join table):

project_relation.id project_relation.relation_type project_relation.relation_id project_relation.project_id ...

Project (right table):

project.id project.name ....

I created a sub-type called ProjectAccounts where the discriminator field is project_relation.relation_type and the discriminator value is "Accounts" .

I created a Relationship 1:n between Accounts and ProjectAccounts and then created a 1:n relationship between Projects and ProjectRelation. I left the "automatically detect m:n relationships" checked, so the m:n relationships were generated. The relationships / classes all generated fine.

If I reference Account.ProjectAccounts property and review the SQL, the discriminator value is included in the WHERE condition.

However, if I reference the Accounts.ProjectCollectionViaProjectAccounts collection and review the SQL, it DOES NOT include the discriminator value in the actual SQL.

Is this a known issue, or am I not doing something properly? simple_smile

ps: I'm evaluating the product by modeling a popular open source CRM system. I'm about 75% complete in less than a day! Cool stuff smile

Thanks!

Shawn

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-May-2007 08:32:51   

Hi Shawn, please provide more info so we can help you in the better way. http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=9076

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39914
Joined: 17-Aug-2003
# Posted on: 15-May-2007 11:09:32   

I'm afraid this is a known issue, as the subtype (account) inherits the relation from its supertype which holds the relation and no subtype filter is appended to the filter.

It will be fixed in the next v2 upgrade (free for v2 customers). We have to fix it in that upgrade as it is an architectural change and will break existing code and we don't add fixes which could break code to a current codebase.

Frans Bouma | Lead developer LLBLGen Pro
shware
User
Posts: 23
Joined: 14-May-2007
# Posted on: 15-May-2007 21:59:31   

Hi,

Thanks very much for the responses.

I did mistype the following:

I created a Relationship 1:n between Accounts and ProjectAccounts and then created a 1:n relationship between** Projects and ProjectRelation.** I left the "automatically detect m:n relationships" checked, so the m:n relationships were generated. The relationships / classes all generated fine.

It should read:

I created a Relationship 1:n between Accounts and ProjectAccounts and then created a 1:n relationship between **Projects and ProjectAccounts. **I left the "automatically detect m:n relationships" checked, so the m:n relationships were generated. The relationships / classes all generated fine.

But....it sounds like it's a known issue and being worked on. I'm able to work around it by going through the 1:n relationship.

Thanks again,

Shawn