Resolve collection identity during strict composition
This commit is contained in:
@@ -32,6 +32,22 @@ func resolveCollectionPolicy(
|
||||
applicationIdentityFields []string,
|
||||
lower *collectionPolicy,
|
||||
) (collectionPolicyResolution, []Diagnostic) {
|
||||
normalizedDeclarations := cloneSequenceDeclarations(declarations)
|
||||
for index := range normalizedDeclarations {
|
||||
declaration := &normalizedDeclarations[index]
|
||||
if !declaration.identityPresent {
|
||||
continue
|
||||
}
|
||||
fields, err := normalizeSequenceIdentityFields(declaration.identityFields)
|
||||
if err != nil {
|
||||
return collectionPolicyResolution{}, []Diagnostic{{
|
||||
Code: CodeSequenceInvalid, Severity: SeverityError, Path: destination.clone(),
|
||||
Message: "collection identity declaration requires at least one field",
|
||||
Primary: collectionDeclarationLocation(declaration.identityLocation, declaration.location),
|
||||
}}
|
||||
}
|
||||
declaration.identityFields = fields
|
||||
}
|
||||
normalizedApplicationIdentityFields := cloneStrings(applicationIdentityFields)
|
||||
if len(applicationIdentityFields) != 0 {
|
||||
var err error
|
||||
@@ -44,8 +60,8 @@ func resolveCollectionPolicy(
|
||||
}
|
||||
}
|
||||
result := collectionPolicyResolution{
|
||||
declarations: cloneSequenceDeclarations(declarations),
|
||||
declarationsPresent: len(declarations) != 0,
|
||||
declarations: normalizedDeclarations,
|
||||
declarationsPresent: len(normalizedDeclarations) != 0,
|
||||
applicationIdentityFields: normalizedApplicationIdentityFields,
|
||||
applicationIdentityPresent: len(normalizedApplicationIdentityFields) != 0,
|
||||
}
|
||||
@@ -55,7 +71,7 @@ func resolveCollectionPolicy(
|
||||
var declaredIdentityLocation *Location
|
||||
var declaredMode sequenceMode
|
||||
var declaredModeLocation *Location
|
||||
for _, declaration := range declarations {
|
||||
for _, declaration := range normalizedDeclarations {
|
||||
if declaration.identityPresent {
|
||||
result.identityDeclarationPresent = true
|
||||
if declaredIdentityFields == nil {
|
||||
|
||||
Reference in New Issue
Block a user