This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/main by this push:
new f18a7b4ee Fix time_seq since function clause
f18a7b4ee is described below
commit f18a7b4eedc973b032ab4fb1e2383c3d6c55f1fb
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Mon Feb 23 18:08:13 2026 -0500
Fix time_seq since function clause
If user specifies a correctly formatted timestamp but it's before 0 unix
time,
return entries since 0 unix time (1970-01-01T00:00:00Z) instead of a
function
clause error.
---
src/chttpd/test/eunit/chttpd_changes_test.erl | 8 ++++++++
src/fabric/src/fabric.erl | 2 ++
2 files changed, 10 insertions(+)
diff --git a/src/chttpd/test/eunit/chttpd_changes_test.erl
b/src/chttpd/test/eunit/chttpd_changes_test.erl
index a89842ae3..8c70c3288 100644
--- a/src/chttpd/test/eunit/chttpd_changes_test.erl
+++ b/src/chttpd/test/eunit/chttpd_changes_test.erl
@@ -534,6 +534,14 @@ t_time_since({_, DbUrl}) ->
"Invalid time"
),
+ Params4 = "?since=1000-01-01T01:01:01Z",
+ Res4 = {_, _, _} = changes(DbUrl, Params4),
+ ?assertEqual(
+ Res4,
+ changes(DbUrl, "?since=0"),
+ "Expected the same result as from '?since=0'"
+ ),
+
{TSeqCode, TSeqRes} = reqraw(get, DbUrl ++ "/_time_seq"),
?assertEqual(200, TSeqCode),
Year = integer_to_binary(element(1, date())),
diff --git a/src/fabric/src/fabric.erl b/src/fabric/src/fabric.erl
index 3a6ce7ebd..1b8434b03 100644
--- a/src/fabric/src/fabric.erl
+++ b/src/fabric/src/fabric.erl
@@ -678,6 +678,8 @@ time_seq_since(DbName, Time) when is_list(Time) ->
_:_ ->
{error, invalid_time_format}
end;
+time_seq_since(DbName, Time) when is_integer(Time), Time < 0 ->
+ time_seq_since(DbName, 0);
time_seq_since(DbName, Time) when is_integer(Time), Time >= 0 ->
fabric_time_seq:since(dbname(DbName), Time).