Skip to content

Commit

Permalink
Add BigInt support
Browse files Browse the repository at this point in the history
  • Loading branch information
denis_savitsky authored and danslapman committed Oct 17, 2023
1 parent e0372c4 commit a7ce439
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion oolong-core/src/main/scala/oolong/AstParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private[oolong] class DefaultAstParser(using quotes: Quotes) extends AstParser {
case '{ !($x: Boolean) } =>
QExpr.Not(parse(x))

case AsTerm(Apply(Select(Ident("BigDecimal"), _), List(literal: Literal))) =>
case AsTerm(Apply(Select(Ident("BigDecimal" | "BigInt"), _), List(literal: Literal))) =>
parse(literal.asExpr)

case AsTerm(Literal(DoubleConstant(c))) =>
Expand Down
14 changes: 14 additions & 0 deletions oolong-mongo/src/test/scala/oolong/mongo/QuerySpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,20 @@ class QuerySpec extends AnyFunSuite {
)
}

test("BigInt is supported without lift") {
case class BITest(field: BigInt)
val q = query[BITest](_.field == BigInt(2_000_000_000L))
val repr = renderQuery[BITest](_.field == BigInt(2_000_000_000L))

test(
q,
repr,
BsonDocument(
"field" -> BsonInt64(2_000_000_000L)
)
)
}

private inline def test(
query: BsonDocument,
repr: String,
Expand Down

0 comments on commit a7ce439

Please sign in to comment.