func (m *StaticDataSource) DeleteExpression(p interface{}, where expr.Node) (int, error) {

	_, ok := p.(*plan.Delete)
	if !ok {
		return 0, plan.ErrNoPlan
	}

	deletedKeys := make([]*Key, 0)
	m.bt.Ascend(func(a btree.Item) bool {
		di, ok := a.(*DriverItem)
		if !ok {
			u.Warnf("wat?  %T   %#v", a, a)
			return false
		}
		msgCtx := di.SqlDriverMessageMap
		whereValue, ok := vm.Eval(msgCtx, where)
		if !ok {
			u.Debugf("could not evaluate where: %v", msgCtx.Values())
			//return deletedCt, fmt.Errorf("Could not evaluate where clause")
			return true
		}
		switch whereVal := whereValue.(type) {
		case value.BoolValue:
			if whereVal.Val() == false {
				//this means do NOT delete
			} else {
				// Delete!
				indexVal := msgCtx.Values()[m.indexCol]
				deletedKeys = append(deletedKeys, NewKey(makeId(indexVal)))
			}
		case nil:
			// ??
		default:
			if whereVal.Nil() {
				// Doesn't match, so don't delete
			} else {
				u.Warnf("unknown type? %T", whereVal)
			}
		}
		return true
	})

	for _, deleteKey := range deletedKeys {
		if ct, err := m.Delete(deleteKey); err != nil {
			u.Errorf("Could not delete key: %v", deleteKey)
		} else if ct != 1 {
			u.Errorf("delete should have removed 1 key %v", deleteKey)
		}
	}
	return len(deletedKeys), nil
}
// DeleteExpression Delete using a Where Expression
DeleteExpression Delete using a Where Expression
// DeleteExpression Delete using a Where Expression
func (m *StaticDataSource) DeleteExpression(p interface{}, where expr.Node) (int, error) {
	_, ok := p.(*plan.Delete)
	if !ok {
		return 0, plan.ErrNoPlan
	}
	deletedKeys := make([]*Key, 0)
	m.bt.Ascend(func(a btree.Item) bool {
		di, ok := a.(*DriverItem)
		if !ok {
			u.Warnf("wat?  %T   %#v", a, a)
			return false
		}
		msgCtx := di.SqlDriverMessageMap
		whereValue, ok := vm.Eval(msgCtx, where)
		if !ok {
			u.Debugf("could not evaluate where: %v", msgCtx.Values())
			return true
		}
		switch whereVal := whereValue.(type) {
		case value.BoolValue:
			if whereVal.Val() == false {
			} else {
				indexVal := msgCtx.Values()[m.indexCol]
				deletedKeys = append(deletedKeys, NewKey(makeId(indexVal)))
			}
		case nil:
		default:
			if whereVal.Nil() {
			} else {
				u.Warnf("unknown type? %T", whereVal)
			}
		}
		return true
	})
	for _, deleteKey := range deletedKeys {
		if ct, err := m.Delete(deleteKey); err != nil {
			u.Errorf("Could not delete key: %v", deleteKey)
		} else if ct != 1 {
			u.Errorf("delete should have removed 1 key %v", deleteKey)
		}
	}
	return len(deletedKeys), nil
}
func ( m * StaticDataSource ) DeleteExpression ( p interface { } , where expr . Node ) ( int , error ) { _ , ok := p . ( * plan . Delete ) if ! ok { return 0 , plan . ErrNoPlan } deletedKeys := make ( [ ] * Key , 0 ) m . bt . Ascend ( func ( a btree . Item ) bool { di , ok := a . ( * DriverItem ) if ! ok { u . Warnf ( " " , a , a ) return false } msgCtx := di . SqlDriverMessageMap whereValue , ok := vm . Eval ( msgCtx , where ) if ! ok { u . Debugf ( " " , msgCtx . Values ( ) ) return true } switch whereVal := whereValue . ( type ) { case value . BoolValue : if whereVal . Val ( ) == false { } else { indexVal := msgCtx . Values ( ) [ m . indexCol ] deletedKeys = append ( deletedKeys , NewKey ( makeId ( indexVal ) ) ) } case nil : default : if whereVal . Nil ( ) { } else { u . Warnf ( " " , whereVal ) } } return true } ) for _ , deleteKey := range deletedKeys { if ct , err := m . Delete ( deleteKey ) ; err != nil { u . Errorf ( " " , deleteKey ) } else if ct != 1 { u . Errorf ( " " , deleteKey ) } } return len ( deletedKeys ) , nil }
DeleteExpression Delete using a Where Expression
DeleteExpression Delete using a Where Expression
//return deletedCt, fmt.Errorf("Could not evaluate where clause") //this means do NOT delete // Delete! // ?? // Doesn't match, so don't delete