-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathRoutine.cs
More file actions
238 lines (195 loc) · 8.35 KB
/
Copy pathRoutine.cs
File metadata and controls
238 lines (195 loc) · 8.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
namespace NpgsqlRest;
public class Routine
{
/// <summary>
/// Routine type: Function, Procedure, Table, View, or other.
/// </summary>
public required RoutineType Type { get; init; }
/// <summary>
/// Schema name (parsed by quote_ident).
/// </summary>
public required string Schema { get; init; }
/// <summary>
/// PostgreSQL object name (parsed by quote_ident).
/// </summary>
public required string Name { get; init; }
/// <summary>
/// PostgreSQL object comment.
/// </summary>
public required string? Comment { get; init; }
/// <summary>
/// Strict or non-strict function. Strict functions will return NULL if any parameter is NULL.
/// </summary>
public required bool IsStrict { get; init; }
/// <summary>
/// The type of CRUD operation associated with the routine (Select, Insert, Update or Delete).
/// </summary>
public required CrudType CrudType { get; init; }
/// <summary>
/// Indicates whether the routine returns a PostgreSQL record type.
/// </summary>
public required bool ReturnsRecordType { get; init; }
/// <summary>
/// Indicates whether the routine returns a set of records or single record.
/// </summary>
public required bool ReturnsSet { get; init; }
/// <summary>
/// The number of columns returned.
/// </summary>
public required int ColumnCount { get; init; }
/// <summary>
/// The names of the returned columns.
/// </summary>
public required string[] OriginalColumnNames { get; init; }
/// <summary>
/// The converted names of the returned columns.
/// </summary>
public required string[] ColumnNames { get; init; }
/// <summary>
/// Pre-escaped JSON key strings for the returned columns (output of PgConverters.SerializeString).
/// </summary>
public required string[] JsonColumnNames { get; init; }
/// <summary>
/// The type descriptors for the returned columns.
/// </summary>
public required TypeDescriptor[] ColumnsTypeDescriptor { get; init; }
/// <summary>
/// Indicates whether the routine returns an unnamed set.
/// </summary>
public required bool ReturnsUnnamedSet { get; init; }
/// <summary>
/// Indicates whether the routine returns void.
/// </summary>
public required bool IsVoid { get; init; }
/// <summary>
/// The number of parameters.
/// </summary>
public required int ParamCount { get; init; }
/// <summary>
/// Parameters associated with the routine in the order they appear in the routine.
/// </summary>
public required NpgsqlRestParameter[] Parameters { get; init; }
/// <summary>
/// The hash of the parameters associated with the routine.
/// </summary>
public required HashSet<string> ParamsHash { get; init; }
/// <summary>
/// The hash of the parameters associated with the routine.
/// </summary>
public required HashSet<string> OriginalParamsHash { get; init; }
/// <summary>
/// The expression associated with the routine.
/// </summary>
public required string Expression { get; init; }
/// <summary>
/// The full definition of the routine. (Used for code-gen comments)
/// </summary>
public required string FullDefinition { get; init; }
/// <summary>
/// The simple definition of the routine. (Used for code-gen comments)
/// </summary>
public required string SimpleDefinition { get; init; }
/// <summary>
/// The format URL pattern for the routine. If used (not null), placeholder {0} is used to replace the default URL.
/// </summary>
public required string? FormatUrlPattern { get; init; }
/// <summary>
/// The tags associated with the routine.
/// </summary>
public required string[]? Tags { get; init; }
/// <summary>
/// The endpoint handler for the routine.
/// </summary>
public required Func<RoutineEndpoint?, RoutineEndpoint?>? EndpointHandler { get; init; }
/// <summary>
/// Routine is immutable. Will return same results for same inputs.
/// </summary>
public bool Immutable { get; init; } = false;
/// <summary>
/// The meta data associated with the routine.
/// </summary>
public required object? Metadata { get; init; }
internal bool[]? UnknownResultTypeList { get; set; } = null;
/// <summary>
/// When NestedJsonForCompositeTypes is enabled via comment annotation, this contains information
/// about which columns are composite types and their field names/types for nested JSON serialization.
/// Key: first expanded column index for the composite type
/// Value: (fieldNames, fieldDescriptors, convertedColumnName, expandedColumnIndices)
/// </summary>
public Dictionary<int, (string[] FieldNames, TypeDescriptor[] FieldDescriptors, string ConvertedColumnName, int[] ExpandedColumnIndices)>? CompositeColumnInfo { get; set; } = null;
/// <summary>
/// When NestedJsonForCompositeTypes is enabled, this contains information about columns that are
/// arrays of composite types. These arrays need special serialization to convert from PostgreSQL
/// tuple format {"(f1,f2,f3)"} to JSON array of objects [{"field1":f1,"field2":f2}].
/// Key: column index (0-based)
/// Value: (fieldNames for the composite element type, fieldDescriptors for each field)
/// </summary>
public Dictionary<int, (string[] FieldNames, TypeDescriptor[] FieldDescriptors)>? ArrayCompositeColumnInfo { get; set; } = null;
/// <summary>
/// For multi-command SQL files: per-command column metadata and command names.
/// When not null, the rendering uses NpgsqlBatch + NextResult() to iterate result sets
/// and wraps them in a JSON object {resultName: [rows], ...}. Void commands get null.
/// </summary>
public MultiCommandInfo[]? MultiCommandInfo { get; set; } = null;
/// <summary>
/// True if this routine uses multi-command rendering (JSON object with named result sets).
/// </summary>
public bool IsMultiCommand => MultiCommandInfo is not null;
/// <summary>
/// When true, multi-command log includes full SQL text. When false, only file path and statement count.
/// </summary>
public bool LogCommandText { get; set; }
}
/// <summary>
/// Metadata for one command in a multi-command SQL file endpoint.
/// </summary>
public class MultiCommandInfo
{
/// <summary>
/// Result key name in the JSON response. From positional @result annotation or default pattern.
/// </summary>
public required string Name { get; init; }
/// <summary>
/// Pre-escaped JSON key string for the result name (output of PgConverters.SerializeString).
/// </summary>
public required string JsonName { get; init; }
/// <summary>
/// The SQL statement for this command.
/// </summary>
public required string Statement { get; init; }
/// <summary>
/// Number of parameters this command uses (max $N index).
/// </summary>
public required int ParamCount { get; init; }
/// <summary>
/// Column count for this command's result set. 0 for void commands.
/// </summary>
public required int ColumnCount { get; init; }
/// <summary>
/// Column names for this command's result set (camelCase converted).
/// </summary>
public required string[] ColumnNames { get; init; }
/// <summary>
/// Pre-escaped JSON key strings for this command's result columns.
/// </summary>
public required string[] JsonColumnNames { get; init; }
/// <summary>
/// Type descriptors for this command's result columns.
/// </summary>
public required TypeDescriptor[] ColumnTypeDescriptors { get; init; }
/// <summary>
/// When true, this command returns a flat array of values instead of objects.
/// </summary>
public bool ReturnsUnnamedSet { get; init; }
/// <summary>
/// When true, only the first row of this command's result set is returned as a JSON object
/// instead of a JSON array. Configured via positional @single annotation.
/// </summary>
public bool IsSingle { get; init; }
/// <summary>
/// When true, this command is executed for side effects but produces no result key
/// in the JSON response. Used for transaction control, session commands, DO blocks,
/// and the @skip annotation.
/// </summary>
public bool IsSkipped { get; init; }
}