microsoft / DacFx

DacFx, SqlPackage, and other SQL development libraries enable declarative database development and database portability across SQL versions and environments. Share feedback here on dacpacs, bacpacs, and SQL projects.
https://aka.ms/sqlpackage-ref
MIT License
362 stars 21 forks source link

Lacking Documentation for PackageOptions.IgnoreValidationErrors property #462

Open andrew-sumner opened 5 months ago

andrew-sumner commented 5 months ago

I've been working on a utility to filter out objects from our product layer dacpac that we want to override in our client layer dacpac based on this code DACExtensions.

I'd like to ignore some validation errors, unfortunately microsoft.sqlserver.dac.packageoptions.ignorevalidationerrors property is not well documented and the best I've come up with is this which will ignore all validation errors:

if (ignoreValidationErrors)
{
    packageOptions.IgnoreValidationErrors = new List<string>() { "*" };
};

DacPackageExtensions.BuildPackage(
    filteredDacpacPath,
    filteredModel,
    packageMetadata,
    packageOptions);

What value could I use in the IgnoreValidationErrors property to only ignore unresolved reference errors such as Error SQL71501: Error validating element [dbo].[OverrideTableView]: View: [dbo].[OverrideTableView] has an unresolved reference to object [dbo].[OverrideTbl]?

llali commented 5 months ago

@andrew-sumner thanks for your feedback. Please try this: packageOptions.IgnoreValidationErrors = new List() { "SR0029" };

You are right about documentations. We need to improve this and provide the rule ids that match with the validation errors.

andrew-sumner commented 4 months ago

Thanks for that, is there a list of rule ids available anywhere?

dzsquared commented 4 months ago

@andrew-sumner - the validation rule IDs haven't yet made it into our API docs, but here's a quick table of them:

RuleID Name
SR0017 OnePrimaryKey
SR0018 MaxColumnInTable
SR0019 MaxIdentifierLength
SR0020 OneClusteredIndex
SR0021 MaxColumnInIndexKey
SR0022 BreakContinueOnlyInWhile
SR0023 PrimaryXMLIndexClustered
SR0024 XMLIndexOnlyXMLTypeColumn
SR0025 ClrObjectAssemblyReference
SR0027 DuplicateName
SR0029 AllReferencesMustBeResolved
SR0030 UsingXMLIndex
SR0032 SelectAssignRetrieval
SR0034 InsertIntoIdentityColumn
SR0036 ForeignKeyReferencePKUnique
SR0037 ForeignKeyColumnTypeNumberMustMatch
SR0038 NonNullPrimaryKey
SR0039 SubroutineParameterReadOnly
SR0040 WildCardExpansion
SR0041 OneMasterKey
SR0042 FullTextIndexColumnForSql80
SR0043 FullTextIndexColumnForSql90
SR0044 EdgeConstraintMustReferenceNodeTables
SR0046 MultiFullTextIndexOnTable
SR0048 DuplicateVariableParameterName
SR0049 IdentityColumnValidation
SR0050 VardecimalOption
SR0051 AssemblyVisibility
SR0052 EndPoint
SR0053 ColumnUserDefinedTableType
SR0054 InterpreterErrorRouter
SR0057 TableVariablePrefixRule80
SR0058 TableVariablePrefixRule100
SR0059 FileStream
SR0061 OneDefaultConstraintPerColumn
SR0063 PermissionStatementValidation
SR0064 PermissionOnObjectSecurableValidation
SR0065 SequenceValueValidation
SR0066 MismatchedName
SR0067 DifferentNameCasing
SR0068 UndeployableElementValidation
SR0069 ISqlSpecifiesStorageDataCompressionFilestreamOnClause
SR0070 AllReferencesMustBeResolvedForImport
SR0071 MemoryOptimizedObjectsValidation
SR0072 ReferencesToMemoryOptimizedTablesValidation
SR0073 IncrementalStatisticsValidation
SR0074 AzureV12SurfaceAreaValidation
SR0075 DuplicatedTargetObjectReferencesInSecurityPolicy
SR0076 MultiSecurityPoliciesOnTargetObject
SR0077 OperationsOnEncryptedColumn
SR0078 MasterKeyExistsForCredential
SR0079 OneTemporalPeriod
SR0080 SystemVersionedTemporalTable_SchemaMismatch
SR0081 SystemVersionedTemporalTable_MultipleCurrentTables
SR0082 SystemVersionedTemporalTable_ComputedColumns
SR0083 SystemVersionedTemporalTable_NoAlwaysEncryptedCols
SR0084 ExternalTableValidation
SR0085 NoBlockPredicatesTargetingViews
SR0086 SchemaBindingOnSecurityPoliciesValidation
SR0087 SecurityPredicateTargetObjectValidation
SR0088 SystemVersionedTemporalTable_PrimaryKey
SR0089 SystemVersionedTemporalTable_HistoryTableConstraints
SR0090 DwTable_DistributionColumnConstraints
SR0091 DwView_Indexed
SR0092 DwIndex_NoClusteredRowstoreIndexOnTableWithColumnstoreIndex
SR0093 DwView_NoExpand
SR0094 DwUDF_DoNotModifyDatabaseState
SR0095 DwExternalTable_RejectedRowLocation
SR0096 DwCCIndex_NoStringColumnAllowedAsOrderedColumn
SR0098 DwMaterializedViewValidation
SR0099 DwMaxWorkloadGroups
SR0100 DwIdentityColumn_CannotBeDistributionColumn
SR0114 DwWorkloadClassifierStartEndTime
SR0115 DwWorkloadClassifierMax
SR0116 ExternalLibraryValidation
SR0117 ExternalLanguageValidation
SR0118 PredictValidation
SR0119 DwMergeMatchClauseValidation
SR0149 DwSymmetricKey_Validation
SR0211 DwCreateCertificateValidation
SR0150 DwCCIndex_InvalidDataType
SR0153 DwAsymmetricKey_Validation
SR0151 LedgerTableColumnUserDefinedTypeValidation
SR0152 LedgerTableFullTextIndexValidation
SR0154 DwTable_MultiColumnDistributionValidation
SR0155 DwView_MultiColumnDistributionValidation

I'm continuing work on the API documentation and examples, so will keep this open to ensure it lands in there.