Skip to content

Are there examples how to use mods with generated code? #21

Closed Answered by stephenafamo
isgj asked this question in Q&A
Discussion options

You must be logged in to vote
  • SelectWhere contains mods which are supposed to be passed directly to the query builder.
  • psql.Or takes expressions

Your query should be built like this instead:

_, err := models.Users(ctx, db,
	sm.Where(psql.Or(
		models.UserColumns.ID.EQ(psql.Arg(users[0].ID)),
		models.UserColumns.Email.EQ(psql.Arg("a@a.com")),
	)),
).All()

Which provides the expected query

SELECT
"users"."id" AS "id", ....other columns
FROM "users" AS "users"
WHERE (("users"."id" = $1) OR ("users"."primary_email" = $2))

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@isgj
Comment options

@stephenafamo
Comment options

@isgj
Comment options

Answer selected by isgj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants