-
Notifications
You must be signed in to change notification settings - Fork 201
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
Fix context sql #2344
base: main
Are you sure you want to change the base?
Fix context sql #2344
Changes from all commits
08f741c
b4239d0
2ed72b4
132a46e
b0bc518
19e9dbc
d10be7a
4c5a5b8
20f4b6b
b560b20
3567785
1479f34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ public class RequestParser | |
/// <summary> | ||
/// Prefix used for specifying limit in the query string of the URL. | ||
/// </summary> | ||
public const string FIRST_URL = "$first"; | ||
public const string FIRST_URL = "$top"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will provide a synonym $top soon. Lets not make this change in this PR. Thank you for your patience. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related #2474 |
||
/// <summary> | ||
/// Prefix used for specifying paging in the query string of the URL. | ||
/// </summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,7 +219,7 @@ public override string GetSessionParamsQuery(HttpContext? httpContext, IDictiona | |
string paramName = $"{SESSION_PARAM_NAME}{counter.Next()}"; | ||
parameters.Add(paramName, new(claimValue)); | ||
// Append statement to set read only param value - can be set only once for a connection. | ||
string statementToSetReadOnlyParam = "EXEC sp_set_session_context " + $"'{claimType}', " + paramName + ", @read_only = 1;"; | ||
string statementToSetReadOnlyParam = "EXEC sp_set_session_context " + $"'{claimType}', " + paramName + ", @read_only = 0;"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious, did you experience - your mutation operations being blocked because of this setting? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the SQL Endpoint did reject the second query as described in #2341 |
||
sessionMapQuery = sessionMapQuery.Append(statementToSetReadOnlyParam); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,13 @@ public static OkObjectResult FormatFindResult( | |
? DetermineExtraFieldsInResponse(findOperationResponse, context.FieldsToBeReturned) | ||
: DetermineExtraFieldsInResponse(findOperationResponse.EnumerateArray().First(), context.FieldsToBeReturned); | ||
|
||
//Remove RecordCOunt from extraFieldsInResponse if present | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this code is not used, please remove it out completely. |
||
if (extraFieldsInResponse.Contains("RecordCount")) | ||
{ | ||
extraFieldsInResponse.Remove("RecordCount"); | ||
} | ||
*/ | ||
uint defaultPageSize = runtimeConfig.DefaultPageSize(); | ||
uint maxPageSize = runtimeConfig.MaxPageSize(); | ||
|
||
|
@@ -113,13 +120,24 @@ public static OkObjectResult FormatFindResult( | |
queryStringParameters: context!.ParsedQueryString, | ||
after); | ||
|
||
//Get the element RecordCount from the first element of the array | ||
JsonElement recordCountElement = rootEnumerated[0].GetProperty("RecordCount"); | ||
string jsonRecordCount = JsonSerializer.Serialize(new[] | ||
{ | ||
new | ||
{ | ||
recordCount = @$"{rootEnumerated[0].GetProperty("RecordCount")}" | ||
} | ||
}); | ||
|
||
// When there are extra fields present, they are removed before returning the response. | ||
if (extraFieldsInResponse.Count > 0) | ||
{ | ||
rootEnumerated = RemoveExtraFieldsInResponseWithMultipleItems(rootEnumerated, extraFieldsInResponse); | ||
} | ||
|
||
rootEnumerated.Add(nextLink); | ||
rootEnumerated.Add(JsonSerializer.Deserialize<JsonElement>(jsonRecordCount)); | ||
return OkResponse(JsonSerializer.SerializeToElement(rootEnumerated)); | ||
} | ||
|
||
|
@@ -218,13 +236,16 @@ public static OkObjectResult OkResponse(JsonElement jsonResult) | |
// we strip the "[" and "]" and then save the nextLink element | ||
// into a dictionary with a key of "nextLink" and a value that | ||
// represents the nextLink data we require. | ||
string nextLinkJsonString = JsonSerializer.Serialize(resultEnumerated[resultEnumerated.Count - 1]); | ||
string nextLinkJsonString = JsonSerializer.Serialize(resultEnumerated[resultEnumerated.Count - 2]); | ||
string recordCountJsonString = JsonSerializer.Serialize(resultEnumerated[resultEnumerated.Count - 1]); | ||
Dictionary<string, object> nextLink = JsonSerializer.Deserialize<Dictionary<string, object>>(nextLinkJsonString[1..^1])!; | ||
IEnumerable<JsonElement> value = resultEnumerated.Take(resultEnumerated.Count - 1); | ||
Dictionary<string, object> recordCount = JsonSerializer.Deserialize<Dictionary<string, object>>(recordCountJsonString[1..^1])!; | ||
IEnumerable<JsonElement> value = resultEnumerated.Take(resultEnumerated.Count - 2); | ||
return new OkObjectResult(new | ||
{ | ||
value = value, | ||
@nextLink = nextLink["nextLink"] | ||
@nextLink = nextLink["nextLink"], | ||
@recordCount = recordCount["recordCount"] | ||
}); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.2.2" /> | ||
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.38.1" /> | ||
<!--When updating Microsoft.Data.SqlClient, update license URL in scripts/notice-generation.ps1--> | ||
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.0" /> | ||
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.1.4" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please retain the updated 5.2.0 version |
||
<PackageVersion Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.22.0" /> | ||
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.5.0" /> | ||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will soon update this to 8.0. Please refrain from doing so right now.