varigence / BimlPit

Public Issue Tracker for all Varigence Biml products
6 stars 0 forks source link

GetDatabaseSchema GetDropAndCreateDDL Is Not Including Column Default Value Constraint #121

Open TravisKale opened 5 years ago

TravisKale commented 5 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead go to https://varigence.com/Forums?forumName=Biml or email support@varigence.com
[ ] Other... Please describe:

Current behavior

The default column constraint is not being generated for any table by using the following:

var destTableResults = targetConnection.GetDatabaseSchema(); var destTable = destTableResults.TableNodes.First(); var inccorectCreateTableSql= destTable.GetDropAndCreateDdl();

Table Def in SQL:

CREATE TABLE [dbo_Errors].[address]( [tenant_id] [DECIMAL](18, 0) NOT NULL, [address_id] [DECIMAL](18, 0) NOT NULL, [name] NVARCHAR NULL, [address] NVARCHAR NULL, [second_address] NVARCHAR NULL, [third_address] NVARCHAR NULL, [city] NVARCHAR NULL, [state_prov] NVARCHAR NULL, [zippost] NVARCHAR NULL, [country] NVARCHAR NULL, [phone] NVARCHAR NULL, [geocode_lat] [DECIMAL](28, 10) NULL, [geocode_long] [DECIMAL](28, 10) NULL, [active] NVARCHAR NULL, [modified_dttm] [DATETIME] NULL, [created_dttm] [DATETIME] NULL, [DateTimeStamp] [DATETIME] NOT NULL, [CT_Operation] NVARCHAR NOT NULL, [ErrorSource] VARCHAR NOT NULL, [ErrorColumnName] VARCHAR NULL, [ErrorDescription] VARCHAR NULL ) ON [PRIMARY] GO

ALTER TABLE [dbo_Errors].[address] ADD CONSTRAINT [DF_address_DateTimeStamp] DEFAULT (GETDATE()) FOR [DateTimeStamp] GO

GetDropAndCreateDdl generated code for same table:

IF EXISTS (SELECT * from sys.objects WHERE object_id = OBJECT_ID(N'[dbo_Errors].[address]') AND type IN (N'U')) DROP TABLE [dbo_Errors].[address] GO

CREATE TABLE [dbo_Errors].[address] ( -- Columns Definition [tenant_id] decimal(18,0) NOT NULL , [address_id] decimal(18,0) NOT NULL , [name] nvarchar(128) , [address] nvarchar(64) , [second_address] nvarchar(64) , [third_address] nvarchar(64) , [city] nvarchar(64) , [state_prov] nvarchar(32) , [zippost] nvarchar(64) , [country] nvarchar(32) , [phone] nvarchar(32) , [geocode_lat] decimal(28,10) , [geocode_long] decimal(28,10) , [active] nvarchar(1) , [modified_dttm] datetime , [created_dttm] datetime , [DateTimeStamp] datetime NOT NULL , [CT_Operation] nvarchar(1) NOT NULL , [ErrorSource] varchar(50) NOT NULL , [ErrorColumnName] varchar(500) , [ErrorDescription] varchar(500)

-- Constraints

) ON "default" WITH (DATA_COMPRESSION = NONE) GO

Expected behavior

For the SQL statement which creates the default column value constraint to be present when calling GetDropAndCreateDdl.

Minimal reproduction of the problem with instructions

Assuming the first table returned has a default value defined for a column. var destTableResults = targetConnection.GetDatabaseSchema(); var destTable = destTableResults.TableNodes.First(); var inccorectCreateTableSql= destTable.GetDropAndCreateDdl();

What is the motivation / use case for changing the behavior?

When building my staging environment I do not want to drop and create the tables if the definition is the same. When I compare the DropAndCreateDdl statement that is generated from my in memory model where I manually code the column default value, it does not equal the DropAndCreateDdl statment of the GetDatabaseSchema generated model because of the missing constraint statement. The same table was created using the in memory model GetDropAndCreateDdl.

Environment


BimlExpress version: 5.0.64108.0


Visual Studio Version:

- [ ] 2005
- [ ] 2008
- [ ] 2010
- [ ] 2012
- [ ] 2013
- [ ] 2015
- [ ] 2017
- [X] 2019

Target SSIS Version:

- [ ] 2005
- [ ] 2008
- [ ] 2008 R2
- [ ] 2012
- [ ] 2014
- [ x] 2016
- [ ] 2017

Others:

Database: Azure SQL DB
OS: Windows 10