Skip to content

Commit 13e2b3e

Browse files
committed
2.15.0 initial
1 parent be20eb8 commit 13e2b3e

51 files changed

Lines changed: 1541 additions & 1512 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NpgsqlRest/Auth/AuthHandler.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ internal static class AuthHandler
1212
public static async Task HandleLoginAsync(
1313
NpgsqlCommand command,
1414
HttpContext context,
15-
RoutineEndpoint endpoint,
1615
Routine routine,
1716
NpgsqlRestOptions options,
1817
ILogger? logger)
@@ -38,8 +37,8 @@ public static async Task HandleLoginAsync(
3837

3938
for (int i = 0; i < routine.ColumnCount; i++)
4039
{
41-
var name1 = routine.ColumnNames[i];
42-
var name2 = endpoint.ColumnNames[i];
40+
var name1 = routine.OriginalColumnNames[i];
41+
var name2 = routine.ColumnNames[i];
4342
var descriptor = routine.ColumnsTypeDescriptor[i];
4443

4544
if (options.AuthenticationOptions.StatusColumnName is not null)

NpgsqlRest/Defaults/DefaultCommentParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ internal static class DefaultCommentParser
125125
"column-names"
126126
];
127127

128-
public static RoutineEndpoint? Parse(ref Routine routine, ref NpgsqlRestOptions options, ref ILogger? logger, ref RoutineEndpoint routineEndpoint)
128+
public static RoutineEndpoint? Parse(ref Routine routine, ref RoutineEndpoint routineEndpoint, NpgsqlRestOptions options, ILogger? logger)
129129
{
130130
if (options.CommentsMode == CommentsMode.Ignore)
131131
{
@@ -556,7 +556,7 @@ internal static class DefaultCommentParser
556556
// newline [ value ]
557557
else if (haveTag is true && len >= 2 && line.StartsWith(string.Concat(NewLineKey, " ")))
558558
{
559-
var nl = line.Substring(words[0].Length + 1);
559+
var nl = line[(words[0].Length + 1)..];
560560
logger?.CommentSetRawNewLineSeparator(routine.Type, routine.Schema, routine.Name, nl);
561561
routineEndpoint.RawNewLineSeparator = Regex.Unescape(nl);
562562
}

NpgsqlRest/Defaults/DefaultEndpoint.cs

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,11 @@ internal static class DefaultEndpoint
2525
RequestParamType.QueryString :
2626
RequestParamType.BodyJson;
2727

28-
string[] returnRecordNames = new string[routine.ColumnNames.Length];
29-
for (int i = 0; i < routine.ColumnNames.Length; i++)
30-
{
31-
returnRecordNames[i] = options.NameConverter(routine.ColumnNames[i]) ?? "";
32-
}
33-
34-
string[] paramNames = new string[routine.ParamNames.Length];
35-
for (int i = 0; i < routine.ParamNames.Length; i++)
36-
{
37-
var result = options.NameConverter(routine.ParamNames[i]) ?? "";
38-
if (string.IsNullOrEmpty(result))
39-
{
40-
result = $"${i + 1}";
41-
}
42-
paramNames[i] = result;
43-
}
44-
4528
RoutineEndpoint routineEndpoint = new(
4629
url: url,
4730
method: method,
4831
requestParamType: requestParamType,
4932
requiresAuthorization: options.RequiresAuthorization,
50-
columnNames: returnRecordNames,
51-
paramNames: paramNames,
5233
commandTimeout: options.CommandTimeout,
5334
responseContentType: null,
5435
responseHeaders: [],
@@ -74,17 +55,18 @@ internal static class DefaultEndpoint
7455
{
7556
var parsed = DefaultCommentParser.Parse(
7657
ref routine,
77-
ref options,
78-
ref logger,
79-
ref routineEndpoint);
58+
ref routineEndpoint,
59+
options,
60+
logger);
8061
#pragma warning disable CS8602 // Dereference of a possibly null reference.
8162
return routine.EndpointHandler(parsed);
8263
#pragma warning restore CS8602 // Dereference of a possibly null reference.
8364
}
65+
8466
return DefaultCommentParser.Parse(
85-
ref routine,
86-
ref options,
87-
ref logger,
88-
ref routineEndpoint);
67+
ref routine,
68+
ref routineEndpoint,
69+
options,
70+
logger);
8971
}
9072
}

NpgsqlRest/Enums.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public enum RoutineType { Table, View, Function, Procedure, Other }
44
public enum CrudType { Select, Insert, Update, Delete }
55
public enum Method { GET, PUT, POST, DELETE, HEAD, OPTIONS, TRACE, PATCH, CONNECT }
66
public enum RequestParamType { QueryString, BodyJson }
7+
public enum ParamType { QueryString, BodyJson, BodyParam, HeaderParam }
78
public enum CommentHeader { None, Simple, Full }
89
public enum TextResponseNullHandling { EmptyString, NullLiteral, NoContent }
910
public enum QueryStringNullHandling { EmptyString, NullLiteral, Ignore }

NpgsqlRest/Interfaces.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ public interface IRoutineSourceParameterFormatter
4949
/// <param name="index">index of the current parameter</param>
5050
/// <param name="count">total parameter count</param>
5151
/// <returns>string to append to expression or null to skip (404 if endpoint is not handled in the next handler)</returns>
52-
string? AppendCommandParameter(ref NpgsqlRestParameter parameter, ref int index, ref int count) => null;
52+
string? AppendCommandParameter(NpgsqlRestParameter parameter, int index, int count) => null;
5353

5454
/// <summary>
5555
/// Formats the command expression string.
5656
/// </summary>
5757
/// <param name="routine">Current routine data</param>
5858
/// <param name="parameters">Extended parameters list.</param>
5959
/// <returns>expression string or null to skip (404 if endpoint is not handled in the next handler)</returns>
60-
string? FormatCommand(ref Routine routine, ref List<NpgsqlRestParameter> parameters) => null;
60+
string? FormatCommand(Routine routine, List<NpgsqlRestParameter> parameters) => null;
6161

6262
/// <summary>
6363
/// Called when there are no parameters to append.
@@ -73,7 +73,7 @@ public interface IRoutineSourceParameterFormatter
7373
/// <param name="count">total parameter count</param>
7474
/// <param name="context">HTTP context reference</param>
7575
/// <returns>string to append to expression or null to skip (404 if endpoint is not handled in the next handler)</returns>
76-
string? AppendCommandParameter(ref NpgsqlRestParameter parameter, ref int index, ref int count, ref HttpContext context) => null;
76+
string? AppendCommandParameter(NpgsqlRestParameter parameter, int index, int count, HttpContext context) => null;
7777

7878
/// <summary>
7979
/// Formats the command expression string.
@@ -82,14 +82,14 @@ public interface IRoutineSourceParameterFormatter
8282
/// <param name="parameters">Extended parameters list.</param>
8383
/// <param name="context">HTTP context reference</param>
8484
/// <returns>expression string or null to skip (404 if endpoint is not handled in the next handler)</returns>
85-
string? FormatCommand(ref Routine routine, ref List<NpgsqlRestParameter> parameters, ref HttpContext context) => null;
85+
string? FormatCommand(Routine routine, List<NpgsqlRestParameter> parameters, HttpContext context) => null;
8686

8787
/// <summary>
8888
/// Called when there are no parameters to append.
8989
/// </summary>
9090
/// <param name="context">HTTP context reference</param>
9191
/// <returns>string to append to expression or null to skip (404 if endpoint is not handled in the next handler)</returns>
92-
string? AppendEmpty(ref HttpContext context) => null;
92+
string? AppendEmpty(HttpContext context) => null;
9393
}
9494

9595
public interface IRoutineSource

0 commit comments

Comments
 (0)