Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation to disallow multiple create on related entities backed by same database table #2189

Merged
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c5d12a0
Validation to disallow mutations on related entities backed by same d…
ayush3797 Apr 26, 2024
9978ca5
Merge branch 'main' into dev/agarwalayush/prohibitSelfReferencingRela…
ayush3797 Apr 26, 2024
f7ec86c
nit
ayush3797 Apr 26, 2024
2b82df7
Add test for self ref relationship
ayush3797 Apr 26, 2024
d4bfb35
adding test/method summary
ayush3797 Apr 26, 2024
5111bd5
Adding tests for My/Ms/PSql
ayush3797 Apr 26, 2024
ae33246
Update src/Service.Tests/Unittests/MultipleCreateUnitTests/MultipleCr…
ayush3797 Apr 26, 2024
6bfd1d0
Update src/Service.Tests/Unittests/MultipleCreateUnitTests/MultipleCr…
ayush3797 Apr 26, 2024
83f887a
Update src/Core/Resolvers/MultipleCreateOrderHelper.cs
ayush3797 May 1, 2024
fd1a043
Update src/Core/Resolvers/MultipleCreateOrderHelper.cs
ayush3797 May 1, 2024
897fe23
Update src/Service.Tests/Unittests/MultipleCreateUnitTests/MultipleCr…
ayush3797 May 1, 2024
2fc5827
Update src/Service.Tests/Unittests/MultipleCreateUnitTests/MultipleCr…
ayush3797 May 1, 2024
9b300d0
Update src/Core/Resolvers/MultipleCreateOrderHelper.cs
ayush3797 May 1, 2024
007ce79
Merge branch 'main' into dev/agarwalayush/prohibitSelfReferencingRela…
ayush3797 May 1, 2024
eaa4f52
checking type before downcasting
ayush3797 May 1, 2024
da0b65a
formatting fix
ayush3797 May 1, 2024
ac766fe
fixing expected error message
ayush3797 May 1, 2024
ec20de4
Merge branch 'main' into dev/agarwalayush/prohibitSelfReferencingRela…
ayush3797 May 2, 2024
08f54c1
Merge branch 'main' into dev/agarwalayush/prohibitSelfReferencingRela…
ayush3797 May 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Core/Resolvers/MultipleCreateOrderHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ public class MultipleCreateOrderHelper
subStatusCode: DataApiBuilderException.SubStatusCodes.EntityNotFound);
}

DatabaseTable sourceDbTable = (DatabaseTable)sourceDbObject;
ayush3797 marked this conversation as resolved.
Show resolved Hide resolved
DatabaseTable targetDbTable = (DatabaseTable)targetDbObject;
if (sourceDbTable.Equals(targetDbTable))
{
throw new DataApiBuilderException(
message: $"Multiple-create for relationship: {relationshipName} at level: {nestingLevel} having the " +
$"source entity: {sourceEntityName} and target entity: {targetEntityName} backed by same database table is not yet supported.",
ayush3797 marked this conversation as resolved.
Show resolved Hide resolved
statusCode: HttpStatusCode.BadRequest,
subStatusCode: DataApiBuilderException.SubStatusCodes.NotSupported);
}

if (TryDetermineReferencingEntityBasedOnEntityRelationshipMetadata(
sourceEntityName: sourceEntityName,
targetEntityName: targetEntityName,
Expand Down