Issue 33: Finished most aspects of the expression language (#38)

- Most aspects of scans and queries can now be represented using the expression language
- All constructs of the expression language can be used to evaluate items
This commit is contained in:
Leon Mika 2022-11-18 07:31:15 +11:00 committed by GitHub
parent 7d2817812c
commit 917663fac0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 1815 additions and 370 deletions

View file

@ -1,12 +1,22 @@
package queryexpr
import (
"github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression"
"github.com/lmika/audax/internal/dynamo-browse/models"
"strconv"
"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
"github.com/pkg/errors"
)
func (a *astLiteralValue) evalToIR(info *models.TableInfo) (irAtom, error) {
v, err := a.goValue()
if err != nil {
return nil, err
}
return irValue{value: v}, nil
}
func (a *astLiteralValue) dynamoValue() (types.AttributeValue, error) {
if a == nil {
return nil, nil
@ -58,3 +68,19 @@ func (a *astLiteralValue) String() string {
}
return ""
}
type irValue struct {
value any
}
func (i irValue) calcQueryForScan(info *models.TableInfo) (expression.ConditionBuilder, error) {
return expression.ConditionBuilder{}, NodeCannotBeConvertedToQueryError{}
}
func (i irValue) goValue() any {
return i.value
}
func (a irValue) calcOperand(info *models.TableInfo) expression.OperandBuilder {
return expression.Value(a.goValue())
}