mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-04-04 01:48:18 +02:00
fix sql scanning without sqlx magic.
This commit is contained in:
parent
638b9262ec
commit
fa0079c020
@ -134,12 +134,22 @@ func (b *BasicRelay) QueryEvents(filter *nostr.Filter) (events []nostr.Event, er
|
||||
strings.Join(conditions, " AND ") +
|
||||
" ORDER BY created_at LIMIT 100")
|
||||
|
||||
err = b.DB.Select(&events, query, params...)
|
||||
rows, err := b.DB.Query(query, params...)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
log.Warn().Err(err).Interface("filter", filter).Str("query", query).
|
||||
Msg("failed to fetch events")
|
||||
err = fmt.Errorf("failed to fetch events: %w", err)
|
||||
return nil, fmt.Errorf("failed to fetch events: %w", err)
|
||||
}
|
||||
|
||||
return
|
||||
for rows.Next() {
|
||||
var evt nostr.Event
|
||||
err := rows.Scan(&evt.ID, &evt.PubKey, &evt.CreatedAt,
|
||||
&evt.Kind, &evt.Tags, &evt.Content, &evt.Sig)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to scan row: %w", err)
|
||||
}
|
||||
events = append(events, evt)
|
||||
}
|
||||
|
||||
return events, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user