Skip to content

Commit f665b3a

Browse files
committed
reduce warnings
1 parent 8436e6d commit f665b3a

File tree

5 files changed

+39
-29
lines changed

5 files changed

+39
-29
lines changed

c/xtdb_test.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ static void build_transit_string(char *buf, size_t buf_size, const char *key, co
5454
snprintf(buf, buf_size, "\"~:%s\",%s", key, value);
5555
}
5656

57-
static void build_transit_json(char *buf, size_t buf_size, int num_pairs, ...) {
58-
strcat(buf, "[\"^ \"");
59-
/* Note: full implementation would use varargs, simplified for basic testing */
60-
}
61-
6257
// Basic Operations Tests
6358

6459
TEST(connection) {
@@ -643,6 +638,7 @@ TEST(transit_json_format) {
643638
}
644639

645640
TEST(transit_json_encoding) {
641+
(void)conn; /* This test doesn't use database connection */
646642
/* Test basic transit encoding format */
647643
char transit_buf[512] = "";
648644

@@ -677,7 +673,7 @@ TEST(transit_msgpack_copy_from) {
677673
ASSERT(fp != NULL, "Failed to open msgpack file");
678674

679675
fseek(fp, 0, SEEK_END);
680-
long file_size = ftell(fp);
676+
size_t file_size = (size_t)ftell(fp);
681677
fseek(fp, 0, SEEK_SET);
682678

683679
char *msgpack_data = malloc(file_size);
@@ -730,7 +726,7 @@ TEST(transit_json_copy_from) {
730726
ASSERT(fp != NULL, "Failed to open transit-json file");
731727

732728
fseek(fp, 0, SEEK_END);
733-
long file_size = ftell(fp);
729+
size_t file_size = (size_t)ftell(fp);
734730
fseek(fp, 0, SEEK_SET);
735731

736732
char *json_data = malloc(file_size + 1);

csharp/AdbcTest.cs

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ public void TestConnection()
8383
}
8484

8585
[Fact]
86-
public void TestSimpleQuery()
86+
public async Task TestSimpleQuery()
8787
{
8888
using var stmt = _connection.CreateStatement();
8989
stmt.SqlQuery = "SELECT 1 AS x, 'hello' AS greeting";
9090

9191
var result = stmt.ExecuteQuery();
9292
Assert.NotNull(result.Stream);
9393

94-
var batch = result.Stream.ReadNextRecordBatchAsync().Result;
94+
var batch = await result.Stream.ReadNextRecordBatchAsync();
9595
Assert.NotNull(batch);
9696
Assert.Equal(1, batch.Length);
9797
Assert.Equal(2, batch.ColumnCount);
@@ -108,16 +108,17 @@ public void TestSimpleQuery()
108108
}
109109

110110
[Fact]
111-
public void TestQueryWithExpressions()
111+
public async Task TestQueryWithExpressions()
112112
{
113113
using var stmt = _connection.CreateStatement();
114114
stmt.SqlQuery = "SELECT 2 + 2 AS sum, UPPER('hello') AS upper_greeting";
115115

116116
var result = stmt.ExecuteQuery();
117-
var batch = result.Stream.ReadNextRecordBatchAsync().Result;
117+
Assert.NotNull(result.Stream);
118+
var batch = await result.Stream!.ReadNextRecordBatchAsync();
118119

119120
Assert.NotNull(batch);
120-
Assert.Equal(1, batch.Length);
121+
Assert.Equal(1, batch!.Length);
121122
}
122123

123124
[Fact]
@@ -133,7 +134,7 @@ public void TestSystemTables()
133134
// === DML Tests ===
134135

135136
[Fact]
136-
public void TestInsertAndQuery()
137+
public async Task TestInsertAndQuery()
137138
{
138139
var table = GetCleanTable();
139140

@@ -154,10 +155,11 @@ public void TestInsertAndQuery()
154155
using var queryStmt = _connection.CreateStatement();
155156
queryStmt.SqlQuery = $"SELECT * FROM {table} ORDER BY _id";
156157
var result = queryStmt.ExecuteQuery();
157-
var batch = result.Stream.ReadNextRecordBatchAsync().Result;
158+
Assert.NotNull(result.Stream);
159+
var batch = await result.Stream!.ReadNextRecordBatchAsync();
158160

159161
Assert.NotNull(batch);
160-
Assert.Equal(3, batch.Length);
162+
Assert.Equal(3, batch!.Length);
161163
}
162164
finally
163165
{
@@ -166,7 +168,7 @@ public void TestInsertAndQuery()
166168
}
167169

168170
[Fact]
169-
public void TestUpdate()
171+
public async Task TestUpdate()
170172
{
171173
var table = GetCleanTable();
172174

@@ -190,10 +192,11 @@ public void TestUpdate()
190192
using var queryStmt = _connection.CreateStatement();
191193
queryStmt.SqlQuery = $"SELECT price FROM {table} WHERE _id = 1";
192194
var result = queryStmt.ExecuteQuery();
193-
var batch = result.Stream.ReadNextRecordBatchAsync().Result;
195+
Assert.NotNull(result.Stream);
196+
var batch = await result.Stream!.ReadNextRecordBatchAsync();
194197

195198
Assert.NotNull(batch);
196-
Assert.Equal(1, batch.Length);
199+
Assert.Equal(1, batch!.Length);
197200
}
198201
finally
199202
{
@@ -202,7 +205,7 @@ public void TestUpdate()
202205
}
203206

204207
[Fact]
205-
public void TestDelete()
208+
public async Task TestDelete()
206209
{
207210
var table = GetCleanTable();
208211

@@ -226,10 +229,11 @@ public void TestDelete()
226229
using var queryStmt = _connection.CreateStatement();
227230
queryStmt.SqlQuery = $"SELECT * FROM {table}";
228231
var result = queryStmt.ExecuteQuery();
229-
var batch = result.Stream.ReadNextRecordBatchAsync().Result;
232+
Assert.NotNull(result.Stream);
233+
var batch = await result.Stream!.ReadNextRecordBatchAsync();
230234

231235
Assert.NotNull(batch);
232-
Assert.Equal(1, batch.Length);
236+
Assert.Equal(1, batch!.Length);
233237
}
234238
finally
235239
{
@@ -238,7 +242,7 @@ public void TestDelete()
238242
}
239243

240244
[Fact]
241-
public void TestHistoricalQuery()
245+
public async Task TestHistoricalQuery()
242246
{
243247
var table = GetCleanTable();
244248

@@ -262,11 +266,12 @@ public void TestHistoricalQuery()
262266
using var queryStmt = _connection.CreateStatement();
263267
queryStmt.SqlQuery = $"SELECT *, _valid_from, _valid_to FROM {table} FOR ALL VALID_TIME ORDER BY _id, _valid_from";
264268
var result = queryStmt.ExecuteQuery();
265-
var batch = result.Stream.ReadNextRecordBatchAsync().Result;
269+
Assert.NotNull(result.Stream);
270+
var batch = await result.Stream!.ReadNextRecordBatchAsync();
266271

267272
Assert.NotNull(batch);
268273
// Should have 2 versions
269-
Assert.Equal(2, batch.Length);
274+
Assert.Equal(2, batch!.Length);
270275
}
271276
finally
272277
{
@@ -275,7 +280,7 @@ public void TestHistoricalQuery()
275280
}
276281

277282
[Fact]
278-
public void TestErase()
283+
public async Task TestErase()
279284
{
280285
var table = GetCleanTable();
281286

@@ -306,11 +311,12 @@ public void TestErase()
306311
using var queryStmt = _connection.CreateStatement();
307312
queryStmt.SqlQuery = $"SELECT * FROM {table} FOR ALL VALID_TIME ORDER BY _id";
308313
var result = queryStmt.ExecuteQuery();
309-
var batch = result.Stream.ReadNextRecordBatchAsync().Result;
314+
Assert.NotNull(result.Stream);
315+
var batch = await result.Stream!.ReadNextRecordBatchAsync();
310316

311317
Assert.NotNull(batch);
312318
// Only record 2 should remain
313-
Assert.Equal(1, batch.Length);
319+
Assert.Equal(1, batch!.Length);
314320
}
315321
finally
316322
{

csharp/XtdbTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public async Task TestParseTransitJson()
368368
}
369369

370370
[Fact]
371-
public async Task TestTransitJsonEncoding()
371+
public void TestTransitJsonEncoding()
372372
{
373373
// Test transit encoding capabilities
374374
var data = new Dictionary<string, object>

csharp/XtdbTests.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>net9.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<IsTestProject>true</IsTestProject>
7+
<Nullable>enable</Nullable>
78
<!-- Suppress experimental API warnings - the PgTypeInfoResolverFactory API is marked experimental -->
89
<NoWarn>$(NoWarn);NPG9001</NoWarn>
910
<!-- Disable auto-generation of assembly info to avoid duplicates -->
@@ -29,4 +30,11 @@
2930
<ProjectReference Include="Npgsql.XtdbTransit\Npgsql.XtdbTransit.csproj" />
3031
</ItemGroup>
3132

33+
<ItemGroup>
34+
<!-- Exclude XtdbHelloWorld.cs from test project - it's a standalone demo, not a test -->
35+
<Compile Remove="XtdbHelloWorld.cs" />
36+
<!-- Exclude Npgsql.XtdbTransit source files - they're compiled via ProjectReference -->
37+
<Compile Remove="Npgsql.XtdbTransit\**\*.cs" />
38+
</ItemGroup>
39+
3240
</Project>

elixir/lib/xtdb_example.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ defmodule XTDBExample do
433433
Postgrex.rollback(conn, :done)
434434
rescue
435435
e ->
436-
if String.contains?(to_string(e), "COPY IN not in progress") do
436+
if String.contains?(Exception.message(e), "COPY IN not in progress") do
437437
IO.puts("✗ BUG REPRODUCED: 'COPY IN not in progress' error!")
438438
IO.puts(" Error: #{inspect(e)}")
439439
Postgrex.rollback(conn, {:error, :bug_reproduced})

0 commit comments

Comments
 (0)