From: Peter Rabbitson Date: Fri, 15 Jan 2010 00:19:08 +0000 (+0000) Subject: Merge 'trunk' into 'null_column_regression' X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8c9c805b37142e8c746af9a7d106dac49d04fc9d;hp=37cb0de173eed31c34a583b1404fcef6f41da0ce;p=dbsrgits%2FDBIx-Class-Historic.git Merge 'trunk' into 'null_column_regression' r8162@Thesaurus (orig r8150): abraxxa | 2009-12-18 15:59:58 +0100 Schema POD inprovement for dclone r8163@Thesaurus (orig r8151): abraxxa | 2009-12-18 16:07:27 +0100 link to DBIx::Class::Row r8164@Thesaurus (orig r8152): abraxxa | 2009-12-18 16:08:56 +0100 fixed typo in Changes r8165@Thesaurus (orig r8153): abraxxa | 2009-12-18 16:14:47 +0100 dclone pod take #2 r8169@Thesaurus (orig r8157): ribasushi | 2009-12-19 18:47:42 +0100 detabify r8170@Thesaurus (orig r8158): ribasushi | 2009-12-19 19:41:42 +0100 Fix RT52812 r8171@Thesaurus (orig r8159): caelum | 2009-12-23 07:16:29 +0100 minor POD fixes r8175@Thesaurus (orig r8163): ribasushi | 2009-12-24 09:59:52 +0100 Fix deployment_statements context sensitivity regression r8176@Thesaurus (orig r8164): ribasushi | 2009-12-24 10:13:37 +0100 Don't call the PK setter if no PK r8204@Thesaurus (orig r8192): caelum | 2009-12-30 22:58:47 +0100 bump CAG dep r8231@Thesaurus (orig r8219): matthewt | 2010-01-02 01:41:12 +0100 fix typo in variable name r8238@Thesaurus (orig r8226): rafl | 2010-01-02 18:46:40 +0100 Merge branch 'native_traits' * native_traits: Port replicated storage from MXAH to native traits. Create branch native_traits r8244@Thesaurus (orig r8232): caelum | 2010-01-04 00:30:51 +0100 fix _rebless into sybase/mssql/nobindvars r8247@Thesaurus (orig r8235): caelum | 2010-01-05 13:54:56 +0100 r22328@hlagh (orig r8201): caelum | 2009-12-31 12:29:51 -0500 new branch to fix table aliases in queries over the 30char limit r22329@hlagh (orig r8202): caelum | 2009-12-31 12:55:50 -0500 failing test r22330@hlagh (orig r8203): caelum | 2009-12-31 13:00:35 -0500 switch oracle tests to done_testing() r22331@hlagh (orig r8204): caelum | 2009-12-31 15:02:50 -0500 got something working r22332@hlagh (orig r8205): caelum | 2009-12-31 15:08:30 -0500 POD touchups r22343@hlagh (orig r8216): caelum | 2010-01-01 07:42:03 -0500 fix uninitialized warning and a bug in ResultSet r22419@hlagh (orig r8234): caelum | 2010-01-05 07:53:18 -0500 append half of a base64 MD5 to shortened table aliases for Oracle r8249@Thesaurus (orig r8237): caelum | 2010-01-05 15:27:40 +0100 minor change: use more of the hash if possible for oracle table alias shortening r8251@Thesaurus (orig r8239): caelum | 2010-01-06 02:20:17 +0100 bump perl_version to 5.8.1 r8252@Thesaurus (orig r8240): caelum | 2010-01-06 02:21:41 +0100 remove alignment mark on base64 md5 r8260@Thesaurus (orig r8248): ribasushi | 2010-01-07 11:21:55 +0100 5.8.1 is minimum required perl r8261@Thesaurus (orig r8249): ribasushi | 2010-01-07 11:22:42 +0100 Minor optimization r8262@Thesaurus (orig r8250): ribasushi | 2010-01-07 11:23:35 +0100 Wrong title r8265@Thesaurus (orig r8253): ribasushi | 2010-01-08 17:48:50 +0100 Resolve problem reported by http://lists.scsys.co.uk/pipermail/dbix-class/2009-December/008699.html r8266@Thesaurus (orig r8254): ribasushi | 2010-01-08 17:52:01 +0100 Put utf8columns in line with the store_column fix r8267@Thesaurus (orig r8255): ribasushi | 2010-01-08 19:03:26 +0100 Tests while hunting for something else r8268@Thesaurus (orig r8256): ribasushi | 2010-01-08 19:14:42 +0100 Make test look even more like http://lists.scsys.co.uk/pipermail/dbix-class/2009-November/008599.html r8277@Thesaurus (orig r8265): ribasushi | 2010-01-09 02:16:14 +0100 r8263@Thesaurus (orig r8251): ribasushi | 2010-01-08 15:43:38 +0100 New branch to find a leak r8264@Thesaurus (orig r8252): ribasushi | 2010-01-08 15:52:46 +0100 Weird test failures r8272@Thesaurus (orig r8260): ribasushi | 2010-01-09 01:24:56 +0100 Proper invocation r8273@Thesaurus (orig r8261): ribasushi | 2010-01-09 01:35:34 +0100 Test for the real leak reason r8274@Thesaurus (orig r8262): ribasushi | 2010-01-09 01:37:33 +0100 Void ctx as it should be r8275@Thesaurus (orig r8263): ribasushi | 2010-01-09 02:10:13 +0100 A "fix" for sqlt-related schema leaks r8276@Thesaurus (orig r8264): ribasushi | 2010-01-09 02:15:53 +0100 Changes r8287@Thesaurus (orig r8275): caelum | 2010-01-10 11:29:06 +0100 r22483@hlagh (orig r8272): caelum | 2010-01-09 05:52:15 -0500 new branch to add "normalize_connect_info" class method to Storage::DBI r22495@hlagh (orig r8274): caelum | 2010-01-10 05:27:42 -0500 split connect_info parser out into private _normalize_connect_info r8289@Thesaurus (orig r8277): caelum | 2010-01-10 12:04:52 +0100 fix connection details in ::DBI::Replicated docs r8291@Thesaurus (orig r8279): ribasushi | 2010-01-11 09:50:21 +0100 r8077@Thesaurus (orig r8065): ribasushi | 2009-12-12 14:24:30 +0100 Branch for yet another mssql ordered prefetch problem r8079@Thesaurus (orig r8067): ribasushi | 2009-12-12 14:37:48 +0100 prefetch does not get disassembled properly r8112@Thesaurus (orig r8100): ribasushi | 2009-12-13 00:07:00 +0100 Extra test to highlight search_related inefficiency r8113@Thesaurus (orig r8101): ribasushi | 2009-12-13 00:17:44 +0100 Real test for search_related and prefetch r8114@Thesaurus (orig r8102): ribasushi | 2009-12-13 00:19:57 +0100 Fix corner case regression on search_related on a prefetching rs r8115@Thesaurus (orig r8103): ribasushi | 2009-12-13 00:21:05 +0100 Isolate prefetch heads using RNO with a subquery r8116@Thesaurus (orig r8104): ribasushi | 2009-12-13 00:23:46 +0100 Changes r8125@Thesaurus (orig r8113): ribasushi | 2009-12-15 13:06:26 +0100 Extend mssql limited prefetch tests r8126@Thesaurus (orig r8114): ribasushi | 2009-12-15 13:08:56 +0100 Add extra test to prove Alan wrong :) r8132@Thesaurus (orig r8120): ribasushi | 2009-12-16 00:38:04 +0100 Do not realias tables in the RNO subqueries r8133@Thesaurus (orig r8121): ribasushi | 2009-12-16 00:50:52 +0100 Deliberately disturb alphabetical order r8134@Thesaurus (orig r8122): ribasushi | 2009-12-16 10:26:43 +0100 Got a failing test r8135@Thesaurus (orig r8123): ribasushi | 2009-12-16 10:49:10 +0100 Cleanup r8136@Thesaurus (orig r8124): ribasushi | 2009-12-16 10:51:58 +0100 More moving around r8137@Thesaurus (orig r8125): ribasushi | 2009-12-16 11:25:37 +0100 The real mssql problem - it's... bad r8138@Thesaurus (orig r8126): ribasushi | 2009-12-16 11:29:20 +0100 Clearer debug r8139@Thesaurus (orig r8127): ribasushi | 2009-12-16 11:47:48 +0100 This is horrific but the tests pass... maybe someone will figure out something better r8140@Thesaurus (orig r8128): ribasushi | 2009-12-16 16:45:47 +0100 cleanup tests r8187@Thesaurus (orig r8175): ribasushi | 2009-12-24 16:22:30 +0100 Ordered subqueries do not work in mssql after all r8271@Thesaurus (orig r8259): ribasushi | 2010-01-08 23:58:13 +0100 Cleaner RNO sql r8279@Thesaurus (orig r8267): ribasushi | 2010-01-09 10:13:16 +0100 Subqueries no longer experimental r8280@Thesaurus (orig r8268): ribasushi | 2010-01-09 11:26:46 +0100 Close the book on mssql ordered subqueries r8281@Thesaurus (orig r8269): ribasushi | 2010-01-09 11:36:36 +0100 Changes and typos r8283@Thesaurus (orig r8271): ribasushi | 2010-01-09 11:42:21 +0100 Highlight the real problem r8285@Thesaurus (orig r8273): ribasushi | 2010-01-10 10:07:10 +0100 Rename subquery to subselect and rewrite POD (per castaway) r8290@Thesaurus (orig r8278): ribasushi | 2010-01-10 17:01:24 +0100 rename as per mst r8295@Thesaurus (orig r8283): caelum | 2010-01-11 23:42:30 +0100 make a public ::Schema::unregister_source r8298@Thesaurus (orig r8286): abraxxa | 2010-01-12 18:04:18 +0100 fixed a typo in Changes more detailed explanation for the warning about has_one/might_have rels on nullable columns r8307@Thesaurus (orig r8295): abraxxa | 2010-01-13 17:28:05 +0100 added the sources parser arg to the example code --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index baf6be2..5827fb4 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -974,19 +974,6 @@ sub _construct_object { sub _collapse_result { my ($self, $as_proto, $row) = @_; - # if the first row that ever came in is totally empty - this means we got - # hit by a smooth^Wempty left-joined resultset. Just noop in that case - # instead of producing a {} - # - my $has_def; - for (@$row) { - if (defined $_) { - $has_def++; - last; - } - } - return undef unless $has_def; - my @copy = @$row; # 'foo' => [ undef, 'foo' ] @@ -1247,11 +1234,6 @@ sub _count_rs { $tmp_attrs->{select} = $rsrc->storage->_count_select ($rsrc, $tmp_attrs); $tmp_attrs->{as} = 'count'; - # read the comment on top of the actual function to see what this does - $tmp_attrs->{from} = $self->result_source->schema->storage->_straight_join_to_node ( - $tmp_attrs->{from}, $tmp_attrs->{alias} - ); - my $tmp_rs = $rsrc->resultset_class->new($rsrc, $tmp_attrs)->get_column ('count'); return $tmp_rs; @@ -1279,11 +1261,6 @@ sub _count_subq_rs { $sub_attrs->{select} = $rsrc->storage->_subq_count_select ($rsrc, $sub_attrs); - # read the comment on top of the actual function to see what this does - $sub_attrs->{from} = $self->result_source->schema->storage->_straight_join_to_node ( - $sub_attrs->{from}, $sub_attrs->{alias} - ); - # this is so that the query can be simplified e.g. # * non-limiting joins can be pruned # * ordering can be thrown away in things like Top limit @@ -2510,10 +2487,11 @@ sub related_resultset { $self->{related_resultsets} ||= {}; return $self->{related_resultsets}{$rel} ||= do { - my $rel_info = $self->result_source->relationship_info($rel); + my $rsrc = $self->result_source; + my $rel_info = $rsrc->relationship_info($rel); $self->throw_exception( - "search_related: result source '" . $self->result_source->source_name . + "search_related: result source '" . $rsrc->source_name . "' has no such relationship $rel") unless $rel_info; @@ -2524,6 +2502,13 @@ sub related_resultset { my $alias = $self->result_source->storage ->relname_to_table_alias($rel, $join_count); + # since this is search_related, and we already slid the select window inwards + # (the select/as attrs were deleted in the beginning), we need to flip all + # left joins to inner, so we get the expected results + # read the comment on top of the actual function to see what this does + $attrs->{from} = $rsrc->schema->storage->_straight_join_to_node ($attrs->{from}, $alias); + + #XXX - temp fix for result_class bug. There likely is a more elegant fix -groditi delete @{$attrs}{qw(result_class alias)}; @@ -2536,7 +2521,7 @@ sub related_resultset { } } - my $rel_source = $self->result_source->related_source($rel); + my $rel_source = $rsrc->related_source($rel); my $new = do { @@ -2687,7 +2672,6 @@ sub _chain_relationship { # the join in question so we could tell it *is* the search_related) my $already_joined; - # we consider the last one thus reverse for my $j (reverse @requested_joins) { if ($rel eq $j->[0]{-join_path}[-1]) { @@ -2696,7 +2680,6 @@ sub _chain_relationship { last; } } - # alternative way to scan the entire chain - not backwards compatible # for my $j (reverse @$from) { # next unless ref $j eq 'ARRAY'; diff --git a/t/inflate/hri.t b/t/inflate/hri.t index 292c943..69fa4ff 100644 --- a/t/inflate/hri.t +++ b/t/inflate/hri.t @@ -45,7 +45,7 @@ sub check_cols_of { my @dbic_reltable = $dbic_obj->$col; my @hashref_reltable = @{$datahashref->{$col}}; - is (scalar @hashref_reltable, scalar @dbic_reltable, 'number of related entries'); + is (scalar @dbic_reltable, scalar @hashref_reltable, 'number of related entries'); # for my $index (0..scalar @hashref_reltable) { for my $index (0..scalar @dbic_reltable) { diff --git a/t/prefetch/double_prefetch.t b/t/prefetch/double_prefetch.t index 6142098..d82f4c4 100644 --- a/t/prefetch/double_prefetch.t +++ b/t/prefetch/double_prefetch.t @@ -27,7 +27,7 @@ is_same_sql( single_track_2.trackid, single_track_2.cd, single_track_2.position, single_track_2.title, single_track_2.last_updated_on, single_track_2.last_updated_at, single_track_2.small_dt, cd.cdid, cd.artist, cd.title, cd.year, cd.genreid, cd.single_track FROM artist me - LEFT JOIN cd cds ON cds.artist = me.artistid + JOIN cd cds ON cds.artist = me.artistid LEFT JOIN track single_track ON single_track.trackid = cds.single_track LEFT JOIN track single_track_2 ON single_track_2.trackid = cds.single_track LEFT JOIN cd cd ON cd.cdid = single_track_2.cd diff --git a/t/relationship/core.t b/t/relationship/core.t index 90e49a3..62776fa 100644 --- a/t/relationship/core.t +++ b/t/relationship/core.t @@ -268,7 +268,7 @@ is_same_sql_bind ( '( SELECT artist_undirected_maps.id1, artist_undirected_maps.id2 FROM artist me - LEFT JOIN artist_undirected_map artist_undirected_maps + JOIN artist_undirected_map artist_undirected_maps ON artist_undirected_maps.id1 = me.artistid OR artist_undirected_maps.id2 = me.artistid WHERE ( artistid = ? ) )', diff --git a/t/resultset/nulls_only.t b/t/resultset/nulls_only.t new file mode 100644 index 0000000..facf299 --- /dev/null +++ b/t/resultset/nulls_only.t @@ -0,0 +1,29 @@ +use strict; +use warnings; + +use lib qw(t/lib); +use Test::More; +use Test::Exception; +use DBICTest; + +my $schema = DBICTest->init_schema(); + + +my $cd_rs = $schema->resultset('CD')->search ({ genreid => undef }, { columns => [ 'genreid' ]} ); +my $count = $cd_rs->count; +cmp_ok ( $count, '>', 1, 'several CDs with no genre'); + +my @objects = $cd_rs->all; +is (scalar @objects, $count, 'Correct amount of objects without limit'); +isa_ok ($_, 'DBICTest::CD') for @objects; + +is_deeply ( + [ map { values %{{$_->get_columns}} } (@objects) ], + [ (undef) x $count ], + 'All values are indeed undef' +); + + +isa_ok ($cd_rs->search ({}, { rows => 1 })->single, 'DBICTest::CD'); + +done_testing;