FiberOpticFoxF
Convex Community16mo ago
9 replies
FiberOpticFox

Paginated Query With Empty String Argument Gives Unexpected Results

I have a paginated query implemented something like this
const getDataByClerkId = query({
args: {
  clerkId: v.string(),
  utcTimestamp: v.number(),
  paginationOpts: paginationOptsValidator,
},
handler: async (ctx, args) => {
  ctx.db.query("TableName")
  .withIndex("by_clerkId", (q) => q.eq("clerkId", args.clerkId))
  .filter((q) => q.lte(q.field("_creationTime"), args.utcTimestamp))
  .order("desc")
  .paginate(args.paginationOpts)
}
})


and when argument to the query is { clerkId: "" }, it gives me back documents where the clerkId field is a non-empty string. I've noticed that it works fine when the argument is a non-empty string. So what's the deal with the empty string?

I see this behaviour in my app, as well as running the function on convex dashboard.
If you want more details of the specific convex instance, dm me.
Was this page helpful?