- Converted Tamarin script language to Risor - Added a "find" and "merge" method to the result set script type. - Added the ability to copy the table of results to the pasteboard by pressing C - Added the -q flag, which will run a query and display the results as a CSV file on the command line - Upgraded Go to 1.21 in Github actions - Fix issue with missing limits - Added the '-where' switch to the mark - Added the 'marked' function to the query expression. - Added a sampled time and count on the right-side of the mode line - Added the 'M' key binding to toggle the marked items - Started working on tab completion for 'sa' and 'da' commands - Added count and sample time to the right-side of the mode line - Added Ctrl+V to the prompt to paste the text of the pasteboard with all whitespace characters trimmed - Fixed failing unit tests
79 lines
1.8 KiB
Go
79 lines
1.8 KiB
Go
package queryexpr
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression"
|
|
"github.com/lmika/dynamo-browse/internal/dynamo-browse/models"
|
|
"strings"
|
|
)
|
|
|
|
func (dt *astRef) evalToIR(ctx *evalContext, info *models.TableInfo) (irAtom, error) {
|
|
return irNamePath{name: dt.Name}, nil
|
|
}
|
|
|
|
func (dt *astRef) unqualifiedName() (string, bool) {
|
|
return dt.Name, true
|
|
}
|
|
|
|
func (dt *astRef) evalItem(ctx *evalContext, item models.Item) (exprValue, error) {
|
|
res, hasV := item[dt.Name]
|
|
if !hasV {
|
|
return undefinedExprValue{}, nil
|
|
}
|
|
|
|
return newExprValueFromAttributeValue(res)
|
|
}
|
|
|
|
func (dt *astRef) canModifyItem(ctx *evalContext, item models.Item) bool {
|
|
return true
|
|
}
|
|
|
|
func (dt *astRef) setEvalItem(ctx *evalContext, item models.Item, value exprValue) error {
|
|
item[dt.Name] = value.asAttributeValue()
|
|
return nil
|
|
}
|
|
|
|
func (dt *astRef) deleteAttribute(ctx *evalContext, item models.Item) error {
|
|
delete(item, dt.Name)
|
|
return nil
|
|
}
|
|
|
|
func (a *astRef) String() string {
|
|
return a.Name
|
|
}
|
|
|
|
type irNamePath struct {
|
|
name string
|
|
quals []any
|
|
}
|
|
|
|
func (i irNamePath) calcQueryForScan(info *models.TableInfo) (expression.ConditionBuilder, error) {
|
|
return expression.ConditionBuilder{}, NodeCannotBeConvertedToQueryError{}
|
|
}
|
|
|
|
func (i irNamePath) calcOperand(info *models.TableInfo) expression.OperandBuilder {
|
|
return i.calcName(info)
|
|
}
|
|
|
|
func (i irNamePath) keyName() string {
|
|
if len(i.quals) > 0 {
|
|
return ""
|
|
}
|
|
return i.name
|
|
}
|
|
|
|
func (i irNamePath) calcName(info *models.TableInfo) expression.NameBuilder {
|
|
var fullName strings.Builder
|
|
fullName.WriteString(i.name)
|
|
|
|
for _, qual := range i.quals {
|
|
switch v := qual.(type) {
|
|
case string:
|
|
fullName.WriteString("." + v)
|
|
case int64:
|
|
fullName.WriteString(fmt.Sprintf("[%v]", qual))
|
|
}
|
|
}
|
|
return expression.NameNoDotSplit(fullName.String())
|
|
}
|