Fix Neo4j query returning zero events for REQ filters (v0.49.1)
Some checks failed
Go / build-and-release (push) Failing after 29s
Some checks failed
Go / build-and-release (push) Failing after 29s
- Fix zero-value timestamp filter bug: since/until with value 0 were being added as WHERE clauses, causing queries to match no events - Fix event parsing: use direct slice assignment instead of copy() on nil slices for ID, Pubkey, and Sig fields Files modified: - pkg/neo4j/query-events.go: Fix buildCypherQuery and parseEventsFromResult Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -130,11 +130,13 @@ func (n *N) buildCypherQuery(f *filter.F, includeDeleteEvents bool) (string, map
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Time range filters - for temporal queries
|
// Time range filters - for temporal queries
|
||||||
if f.Since != nil {
|
// Note: Check both pointer and value - a zero timestamp (Unix epoch 1970) is almost
|
||||||
|
// certainly not a valid constraint as Nostr events didn't exist then
|
||||||
|
if f.Since != nil && f.Since.V > 0 {
|
||||||
params["since"] = f.Since.V
|
params["since"] = f.Since.V
|
||||||
whereClauses = append(whereClauses, "e.created_at >= $since")
|
whereClauses = append(whereClauses, "e.created_at >= $since")
|
||||||
}
|
}
|
||||||
if f.Until != nil {
|
if f.Until != nil && f.Until.V > 0 {
|
||||||
params["until"] = f.Until.V
|
params["until"] = f.Until.V
|
||||||
whereClauses = append(whereClauses, "e.created_at <= $until")
|
whereClauses = append(whereClauses, "e.created_at <= $until")
|
||||||
}
|
}
|
||||||
@@ -300,19 +302,17 @@ func (n *N) parseEventsFromResult(result *CollectedResult) ([]*event.E, error) {
|
|||||||
_ = tags.UnmarshalJSON([]byte(tagsStr))
|
_ = tags.UnmarshalJSON([]byte(tagsStr))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create event
|
// Create event with decoded binary fields
|
||||||
e := &event.E{
|
e := &event.E{
|
||||||
|
ID: id,
|
||||||
|
Pubkey: pubkey,
|
||||||
Kind: uint16(kind),
|
Kind: uint16(kind),
|
||||||
CreatedAt: createdAt,
|
CreatedAt: createdAt,
|
||||||
Content: []byte(content),
|
Content: []byte(content),
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
|
Sig: sig,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy fixed-size arrays
|
|
||||||
copy(e.ID[:], id)
|
|
||||||
copy(e.Sig[:], sig)
|
|
||||||
copy(e.Pubkey[:], pubkey)
|
|
||||||
|
|
||||||
events = append(events, e)
|
events = append(events, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v0.49.0
|
v0.49.1
|
||||||
|
|||||||
Reference in New Issue
Block a user