Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions context_test.go

This file was deleted.

5 changes: 3 additions & 2 deletions jqresult/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions jqresult/normalize.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package jqresult

import (
"encoding/json"
"math/big"

"github.com/wader/gojq"
)

Expand Down Expand Up @@ -42,9 +39,6 @@ func NormalizeForEncode(v any) (any, error) {
}
return out, nil
default:
if isEncodeLeaf(v) {
return v, nil
}
return v, nil
}
}
Expand All @@ -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
}
}
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down
Loading