diff --git a/context_test.go b/context_test.go deleted file mode 100644 index 65f2bfb..0000000 --- a/context_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package main - -import ( - "context" - "testing" - "time" -) - -func TestWithCancelPreservesParentDeadline(t *testing.T) { - t.Parallel() - - parent, cancel := context.WithTimeout(context.Background(), time.Minute) - defer cancel() - - child, childCancel := context.WithCancel(parent) - defer childCancel() - - got, ok := child.Deadline() - if !ok { - t.Fatal("child deadline missing") - } - want, _ := parent.Deadline() - if !got.Equal(want) { - t.Fatalf("deadline = %v, want %v", got, want) - } -} diff --git a/jqresult/compile.go b/jqresult/compile.go index 26ec1a4..728e482 100644 --- a/jqresult/compile.go +++ b/jqresult/compile.go @@ -4,8 +4,9 @@ import ( "github.com/wader/gojq" ) -// Compile parses filter and returns executable jq code for the given input mode. -func Compile(filter string, mode InputMode) (*gojq.Code, error) { +// Compile parses filter and returns executable jq code. +// The mode parameter is retained for source compatibility; compilation is mode-independent. +func Compile(filter string, _ InputMode) (*gojq.Code, error) { q, err := gojq.Parse(filter) if err != nil { return nil, err diff --git a/jqresult/normalize.go b/jqresult/normalize.go index 9ce11aa..29cd72a 100644 --- a/jqresult/normalize.go +++ b/jqresult/normalize.go @@ -1,9 +1,6 @@ package jqresult import ( - "encoding/json" - "math/big" - "github.com/wader/gojq" ) @@ -42,9 +39,6 @@ func NormalizeForEncode(v any) (any, error) { } return out, nil default: - if isEncodeLeaf(v) { - return v, nil - } return v, nil } } @@ -64,16 +58,3 @@ func normalizeIter(it gojq.Iter) ([]any, error) { } return out, nil } - -// isEncodeLeaf reports values that cannot contain gojq.Iter and need no further normalization. -func isEncodeLeaf(v any) bool { - switch v.(type) { - case nil, bool, int, int8, int16, int32, int64, - uint, uint8, uint16, uint32, uint64, - float32, float64, string, - json.Number, *big.Int: - return true - default: - return false - } -} diff --git a/main.go b/main.go index 66d352f..cc2209d 100644 --- a/main.go +++ b/main.go @@ -601,6 +601,7 @@ func runJqOutput( jqCode *gojq.Code, ) error { useEager := jqMode == jqresult.InputEager + // Read-write DML always materializes the full result set before jq runs. if _, ok := mode.(readWrite); ok { useEager = true } @@ -623,8 +624,6 @@ func runJqOutput( } switch mode := mode.(type) { - case readWrite: - panic("read-write jq uses eager materialization") case single: enc, err := newEncoder(os.Stdout, o.Format, o.CompactOutput, o.JqRawOutput) if err != nil {