FK/UC/PK name patterns. Missing something?

Posts   
 
    
raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 09-Jun-2014 16:20:26   

Quite a lot of small, lovely improvements. Thanks.

I do not know if this is the expected result. ... or something is wrongly configured.

On northwind (already created ddbb & llblgen project)

1.

UC_{$TableName}_{$FieldNames}

Result (Create script)


-- Should be [UC_Shippers_CompanyName] ??
ALTER TABLE [dbo].[Shippers] 
    ADD CONSTRAINT [UC_6647bca44879f2219c739e6c220] UNIQUE NONCLUSTERED
    (
        [CompanyName] 
    )
GO

ALTER TABLE [dbo].[Suppliers] 
    ADD CONSTRAINT [UC_d6cdae143d19d349c0d381ad7b6] UNIQUE NONCLUSTERED
    (
        [CompanyName], [ContactName] 
    )
GO

2.

FK_{$TableName}_{$PkTableName}

Result (Create script):


-- Should be [FK_CustomerCustomerDemo_CustomerDemographics]
ALTER TABLE [dbo].[CustomerCustomerDemo] 
    ADD CONSTRAINT [FK_CustomerCustomerDemo] FOREIGN KEY
    (
        [CustomerTypeID] 
    )
    REFERENCES [dbo].[CustomerDemographics]
    (
        [CustomerTypeID] 
    )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
GO

-- OK
ALTER TABLE [dbo].[CustomerCustomerDemo] 
    ADD CONSTRAINT [FK_CustomerCustomerDemo_Customers] FOREIGN KEY
    (
        [CustomerID] 
    )
    REFERENCES [dbo].[Customers]
    (
        [CustomerID] 
    )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
GO

Best regards

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 09-Jun-2014 16:34:56   

I'll look into it. I have to check whether a changed pattern will result in new names on existing elements in all cases.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 10-Jun-2014 11:15:53   

Your post showed we missed some essential documentation: when are the patterns applied? They're not applied when you change them. The reason is that it would otherwise cause a lot of changes for existing projects which read an existing schema. (as the default is UC_{Guid})

The patterns are applied when a new UC/FK/PK is created, and when an element is renamed and 'Sync relational model data element name after rename' is set to true. So when you rename an entity and that setting is set to true, the table name is renamed and this triggers renames of FK constraints using the pattern.

We'll update the beta docs (and real docs of course wink ) with an updated section about this, as it's currently indeed confusing.

Frans Bouma | Lead developer LLBLGen Pro
raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 10-Jun-2014 11:24:19   

Good enough. It makes sense. simple_smile Thanks.