Skip to content

Commit f6ce34e

Browse files
committed
1.5.1
1 parent 1689e15 commit f6ce34e

7 files changed

Lines changed: 364 additions & 31 deletions

File tree

NpgsqlRest/NpgsqlRest.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2929
<PackageReadmeFile>README.MD</PackageReadmeFile>
3030
<DocumentationFile>bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile>
31-
<Version>1.5.0</Version>
32-
<AssemblyVersion>1.5.0</AssemblyVersion>
33-
<FileVersion>1.5.0</FileVersion>
34-
<PackageVersion>1.5.0</PackageVersion>
31+
<Version>1.5.1</Version>
32+
<AssemblyVersion>1.5.1</AssemblyVersion>
33+
<FileVersion>1.5.1</FileVersion>
34+
<PackageVersion>1.5.1</PackageVersion>
3535
</PropertyGroup>
3636

3737
<ItemGroup>

NpgsqlRest/PgConverters.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ bool IsNull()
174174
current.Append(currentChar);
175175
}
176176
}
177-
else
177+
else if (descriptor.IsDateTime)
178+
{
179+
//json time requires T between date and time
180+
current.Append(currentChar == ' ' ? 'T' : currentChar);
181+
}
182+
else
178183
{
179184
if (currentChar == '\n')
180185
{

NpgsqlRestPerfTest/NpgsqlRestPerfTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="NpgsqlRest" Version="1.4.0" />
13+
<PackageReference Include="NpgsqlRest" Version="1.5.0" />
1414
</ItemGroup>
1515

1616
</Project>

NpgsqlRestPerfTest/perf_tests.http

Lines changed: 122 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
@host=http://localhost:5000
22

3-
// NpgsqlRest endpoint test
4-
53
// function public.perf_test(
64
// _records integer,
75
// _text_param text,
@@ -25,11 +23,85 @@ POST {{host}}/api/perf-test
2523
content-type: application/json
2624

2725
{
28-
"_records": 5,
29-
"_text_param": "ABCXYZ",
30-
"_int_param": 99,
31-
"_ts_param": "2024-01-19",
32-
"_bool_param": true
26+
"_records": 5,
27+
"_text_param": "ABCXYZ",
28+
"_int_param": 99,
29+
"_ts_param": "2024-01-19",
30+
"_bool_param": true
31+
}
32+
33+
###
34+
35+
// function public.perf_test_arrays(
36+
// _records integer,
37+
// _text_param text,
38+
// _int_param integer,
39+
// _ts_param timestamp without time zone,
40+
// _bool_param boolean
41+
// )
42+
// returns table(
43+
// id1 integer[],
44+
// foo1 text[],
45+
// bar1 text[],
46+
// datetime1 timestamp without time zone[],
47+
// id2 integer[],
48+
// foo2 text[],
49+
// bar2 text[],
50+
// datetime2 timestamp without time zone[],
51+
// long_foo_bar text[],
52+
// is_foobar boolean[]
53+
// )
54+
POST {{host}}/api/perf-test-arrays
55+
content-type: application/json
56+
57+
{
58+
"_records": 5,
59+
"_text_param": "ABCXYZ",
60+
"_int_param": 99,
61+
"_ts_param": "2024-01-19",
62+
"_bool_param": true
63+
}
64+
65+
###
66+
67+
// function public.perf_test_record(
68+
// _records integer,
69+
// _text_param text,
70+
// _int_param integer,
71+
// _ts_param timestamp without time zone,
72+
// _bool_param boolean
73+
// )
74+
// returns setof record
75+
POST {{host}}/api/perf-test-record
76+
content-type: application/json
77+
78+
{
79+
"_records": 5,
80+
"_text_param": "ABCXYZ",
81+
"_int_param": 99,
82+
"_ts_param": "2024-01-19",
83+
"_bool_param": true
84+
}
85+
86+
###
87+
88+
// function public.perf_test_record_arrays(
89+
// _records integer,
90+
// _text_param text,
91+
// _int_param integer,
92+
// _ts_param timestamp without time zone,
93+
// _bool_param boolean
94+
// )
95+
// returns setof record
96+
POST {{host}}/api/perf-test-record-arrays
97+
content-type: application/json
98+
99+
{
100+
"_records": 5,
101+
"_text_param": "ABCXYZ",
102+
"_int_param": 99,
103+
"_ts_param": "2024-01-19",
104+
"_bool_param": true
33105
}
34106

35107
###
@@ -40,11 +112,49 @@ POST http://127.0.0.1:3000/rpc/perf_test
40112
content-type: application/json
41113

42114
{
43-
"_records": 5,
44-
"_text_param": "ABCXYZ",
45-
"_int_param": 99,
46-
"_ts_param": "2024-01-19",
47-
"_bool_param": true
115+
"_records": 5,
116+
"_text_param": "ABCXYZ",
117+
"_int_param": 99,
118+
"_ts_param": "2024-01-19",
119+
"_bool_param": true
120+
}
121+
122+
###
123+
124+
POST http://127.0.0.1:3000/rpc/perf_test_arrays
125+
content-type: application/json
126+
127+
{
128+
"_records": 5,
129+
"_text_param": "ABCXYZ",
130+
"_int_param": 99,
131+
"_ts_param": "2024-01-19",
132+
"_bool_param": true
48133
}
49134

50135
###
136+
137+
138+
POST http://127.0.0.1:3000/rpc/perf_test_record
139+
content-type: application/json
140+
141+
{
142+
"_records": 5,
143+
"_text_param": "ABCXYZ",
144+
"_int_param": 99,
145+
"_ts_param": "2024-01-19",
146+
"_bool_param": true
147+
}
148+
149+
###
150+
151+
POST http://127.0.0.1:3000/rpc/perf_test_record_arrays
152+
content-type: application/json
153+
154+
{
155+
"_records": 5,
156+
"_text_param": "ABCXYZ",
157+
"_int_param": 99,
158+
"_ts_param": "2024-01-19",
159+
"_bool_param": true
160+
}

NpgsqlRestPerfTest/test_function.sql

Lines changed: 128 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
-- create on perf_tests database
22

3-
4-
create function perf_test(
3+
create or replace function perf_test(
54
_records int,
65
_text_param text,
76
_int_param int,
@@ -23,20 +22,20 @@ returns table(
2322
language sql
2423
as
2524
$$
26-
select
27-
i + _int_param as id1,
28-
'foo' || '_' || _text_param || '_' || i::text as foo1,
29-
'bar' || i::text as bar1,
30-
(_ts_param::date) + (i::text || ' days')::interval as datetime1,
31-
i+1 + _int_param as id2,
32-
'foo' || '_' || _text_param || '_' || (i+1)::text as foo2,
33-
'bar' || '_' || _text_param || '_' || (i+1)::text as bar2,
34-
(_ts_param::date) + ((i+1)::text || ' days')::interval as datetime2,
25+
select
26+
i + _int_param as id1,
27+
'foo' || '_' || _text_param || '_' || i::text as foo1,
28+
'bar' || i::text as bar1,
29+
(_ts_param::date) + (i::text || ' days')::interval as datetime1,
30+
i+1 + _int_param as id2,
31+
'foo' || '_' || _text_param || '_' || (i+1)::text as foo2,
32+
'bar' || '_' || _text_param || '_' || (i+1)::text as bar2,
33+
(_ts_param::date) + ((i+1)::text || ' days')::interval as datetime2,
3534
'long_foo_bar_' || '_' || _text_param || '_' || (i+2)::text as long_foo_bar,
3635
(i % 2)::boolean and _bool_param as is_foobar
37-
from
36+
from
3837
generate_series(1, _records) as i
39-
$$;
38+
$$;
4039
/*
4140
select * from perf_test(
4241
_records => 10,
@@ -46,3 +45,119 @@ select * from perf_test(
4645
_bool_param => true
4746
)
4847
*/
48+
49+
create or replace function perf_test_arrays(
50+
_records int,
51+
_text_param text,
52+
_int_param int,
53+
_ts_param timestamp,
54+
_bool_param bool
55+
)
56+
returns table(
57+
id1 int[],
58+
foo1 text[],
59+
bar1 text[],
60+
datetime1 timestamp[],
61+
id2 int[],
62+
foo2 text[],
63+
bar2 text[],
64+
datetime2 timestamp[],
65+
long_foo_bar text[],
66+
is_foobar bool[]
67+
)
68+
language sql
69+
as
70+
$$
71+
select
72+
array[i + _int_param, i + _int_param + 1, i + _int_param + 2] as id1,
73+
array['foo' || '_' || _text_param || '_' || i::text, 'foo2', 'foo3'] as foo1,
74+
array['bar' || i::text, 'bar2', 'bar3'] as bar1,
75+
array[(_ts_param::date) + (i::text || ' days')::interval, _ts_param::date + '1 days'::interval, _ts_param::date + '2 days'::interval] as datetime1,
76+
array[i+1 + _int_param, i+2 + _int_param, i+3 + _int_param] as id2,
77+
array['foo' || '_' || _text_param || '_' || (i+1)::text, 'foo' || '_' || _text_param || '_' || (i+2)::text, 'foo' || '_' || _text_param || '_' || (i+3)::text] as foo2,
78+
array['bar' || '_' || _text_param || '_' || (i+1)::text, 'bar' || '_' || _text_param || '_' || (i+2)::text, 'bar' || '_' || _text_param || '_' || (i+3)::text] as bar2,
79+
array[(_ts_param::date) + ((i+1)::text || ' days')::interval, _ts_param::date + '1 days'::interval, _ts_param::date + '2 days'::interval] as datetime2,
80+
array['long_foo_bar_' || '_' || _text_param || '_' || (i+2)::text, 'long_foo_bar_' || '_' || _text_param || '_' || (i+3)::text, 'long_foo_bar_' || '_' || _text_param || '_' || (i+4)::text] as long_foo_bar,
81+
array[(i % 2)::boolean and _bool_param, ((i+1) % 2)::boolean and _bool_param, ((i+2) % 2)::boolean and _bool_param] as is_foobar
82+
from
83+
generate_series(1, _records) as i
84+
$$;
85+
/*
86+
select * from perf_test_arrays(
87+
_records => 10,
88+
_text_param => 'abcxyz',
89+
_int_param => 999,
90+
_ts_param => '2024-01-01',
91+
_bool_param => true
92+
)
93+
*/
94+
95+
create or replace function perf_test_record(
96+
_records int,
97+
_text_param text,
98+
_int_param int,
99+
_ts_param timestamp,
100+
_bool_param bool
101+
)
102+
returns setof record
103+
language sql
104+
as
105+
$$
106+
select
107+
i + _int_param as id1,
108+
'foo' || '_' || _text_param || '_' || i::text as foo1,
109+
'bar' || i::text as bar1,
110+
(_ts_param::date) + (i::text || ' days')::interval as datetime1,
111+
i+1 + _int_param as id2,
112+
'foo' || '_' || _text_param || '_' || (i+1)::text as foo2,
113+
'bar' || '_' || _text_param || '_' || (i+1)::text as bar2,
114+
(_ts_param::date) + ((i+1)::text || ' days')::interval as datetime2,
115+
'long_foo_bar_' || '_' || _text_param || '_' || (i+2)::text as long_foo_bar,
116+
(i % 2)::boolean and _bool_param as is_foobar
117+
from
118+
generate_series(1, _records) as i
119+
$$;
120+
/*
121+
select perf_test_record(
122+
_records => 10,
123+
_text_param => 'abcxyz',
124+
_int_param => 999,
125+
_ts_param => '2024-01-01',
126+
_bool_param => true
127+
)
128+
*/
129+
130+
create or replace function perf_test_record_arrays(
131+
_records int,
132+
_text_param text,
133+
_int_param int,
134+
_ts_param timestamp,
135+
_bool_param bool
136+
)
137+
returns setof record
138+
language sql
139+
as
140+
$$
141+
select
142+
array[i + _int_param, i + _int_param + 1, i + _int_param + 2] as id1,
143+
array['foo' || '_' || _text_param || '_' || i::text, 'foo2', 'foo3'] as foo1,
144+
array['bar' || i::text, 'bar2', 'bar3'] as bar1,
145+
array[(_ts_param::date) + (i::text || ' days')::interval, _ts_param::date + '1 days'::interval, _ts_param::date + '2 days'::interval] as datetime1,
146+
array[i+1 + _int_param, i+2 + _int_param, i+3 + _int_param] as id2,
147+
array['foo' || '_' || _text_param || '_' || (i+1)::text, 'foo' || '_' || _text_param || '_' || (i+2)::text, 'foo' || '_' || _text_param || '_' || (i+3)::text] as foo2,
148+
array['bar' || '_' || _text_param || '_' || (i+1)::text, 'bar' || '_' || _text_param || '_' || (i+2)::text, 'bar' || '_' || _text_param || '_' || (i+3)::text] as bar2,
149+
array[(_ts_param::date) + ((i+1)::text || ' days')::interval, _ts_param::date + '1 days'::interval, _ts_param::date + '2 days'::interval] as datetime2,
150+
array['long_foo_bar_' || '_' || _text_param || '_' || (i+2)::text, 'long_foo_bar_' || '_' || _text_param || '_' || (i+3)::text, 'long_foo_bar_' || '_' || _text_param || '_' || (i+4)::text] as long_foo_bar,
151+
array[(i % 2)::boolean and _bool_param, ((i+1) % 2)::boolean and _bool_param, ((i+2) % 2)::boolean and _bool_param] as is_foobar
152+
from
153+
generate_series(1, _records) as i
154+
$$;
155+
/*
156+
select perf_test_record_arrays(
157+
_records => 10,
158+
_text_param => 'abcxyz',
159+
_int_param => 999,
160+
_ts_param => '2024-01-01',
161+
_bool_param => true
162+
)
163+
*/

0 commit comments

Comments
 (0)