Help language development. Donate to The Perl Foundation

ORM::ActiveRecord cpan:GDONALD last updated on 2019-10-24

t/004-model-where.t6
use v6.d;
use lib 'lib';
use ORM::ActiveRecord::Model;
use Test;

class User is Model {
  submethod BUILD {
    self.validate: 'fname', { :presence }
  }
}

plan 4;

%*ENV<DISABLE-SQL-LOG> = True;

my $fred = User.create({fname => 'Fred'});
ok $fred.is-valid;
my $barney = User.create({fname => 'Barney'});
ok $barney.is-valid;

ok User.count == 2;

my $result = User.where({fname => 'Fred'}).first;
ok $result == $fred;

User.destroy-all;