Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1a4798c
Rename to ReferencingColumns
Aniruddh25 Apr 12, 2022
b6513b8
Rename to Referencing Columns
Aniruddh25 Apr 12, 2022
e49672c
BuildForeignKeyQuery
Aniruddh25 Apr 12, 2022
ba42ff1
PopulateForeignKeyDefinitionAsync
Aniruddh25 Apr 12, 2022
545364a
Add multiple column foreign key reference
Aniruddh25 Apr 12, 2022
b60c6a5
Fix build errors
Aniruddh25 Apr 12, 2022
a6da0cc
Remove foreign key information from runtime(resolver) config file
Aniruddh25 Apr 12, 2022
5a10b82
Get foreign key info in bulk
Aniruddh25 Apr 13, 2022
3f3e008
Fix tests
Aniruddh25 Apr 13, 2022
6293125
Fix stocks and comics test values to conform constraint
Aniruddh25 Apr 13, 2022
c0e151c
Add book_website_placement to sql-config-test
Aniruddh25 Apr 13, 2022
b065be9
Fix Put update test
Aniruddh25 Apr 13, 2022
02202c8
Merge from origin/main
Aniruddh25 Apr 13, 2022
2206f51
Fix Rest API tests for categoryName constraint
Aniruddh25 Apr 13, 2022
fcf7c24
Enclose columnName in quotes for PostgreSql
Aniruddh25 Apr 13, 2022
7285270
Fix MySQL foreign query
Aniruddh25 Apr 13, 2022
de97e34
Add new foreign key tests
Aniruddh25 Apr 13, 2022
5a11193
Modify sql-config-test to explicitly include referenced columns in fo…
Aniruddh25 Apr 13, 2022
685c700
Compare ForeignKeyDefinitions
Aniruddh25 Apr 13, 2022
192263c
Check for additional types in EdmModelBuilder
Aniruddh25 Apr 13, 2022
cec794a
Fix formatting
Aniruddh25 Apr 13, 2022
27e94af
sql-config PreserveNewest
Aniruddh25 Apr 13, 2022
bc7192c
Remove unnecessary HttpVerbs
Aniruddh25 Apr 13, 2022
c6751df
Address review comments
Aniruddh25 Apr 20, 2022
0f601b1
Merge origin/main
Aniruddh25 Apr 20, 2022
16a3c37
Remove CreateParams from the interface
Aniruddh25 Apr 20, 2022
941bb47
Added a TODO comment to track removal of nullability of _queryExecuto…
Aniruddh25 Apr 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions DataGateway.Service.Tests/SqlTests/MsSqlRestApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public class MsSqlRestApiTests : RestApiTestBase
// the insertion.
$"SELECT [categoryid],[pieceid],[categoryName],[piecesAvailable]," +
$"[piecesRequired] FROM { _Composite_NonAutoGenPK } " +
$"WHERE [categoryid] = 5 AND [pieceid] = 2 AND [categoryName] = 'Thriller' " +
$"WHERE [categoryid] = 5 AND [pieceid] = 2 AND [categoryName] = 'FairyTales' " +
$"AND [piecesAvailable] = 0 AND [piecesRequired] = 0 " +
$"FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER"
},
Expand Down Expand Up @@ -237,9 +237,9 @@ public class MsSqlRestApiTests : RestApiTestBase
},
{
"PutOne_Update_CompositeNonAutoGenPK_Test",
$"SELECT [categoryid], [pieceid], [categoryName],[piecesAvailable]," +
$"SELECT [categoryid], [pieceid], [categoryName], [piecesAvailable]," +
$"[piecesRequired] FROM { _Composite_NonAutoGenPK } " +
$"WHERE [categoryid] = 2 AND [pieceid] = 1 AND [categoryName] = 'History' " +
$"WHERE [categoryid] = 2 AND [pieceid] = 1 AND [categoryName] = 'SciFi' " +
$"AND [piecesAvailable] = 10 AND [piecesRequired] = 5 " +
$"FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER"
},
Expand All @@ -265,16 +265,17 @@ public class MsSqlRestApiTests : RestApiTestBase
},
{
"PutOne_Insert_AutoGenNonPK_Test",
$"SELECT [id], [title], [volume] FROM { _integration_AutoGenNonPK_TableName } " +
$"SELECT [id], [title], [volume], [categoryName] FROM { _integration_AutoGenNonPK_TableName } " +
$"WHERE id = { STARTING_ID_FOR_TEST_INSERTS } AND [title] = 'Star Trek' " +
$"AND [categoryName] = 'Suspense' " +
$"AND [volume] IS NOT NULL " +
$"FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER"
},
{
"PutOne_Insert_CompositeNonAutoGenPK_Test",
$"SELECT [categoryid], [pieceid], [categoryName],[piecesAvailable]," +
$"[piecesRequired] FROM { _Composite_NonAutoGenPK } " +
$"WHERE [categoryid] = 3 AND [pieceid] = 1 AND [categoryName] = 'comics' " +
$"WHERE [categoryid] = 3 AND [pieceid] = 1 AND [categoryName] = 'SciFi' " +
$"AND [piecesAvailable] = 2 AND [piecesRequired] = 1 " +
$"FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER"
},
Expand All @@ -297,15 +298,15 @@ public class MsSqlRestApiTests : RestApiTestBase
"PatchOne_Insert_CompositeNonAutoGenPK_Test",
$"SELECT [categoryid], [pieceid], [categoryName],[piecesAvailable]," +
$"[piecesRequired] FROM { _Composite_NonAutoGenPK } " +
$"WHERE [categoryid] = 4 AND [pieceid] = 1 AND [categoryName] = 'Suspense' " +
$"WHERE [categoryid] = 4 AND [pieceid] = 1 AND [categoryName] = 'FairyTales' " +
$"AND [piecesAvailable] = 5 AND [piecesRequired] = 4 " +
$"FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER"
},
{
"PatchOne_Insert_Default_Test",
$"SELECT [categoryid], [pieceid], [categoryName],[piecesAvailable]," +
$"[piecesRequired] FROM { _Composite_NonAutoGenPK } " +
$"WHERE [categoryid] = 7 AND [pieceid] = 1 AND [categoryName] = 'Drama' " +
$"WHERE [categoryid] = 7 AND [pieceid] = 1 AND [categoryName] = 'SciFi' " +
$"AND [piecesAvailable] = 0 AND [piecesRequired] = 0 " +
$"FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER"
},
Expand All @@ -332,7 +333,7 @@ public class MsSqlRestApiTests : RestApiTestBase
"PatchOne_Update_CompositeNonAutoGenPK_Test",
$"SELECT [categoryid], [pieceid], [categoryName],[piecesAvailable]," +
$"[piecesRequired] FROM { _Composite_NonAutoGenPK } " +
$"WHERE [categoryid] = 1 AND [pieceid] = 1 AND [categoryName] = 'books' " +
$"WHERE [categoryid] = 1 AND [pieceid] = 1 AND [categoryName] = 'SciFi' " +
$"AND [piecesAvailable]= 10 AND [piecesRequired] = 0 " +
$"FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER"
},
Expand Down
16 changes: 8 additions & 8 deletions DataGateway.Service.Tests/SqlTests/MySqlRestApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ SELECT JSON_OBJECT('categoryid', categoryid, 'pieceid', pieceid, 'categoryName',
FROM (
SELECT categoryid, pieceid, categoryName,piecesAvailable,piecesRequired
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 5 AND pieceid = 2 AND categoryName ='Thriller' AND piecesAvailable = 0
WHERE categoryid = 5 AND pieceid = 2 AND categoryName ='FairyTales' AND piecesAvailable = 0
AND piecesRequired = 0
) AS subq
"
Expand Down Expand Up @@ -436,7 +436,7 @@ SELECT JSON_OBJECT('categoryid', categoryid, 'pieceid', pieceid, 'categoryName',
FROM (
SELECT categoryid, pieceid, categoryName,piecesAvailable,piecesRequired
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 2 AND pieceid = 1 AND categoryName ='History' AND piecesAvailable = 10
WHERE categoryid = 2 AND pieceid = 1 AND categoryName ='SciFi' AND piecesAvailable = 10
AND piecesRequired = 5
) AS subq
"
Expand Down Expand Up @@ -466,9 +466,9 @@ AND issue_number is NULL
},
{
"PutOne_Insert_AutoGenNonPK_Test",
@"SELECT JSON_OBJECT('id', id, 'title', title, 'volume', volume ) AS data
@"SELECT JSON_OBJECT('id', id, 'title', title, 'volume', volume, 'categoryName', categoryName) AS data
FROM (
SELECT id, title, volume
SELECT id, title, volume, categoryName
FROM " + _integration_AutoGenNonPK_TableName + @"
WHERE id = " + $"{STARTING_ID_FOR_TEST_INSERTS}" + @" AND title = 'Star Trek'
AND volume IS NOT NULL
Expand All @@ -483,7 +483,7 @@ SELECT JSON_OBJECT('categoryid', categoryid, 'pieceid', pieceid, 'categoryName',
FROM (
SELECT categoryid, pieceid, categoryName,piecesAvailable,piecesRequired
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 3 AND pieceid = 1 AND categoryName ='comics' AND piecesAvailable = 2
WHERE categoryid = 3 AND pieceid = 1 AND categoryName ='SciFi' AND piecesAvailable = 2
AND piecesRequired = 1
) AS subq
"
Expand Down Expand Up @@ -520,7 +520,7 @@ SELECT JSON_OBJECT('categoryid', categoryid, 'pieceid', pieceid, 'categoryName',
FROM (
SELECT categoryid, pieceid, categoryName,piecesAvailable,piecesRequired
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 4 AND pieceid = 1 AND categoryName ='Suspense' AND piecesAvailable = 5
WHERE categoryid = 4 AND pieceid = 1 AND categoryName ='FairyTales' AND piecesAvailable = 5
AND piecesRequired = 4
) AS subq
"
Expand All @@ -533,7 +533,7 @@ SELECT JSON_OBJECT('categoryid', categoryid, 'pieceid', pieceid, 'categoryName',
FROM (
SELECT categoryid, pieceid, categoryName,piecesAvailable,piecesRequired
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 7 AND pieceid = 1 AND categoryName ='Drama' AND piecesAvailable = 0
WHERE categoryid = 7 AND pieceid = 1 AND categoryName ='SciFi' AND piecesAvailable = 0
AND piecesRequired = 0
) AS subq
"
Expand Down Expand Up @@ -581,7 +581,7 @@ SELECT JSON_OBJECT('categoryid', categoryid, 'pieceid', pieceid, 'categoryName',
FROM (
SELECT categoryid, pieceid, categoryName,piecesAvailable,piecesRequired
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 1 AND pieceid = 1 AND categoryName ='books' AND piecesAvailable = 10
WHERE categoryid = 1 AND pieceid = 1 AND categoryName ='SciFi' AND piecesAvailable = 10
AND piecesRequired = 0
) AS subq
"
Expand Down
14 changes: 7 additions & 7 deletions DataGateway.Service.Tests/SqlTests/PostgreSqlRestApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ SELECT to_jsonb(subq) AS data
FROM (
SELECT categoryid, pieceid, ""categoryName"", ""piecesAvailable"", ""piecesRequired""
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 5 AND pieceid = 2 AND ""categoryName"" = 'Thriller'
WHERE categoryid = 5 AND pieceid = 2 AND ""categoryName"" = 'FairyTales'
AND ""piecesAvailable"" = 0 AND ""piecesRequired"" = 0
) AS subq
"
Expand Down Expand Up @@ -417,7 +417,7 @@ SELECT to_jsonb(subq) AS data
FROM (
SELECT categoryid, pieceid, ""categoryName"", ""piecesAvailable"", ""piecesRequired""
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 2 AND pieceid = 1 AND ""categoryName"" = 'History'
WHERE categoryid = 2 AND pieceid = 1 AND ""categoryName"" = 'SciFi'
AND ""piecesAvailable"" = 10 AND ""piecesRequired"" = 5
) AS subq
"
Expand Down Expand Up @@ -457,7 +457,7 @@ SELECT to_jsonb(subq) AS data
@"
SELECT to_jsonb(subq) AS data
FROM (
SELECT id, title, volume
SELECT id, title, volume, ""categoryName""
FROM " + _integration_AutoGenNonPK_TableName + @"
WHERE id = " + STARTING_ID_FOR_TEST_INSERTS + @"
AND title = 'Star Trek' AND volume IS NOT NULL
Expand All @@ -471,7 +471,7 @@ SELECT to_jsonb(subq) AS data
FROM (
SELECT categoryid, pieceid, ""categoryName"", ""piecesAvailable"", ""piecesRequired""
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 3 AND pieceid = 1 AND ""categoryName"" = 'comics'
WHERE categoryid = 3 AND pieceid = 1 AND ""categoryName"" = 'SciFi'
AND ""piecesAvailable"" = 2 AND ""piecesRequired"" = 1
) AS subq
"
Expand Down Expand Up @@ -506,7 +506,7 @@ SELECT to_jsonb(subq) AS data
FROM (
SELECT categoryid, pieceid, ""categoryName"", ""piecesAvailable"", ""piecesRequired""
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 4 AND pieceid = 1 AND ""categoryName"" = 'Suspense'
WHERE categoryid = 4 AND pieceid = 1 AND ""categoryName"" = 'FairyTales'
AND ""piecesAvailable"" = 5 AND ""piecesRequired"" = 4
) AS subq
"
Expand All @@ -518,7 +518,7 @@ SELECT to_jsonb(subq) AS data
FROM (
SELECT categoryid, pieceid, ""categoryName"", ""piecesAvailable"", ""piecesRequired""
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 7 AND pieceid = 1 AND ""categoryName"" = 'Drama'
WHERE categoryid = 7 AND pieceid = 1 AND ""categoryName"" = 'SciFi'
AND ""piecesAvailable"" = 0 AND ""piecesRequired"" = 0
) AS subq
"
Expand Down Expand Up @@ -563,7 +563,7 @@ SELECT to_jsonb(subq) AS data
FROM (
SELECT categoryid, pieceid, ""categoryName"", ""piecesAvailable"", ""piecesRequired""
FROM " + _Composite_NonAutoGenPK + @"
WHERE categoryid = 1 AND pieceid = 1 AND ""categoryName"" = 'books'
WHERE categoryid = 1 AND pieceid = 1 AND ""categoryName"" = 'SciFi'
AND ""piecesAvailable"" = 10 AND ""piecesRequired"" = 0
) AS subq
"
Expand Down
13 changes: 7 additions & 6 deletions DataGateway.Service.Tests/SqlTests/RestApiTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ await SetupAndRunRestApiTest(
{
""categoryid"": ""5"",
""pieceid"": ""2"",
""categoryName"":""Thriller""
""categoryName"":""FairyTales""
}";

expectedLocationHeader = $"categoryid/5/pieceid/2";
Expand Down Expand Up @@ -521,7 +521,7 @@ await SetupAndRunRestApiTest(

requestBody = @"
{
""categoryName"":""History"",
""categoryName"":""SciFi"",
""piecesAvailable"":""10"",
""piecesRequired"":""5""
}";
Expand Down Expand Up @@ -633,7 +633,8 @@ await SetupAndRunRestApiTest(
// that is autogenerated.
requestBody = @"
{
""title"": ""Star Trek""
""title"": ""Star Trek"",
""categoryName"" : ""Suspense""
}";

expectedLocationHeader = $"id/{STARTING_ID_FOR_TEST_INSERTS}";
Expand All @@ -651,7 +652,7 @@ await SetupAndRunRestApiTest(

requestBody = @"
{
""categoryName"":""comics"",
""categoryName"":""SciFi"",
""piecesAvailable"":""2"",
""piecesRequired"":""1""
}";
Expand Down Expand Up @@ -719,7 +720,7 @@ await SetupAndRunRestApiTest(

requestBody = @"
{
""categoryName"": ""Suspense"",
""categoryName"": ""FairyTales"",
""piecesAvailable"":""5"",
""piecesRequired"":""4""
}";
Expand All @@ -739,7 +740,7 @@ await SetupAndRunRestApiTest(

requestBody = @"
{
""categoryName"": ""Drama""
""categoryName"": ""SciFi""
}";
expectedLocationHeader = $"categoryid/7/pieceid/1";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.IO;
using Azure.DataGateway.Service.Models;
using Azure.DataGateway.Service.Services;
Expand Down Expand Up @@ -31,6 +32,13 @@ SqlGraphQLFileMetadataProvider expectedMetadataProvider
actualTableDefinition.PrimaryKey,
$"Did not find the expected primary keys for table {tableName}");

CollectionAssert.AreEqual(
new SortedDictionary<string, ForeignKeyDefinition>
(expectedTableDefinition.ForeignKeys),
new SortedDictionary<string, ForeignKeyDefinition>
(actualTableDefinition.ForeignKeys),
$"Did not find the expected foreign keys for table {tableName}");

foreach ((string columnName, ColumnDefinition expectedColumnDefinition) in expectedTableDefinition.Columns)
{
ColumnDefinition actualColumnDefinition;
Expand Down
18 changes: 9 additions & 9 deletions DataGateway.Service.Tests/SqlTests/SqlTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,30 @@ protected static async Task InitializeTestFixture(TestContext context, string te
{
case TestCategory.POSTGRESQL:
_queryBuilder = new PostgresQueryBuilder();
_metadataStoreProvider = new SqlGraphQLFileMetadataProvider(
config,
new PostgreSqlMetadataProvider(config));
_defaultSchemaName = "public";
_dbExceptionParser = new PostgresDbExceptionParser();
_queryExecutor = new QueryExecutor<NpgsqlConnection>(config, _dbExceptionParser);
_metadataStoreProvider = new SqlGraphQLFileMetadataProvider(
config,
new PostgreSqlMetadataProvider(config, _queryExecutor, _queryBuilder));
break;
case TestCategory.MSSQL:
_queryBuilder = new MsSqlQueryBuilder();
_metadataStoreProvider = new SqlGraphQLFileMetadataProvider(
config,
new MsSqlMetadataProvider(config));
_defaultSchemaName = "dbo";
_dbExceptionParser = new DbExceptionParserBase();
_queryExecutor = new QueryExecutor<SqlConnection>(config, _dbExceptionParser);
_metadataStoreProvider = new SqlGraphQLFileMetadataProvider(
config,
new MsSqlMetadataProvider(config, _queryExecutor, _queryBuilder));
break;
case TestCategory.MYSQL:
_queryBuilder = new MySqlQueryBuilder();
_metadataStoreProvider = new SqlGraphQLFileMetadataProvider(
config,
new MySqlMetadataProvider(config));
_defaultSchemaName = "mysql";
_dbExceptionParser = new MySqlDbExceptionParser();
_queryExecutor = new QueryExecutor<MySqlConnection>(config, _dbExceptionParser);
_metadataStoreProvider = new SqlGraphQLFileMetadataProvider(
config,
new MySqlMetadataProvider(config, _queryExecutor, _queryBuilder));
break;
}

Expand Down
Loading