File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -654,6 +654,17 @@ describe Interro do
654654 UserQuery .new.search(" search" ).should contain user
655655 end
656656
657+ it " can check whether any records match" do
658+ user = create_user
659+ matching = UserQuery .new.with_id(user.id)
660+ empty = UserQuery .new.with_id(UUID .v7)
661+
662+ matching.any?.should eq true
663+ matching.none?.should eq false
664+ empty.any?.should eq false
665+ empty.none?.should eq true
666+ end
667+
657668 describe " transactions" do
658669 it " commits without error" do
659670 user = nil
Original file line number Diff line number Diff line change @@ -501,6 +501,10 @@ module Interro
501501 end
502502
503503 def any ? : Bool
504+ ! none?
505+ end
506+
507+ def none ? : Bool
504508 sql = String .build do |str |
505509 str << " SELECT 1 AS one"
506510 str << " FROM " << sql_table_name
@@ -512,7 +516,7 @@ module Interro
512516 str << " LIMIT 1"
513517 end
514518
515- !! connection(CONFIG .read_db).query_one? sql, args: @args , as: Int32
519+ ! connection(CONFIG .read_db).query_one? sql, args: @args , as: Int32
516520 end
517521
518522 protected def insert (** values) : T
You can’t perform that action at this time.
0 commit comments