From 4648e71e8651d5a9047ef9705f956cdb85b646f6 Mon Sep 17 00:00:00 2001 From: Chris Garvis Date: Tue, 12 May 2026 22:59:54 -0400 Subject: [PATCH] Widen num_rows typespec to include :copy_stream and nil The COPY IN streaming path sets num_rows to the atom :copy_stream as a sentinel value (protocol.ex:2733), and multi-command transaction results set num_rows to nil (protocol.ex:3099). Both are intentional and tested, but the @type t declaration only allowed integer. Widen num_rows to integer | :copy_stream | nil to match the actual runtime values produced by the driver. --- lib/postgrex/result.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/postgrex/result.ex b/lib/postgrex/result.ex index 1e39ca39..3cd4d7a9 100644 --- a/lib/postgrex/result.ex +++ b/lib/postgrex/result.ex @@ -7,7 +7,8 @@ defmodule Postgrex.Result do * `columns` - The column names; * `rows` - The result set. A list of lists, each inner list corresponding to a row, each element in the inner list corresponds to a column; - * `num_rows` - The number of fetched or affected rows; + * `num_rows` - The number of fetched or affected rows, or `:copy_stream` while + a COPY FROM STDIN stream is in progress, or `nil` for multi-command results; * `connection_id` - The OS pid of the PostgreSQL backend that executed the query; * `messages` - A list of maps of messages, such as hints and notices, sent by the driver during the execution of the query. @@ -17,7 +18,7 @@ defmodule Postgrex.Result do command: atom | [atom], columns: [String.t()] | nil, rows: [[term] | binary] | nil, - num_rows: integer, + num_rows: integer | :copy_stream | nil, connection_id: pos_integer, messages: [map()] }