Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
ab0b5d7
♻️ float to decimal & set DivisionPrecision = 8
frank-hsieh-asj Feb 17, 2022
43f83f6
Merge pull request #1 from ASJadeTech/refactory/float-to-decimal
asj-martin Feb 17, 2022
574f7f3
add regexp
tbal999 Jul 7, 2022
bfd1b96
Merge pull request #2 from ASJadeTech/main
tbal999 Jul 7, 2022
5e0f34e
Merge pull request #1 from xiatechs/feature/regex
tbal999 Jul 7, 2022
328dbf9
Merge pull request #3 from xiatechs/develop
tbal999 Jul 7, 2022
840ede8
add some new features to go-jsonata [xia]
tbal999 Sep 19, 2022
68dea73
further additions
tbal999 Sep 19, 2022
f6d3217
adjust contributing
tbal999 Sep 19, 2022
f627995
Merge pull request #4 from xiatechs/feature/xia1
tbal999 Sep 19, 2022
1abafe3
1.18
tbal999 Sep 19, 2022
f06761b
add @ to lexer
tbal999 Sep 21, 2022
9af3332
different approach
tbal999 Sep 21, 2022
74852c4
change name for new funcs
tbal999 Sep 22, 2022
36922a6
add obj merge func
tbal999 Sep 22, 2022
022afb9
Merge pull request #5 from xiatechs/feature/joinoperator
tbal999 Sep 22, 2022
e1c7a4c
make left join
tbal999 Sep 26, 2022
c5c577d
join enhancement
tbal999 Sep 27, 2022
bad44b7
fix
tbal999 Sep 27, 2022
ef957bf
add test
tbal999 Sep 27, 2022
e582d2a
test & gofmt
tbal999 Sep 27, 2022
4cc632d
update dev
Nov 29, 2022
42def18
add mutex
Dec 12, 2022
bb14382
another
Dec 12, 2022
03374d4
and another
Dec 12, 2022
45655f2
fix tests etc
Dec 12, 2022
2104ff5
Merge pull request #6 from xiatechs/feature/mutex
tbal999 Dec 12, 2022
71c66fe
thread safety (#7)
tbal999 Dec 12, 2022
5befb7d
add eval functionality (#9)
tbal999 Mar 14, 2023
4276483
Feature/eval (#10)
tbal999 Mar 15, 2023
42e6f55
add go timezones (#11)
tbal999 Mar 17, 2023
7957ab7
Modify date time string to match the layout provided (#12)
pocockn Mar 23, 2023
30f0186
Timeformats fix (#13)
pocockn Mar 23, 2023
ed4855f
Update to go 1.19
pocockn Mar 24, 2023
aac0abd
Bump to Go 1.20
pocockn Mar 24, 2023
928dc02
Time/localconsts (#14)
tbal999 Mar 28, 2023
49373f6
fix null bug (#15)
tbal999 Apr 13, 2023
4a6a7c0
test
golbanstefan May 18, 2023
6775490
improve the errors
golbanstefan May 18, 2023
e7e6c48
Merge branch 'main' into improve-errors
golbanstefan May 18, 2023
cc20d0a
solve cooments and logs
golbanstefan May 18, 2023
30e9103
solve cooments and logs
golbanstefan May 18, 2023
1861ad7
delete idea files
golbanstefan May 18, 2023
d58a160
Merge pull request #17 from xiatechs/improve-errors
golbanstefan May 18, 2023
44fd010
Allow empty arrays to be returned (#18)
Jarrah-libremfg May 30, 2023
bbead99
Json objects to document func (#19)
tbal999 Oct 2, 2023
0a4fc93
XC-1364 (#20)
tbal999 Oct 10, 2023
bf6cd95
Feature/xc 1539 (#21)
tbal999 Nov 9, 2023
bfdb0aa
add time date dimension functions (#22)
tbal999 Nov 17, 2023
48c87cf
add adjustments (#23)
tbal999 Nov 20, 2023
11a33a1
Enhancement to oneToMany function to add sql like join types (#25)
tbal999 Nov 27, 2023
834811c
fix offset (#26)
tbal999 Nov 29, 2023
d1badc0
Rename keys (#29)
Dec 12, 2023
933f57f
fix bug (#30)
tbal999 Dec 12, 2023
5c4e36c
add fold function & goccy (#31)
tbal999 Dec 13, 2023
353b4d4
Update env.go
tbal999 Dec 13, 2023
98098e0
fix bug - 000 end to timestamp (#33)
tbal999 Mar 20, 2024
61ce7d5
Fix panic calling $distinct on array of arrays (#34)
Jarrah-libremfg Apr 17, 2024
72bb1f2
add monday-weekday (#35)
tbal999 Apr 26, 2024
c158b1f
Updated objectsToDocument function to deal with array syntax
Nov 27, 2024
a868852
chore: extended testing chassis
Nov 28, 2024
98d0360
chore: switch to goccy
Nov 28, 2024
88b5976
chore: some comments
Nov 28, 2024
7eebaae
chore: simplify chassis
Nov 28, 2024
58374e2
chore: clean up readme
Nov 28, 2024
629e86d
chore(AS-3797): add test coverage
xiatech-ricky Dec 18, 2024
dd436d6
chore(as-3797): throw error if no Code found
xiatech-ricky Dec 18, 2024
6fd16a4
Merge pull request #38 from xiatechs/AS-3691
xiatech-ricky Dec 19, 2024
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
40 changes: 18 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
on: [push]
on:
push:
branches: '*'
pull_request:
branches: '*'

name: Test
jobs:
test:
strategy:
matrix:
go-version: [1.16.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: |
go get -u honnef.co/go/tools/cmd/staticcheck@latest
go get -u golang.org/x/tools/cmd/goimports
- name: Run staticcheck
run: staticcheck ./...
- name: Check code formatting
run: test -z $(goimports -l .)
- name: Run Test
run: go test ./...
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.1'

- name: Checkout code
uses: actions/checkout@v2

- name: Unit tests
run: go test ./... -race
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*.dll
*.so
*.dylib
.idea
.idea/*

# Test binary, built with `go test -c`
*.test
Expand All @@ -13,3 +15,7 @@

# Dependency directories (remove the comment below to include it)
# vendor/

# specific files
jlib/timeparse/outputdata.json
jlib/timeparse/outputdata_lite.json
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to blues/jsonata-go
# Contributing to blues/jsonata-go [xiatechs fork]

We love pull requests from everyone. By participating in this project, you
agree to abide by the Blues Inc [code of conduct].
Expand All @@ -18,7 +18,7 @@ clean up inconsistent whitespace )
* by closing [issues][]
* by reviewing patches

[issues]: https://github.com/blues/jsonata-go/issues
[issues]: https://github.com/xiatechs/jsonata-go/issues

## Submitting an Issue

Expand Down Expand Up @@ -55,7 +55,7 @@ clean up inconsistent whitespace )
* If you don't know how to add tests, please put in a PR and leave a comment asking for help.
We love helping!

[repo]: https://github.com/blues/jsonata-go/tree/master
[repo]: https://github.com/xiatechs/jsonata-go/tree/master
[fork]: https://help.github.com/articles/fork-a-repo/
[branch]:
https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ It currently has feature parity with jsonata-js 1.5.4. As well as a most of the

## Install

go get github.com/blues/jsonata-go
go get github.com/xiatechs/jsonata-go

## Usage

```Go
import (
"encoding/json"
"github.com/goccy/go-json"
"fmt"
"log"

jsonata "github.com/blues/jsonata-go"
jsonata "github.com/xiatechs/jsonata-go"
)

const jsonString = `
Expand Down Expand Up @@ -56,7 +56,7 @@ func main() {

## JSONata Server
A locally hosted version of [JSONata Exerciser](http://try.jsonata.org/)
for testing is [available here](https://github.com/blues/jsonata-go/jsonata-server).
for testing is [available here](https://github.com/xiatechs/jsonata-go/jsonata-server).

## JSONata tests
A CLI tool for running jsonata-go against the [JSONata test suite](https://github.com/jsonata-js/jsonata/tree/master/test/test-suite) is [available here](./jsonata-test).
Expand Down
21 changes: 14 additions & 7 deletions callable.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
package jsonata

import (
"encoding/json"
"fmt"
"github.com/goccy/go-json"
"reflect"
"regexp"
"strings"
"sync"

"github.com/blues/jsonata-go/jlib"
"github.com/blues/jsonata-go/jparse"
"github.com/blues/jsonata-go/jtypes"
"github.com/xiatechs/jsonata-go/jlib"
"github.com/xiatechs/jsonata-go/jparse"
"github.com/xiatechs/jsonata-go/jtypes"
)

type callableName struct {
mu sync.Mutex
name string
}

Expand All @@ -25,6 +27,8 @@ func (n callableName) Name() string {
}

func (n *callableName) SetName(s string) {
n.mu.Lock()
defer n.mu.Unlock()
n.name = s
}

Expand Down Expand Up @@ -76,6 +80,7 @@ func newGoCallableParam(typ reflect.Type) goCallableParam {
// A goCallable represents a built-in or third party Go function.
// It implements the Callable interface.
type goCallable struct {
mu sync.Mutex
callableName
callableMarshaler
fn reflect.Value
Expand Down Expand Up @@ -205,6 +210,8 @@ func makeGoCallableParams(typ reflect.Type) []goCallableParam {
}

func (c *goCallable) SetContext(context reflect.Value) {
c.mu.Lock()
defer c.mu.Unlock()
c.context = context
}

Expand Down Expand Up @@ -682,7 +689,7 @@ func (f *transformationCallable) Call(argv []reflect.Value) (reflect.Value, erro

obj, err := f.clone(argv[0])
if err != nil {
return undefined, newEvalError(ErrClone, nil, nil)
return undefined, newEvalError(ErrClone, nil, nil, 0)
}

if obj == undefined {
Expand Down Expand Up @@ -739,7 +746,7 @@ func (f *transformationCallable) updateEntries(item reflect.Value) error {
}

if !jtypes.IsMap(updates) {
return newEvalError(ErrIllegalUpdate, f.updates, nil)
return newEvalError(ErrIllegalUpdate, f.updates, nil, 0)
}

for _, key := range updates.MapKeys() {
Expand All @@ -759,7 +766,7 @@ func (f *transformationCallable) deleteEntries(item reflect.Value) error {
deletes = arrayify(deletes)

if !jtypes.IsArrayOf(deletes, jtypes.IsString) {
return newEvalError(ErrIllegalDelete, f.deletes, nil)
return newEvalError(ErrIllegalDelete, f.deletes, nil, 0)
}

for i := 0; i < deletes.Len(); i++ {
Expand Down
23 changes: 19 additions & 4 deletions callable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import (
"regexp"
"sort"
"strings"
"sync"
"testing"

"github.com/blues/jsonata-go/jparse"
"github.com/blues/jsonata-go/jtypes"
"github.com/stretchr/testify/assert"

"github.com/xiatechs/jsonata-go/jparse"
"github.com/xiatechs/jsonata-go/jtypes"
)

var (
Expand Down Expand Up @@ -2328,8 +2331,8 @@ func testTransformationCallable(t *testing.T, tests []transformationCallableTest
}
}

if !reflect.DeepEqual(err, test.Error) {
t.Errorf("transform %d: expected error %v, got %v", i+1, test.Error, err)
if err != nil && test.Error != nil {
assert.EqualError(t, err, test.Error.Error())
}
}
}
Expand Down Expand Up @@ -2371,6 +2374,7 @@ func TestRegexCallable(t *testing.T) {
"groups": []string{},
"next": &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "ac",
Expand All @@ -2379,6 +2383,7 @@ func TestRegexCallable(t *testing.T) {
groups: []string{},
next: &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "ad",
Expand All @@ -2387,6 +2392,7 @@ func TestRegexCallable(t *testing.T) {
groups: []string{},
next: &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "ab",
Expand All @@ -2395,6 +2401,7 @@ func TestRegexCallable(t *testing.T) {
groups: []string{},
next: &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "a",
Expand Down Expand Up @@ -2425,6 +2432,7 @@ func TestRegexCallable(t *testing.T) {
},
"next": &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "ac",
Expand All @@ -2435,6 +2443,7 @@ func TestRegexCallable(t *testing.T) {
},
next: &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "ad",
Expand All @@ -2445,6 +2454,7 @@ func TestRegexCallable(t *testing.T) {
},
next: &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "ab",
Expand All @@ -2455,6 +2465,7 @@ func TestRegexCallable(t *testing.T) {
},
next: &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "a",
Expand Down Expand Up @@ -2491,6 +2502,7 @@ func TestRegexCallable(t *testing.T) {
},
"next": &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "ac",
Expand All @@ -2502,6 +2514,7 @@ func TestRegexCallable(t *testing.T) {
},
next: &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "ad",
Expand All @@ -2513,6 +2526,7 @@ func TestRegexCallable(t *testing.T) {
},
next: &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "ab",
Expand All @@ -2524,6 +2538,7 @@ func TestRegexCallable(t *testing.T) {
},
next: &matchCallable{
callableName: callableName{
sync.Mutex{},
"next",
},
match: "a",
Expand Down
7 changes: 7 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package config

var defaultDivisionPrecision int32 = 8

func GetDivisionPrecision() int32 {
return defaultDivisionPrecision
}
Loading