-> This version fixes core regressions, which is a subtle bug because
the module just starts to return bad data... Recommend upgrade
immediately.
Jonathan Yu
14 years ago
0 | 0 | Revision history for DBIx::Class |
1 | ||
2 | 0.08106 2009-06-11 21:42:00 (UTC) | |
3 | - Switched SQLite storage driver to DateTime::Format::SQLite | |
4 | (proper timezone handling) | |
5 | - Fix more test problems | |
1 | 6 | |
2 | 7 | 0.08105 2009-06-11 19:04:00 (UTC) |
3 | 8 | - Update of numeric columns now properly uses != to determine |
49 | 49 | MailingList: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class |
50 | 50 | license: http://dev.perl.org/licenses/ |
51 | 51 | repository: http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/ |
52 | version: 0.08105 | |
52 | version: 0.08106 |
0 | libdbix-class-perl (0.08105-1) unstable; urgency=low | |
0 | libdbix-class-perl (0.08106-1) unstable; urgency=low | |
1 | 1 | |
2 | 2 | [ Jonathan Yu ] |
3 | 3 | * New upstream release (many bugfixes, no feature changes) |
4 | -> This version fixes core regressions, which is a subtle bug because | |
5 | the module just starts to return bad data... Recommend upgrade | |
6 | immediately. | |
4 | 7 | * Added /me to uploaders & copyright |
5 | 8 | * Updated M::I information |
6 | 9 |
278 | 278 | my $count = $rs->count; |
279 | 279 | |
280 | 280 | # Equivalent SQL: |
281 | # SELECT COUNT( DISTINCT( me.name ) ) FROM artist me | |
281 | # SELECT COUNT( * ) FROM (SELECT me.name FROM artist me GROUP BY me.name) count_subq: | |
282 | 282 | |
283 | 283 | =head2 Grouping results |
284 | 284 |
1926 | 1926 | |
1927 | 1927 | sub as_query { |
1928 | 1928 | my $self = shift; |
1929 | return $self->result_source->storage->as_query($self->_resolved_attrs); | |
1929 | ||
1930 | my $attrs = $self->_resolved_attrs_copy; | |
1931 | ||
1932 | my ($sqlbind, $bind_attrs) = $self->result_source->storage | |
1933 | ->_select_args_to_query ($attrs->{from}, $attrs->{select}, $attrs->{where}, $attrs); | |
1934 | ||
1935 | return $sqlbind; | |
1930 | 1936 | } |
1931 | 1937 | |
1932 | 1938 | =head2 find_or_new |
909 | 909 | return ($sql, \@bind); |
910 | 910 | } |
911 | 911 | |
912 | =head2 as_query | |
913 | ||
914 | =over 4 | |
915 | ||
916 | =item Arguments: $rs_attrs | |
917 | ||
918 | =item Return Value: \[ $sql, @bind ] | |
919 | ||
920 | =back | |
921 | ||
922 | Returns the SQL statement and bind vars that would result from the given | |
923 | ResultSet attributes (does not actually run a query) | |
924 | ||
925 | =cut | |
926 | ||
927 | sub as_query { | |
928 | my ($self, $rs_attr) = @_; | |
929 | ||
930 | my $sql_maker = $self->sql_maker; | |
931 | local $sql_maker->{for}; | |
932 | ||
933 | # my ($op, $bind, $ident, $bind_attrs, $select, $cond, $order, $rows, $offset) = $self->_select_args(...); | |
934 | my @args = $self->_select_args($rs_attr->{from}, $rs_attr->{select}, $rs_attr->{where}, $rs_attr); | |
935 | ||
936 | # my ($sql, $bind) = $self->_prep_for_execute($op, $bind, $ident, [ $select, $cond, $order, $rows, $offset ]); | |
937 | my ($sql, $bind) = $self->_prep_for_execute( | |
938 | @args[0 .. 2], | |
939 | [ @args[4 .. $#args] ], | |
940 | ); | |
941 | return \[ "($sql)", @{ $bind || [] }]; | |
942 | } | |
943 | 912 | |
944 | 913 | sub _fix_bind_params { |
945 | 914 | my ($self, @bind) = @_; |
1224 | 1193 | my $sql_maker = $self->sql_maker; |
1225 | 1194 | local $sql_maker->{for}; |
1226 | 1195 | return $self->_execute($self->_select_args(@_)); |
1196 | } | |
1197 | ||
1198 | sub _select_args_to_query { | |
1199 | my $self = shift; | |
1200 | ||
1201 | my $sql_maker = $self->sql_maker; | |
1202 | local $sql_maker->{for}; | |
1203 | ||
1204 | # my ($op, $bind, $ident, $bind_attrs, $select, $cond, $order, $rows, $offset) | |
1205 | # = $self->_select_args($ident, $select, $cond, $attrs); | |
1206 | my ($op, $bind, $ident, $bind_attrs, @args) = | |
1207 | $self->_select_args(@_); | |
1208 | ||
1209 | # my ($sql, $bind) = $self->_prep_for_execute($op, $bind, $ident, [ $select, $cond, $order, $rows, $offset ]); | |
1210 | my ($sql, $prepared_bind) = $self->_prep_for_execute($op, $bind, $ident, \@args); | |
1211 | ||
1212 | return \[ "($sql)", @{ $prepared_bind || [] }]; | |
1227 | 1213 | } |
1228 | 1214 | |
1229 | 1215 | sub _select_args { |
23 | 23 | # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports |
24 | 24 | # brain damage and presumably various other packaging systems too |
25 | 25 | |
26 | $VERSION = '0.08105'; | |
26 | $VERSION = '0.08106'; | |
27 | 27 | |
28 | 28 | $VERSION = eval $VERSION; # numify for warning-free dev releases |
29 | 29 |
10 | 10 | |
11 | 11 | plan tests => 106; |
12 | 12 | |
13 | eval { require DateTime::Format::MySQL }; | |
13 | eval { require DateTime::Format::SQLite }; | |
14 | 14 | my $NO_DTFM = $@ ? 1 : 0; |
15 | 15 | |
16 | 16 | my @art = $schema->resultset("Artist")->search({ }, { order_by => 'name DESC'}); |
194 | 194 | |
195 | 195 | # get_inflated_columns w/relation and accessor alias |
196 | 196 | SKIP: { |
197 | skip "This test requires DateTime::Format::MySQL", 8 if $NO_DTFM; | |
197 | skip "This test requires DateTime::Format::SQLite", 8 if $NO_DTFM; | |
198 | 198 | |
199 | 199 | isa_ok($new->updated_date, 'DateTime', 'have inflated object via accessor'); |
200 | 200 | my %tdata = $new->get_inflated_columns; |
388 | 388 | |
389 | 389 | # test get_inflated_columns with objects |
390 | 390 | SKIP: { |
391 | skip "This test requires DateTime::Format::MySQL", 5 if $NO_DTFM; | |
391 | skip "This test requires DateTime::Format::SQLite", 5 if $NO_DTFM; | |
392 | 392 | my $event = $schema->resultset('Event')->search->first; |
393 | 393 | my %edata = $event->get_inflated_columns; |
394 | 394 | is($edata{'id'}, $event->id, 'got id'); |
50 | 50 | |
51 | 51 | # Make sure the carp/croak override in SQLA works (via SQLAHacks) |
52 | 52 | my $file = __FILE__; |
53 | $file = "\Q$file\E"; | |
53 | 54 | throws_ok (sub { |
54 | 55 | $schema->resultset ('Artist')->search ({}, { order_by => { -asc => 'stuff', -desc => 'staff' } } )->as_query; |
55 | 56 | }, qr/$file/, 'Exception correctly croak()ed'); |