File tree Expand file tree Collapse file tree 3 files changed +19
-8
lines changed
oolong-core/src/main/scala/oolong Expand file tree Collapse file tree 3 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -163,10 +163,10 @@ private[oolong] class DefaultAstParser(using quotes: Quotes) extends AstParser {
163
163
case ' { ($x : Option [_]).nonEmpty } =>
164
164
QExpr .Exists (parse(x), QExpr .Constant (true ))
165
165
166
- case ' { ($x : Instant ).isBefore($s) } =>
166
+ case ' { ($x : Instant ).isBefore($s : Instant ) } =>
167
167
QExpr .Lt (parse(x), parse(s))
168
168
169
- case ' { ($x : Instant ).isAfter($s) } =>
169
+ case ' { ($x : Instant ).isAfter($s : Instant ) } =>
170
170
QExpr .Gt (parse(x), parse(s))
171
171
172
172
case PropSelector (name, path) if name == paramName =>
Original file line number Diff line number Diff line change @@ -19,8 +19,15 @@ private[oolong] object BsonUtils {
19
19
case ' { $s : t } =>
20
20
Expr .summon[BsonEncoder [t]] match {
21
21
case Some (encoder) => ' { $ { encoder }.bson($ { s }) }
22
- case _ => report.errorAndAbort(s " Didn't find bson encoder for type ${TypeRepr .of[t].show}" )
22
+ case None if TypeRepr .of[t].isSingleton =>
23
+ TypeRepr .of[t].widen.asType match {
24
+ case ' [tx] =>
25
+ Expr .summon[BsonEncoder [tx]] match {
26
+ case Some (encoder) => ' { $ { encoder }.bson($ { s.asExprOf[tx] }) }
27
+ case _ => report.errorAndAbort(s " Didn't find bson encoder for type ${TypeRepr .of[t].widen.show}" )
28
+ }
29
+ }
30
+ case _ => report.errorAndAbort(s " Didn't find bson encoder for type ${TypeRepr .of[t].widen.show}" )
23
31
}
24
32
}
25
-
26
33
}
Original file line number Diff line number Diff line change @@ -1170,8 +1170,10 @@ class QuerySpec extends AnyFunSuite {
1170
1170
1171
1171
test(" Instant.ifBefore is supported" ) {
1172
1172
case class InstantTest (field : Instant )
1173
- val q = query[InstantTest ](_.field.isBefore(lift(Instant .parse(" 2020-01-01T00:00:00Z" ))))
1174
- val repr = renderQuery[InstantTest ](_.field.isBefore(lift(Instant .parse(" 2020-01-01T00:00:00Z" ))))
1173
+
1174
+ val instant = Instant .parse(" 2020-01-01T00:00:00Z" )
1175
+ val q = query[InstantTest ](_.field.isBefore(lift(instant)))
1176
+ val repr = renderQuery[InstantTest ](_.field.isBefore(lift(instant)))
1175
1177
1176
1178
test(
1177
1179
q,
@@ -1185,8 +1187,10 @@ class QuerySpec extends AnyFunSuite {
1185
1187
1186
1188
test(" Instant.isAfter is supported" ) {
1187
1189
case class InstantTest (field : Instant )
1188
- val q = query[InstantTest ](_.field.isAfter(lift(Instant .parse(" 2020-01-01T00:00:00Z" ))))
1189
- val repr = renderQuery[InstantTest ](_.field.isAfter(lift(Instant .parse(" 2020-01-01T00:00:00Z" ))))
1190
+
1191
+ val instant = Instant .parse(" 2020-01-01T00:00:00Z" )
1192
+ val q = query[InstantTest ](_.field.isAfter(lift(instant)))
1193
+ val repr = renderQuery[InstantTest ](_.field.isAfter(lift(instant)))
1190
1194
1191
1195
test(
1192
1196
q,
You can’t perform that action at this time.
0 commit comments