X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2Fmysql.pm;h=7d0ad04f9389d4bb2549a015616297e5c9ac0816;hb=87b1255103d7b8873b225416cb381c50011f4c06;hp=83ee8b2c714556369e39952b8ab9d79eecc88756;hpb=a5bd5d88980681e140bc910d0cd38dd21db48218;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/mysql.pm b/lib/DBIx/Class/Storage/DBI/mysql.pm index 83ee8b2..7d0ad04 100644 --- a/lib/DBIx/Class/Storage/DBI/mysql.pm +++ b/lib/DBIx/Class/Storage/DBI/mysql.pm @@ -5,8 +5,6 @@ use warnings; use base qw/DBIx::Class::Storage::DBI/; -use namespace::clean; - __PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::MySQL'); __PACKAGE__->sql_limit_dialect ('LimitXY'); __PACKAGE__->sql_quote_char ('`'); @@ -44,13 +42,19 @@ sub _prep_for_execute { return $self->next::method(@_) if ( $_[0] eq 'select' or $_[0] eq 'insert' ); - # FIXME FIXME FIXME - this is a terrible, gross, incomplete hack - # it should be trivial for mst to port this to DQ (and a good - # exercise as well, since we do not yet have such wide tree walking - # in place). For the time being this will work in limited cases, - # mainly complex update/delete, which is really all we want it for - # currently (allows us to fix some bugs without breaking MySQL in - # the process, and is also crucial for Shadow to be usable) + # FIXME FIXME FIXME - this is a terrible, gross, incomplete, MySQL-specific + # hack but it works rather well for the limited amount of actual use cases + # which can not be done in any other way on MySQL. This allows us to fix + # some bugs without breaking MySQL support in the process and is also + # crucial for more complex things like Shadow to be usable + # + # This code is just a pre-analyzer, working in tandem with ::SQLMaker::MySQL, + # where the possibly-set value of {_modification_target_referenced_re} is + # used to demarcate which part of the final SQL to double-wrap in a subquery. + # + # This is covered extensively by "offline" tests, so when the DQ work + # resumes, this will get flagged. Afaik there are no AST-visitor code of that + # magnitude yet (Oct 2015) within DQ, so a good exercise overall. # extract the source name, construct modification indicator re my $sm = $self->sql_maker; @@ -106,15 +110,17 @@ sub _run_connection_actions { sub sql_maker { my $self = shift; - unless ($self->_sql_maker) { - my $maker = $self->next::method (@_); + # it is critical to get the version *before* calling next::method + # otherwise the potential connect will obliterate the sql_maker + # next::method will populate in the _sql_maker accessor + my $mysql_ver = $self->_server_info->{normalized_dbms_version}; - # mysql 3 does not understand a bare JOIN - my $mysql_ver = $self->_dbh_get_info('SQL_DBMS_VER'); - $maker->{_default_jointype} = 'INNER' if $mysql_ver =~ /^3/; - } + my $sm = $self->next::method(@_); - return $self->_sql_maker; + # mysql 3 does not understand a bare JOIN + $sm->{_default_jointype} = 'INNER' if $mysql_ver < 4; + + $sm; } sub sqlt_type { @@ -204,12 +210,13 @@ Enables session-wide strict options upon connecting. Equivalent to: ] }); -=head1 AUTHORS - -See L +=head1 FURTHER QUESTIONS? -=head1 LICENSE +Check the list of L. -You may distribute this code under the same terms as Perl itself. +=head1 COPYRIGHT AND LICENSE -=cut +This module is free software L +by the L. You can +redistribute it and/or modify it under the same terms as the +L.