Alberto Luaces <alua...@udc.es> writes: >> Sencondly, DBIx::Class only hits the database when it absolutely has >>to, >> e.g. to fetch restults. This includes the initial connection. However, >> you can force it to connect early by calling >> >> $schema->storage->ensure_connected; >> >> Which will throw an exception if it fails to connect. > > Yes, it sounds sensible for an ORM to be lazy, but I did not imagine > that it could even involve connections. Thanks a lot for the pointer.
Oops, I spoke too soon. ensure_connected is not throwing. Here is the code for reference: 1 use lib './lib'; 2 use DAAO; 3 4 my $r = DAAO->connect("dbi:SQLite:non-existent.db"); 5 $r->storage->ensure_connected; 6 7 my $resultset = $r->resultset('Alumno')->search; 8 9 my $person = $resultset->next; # Iterator 10 11 print $person->asistencia; It does not crash until line 9, when the iterator is used. -- Alberto _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk