interim blocked_by_lack_of_per_resultset_storage_attributes/mysql_bit_as_tinyint
Peter Rabbitson [Fri, 13 Aug 2010 08:44:56 +0000 (10:44 +0200)]
lib/DBIx/Class/Storage/DBI.pm
lib/DBIx/Class/Storage/DBI/mysql.pm
t/71mysql.t

index c26525d..2edbd29 100644 (file)
@@ -54,10 +54,12 @@ __PACKAGE__->mk_group_accessors('simple' => @storage_options);
 # will get the same rdbms version). _determine_supports_X does not need to
 # exist on a driver, as we ->can for it before calling.
 
-my @capabilities = (qw/insert_returning placeholders typeless_placeholders/);
-__PACKAGE__->mk_group_accessors( dbms_capability => map { "_supports_$_" } @capabilities );
-__PACKAGE__->mk_group_accessors( use_dbms_capability => map { "_use_$_" } @capabilities );
-
+__PACKAGE__->mk_dbi_capability_accessors (qw/insert_returning placeholders typeless_placeholders/);
+sub mk_dbi_capability_accessors {
+  my $class = shift;
+  $class->mk_group_accessors( dbms_capability => map { "_supports_$_" } @_ );
+  $class->mk_group_accessors( use_dbms_capability => map { "_use_$_" } @_ );
+}
 
 # Each of these methods need _determine_driver called before itself
 # in order to function reliably. This is a purely DRY optimization
index 7663735..6cd376c 100644 (file)
@@ -13,7 +13,8 @@ use namespace::clean;
 
 __PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks::MySQL');
 
-__PACKAGE__->mk_group_accessors(simple => qw/_bit_as/);
+__PACKAGE__->mk_dbi_capability_accessors(qw/bit_as_unsigned/);
+__PACKAGE__->mk_group_accessors(inherited => qw/_cast_bit_bit_as/);
 
 sub with_deferred_fk_checks {
   my ($self, $sub) = @_;
@@ -31,6 +32,12 @@ sub connect_call_set_strict_mode {
   $self->_do_query(q|SET SQL_AUTO_IS_NULL = 0|);
 }
 
+sub connect_call_bit_as_unsigned {
+  my $self = shift;
+
+  $self->_bit_as('UNSIGNED');
+}
+
 sub _dbh_last_insert_id {
   my ($self, $dbh, $source, $col) = @_;
   $dbh->{mysql_insertid};
@@ -128,19 +135,14 @@ inserted correctly.
 
 =cut
 
-sub connect_call_bit_as_unsigned {
-  my $self = shift;
-
-  $self->_bit_as('UNSIGNED');
-}
 
 sub bind_attribute_by_data_type {
   my $self        = shift;
   my ($data_type) = @_;
 
-  my $res = $self->next::method(@_) || {};
+  my $res = $self->next::method(@_);
 
-  if ($data_type && $self->_bit_as && lc($data_type) eq 'bit') {
+  if ($data_type && lc($data_type) eq 'bit' && $self->_bit_as && ) {
     $res->{TYPE} = SQL_INTEGER;
   }
 
index 29aca08..0603c90 100644 (file)
@@ -1,5 +1,5 @@
 use strict;
-use warnings;  
+use warnings;
 
 use Test::More;
 use Test::Exception;
@@ -58,9 +58,7 @@ else {
   $dbh->do("CREATE TABLE bitfield_test (id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, bitfield_1 BIT(1));");
 }
 
-#'dbi:mysql:host=localhost;database=dbic_test', 'dbic_test', '');
-
-# make sure sqlt_type overrides work (::Storage::DBI::mysql does this) 
+# make sure sqlt_type overrides work (::Storage::DBI::mysql does this)
 {
   my $schema = DBICTest::Schema->connect($dsn, $user, $pass);