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

scanonly not working #489

Closed
imraan-go opened this issue Mar 19, 2022 · 1 comment
Closed

scanonly not working #489

imraan-go opened this issue Mar 19, 2022 · 1 comment

Comments

@imraan-go
Copy link

Looks like fields declared with scanonly is not included in Scan. The field gets ommitted from select queries. But according to the documentation, It should only omit this field from insert and update.

type Customer struct {
	Id                string       `json:"id" bun:"id,pk,scanonly"`
	PhoneNumber       string       `json:"phone_number" bun:"phone_number"`
}
customer := Customer{}
err := repo.db.NewSelect().
		Model(&customer).
		Where("phone_number = ?", "524-322-3322").
		Limit(1).
		Scan(ctx)

The above code produces the following query:

 SELECT "customer"."phone_number" FROM "customers" AS "customer" WHERE (phone_number = '01700000000') LIMIT 1
@vmihailenco
Copy link
Member

This is a duplicate of #374 (comment)

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