Re: [Dbix-class] CDBICompat NumExplodingSheep
Dave Howorth wrote: I wrote: I think there are some problems in test t/cdbi-t/15-accessor-new.t ... I also think there's a problem with find_or_create() and accessor_for(). For starters there're no tests! But I haven't yet got a set of tests for which I understand the results and which agree with the failure I'm seeing in my application. They're similar to the one for search() I'll post some tests when I have them. Hi Dave, I contacted the CDBI-compat shim maintainer and here is his reply. I also included him in the CC, please reply-all if you discuss it with him to keep me in the loop. == Peter Rabbitson wrote: Haven't seen you on IRC for a while, figured I'll try here. We got a bugreport[1] against the compat layer some time ago. I applied his indeed failing tests[2], and TODOified[3] them. If you can drop by to see if this can/needs to be fixed it'd be great. In general, I think you're right to do the full hash copy. But I ran the new tests through CDBI and insert() doesn't appear to honor accessor_name_for() for the hash keys. So this sort of thing doesn't work. eval { my $data = { %$data }; $data-{sheep} = 2; ok my $bt = Film-insert($data), Modified accessor - with accessor; isa_ok $bt, Film; is $bt-sheep, 2, 'sheep bursting violently'; }; is $@, '', No errors; Whether this is a bug or feature of CDBI is arguable, insert() and the accessors have always been a little out of sync, but as far as CDBI::Compat is concerned just go with what CDBI actually does. So those new tests should probably be pulled. ___ 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
Re: [Dbix-class] CDBICompat NumExplodingSheep
I wrote: I think there are some problems in test t/cdbi-t/15-accessor-new.t ... I also think there's a problem with find_or_create() and accessor_for(). For starters there're no tests! But I haven't yet got a set of tests for which I understand the results and which agree with the failure I'm seeing in my application. They're similar to the one for search() I'll post some tests when I have them. OK. I've attached a patch to t/cdbi-t/15-accessor.t that does several things: (1) Fixes the way the arguments are built so the sheep argument is correct in the tests. (2) Adds explicit tests for the number of sheep so we can be sure which database record is actually returned. (3) Adds tests for find_or_create() with modified accessor names. (4) Fixes the test for search() to report all errors I still don't fully understand what's going on in the output below but I think they are genuine test failures. I'd appreciate it if somebody else could run the tests to make sure the results are not some artefact of my test environment. I also attached a copy of the modified test script so you don't even have to apply the patch first :) I don't know what the DestroyWarning at the end is all about. Thanks, Dave 1..75 ok 1 - Modified accessor - with column name ok 2 - The object isa Film ok 3 - sheep bursting violently ok 4 - No errors ok 5 - Modified accessor - with accessor ok 6 - The object isa Film ok 7 - sheep bursting violently ok 8 - No errors DBIx::Class::CDBICompat::Retrieve::find_or_create(): Query returned more than one row. SQL that returns multiple rows is DEPRECATED for -find and -single at ../15-accessor-new.t line 80 ok 9 - find_or_create Modified accessor - find with column name ok 10 - The object isa Film ok 11 - sheep bursting violently ok 12 - No errors DBIx::Class::CDBICompat::Retrieve::find_or_create(): Query returned more than one row. SQL that returns multiple rows is DEPRECATED for -find and -single at ../15-accessor-new.t line 90 ok 13 - find_or_create Modified accessor - find with accessor ok 14 - The object isa Film ok 15 - sheep bursting violently ok 16 - No errors DBIx::Class::CDBICompat::Retrieve::find_or_create(): Query returned more than one row. SQL that returns multiple rows is DEPRECATED for -find and -single at ../15-accessor-new.t line 100 ok 17 - find_or_create Modified accessor - create with column name ok 18 - The object isa Film not ok 19 - sheep bursting violently # Failed test 'sheep bursting violently' # at ../15-accessor-new.t line 103. # got: '1' # expected: '3' ok 20 - No errors DBIx::Class::CDBICompat::Retrieve::find_or_create(): Query returned more than one row. SQL that returns multiple rows is DEPRECATED for -find and -single at ../15-accessor-new.t line 110 ok 21 - find_or_create Modified accessor - create with accessor ok 22 - The object isa Film not ok 23 - sheep bursting violently # Failed test 'sheep bursting violently' # at ../15-accessor-new.t line 113. # got: '1' # expected: '4' ok 24 - No errors not ok 25 - No errors # Failed test 'No errors' # at ../15-accessor-new.t line 121. # got: 'DBIx::Class::CDBICompat::Relationships::search(): DBI Exception: DBD::SQLite::db prepare_cached failed: no such column: sheep(1) at dbdimp.c line 271 [for Statement SELECT me.title FROM Movies me WHERE ( sheep = ? )] at ../15-accessor-new.t line 118 # ' # expected: '' ok 26 - Modified mutator - with mutator ok 27 - The object isa Film ok 28 - No errors ok 29 - Modified mutator - with column name ok 30 - The object isa Film ok 31 - No errors ok 32 - Modified mutator - with accessor ok 33 - The object isa Film ok 34 - No errors ok 35 ok 36 - no hasa film ok 37 - hasa movie ok 38 - The object isa Film ok 39 - - Bad Taste ok 40 - No errors ok 41 - Can't locate object method film via package Actor at ../15-accessor-new.t line 173. # ok 42 - 'main' cannot alter the value of 'film' on objects of class 'Actor' at ../15-accessor-new.t line 176 # ok 43 - Set movie through hasa ok 44 - hasa movie ok 45 - The object isa Film ok 46 - - Another Film ok 47 - No problem ok 48 - a custom accessor without a custom mutator is setable ok 49 - nonpersistent is a column ok 50 - - but it's not real ok 51 - Title set OK ok 52 - As is non persistent value ok 53 - Re-retrieve film ok 54 - Title still OK ok 55 - Non persistent value gone ok 56 - Can set it ok 57 - And it's there again ok 58 - Commit the film ok 59 - And it's still there ok 60 - Actor has no specific essential columns ok 61 - nonpersistent is a column ok 62 - - but it's not real ok 63 - no problems retrieving actors ok 64 - The object isa Actor ok 65 - Can update Naked ok 66 - Make Naked read only ok 67 - Can't update Naked any more ok 68 - But can still update Secrets and Lies ok 69 - And can still create new films isa Film ok 70 - Make all Films read only ok 71 - Still can't update Naked ok 72 - And can't update SL any more ok 73 - And can't delete 4 Days in July ok 74
[Dbix-class] CDBICompat NumExplodingSheep
I think there are some problems in test t/cdbi-t/15-accessor-new.t = I think there's a latent bug after line 53: my $data = { Title= 'Bad Taste', Director = 'Peter Jackson', Rating = 'R', }; eval { my $data = $data; $data-{NumExplodingSheep} = 1; ok my $bt = Film-create($data), Modified accessor - with column name; isa_ok $bt, Film; }; is $@, '', No errors; eval { my $data = $data; $data-{sheep} = 1; ok my $bt = Film-create($data), Modified accessor - with accessor; isa_ok $bt, Film; }; is $@, '', No errors; The problem is that in the second eval $data-{NumExplodingSheep} still has the value 1 [the lovely tricky assignment is only doing a top-level copy, so the value from the first eval was copied into the top-level lexical and made available in the second eval]. So that test isn't really a fair test of what it claims to be testing. Luckily, the test still passes after hacking in a: delete $data-{NumExplodingSheep}; which is good news. I expect something like my $data = { %$data }; might be better, or even using different variable names. = I think there's an actual problem with Can search with modified accessor. Namely, there is no is $@, '', No errors; after the eval. After adding one, I see this output: not ok 17 - No errors # Failed test 'No errors' # at ../15-accessor-new.t line 108. # got: 'DBIx::Class::CDBICompat::HasA::search(): DBI Exception: DBD::SQLite::db prepare_cached failed: no such column: sheep(1) at dbdimp.c line 271 [for Statement SELECT me.title FROM Movies me WHERE ( sheep = ? )] at ../15-accessor-new.t line 104 # ' # expected: '' (line and test numbers are not quite right because of other things I changed above) So AFAICT, search() does NOT work. = I also think there's a problem with find_or_create() and accessor_for(). For starters there're no tests! But I haven't yet got a set of tests for which I understand the results and which agree with the failure I'm seeing in my application. They're similar to the one for search() I'll post some tests when I have them. = More generally, the description of DBIx::Class::CDBICompat says DBIx::Class features a fully featured compatibility layer with Class::DBI and there's an impressively short list of limitations. I'm beginning to have doubts about that description - has anybody used this stuff? Cheers, Dave ___ 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
Re: [Dbix-class] CDBICompat
Matt S Trout wrote: On Tue, Nov 11, 2008 at 12:10:03PM +, Dave Howorth wrote: Dave Howorth wrote: I've poked around some more and think I've found the source of the problem. I went back to a small example that worked and then experimented until it broke. I looked at the cdbi-t tests to see how connection() is tested. AFAICT, it isn't! So here are two tests for connection. The first one passes for me and the second one fails. Are you testing against CPAN or dev release? The latter has many many fixes by schwern integrated. If you can produce a test against current trunk that still fails, we can see about digging around and fixing it. I'm running against a dev release. I just updated to rev 5158 and ran the tests again with the same results - #1 works, #2 fails. In poking around to get my code working I found that a lot of POD in DBIx::Class::DB has been concealed because the class is deprecated except for CDBICompat. Once I discovered it, that POD gave me a hint and I've found that adding the line: __PACKAGE__-setup_schema_instance; immediately after use base 'DBIx::Class::CDBICompat'; appears to make my code work. So I'd suggest that at a minimum the description of that method ought to be copied into the LIMITATIONS section of the DBIx::Class::CDBICompat POD. I don't know if any more of that POD is also still relevant. Nicer would be something that called the method automatically, of course :) But I haven't figured that out. Cheers, Dave ___ 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
[Dbix-class] CDBICompat sth_to_objects
The implementation of sth_to_objects in DBIx/Class/CDBICompat/ImaDBI.pm doesn't seem to be fully compatible with that in Class/DBI.pm Specifically, the method in Class::DBI is context aware and returns an iterator in scalar context. The CDBICompat version isn't context aware and so returns a row count! I see there is DBIx::Class::CDBICompat::Iterator which says See DBIx::Class::CDBICompat for directions for use but I can see no mention of the word iterator in the DBIx::Class::CDBICompat POD. So I don't know whether CLass::DBI's array vs iterator feature is supposed to work in CDBICompat or not. If it isn't, it should die rather than return faulty data, IMHO. Cheers, Dave PS OT but I'm also confused by this code in Class::DBI sub _ids_to_objects { my ($class, $data) = @_; return $#$data + 1 unless defined wantarray; return map $class-construct($_), @$data if wantarray; return $class-_my_iterator-new($class = $data); } I think 'defined wantarray' only returns undefined in void context, so I don't understand why it's returning the record count? ___ 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
[Fwd: Abwesenheitsnotiz: [Dbix-class] CDBICompat sth_to_objects]
I just got the following in response to my posting. Perhaps this spammer could have his subscription terminated. Original Message Subject:Abwesenheitsnotiz: [Dbix-class] CDBICompat sth_to_objects Date: Mon, 17 Nov 2008 16:45:50 +0100 From: Holger Göbber [EMAIL PROTECTED] To: Dave Howorth (via Nabble) [EMAIL PROTECTED] Sehr geehrte Kunden. Ich bin vom 17.11 bis 21.11.2008 nicht im Haus. Bei Fragen wenden Sie sich bitte an meinen Kollegen Jakob Reiter unter: [EMAIL PROTECTED] Mit freundlichen Grüßen, Holger Göbber Exelution GmbH ___ 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
Re: [Dbix-class] CDBICompat
Dave Howorth wrote: I've poked around some more and think I've found the source of the problem. I went back to a small example that worked and then experimented until it broke. I looked at the cdbi-t tests to see how connection() is tested. AFAICT, it isn't! So here are two tests for connection. The first one passes for me and the second one fails. Both pass if I replace use base 'DBIx::Class::CDBICompat'; with use base 'Class::DBI'; So can I ask that the tests be added to the test suite. I'm afraid I don't know enough about DBIC internals to offer a patch so the test passes. Thanks and regards, Dave Howorth cdbicompat-connection-test-1.t Description: Troff document cdbicompat-connection-test-2.t Description: Troff document ___ 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