fix handleevents not prompting auth for event publish with auth-required
This commit is contained in:
@@ -58,7 +58,7 @@ func (d *D) GetSerialById(id []byte) (ser *types.Uint40, err error) {
|
||||
return
|
||||
}
|
||||
if !idFound {
|
||||
// err = errorf.T("id not found in database: %s", hex.Enc(id))
|
||||
err = errorf.E("id not found in database")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
// TestInlineSmallEventStorage tests the Reiser4-inspired inline storage optimization
|
||||
// for small events (<=384 bytes).
|
||||
// for small events (<=1024 bytes by default).
|
||||
func TestInlineSmallEventStorage(t *testing.T) {
|
||||
// Create a temporary directory for the database
|
||||
tempDir, err := os.MkdirTemp("", "test-inline-db-*")
|
||||
@@ -129,8 +129,8 @@ func TestInlineSmallEventStorage(t *testing.T) {
|
||||
largeEvent := event.New()
|
||||
largeEvent.Kind = kind.TextNote.K
|
||||
largeEvent.CreatedAt = timestamp.Now().V
|
||||
// Create content larger than 384 bytes
|
||||
largeContent := make([]byte, 500)
|
||||
// Create content larger than 1024 bytes (the default inline storage threshold)
|
||||
largeContent := make([]byte, 1500)
|
||||
for i := range largeContent {
|
||||
largeContent[i] = 'x'
|
||||
}
|
||||
|
||||
@@ -93,21 +93,12 @@ func (n *N) ProcessDelete(ev *event.E, admins [][]byte) error {
|
||||
continue
|
||||
}
|
||||
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
if result.Next(ctx) {
|
||||
record := result.Record()
|
||||
if record != nil {
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
if ok {
|
||||
if pubkeyStr, ok := recordMap["pubkey"].(string); ok {
|
||||
pubkeyValue, found := record.Get("pubkey")
|
||||
if found {
|
||||
if pubkeyStr, ok := pubkeyValue.(string); ok {
|
||||
pubkey, err := hex.Dec(pubkeyStr)
|
||||
if err != nil {
|
||||
continue
|
||||
@@ -160,12 +151,7 @@ LIMIT 1`
|
||||
return nil // Not deleted
|
||||
}
|
||||
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if ok && neo4jResult.Next(ctx) {
|
||||
if result.Next(ctx) {
|
||||
return fmt.Errorf("event has been deleted")
|
||||
}
|
||||
|
||||
|
||||
@@ -82,35 +82,30 @@ RETURN e.id AS id,
|
||||
events = make(map[uint64]*event.E)
|
||||
ctx := context.Background()
|
||||
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return events, nil
|
||||
}
|
||||
|
||||
for neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
for result.Next(ctx) {
|
||||
record := result.Record()
|
||||
if record == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
// Parse event
|
||||
idStr, _ := recordMap["id"].(string)
|
||||
kind, _ := recordMap["kind"].(int64)
|
||||
createdAt, _ := recordMap["created_at"].(int64)
|
||||
content, _ := recordMap["content"].(string)
|
||||
sigStr, _ := recordMap["sig"].(string)
|
||||
pubkeyStr, _ := recordMap["pubkey"].(string)
|
||||
tagsStr, _ := recordMap["tags"].(string)
|
||||
serialVal, _ := recordMap["serial"].(int64)
|
||||
idRaw, _ := record.Get("id")
|
||||
kindRaw, _ := record.Get("kind")
|
||||
createdAtRaw, _ := record.Get("created_at")
|
||||
contentRaw, _ := record.Get("content")
|
||||
sigRaw, _ := record.Get("sig")
|
||||
pubkeyRaw, _ := record.Get("pubkey")
|
||||
tagsRaw, _ := record.Get("tags")
|
||||
serialRaw, _ := record.Get("serial")
|
||||
|
||||
idStr, _ := idRaw.(string)
|
||||
kind, _ := kindRaw.(int64)
|
||||
createdAt, _ := createdAtRaw.(int64)
|
||||
content, _ := contentRaw.(string)
|
||||
sigStr, _ := sigRaw.(string)
|
||||
pubkeyStr, _ := pubkeyRaw.(string)
|
||||
tagsStr, _ := tagsRaw.(string)
|
||||
serialVal, _ := serialRaw.(int64)
|
||||
|
||||
id, err := hex.Dec(idStr)
|
||||
if err != nil {
|
||||
@@ -160,21 +155,13 @@ func (n *N) GetSerialById(id []byte) (ser *types.Uint40, err error) {
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid result type")
|
||||
}
|
||||
|
||||
if neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
if result.Next(ctx) {
|
||||
record := result.Record()
|
||||
if record != nil {
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
if ok {
|
||||
if serialVal, ok := recordMap["serial"].(int64); ok {
|
||||
serialRaw, found := record.Get("serial")
|
||||
if found {
|
||||
if serialVal, ok := serialRaw.(int64); ok {
|
||||
ser = &types.Uint40{}
|
||||
ser.Set(uint64(serialVal))
|
||||
return ser, nil
|
||||
@@ -221,28 +208,24 @@ RETURN e.id AS id, e.serial AS serial`
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return serials, nil
|
||||
}
|
||||
|
||||
for neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
for result.Next(ctx) {
|
||||
record := result.Record()
|
||||
if record == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
if !ok {
|
||||
idRaw, found := record.Get("id")
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
serialRaw, found := record.Get("serial")
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
|
||||
idStr, _ := recordMap["id"].(string)
|
||||
serialVal, _ := recordMap["serial"].(int64)
|
||||
idStr, _ := idRaw.(string)
|
||||
serialVal, _ := serialRaw.(int64)
|
||||
|
||||
serial := &types.Uint40{}
|
||||
serial.Set(uint64(serialVal))
|
||||
@@ -322,43 +305,45 @@ RETURN e.id AS id,
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid result type")
|
||||
}
|
||||
|
||||
if neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
if result.Next(ctx) {
|
||||
record := result.Record()
|
||||
if record != nil {
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
if ok {
|
||||
idStr, _ := recordMap["id"].(string)
|
||||
pubkeyStr, _ := recordMap["pubkey"].(string)
|
||||
createdAt, _ := recordMap["created_at"].(int64)
|
||||
|
||||
id, err := hex.Dec(idStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pubkey, err := hex.Dec(pubkeyStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fidpk = &store.IdPkTs{
|
||||
Id: id,
|
||||
Pub: pubkey,
|
||||
Ts: createdAt,
|
||||
Ser: serial,
|
||||
}
|
||||
|
||||
return fidpk, nil
|
||||
idRaw, found := record.Get("id")
|
||||
if !found {
|
||||
return nil, fmt.Errorf("event not found")
|
||||
}
|
||||
pubkeyRaw, found := record.Get("pubkey")
|
||||
if !found {
|
||||
return nil, fmt.Errorf("event not found")
|
||||
}
|
||||
createdAtRaw, found := record.Get("created_at")
|
||||
if !found {
|
||||
return nil, fmt.Errorf("event not found")
|
||||
}
|
||||
|
||||
idStr, _ := idRaw.(string)
|
||||
pubkeyStr, _ := pubkeyRaw.(string)
|
||||
createdAt, _ := createdAtRaw.(int64)
|
||||
|
||||
id, err := hex.Dec(idStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pubkey, err := hex.Dec(pubkeyStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fidpk = &store.IdPkTs{
|
||||
Id: id,
|
||||
Pub: pubkey,
|
||||
Ts: createdAt,
|
||||
Ser: serial,
|
||||
}
|
||||
|
||||
return fidpk, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,30 +382,34 @@ RETURN e.id AS id,
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return fidpks, nil
|
||||
}
|
||||
|
||||
for neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
for result.Next(ctx) {
|
||||
record := result.Record()
|
||||
if record == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
if !ok {
|
||||
idRaw, found := record.Get("id")
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
pubkeyRaw, found := record.Get("pubkey")
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
createdAtRaw, found := record.Get("created_at")
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
serialRaw, found := record.Get("serial")
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
|
||||
idStr, _ := recordMap["id"].(string)
|
||||
pubkeyStr, _ := recordMap["pubkey"].(string)
|
||||
createdAt, _ := recordMap["created_at"].(int64)
|
||||
serialVal, _ := recordMap["serial"].(int64)
|
||||
idStr, _ := idRaw.(string)
|
||||
pubkeyStr, _ := pubkeyRaw.(string)
|
||||
createdAt, _ := createdAtRaw.(int64)
|
||||
serialVal, _ := serialRaw.(int64)
|
||||
|
||||
id, err := hex.Dec(idStr)
|
||||
if err != nil {
|
||||
|
||||
@@ -42,21 +42,13 @@ func (n *N) GetMarker(key string) (value []byte, err error) {
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid result type")
|
||||
}
|
||||
|
||||
if neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
if result.Next(ctx) {
|
||||
record := result.Record()
|
||||
if record != nil {
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
if ok {
|
||||
if valueStr, ok := recordMap["value"].(string); ok {
|
||||
valueRaw, found := record.Get("value")
|
||||
if found {
|
||||
if valueStr, ok := valueRaw.(string); ok {
|
||||
// Decode hex value
|
||||
value, err = hex.Dec(valueStr)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
"next.orly.dev/pkg/database/indexes/types"
|
||||
"next.orly.dev/pkg/encoders/event"
|
||||
"next.orly.dev/pkg/encoders/filter"
|
||||
@@ -113,7 +114,7 @@ func (n *N) buildCypherQuery(f *filter.F, includeDeleteEvents bool) (string, map
|
||||
// Tag filters - this is where Neo4j's graph capabilities shine
|
||||
// We can efficiently traverse tag relationships
|
||||
tagIndex := 0
|
||||
for tagType, tagValues := range *f.Tags {
|
||||
for _, tagValues := range *f.Tags {
|
||||
if len(tagValues.T) > 0 {
|
||||
tagVarName := fmt.Sprintf("t%d", tagIndex)
|
||||
tagTypeParam := fmt.Sprintf("tagType_%d", tagIndex)
|
||||
@@ -122,14 +123,17 @@ func (n *N) buildCypherQuery(f *filter.F, includeDeleteEvents bool) (string, map
|
||||
// Add tag relationship to MATCH clause
|
||||
matchClause += fmt.Sprintf(" OPTIONAL MATCH (e)-[:TAGGED_WITH]->(%s:Tag)", tagVarName)
|
||||
|
||||
// Convert tag values to strings
|
||||
tagValueStrings := make([]string, len(tagValues.T))
|
||||
for i, tv := range tagValues.T {
|
||||
// The first element is the tag type (e.g., "e", "p", etc.)
|
||||
tagType := string(tagValues.T[0])
|
||||
|
||||
// Convert remaining tag values to strings (skip first element which is the type)
|
||||
tagValueStrings := make([]string, len(tagValues.T)-1)
|
||||
for i, tv := range tagValues.T[1:] {
|
||||
tagValueStrings[i] = string(tv)
|
||||
}
|
||||
|
||||
// Add WHERE conditions for this tag
|
||||
params[tagTypeParam] = string(tagType)
|
||||
params[tagTypeParam] = tagType
|
||||
params[tagValuesParam] = tagValueStrings
|
||||
whereClauses = append(whereClauses,
|
||||
fmt.Sprintf("(%s.type = $%s AND %s.value IN $%s)",
|
||||
@@ -179,40 +183,42 @@ RETURN e.id AS id,
|
||||
|
||||
// parseEventsFromResult converts Neo4j query results to Nostr events
|
||||
func (n *N) parseEventsFromResult(result any) ([]*event.E, error) {
|
||||
// Type assert to Neo4j result
|
||||
neo4jResult, ok := result.(interface {
|
||||
events := make([]*event.E, 0)
|
||||
ctx := context.Background()
|
||||
|
||||
// Type assert to the interface we actually use
|
||||
resultIter, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Record() *neo4j.Record
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid result type")
|
||||
}
|
||||
|
||||
events := make([]*event.E, 0)
|
||||
ctx := context.Background()
|
||||
|
||||
// Iterate through result records
|
||||
for neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
for resultIter.Next(ctx) {
|
||||
record := resultIter.Record()
|
||||
if record == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// Extract fields from record
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
// Parse event fields
|
||||
idStr, _ := recordMap["id"].(string)
|
||||
kind, _ := recordMap["kind"].(int64)
|
||||
createdAt, _ := recordMap["created_at"].(int64)
|
||||
content, _ := recordMap["content"].(string)
|
||||
sigStr, _ := recordMap["sig"].(string)
|
||||
pubkeyStr, _ := recordMap["pubkey"].(string)
|
||||
tagsStr, _ := recordMap["tags"].(string)
|
||||
idRaw, _ := record.Get("id")
|
||||
kindRaw, _ := record.Get("kind")
|
||||
createdAtRaw, _ := record.Get("created_at")
|
||||
contentRaw, _ := record.Get("content")
|
||||
sigRaw, _ := record.Get("sig")
|
||||
pubkeyRaw, _ := record.Get("pubkey")
|
||||
tagsRaw, _ := record.Get("tags")
|
||||
|
||||
idStr, _ := idRaw.(string)
|
||||
kind, _ := kindRaw.(int64)
|
||||
createdAt, _ := createdAtRaw.(int64)
|
||||
content, _ := contentRaw.(string)
|
||||
sigStr, _ := sigRaw.(string)
|
||||
pubkeyStr, _ := pubkeyRaw.(string)
|
||||
tagsStr, _ := tagsRaw.(string)
|
||||
|
||||
// Decode hex strings
|
||||
id, err := hex.Dec(idStr)
|
||||
@@ -250,7 +256,7 @@ func (n *N) parseEventsFromResult(result any) ([]*event.E, error) {
|
||||
events = append(events, e)
|
||||
}
|
||||
|
||||
if err := neo4jResult.Err(); err != nil {
|
||||
if err := resultIter.Err(); err != nil {
|
||||
return nil, fmt.Errorf("error iterating results: %w", err)
|
||||
}
|
||||
|
||||
@@ -323,27 +329,31 @@ func (n *N) QueryForSerials(c context.Context, f *filter.F) (
|
||||
serials = make([]*types.Uint40, 0)
|
||||
ctx := context.Background()
|
||||
|
||||
neo4jResult, ok := result.(interface {
|
||||
resultIter, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Record() *neo4j.Record
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid result type")
|
||||
}
|
||||
|
||||
for neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
for resultIter.Next(ctx) {
|
||||
record := resultIter.Record()
|
||||
if record == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
serialRaw, found := record.Get("serial")
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
|
||||
serialVal, ok := serialRaw.(int64)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
serialVal, _ := recordMap["serial"].(int64)
|
||||
serial := types.Uint40{}
|
||||
serial.Set(uint64(serialVal))
|
||||
serials = append(serials, &serial)
|
||||
@@ -386,30 +396,30 @@ func (n *N) QueryForIds(c context.Context, f *filter.F) (
|
||||
idPkTs = make([]*store.IdPkTs, 0)
|
||||
ctx := context.Background()
|
||||
|
||||
neo4jResult, ok := result.(interface {
|
||||
resultIter, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Record() *neo4j.Record
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid result type")
|
||||
}
|
||||
|
||||
for neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
for resultIter.Next(ctx) {
|
||||
record := resultIter.Record()
|
||||
if record == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
idRaw, _ := record.Get("id")
|
||||
pubkeyRaw, _ := record.Get("pubkey")
|
||||
createdAtRaw, _ := record.Get("created_at")
|
||||
serialRaw, _ := record.Get("serial")
|
||||
|
||||
idStr, _ := recordMap["id"].(string)
|
||||
pubkeyStr, _ := recordMap["pubkey"].(string)
|
||||
createdAt, _ := recordMap["created_at"].(int64)
|
||||
serialVal, _ := recordMap["serial"].(int64)
|
||||
idStr, _ := idRaw.(string)
|
||||
pubkeyStr, _ := pubkeyRaw.(string)
|
||||
createdAt, _ := createdAtRaw.(int64)
|
||||
serialVal, _ := serialRaw.(int64)
|
||||
|
||||
id, err := hex.Dec(idStr)
|
||||
if err != nil {
|
||||
@@ -456,22 +466,24 @@ func (n *N) CountEvents(c context.Context, f *filter.F) (
|
||||
|
||||
// Parse count from result
|
||||
ctx := context.Background()
|
||||
neo4jResult, ok := result.(interface {
|
||||
resultIter, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Record() *neo4j.Record
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return 0, false, fmt.Errorf("invalid result type")
|
||||
}
|
||||
|
||||
if neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
if resultIter.Next(ctx) {
|
||||
record := resultIter.Record()
|
||||
if record != nil {
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
if ok {
|
||||
countVal, _ := recordMap["count"].(int64)
|
||||
count = int(countVal)
|
||||
countRaw, found := record.Get("count")
|
||||
if found {
|
||||
countVal, ok := countRaw.(int64)
|
||||
if ok {
|
||||
count = int(countVal)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,7 @@ func (n *N) SaveEvent(c context.Context, ev *event.E) (exists bool, err error) {
|
||||
|
||||
// Check if we got a result
|
||||
ctx := context.Background()
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if ok && neo4jResult.Next(ctx) {
|
||||
if result.Next(ctx) {
|
||||
return true, nil // Event already exists
|
||||
}
|
||||
|
||||
@@ -232,30 +227,25 @@ ORDER BY e.created_at DESC`
|
||||
}
|
||||
|
||||
// Parse results
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return false, nil, fmt.Errorf("invalid result type")
|
||||
}
|
||||
|
||||
var serials types.Uint40s
|
||||
wouldReplace := false
|
||||
|
||||
for neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
for result.Next(ctx) {
|
||||
record := result.Record()
|
||||
if record == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
serialRaw, found := record.Get("serial")
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
|
||||
serialVal, ok := serialRaw.(int64)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
serialVal, _ := recordMap["serial"].(int64)
|
||||
wouldReplace = true
|
||||
serial := types.Uint40{}
|
||||
serial.Set(uint64(serialVal))
|
||||
|
||||
@@ -31,22 +31,13 @@ func (n *N) getNextSerial() (uint64, error) {
|
||||
return 0, fmt.Errorf("failed to query serial counter: %w", err)
|
||||
}
|
||||
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if !ok {
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
var currentSerial uint64 = 1
|
||||
if neo4jResult.Next(ctx) {
|
||||
record := neo4jResult.Record()
|
||||
if result.Next(ctx) {
|
||||
record := result.Record()
|
||||
if record != nil {
|
||||
recordMap, ok := (*record).(map[string]any)
|
||||
if ok {
|
||||
if value, ok := recordMap["value"].(int64); ok {
|
||||
valueRaw, found := record.Get("value")
|
||||
if found {
|
||||
if value, ok := valueRaw.(int64); ok {
|
||||
currentSerial = uint64(value)
|
||||
}
|
||||
}
|
||||
@@ -86,12 +77,7 @@ func (n *N) initSerialCounter() error {
|
||||
return fmt.Errorf("failed to check serial counter: %w", err)
|
||||
}
|
||||
|
||||
neo4jResult, ok := result.(interface {
|
||||
Next(context.Context) bool
|
||||
Record() *interface{}
|
||||
Err() error
|
||||
})
|
||||
if ok && neo4jResult.Next(ctx) {
|
||||
if result.Next(ctx) {
|
||||
// Counter already exists
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
v0.29.3
|
||||
v0.29.4
|
||||
Reference in New Issue
Block a user