forked from sourcenetwork/defradb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into nasdf/fix/gql-error-response
- Loading branch information
Showing
30 changed files
with
1,680 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package connor | ||
|
||
import ( | ||
"github.com/sourcenetwork/defradb/client" | ||
|
||
"github.com/sourcenetwork/immutable" | ||
) | ||
|
||
// all is an operator which allows the evaluation of | ||
// a number of conditions over a list of values | ||
// matching if all of them match. | ||
func all(condition, data any) (bool, error) { | ||
switch t := data.(type) { | ||
case []string: | ||
return allSlice(condition, t) | ||
|
||
case []immutable.Option[string]: | ||
return allSlice(condition, t) | ||
|
||
case []int64: | ||
return allSlice(condition, t) | ||
|
||
case []immutable.Option[int64]: | ||
return allSlice(condition, t) | ||
|
||
case []bool: | ||
return allSlice(condition, t) | ||
|
||
case []immutable.Option[bool]: | ||
return allSlice(condition, t) | ||
|
||
case []float64: | ||
return allSlice(condition, t) | ||
|
||
case []immutable.Option[float64]: | ||
return allSlice(condition, t) | ||
|
||
default: | ||
return false, client.NewErrUnhandledType("data", data) | ||
} | ||
} | ||
|
||
func allSlice[T any](condition any, data []T) (bool, error) { | ||
for _, c := range data { | ||
m, err := eq(condition, c) | ||
if err != nil { | ||
return false, err | ||
} else if !m { | ||
return false, nil | ||
} | ||
} | ||
return true, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package connor | ||
|
||
import ( | ||
"github.com/sourcenetwork/defradb/client" | ||
|
||
"github.com/sourcenetwork/immutable" | ||
) | ||
|
||
// anyOp is an operator which allows the evaluation of | ||
// a number of conditions over a list of values | ||
// matching if any of them match. | ||
func anyOp(condition, data any) (bool, error) { | ||
switch t := data.(type) { | ||
case []string: | ||
return anySlice(condition, t) | ||
|
||
case []immutable.Option[string]: | ||
return anySlice(condition, t) | ||
|
||
case []int64: | ||
return anySlice(condition, t) | ||
|
||
case []immutable.Option[int64]: | ||
return anySlice(condition, t) | ||
|
||
case []bool: | ||
return anySlice(condition, t) | ||
|
||
case []immutable.Option[bool]: | ||
return anySlice(condition, t) | ||
|
||
case []float64: | ||
return anySlice(condition, t) | ||
|
||
case []immutable.Option[float64]: | ||
return anySlice(condition, t) | ||
|
||
default: | ||
return false, client.NewErrUnhandledType("data", data) | ||
} | ||
} | ||
|
||
func anySlice[T any](condition any, data []T) (bool, error) { | ||
for _, c := range data { | ||
m, err := eq(condition, c) | ||
if err != nil { | ||
return false, err | ||
} else if m { | ||
return true, nil | ||
} | ||
} | ||
return false, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package connor | ||
|
||
// none is an operator which allows the evaluation of | ||
// a number of conditions over a list of values | ||
// matching if all of them do not match. | ||
func none(condition, data any) (bool, error) { | ||
m, err := anyOp(condition, data) | ||
if err != nil { | ||
return false, err | ||
} | ||
return !m, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.