MCPcopy Create free account
hub / github.com/compozy/agh / insertRecord

Function insertRecord

internal/resources/kernel.go:1032–1055  ·  view source on GitHub ↗
(ctx context.Context, exec sqlExecutor, record RawRecord)

Source from the content-addressed store, hash-verified

1030}
1031
1032func insertRecord(ctx context.Context, exec sqlExecutor, record RawRecord) error {
1033 if _, err := exec.ExecContext(
1034 ctx,
1035 `INSERT INTO resource_records (
1036 kind, id, version, scope_kind, scope_id, owner_kind,
1037 owner_id, source_kind, source_id, spec_json, created_at, updated_at
1038 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
1039 record.Kind,
1040 record.ID,
1041 record.Version,
1042 record.Scope.Kind,
1043 nullableScopeID(record.Scope),
1044 record.Owner.Kind,
1045 record.Owner.ID,
1046 record.Source.Kind,
1047 record.Source.ID,
1048 string(record.SpecJSON),
1049 store.FormatTimestamp(record.CreatedAt),
1050 store.FormatTimestamp(record.UpdatedAt),
1051 ); err != nil {
1052 return fmt.Errorf("resources: insert record %q/%q: %w", record.Kind, record.ID, err)
1053 }
1054 return nil
1055}
1056
1057func updateRecord(ctx context.Context, exec sqlExecutor, record RawRecord, expectedVersion int64) error {
1058 result, err := exec.ExecContext(

Callers 1

insertRawRecordMethod · 0.85

Calls 3

FormatTimestampFunction · 0.92
nullableScopeIDFunction · 0.85
ExecContextMethod · 0.65

Tested by

no test coverage detected