Skip to content

Type 'UUID' does not conform to protocol 'QueryExpression' #45

Answered by stephencelis
whoyawn asked this question in Q&A
Discussion options

You must be logged in to vote

@whoyawn To use the query builder with one of these types they must be explicitly bound so that we know what to represent the UUID as. This can be done using #bind.

 let query = Workout
-  .where { $0.id.eq(workout.id) }
+  .where { $0.id.eq(#bind(workout.id)) }
   .fetchAll(db)

I've PR'd #46 to add this info to the docs @bradhowes linked to.

We also have #37, which we will likely merge in the future, to make these operations simpler when using a default representation. In this case, lowercased will probably be the default UUID representation, so you would be able to remove the @Column(as:) and #bind whenever we release that functionality.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by whoyawn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants