From DBIx::Class::ResultSet we read that:
WARNING
If called on an object, proxies to "new_result" instead, so
my $cd = $schema->resultset('CD')->new({ title => 'Spoon' });
will return a CD object, not a ResultSet, and is equivalent to:
my $cd = $schema->resultset('CD')->new_result({ title => 'Spoon' });
Could someone explain what is differences between object and ResultSet?
The warning is about the difference between calling new
on a ResultSet object and the ResultSet class name. If you want to create a new ResultSet object using the ResultSet constructor, call new
on the ResultSet package:
my $resultset = DBIx::Class::ResultSet->new(...);
(Although you typically don't have to create ResultSet objects this way.) If you call new
on a ResultSet object, you won't get a new ResultSet object but a corresponding result (row) object:
my $row = $resultset->new(...);
Many other Perl classes make no difference whether new
is called on the class name or an object of the class, hence the warning.