File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed
oolong-core/src/main/scala/oolong
oolong-mongo/src/test/scala/oolong/mongo Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -29,4 +29,6 @@ DisableSyntax.regex = [
29
29
pattern = "import cats\\ .implicits"
30
30
message = "Use granular imports"
31
31
}
32
- ]
32
+ ]
33
+
34
+ OrganizeImports.targetDialect = Scala3
Original file line number Diff line number Diff line change 1
1
package oolong
2
2
3
+ import java .time .Instant
3
4
import java .util .regex .Pattern
4
5
import scala .annotation .tailrec
5
6
import scala .language .postfixOps
@@ -162,6 +163,12 @@ private[oolong] class DefaultAstParser(using quotes: Quotes) extends AstParser {
162
163
case ' { ($x : Option [_]).nonEmpty } =>
163
164
QExpr .Exists (parse(x), QExpr .Constant (true ))
164
165
166
+ case ' { ($x : Instant ).isBefore($s) } =>
167
+ QExpr .Lt (parse(x), parse(s))
168
+
169
+ case ' { ($x : Instant ).isAfter($s) } =>
170
+ QExpr .Gt (parse(x), parse(s))
171
+
165
172
case PropSelector (name, path) if name == paramName =>
166
173
QExpr .Prop (path.mkString(" ." ))
167
174
Original file line number Diff line number Diff line change 1
1
package oolong .mongo
2
2
3
+ import java .time .Instant
3
4
import java .time .LocalDate
4
5
import java .time .ZoneOffset
5
6
import java .util .regex .Pattern
@@ -1167,6 +1168,36 @@ class QuerySpec extends AnyFunSuite {
1167
1168
)
1168
1169
}
1169
1170
1171
+ test(" Instant.ifBefore is supported" ) {
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" ))))
1175
+
1176
+ test(
1177
+ q,
1178
+ repr,
1179
+ BsonDocument (
1180
+ " field" -> BsonDocument (" $lt" -> BsonDateTime (1577836800000L ))
1181
+ ),
1182
+ ignoreRender = true
1183
+ )
1184
+ }
1185
+
1186
+ test(" Instant.isAfter is supported" ) {
1187
+ 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
+ test(
1192
+ q,
1193
+ repr,
1194
+ BsonDocument (
1195
+ " field" -> BsonDocument (" $gt" -> BsonDateTime (1577836800000L ))
1196
+ ),
1197
+ ignoreRender = true
1198
+ )
1199
+ }
1200
+
1170
1201
private inline def test (
1171
1202
query : BsonDocument ,
1172
1203
repr : String ,
You can’t perform that action at this time.
0 commit comments