Skip to content

Criteria.expr generated weird query #4793

@ichromanrd

Description

@ichromanrd

Hi, I have this query

db.collection.find({ 
  $expr: {
    $lt: [
      { $toLong: '$fieldToBeConverted' },
      1000
    ]
  } 
})

This is the repository code

val expr = Lt.valueOf(
  ToLong.toLong("$fieldTobeConverted")
).lessThanValue(1000)

val criteria = Criteria.expr(expr)

mongoTemplate.find(Query().addCriteria(criteria), Dto::class.java)

turned on the debug mode, and query generated as:

{
  "$lt": [
    "$$expr",
    [
      {
        "$toLong": "$fieldToBeConverted"
      },
      123
    ]
  ]
}

Is this expected? or am I doing it wrong?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions