Skip to content

Commit 6de3c43

Browse files
committed
[DMS-277] checkpoint
1 parent 913fcb2 commit 6de3c43

File tree

3 files changed

+153
-1
lines changed

3 files changed

+153
-1
lines changed

src/backend/EdFi.DataManagementService.Backend.Postgresql/Deploy/Scripts/0000_Create_DMS_Schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
44
-- See the LICENSE and NOTICES files in the project root for more information.
55

6-
CREATE SCHEMA dms;
6+
CREATE SCHEMA IF NOT EXISTS dms;

src/backend/EdFi.DataManagementService.Backend.Postgresql/Operation/SqlAction.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ LockOption lockOption
6565
}
6666
};
6767

68+
await command.PrepareAsync();
6869
await using NpgsqlDataReader reader = await command.ExecuteReaderAsync();
6970

7071
if (!reader.HasRows)
@@ -105,6 +106,7 @@ LockOption lockOption
105106
}
106107
};
107108

109+
await command.PrepareAsync();
108110
await using NpgsqlDataReader reader = await command.ExecuteReaderAsync();
109111

110112
if (!reader.HasRows)
@@ -153,6 +155,7 @@ NpgsqlTransaction transaction
153155
}
154156
};
155157

158+
await command.PrepareAsync();
156159
await using NpgsqlDataReader reader = await command.ExecuteReaderAsync();
157160

158161
var documents = new List<JsonNode>();
@@ -186,6 +189,7 @@ NpgsqlTransaction transaction
186189
Parameters = { new() { Value = resourceName }, }
187190
};
188191

192+
await command.PrepareAsync();
189193
await using NpgsqlDataReader reader = await command.ExecuteReaderAsync();
190194

191195
if (!reader.HasRows)
@@ -226,6 +230,7 @@ NpgsqlTransaction transaction
226230
}
227231
};
228232

233+
await command.PrepareAsync();
229234
return Convert.ToInt64(await command.ExecuteScalarAsync());
230235
}
231236

@@ -257,6 +262,7 @@ NpgsqlTransaction transaction
257262
}
258263
};
259264

265+
await command.PrepareAsync();
260266
return await command.ExecuteNonQueryAsync();
261267
}
262268

@@ -299,6 +305,7 @@ LEFT JOIN dms.Alias a ON
299305
}
300306
};
301307

308+
await command.PrepareAsync();
302309
await using NpgsqlDataReader reader = await command.ExecuteReaderAsync();
303310

304311
if (!reader.HasRows)
@@ -345,6 +352,7 @@ NpgsqlTransaction transaction
345352
}
346353
};
347354

355+
await command.PrepareAsync();
348356
return Convert.ToInt64(await command.ExecuteScalarAsync());
349357
}
350358

@@ -384,6 +392,7 @@ NpgsqlTransaction transaction
384392
}
385393
};
386394

395+
await command.PrepareAsync();
387396
return await command.ExecuteNonQueryAsync();
388397
}
389398

@@ -418,6 +427,7 @@ FROM dms.Alias a
418427
}
419428
};
420429

430+
await command.PrepareAsync();
421431
await using NpgsqlDataReader reader = await command.ExecuteReaderAsync();
422432

423433
List<Guid> result = [];
@@ -456,6 +466,7 @@ USING dms.Document d
456466
}
457467
};
458468

469+
await command.PrepareAsync();
459470
int rowsAffected = await command.ExecuteNonQueryAsync();
460471
return rowsAffected;
461472
}
@@ -485,6 +496,7 @@ NpgsqlTransaction transaction
485496
}
486497
};
487498

499+
await command.PrepareAsync();
488500
int rowsAffected = await command.ExecuteNonQueryAsync();
489501
return rowsAffected;
490502
}
@@ -516,6 +528,9 @@ LockOption lockOption
516528
new() { Value = documentPartitionKey.Value }
517529
}
518530
};
531+
532+
await command.PrepareAsync();
533+
519534
try
520535
{
521536
await using NpgsqlDataReader reader = await command.ExecuteReaderAsync();

tests/RestClient/demo.http

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
@port = 5198
2+
3+
### Note, no descriptor validation yet
4+
5+
### Setup - POST School Year 2025
6+
POST http://localhost:{{port}}/data/ed-fi/schoolYearTypes
7+
8+
{
9+
"schoolYear": 2025,
10+
"currentSchoolYear": false,
11+
"schoolYearDescription": "Year 2025"
12+
}
13+
14+
### Setup - POST School1
15+
POST http://localhost:{{port}}/data/ed-fi/schools
16+
17+
{
18+
"schoolId": 123,
19+
"nameOfInstitution": "School1",
20+
"educationOrganizationCategories": [
21+
{
22+
"educationOrganizationCategoryDescriptor": "string"
23+
}
24+
],
25+
"gradeLevels": [
26+
{
27+
"gradeLevelDescriptor": "string"
28+
}
29+
]
30+
}
31+
32+
### POST Session1, depending on School1 and SchoolYear 2025
33+
34+
POST http://localhost:{{port}}/data/ed-fi/sessions
35+
36+
{
37+
"sessionName": "Session3",
38+
"schoolYearTypeReference": {
39+
"schoolYear": 1900
40+
},
41+
"beginDate": "2025-01-01",
42+
"endDate": "2025-12-12",
43+
"termDescriptor": "uri://ed-fi.org/TermDescriptor#Presentation",
44+
"totalInstructionalDays": 365,
45+
"schoolReference": {
46+
"schoolId": 123
47+
}
48+
}
49+
50+
### POST a bad Session2, invalid school
51+
52+
POST http://localhost:{{port}}/data/ed-fi/sessions
53+
54+
{
55+
"sessionName": "Session2",
56+
"schoolYearTypeReference": {
57+
"schoolYear": 2025
58+
},
59+
"beginDate": "2025-01-01",
60+
"endDate": "2025-12-12",
61+
"termDescriptor": "uri://ed-fi.org/TermDescriptor#Presentation",
62+
"totalInstructionalDays": 365,
63+
"schoolReference": {
64+
"schoolId": 999
65+
}
66+
}
67+
68+
69+
### POST AccountabilityRating1, depending on School1 as EducationOrganization and SchoolYear 2025
70+
71+
POST http://localhost:{{port}}/data/ed-fi/accountabilityRatings
72+
73+
{
74+
"ratingTitle": "AccountabilityRating1",
75+
"rating": "Good",
76+
"schoolYearTypeReference": {
77+
"schoolYear": 2025
78+
},
79+
"educationOrganizationReference": {
80+
"educationOrganizationId": 123
81+
}
82+
}
83+
84+
### Create AccountabilityRating2 with invalid EducationOrganization, expect error
85+
86+
POST http://localhost:{{port}}/data/ed-fi/accountabilityRatings
87+
88+
{
89+
"ratingTitle": "AccountabilityRating1",
90+
"rating": "Good",
91+
"schoolYearTypeReference": {
92+
"schoolYear": 2025
93+
},
94+
"educationOrganizationReference": {
95+
"educationOrganizationId": 999
96+
}
97+
}
98+
99+
### Delete School1, expect error
100+
DELETE http://localhost:{{port}}/data/ed-fi/schools/8168fcad-4bf3-4529-991a-2851b0dd1161
101+
102+
103+
### Create Survey referencing Session1
104+
105+
POST http://localhost:{{port}}/data/ed-fi/surveys
106+
107+
{
108+
"surveyIdentifier": "abc",
109+
"namespace": "defgh",
110+
"surveyTitle": "A Survey",
111+
"schoolYearTypeReference": {
112+
"schoolYear": 2025
113+
},
114+
"sessionReference": {
115+
"schoolId": 123,
116+
"schoolYear": 2025,
117+
"sessionName": "Session1"
118+
}
119+
}
120+
121+
### Update Survey with invalid Session
122+
PUT http://localhost:{{port}}/data/ed-fi/surveys/299f629e-170e-4e23-bd5e-68abcfc46a7e
123+
124+
{
125+
"id": "299f629e-170e-4e23-bd5e-68abcfc46a7e",
126+
"surveyIdentifier": "abc",
127+
"namespace": "defgh",
128+
"surveyTitle": "A Survey",
129+
"schoolYearTypeReference": {
130+
"schoolYear": 2025
131+
},
132+
"sessionReference": {
133+
"schoolId": 123,
134+
"schoolYear": 2025,
135+
"sessionName": "Invalid"
136+
}
137+
}

0 commit comments

Comments
 (0)