Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use where if not implemented explicitConditional.Matches? #301

Open
ganmao opened this issue Apr 1, 2022 · 2 comments
Open

How to use where if not implemented explicitConditional.Matches? #301

ganmao opened this issue Apr 1, 2022 · 2 comments

Comments

@ganmao
Copy link

ganmao commented Apr 1, 2022

ovs.Where(ls, client.Condition {
	Field: &ls.UUID,
	Function: ovsdb.ConditionEqual,
	Value: "myUUID"},
    })

github.com/ovn-org/[email protected]/client/condition.go:80

func (c *explicitConditional) Matches(m model.Model) (bool, error) {
	return false, fmt.Errorf("cannot perform cache comparisons using explicit conditions")
}
@ganmao
Copy link
Author

ganmao commented Apr 1, 2022

github.com/ovn-org/[email protected]/client/api.go:185

func (a api) conditionFromModel(any bool, model model.Model, cond ...model.Condition) Conditional {
	var conditional Conditional
	var err error

	tableName, err := a.getTableFromModel(model)
	if tableName == "" {
		return newErrorConditional(err)
	}

	if len(cond) == 0 {
		conditional, err = newEqualityConditional(a.cache.Mapper(), tableName, any, model)
		if err != nil {
			conditional = newErrorConditional(err)
		}

	} else {
		conditional, err = newExplicitConditional(a.cache.Mapper(), tableName, any, model, cond...)
		if err != nil {
			conditional = newErrorConditional(err)
		}
	}
	return conditional
}

@amorenoz
Copy link
Collaborator

amorenoz commented Apr 4, 2022

You can use Where to perform server-side matches, i.e: methods such as Delete, Update, Mutate.
If you want to use List or Get that operate on the cache, rather than sending commands to the server, you currently need to use WhereCache. At least until #128 is implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants