Closed bbrtj closed 3 years ago
I'm not sure why doesn't this work, seen some previous discussion in issues where someone claimed it did actually work, but seems like there been no significant change to this in DBIx::Class recently, and no change in this Raisin code for the last 7 years.
To be precise, I did not run the MusicApp directly, but used its code for my own needs with PostgreSQL. The entities and models are a bit different, but the general way they're used is the same as in MusicApp.
I was missing two things:
use MyApp::Entity::SomeEntity
at the top of the filewith => 'MyApp::Entity::SomeEntity'
(sort of)So the behavior is very weird and needs to be patched / documented because looks like a bug at first glance:
use
at the top but no with
, I get an error described aboveuse
at the top but having with
entity 'MyApp::Entity::SomeEntity';
to API description I was able to spot an issue (since it was telling me that I probably forgot to load the module)Thanks for reporting! The bug was there from the very beginning and must be fixed now.
The new version is released to CPAN as 0.92.
@khrt Thank you, however I still don't think if the change you've introduced is enough, since the chain $data->first->columns_info
is erroneous if there are no rows in the result (since it's pretty much undef->columns_info
then and there seem to be no checks whether the ResultSet is empty). It would've fixed the non-visible first element in my case, but not the exception with no rows in the database.
@brtastic, right. I skipped that case, let me see what I can do to fix it.
Should be fixed now with the recent change.
The example from MusicApp with DBIx::Class does not work correctly.
This causes an error for empty resultsets and incorrect output for anything else.
The reason seem to be Raisin::Entity, line 148:
->first
method may return a new object that will have the->columns_info
method, but for empty resultsets it returnsundef
->first
method has already moved the iterator to the next position, and every call to->next
will move it even further. The count shown is not equal to the actual count of items returned. If the database has only one record, the result is: