4 #----------------------------------------------------------------------
6 #----------------------------------------------------------------------
9 eval "use DBD::SQLite";
10 plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 25);
18 is_deeply [ Lazy->columns('Primary') ], [qw/this/], "Pri";
19 is_deeply [ sort Lazy->columns('Essential') ], [qw/opop this/], "Essential";
20 is_deeply [ sort Lazy->columns('things') ], [qw/that this/], "things";
21 is_deeply [ sort Lazy->columns('horizon') ], [qw/eep orp/], "horizon";
22 is_deeply [ sort Lazy->columns('vertical') ], [qw/oop opop/], "vertical";
23 is_deeply [ sort Lazy->columns('All') ], [qw/eep oop opop orp that this/], "All";
26 my @groups = Lazy->__grouper->groups_for(Lazy->find_column('this'));
27 is_deeply [ sort @groups ], [sort qw/things Essential Primary/], "this (@groups)";
31 my @groups = Lazy->__grouper->groups_for(Lazy->find_column('that'));
32 is_deeply \@groups, [qw/things/], "that (@groups)";
35 Lazy->create({ this => 1, that => 2, oop => 3, opop => 4, eep => 5 });
37 ok(my $obj = Lazy->retrieve(1), 'Retrieve by Primary');
38 ok($obj->_attribute_exists('this'), "Gets primary");
39 ok($obj->_attribute_exists('opop'), "Gets other essential");
40 ok(!$obj->_attribute_exists('that'), "But other things");
41 ok(!$obj->_attribute_exists('eep'), " nor eep");
42 ok(!$obj->_attribute_exists('orp'), " nor orp");
43 ok(!$obj->_attribute_exists('oop'), " nor oop");
45 ok(my $val = $obj->eep, 'Fetch eep');
46 ok($obj->_attribute_exists('orp'), 'Gets orp too');
47 ok(!$obj->_attribute_exists('oop'), 'But still not oop');
48 ok(!$obj->_attribute_exists('that'), 'nor that');
51 Lazy->columns(All => qw/this that eep orp oop opop/);
52 ok(my $obj = Lazy->retrieve(1), 'Retrieve by Primary');
53 ok !$obj->_attribute_exists('oop'), " Don't have oop";
55 ok !$obj->_attribute_exists('oop'),
56 " Don't have oop - even after getting eep";
59 # Test contructor breaking.
61 eval { # Need a hashref
62 Lazy->create(this => 10, that => 20, oop => 30, opop => 40, eep => 50);
67 Lazy->create({ this => 10, that => 20, theother => 30 });
71 eval { # Multiple false columns
72 Lazy->create({ this => 10, that => 20, theother => 30, andanother => 40 });