Rose-DB

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.780 (01.06.2020) - John Siracusa <siracusa@gmail.com>

    * Added basic support for MariaDB. (Patch by Peter Karman.)

0.779 (08.09.2019) - John Siracusa <siracusa@gmail.com>

    * Added skip_locked support for PostgreSQL. (Patch by fhendrikx.)

0.778 (06.28.2016) - John Siracusa <siracusa@gmail.com>

    * Added mysql_enable_utf8mb4 attribute. (Patch by Alexander Karelas.)
    * Updated tests for the latest versions of MySQL and DateTime::Format::Pg.

0.777 (03.17.2015) - John Siracusa <siracusa@gmail.com>

    * Updated more project URLs.

0.776 (03.17.2015) - John Siracusa <siracusa@gmail.com>

    * Updated project URLs.

Changes  view on Meta::CPAN


0.757 (01.23.2010) - John Siracusa <siracusa@gmail.com>

    * Support for Rose::DB::Object 0.786.

0.756 (12.31.2009) - John Siracusa <siracusa@gmail.com>

    * Support for Rose::DB::Object 0.785.
    * Made fork- and thread-safe (though some databases, notably Oracle, 
      don't support passing a database connection across a fork at all).
    * Updated mysql_enable_utf8() to run "SET NAMES utf8" id a database
      handle already exists.
    * Updated the various validate_*_keywords() methods to no longer accept
      anything that "looks like a function call."  This was done to avoid 
      possible SQL injection attacks, and because the now-pervasive support
      for scalar-reference literals in Rose::DB::Object obviates the need 
      for such permissive SQL inlining.  To restore the old behavior, use
      the default_keyword_function_calls() class method or the 
      keyword_function_calls() object method.

0.755 (10.16.2009) - John Siracusa <siracusa@gmail.com>

Changes  view on Meta::CPAN


0.733 (02.23.2007) - John Siracusa <siracusa@gmail.com>

    * Schema support enabled for MySQL.
    * Added support for Informix's "datetime year to month" column type.
    * Tweaked handling of doubled quotes in PostgreSQL default column values.

0.732 (01.15.2007) - John Siracusa <siracusa@gmail.com>

    * Oracle support improved significantly.
    * Added MySQL $dbh attributes: mysql_auto_reconnect, mysql_enable_utf8,
      and mysql_use_result.
    * Rose::DB objects can now be constructed by specifying only a driver,
      even if no data sources are registered.
    * Documented new() behavior when parameters beyond just type and 
      domain are passed.  (Suggested by Christopher H. Laco)
    * Fixed a bug that prevented foreign keys with columns that use
      reserved words from being auto-initialized correctly.
      (Reported by Clayton Scott)
    * Improved DSN parsing.

lib/Rose/DB.pm  view on Meta::CPAN

Attempt to commit the current transaction by calling the L<commit|DBI/commit> method on the L<DBI> database handle.  If the L<DBI> database handle does not exist or is not connected, 0 is returned.

If the "AutoCommit" database handle attribute is true, the handle is assumed to not be in a transaction and L<Rose::DB::Constants::IN_TRANSACTION|Rose::DB::Constants> (-1) is returned.  If the call to L<DBI>'s L<commit|DBI/commit> method succeeds, 1 ...

=item B<connect>

Constructs and connects the L<DBI> database handle for the current data source, calling L<dbi_connect|/dbi_connect> to create a new L<DBI> database handle if none exists.  If there is no registered data source for the current L<type|/type> and L<doma...

If any L<post_connect_sql|/post_connect_sql> statement failed to execute, the database handle is disconnected and then discarded.

If the database handle returned by L<dbi_connect|/dbi_connect> was originally connected by another L<Rose::DB>-derived object (e.g., if a subclass's custom implementation of L<dbi_connect|/dbi_connect> calls L<DBI>'s L<connect_cached|DBI/connect_cach...

Returns true if the database handle was connected successfully and all L<post_connect_sql|/post_connect_sql> statements (if any) were run successfully, false otherwise.  

=item B<connect_option NAME [, VALUE]>

Get or set a single connection option.  Example:

    $val = $db->connect_option('RaiseError'); # get
    $db->connect_option(AutoCommit => 1);     # set

lib/Rose/DB/MySQL.pm  view on Meta::CPAN

sub mysql_socket             { shift->dbh_attribute('mysql_socket', @_) }
sub mysql_ssl                { shift->dbh_attribute_boolean('mysql_ssl', @_) }
sub mysql_ssl_ca_file        { shift->dbh_attribute('mysql_ssl_ca_file', @_) }
sub mysql_ssl_ca_path        { shift->dbh_attribute('mysql_ssl_ca_path', @_) }
sub mysql_ssl_cipher         { shift->dbh_attribute('mysql_ssl_cipher', @_) }
sub mysql_ssl_client_cert    { shift->dbh_attribute('mysql_ssl_client_cert', @_) }
sub mysql_ssl_client_key     { shift->dbh_attribute('mysql_ssl_client_key', @_) }
sub mysql_use_result         { shift->dbh_attribute_boolean('mysql_use_result', @_) }
sub mysql_bind_type_guessing { shift->dbh_attribute_boolean('mysql_bind_type_guessing', @_) }

sub mysql_enable_utf8
{
  my($self) = shift;
  $self->dbh->do('SET NAMES utf8')  if(@_ && $self->has_dbh);
  $self->dbh_attribute_boolean('mysql_enable_utf8', @_)
}

sub mysql_enable_utf8mb4
{
  my($self) = shift;
  $self->dbh->do('SET NAMES utf8mb4')  if(@_ && $self->has_dbh);
  $self->dbh_attribute_boolean('mysql_enable_utf8mb4', @_)
}

sub database_version
{
  my($self) = shift;
  return $self->{'database_version'}  if(defined $self->{'database_version'});

  my $vers = $self->dbh->get_info(18); # SQL_DBMS_VER

  # Convert to an integer, e.g., 5.1.13 -> 5001013

lib/Rose/DB/MySQL.pm  view on Meta::CPAN

See the L<DBD::mysql|DBD::mysql/mysql_embedded_groups> documentation to learn more about this attribute.

=item B<mysql_embedded_options [STRING]>

Get or set the L<mysql_embedded_options|DBD::mysql/mysql_embedded_options> database handle attribute.  This is set directly on the L<dbh|Rose::DB/dbh>, if one exists.  Otherwise, it will be set when the L<dbh|Rose::DB/dbh> is created.  If no value fo...

Returns the value of this attribute in the L<dbh|Rose::DB/dbh>, if one exists, or the value that will be set when the L<dbh|Rose::DB/dbh> is next created.

See the L<DBD::mysql|DBD::mysql/mysql_embedded_options> documentation to learn more about this attribute.

=item B<mysql_enable_utf8 [BOOL]>

Get or set the L<mysql_enable_utf8|DBD::mysql/mysql_enable_utf8> database handle attribute.  This is set directly on the L<dbh|Rose::DB/dbh>, if one exists, by executing the SQL C<SET NAMES utf8>.  Otherwise, it will be set when the L<dbh|Rose::DB/db...

Returns the value of this attribute in the L<dbh|Rose::DB/dbh>, if one exists, or the value that will be set when the L<dbh|Rose::DB/dbh> is next created.

See the L<DBD::mysql|DBD::mysql/mysql_enable_utf8> documentation to learn more about this attribute.

=item B<mysql_enable_utf8mb4 [BOOL]>

Get or set the L<mysql_enable_utf8mb4|DBD::mysql/mysql_enable_utf8mb4> database handle attribute.  This is set directly on the L<dbh|Rose::DB/dbh>, if one exists, by executing the SQL C<SET NAMES utf8mb4>.  Otherwise, it will be set when the L<dbh|Ro...

Returns the value of this attribute in the L<dbh|Rose::DB/dbh>, if one exists, or the value that will be set when the L<dbh|Rose::DB/dbh> is next created.

See the L<DBD::mysql|DBD::mysql/mysql_enable_utf8mb4> documentation to learn more about this attribute.

=item B<mysql_local_infile [STRING]>

Get or set the L<mysql_local_infile|DBD::mysql/mysql_local_infile> database handle attribute.  This is set directly on the L<dbh|Rose::DB/dbh>, if one exists.  Otherwise, it will be set when the L<dbh|Rose::DB/dbh> is created.  If no value for this a...

Returns the value of this attribute in the L<dbh|Rose::DB/dbh>, if one exists, or the value that will be set when the L<dbh|Rose::DB/dbh> is next created.

See the L<DBD::mysql|DBD::mysql/mysql_local_infile> documentation to learn more about this attribute.

=item B<mysql_multi_statements [BOOL]>

lib/Rose/DB/Registry/Entry.pm  view on Meta::CPAN

    auto_create    => { type => 'boolean', method_spec => { default => 1 } },
    sqlite_unicode => { type => 'boolean' },

    # MySQL
    mysql_auto_reconnect     => { type => 'boolean' },
    mysql_client_found_rows  => { type => 'boolean' },
    mysql_compression        => { type => 'boolean' },
    mysql_connect_timeout    => { type => 'boolean' },
    mysql_embedded_groups    => { type => 'scalar' },
    mysql_embedded_options   => { type => 'scalar' },
    mysql_enable_utf8        => { type => 'boolean' },
    mysql_enable_utf8mb4     => { type => 'boolean' },
    mysql_local_infile       => { type => 'scalar' },
    mysql_multi_statements   => { type => 'boolean' },
    mysql_read_default_file  => { type => 'scalar' },
    mysql_read_default_group => { type => 'scalar' },
    mysql_socket             => { type => 'scalar' },
    mysql_ssl                => { type => 'boolean' },
    mysql_ssl_ca_file        => { type => 'scalar' },
    mysql_ssl_ca_path        => { type => 'scalar' },
    mysql_ssl_cipher         => { type => 'scalar' },
    mysql_ssl_client_cert    => { type => 'scalar' },

lib/Rose/DB/Registry/Entry.pm  view on Meta::CPAN

See the L<DBD::mysql|DBD::mysql/mysql_embedded_groups> documentation to learn more about this attribute.

=item B<mysql_embedded_options [STRING]>

Get or set the L<mysql_embedded_options|DBD::mysql/mysql_embedded_options> database handle attribute.  This is set directly on the L<dbh|Rose::DB/dbh>, if one exists.  Otherwise, it will be set when the L<dbh|Rose::DB/dbh> is created.  If no value fo...

Returns the value of this attribute in the L<dbh|Rose::DB/dbh>, if one exists, or the value that will be set when the L<dbh|Rose::DB/dbh> is next created.

See the L<DBD::mysql|DBD::mysql/mysql_embedded_options> documentation to learn more about this attribute.

=item B<mysql_enable_utf8 [BOOL]>

Get or set the L<mysql_enable_utf8|DBD::mysql/mysql_enable_utf8> database handle attribute.  This is set directly on the L<dbh|Rose::DB/dbh>, if one exists.  Otherwise, it will be set when the L<dbh|Rose::DB/dbh> is created.  If no value for this att...

Returns the value of this attribute in the L<dbh|Rose::DB/dbh>, if one exists, or the value that will be set when the L<dbh|Rose::DB/dbh> is next created.

See the L<DBD::mysql|DBD::mysql/mysql_enable_utf8> documentation to learn more about this attribute.

=item B<mysql_enable_utf8mb4 [BOOL]>

Get or set the L<mysql_enable_utf8mb4|DBD::mysql/mysql_enable_utf8mb4> database handle attribute.  This is set directly on the L<dbh|Rose::DB/dbh>, if one exists.  Otherwise, it will be set when the L<dbh|Rose::DB/dbh> is created.  If no value for th...

Returns the value of this attribute in the L<dbh|Rose::DB/dbh>, if one exists, or the value that will be set when the L<dbh|Rose::DB/dbh> is next created.

See the L<DBD::mysql|DBD::mysql/mysql_enable_utf8mb4> documentation to learn more about this attribute.

=item B<mysql_local_infile [STRING]>

Get or set the L<mysql_local_infile|DBD::mysql/mysql_local_infile> database handle attribute.  This is set directly on the L<dbh|Rose::DB/dbh>, if one exists.  Otherwise, it will be set when the L<dbh|Rose::DB/dbh> is created.  If no value for this a...

Returns the value of this attribute in the L<dbh|Rose::DB/dbh>, if one exists, or the value that will be set when the L<dbh|Rose::DB/dbh> is next created.

See the L<DBD::mysql|DBD::mysql/mysql_local_infile> documentation to learn more about this attribute.

=item B<mysql_multi_statements [BOOL]>

t/mysql.t  view on Meta::CPAN


  $db->autocommit(0);

  is($db->autocommit + 0, 0, 'autocommit() 4');
  is($dbh->{'AutoCommit'} + 0, 0, 'autocommit() 5');

  my $dbh_copy = $db->retain_dbh;

  $db->disconnect;

  foreach my $attr (qw(mysql_auto_reconnect mysql_client_found_rows mysql_compression mysql_connect_timeout mysql_embedded_groups mysql_embedded_options mysql_enable_utf8 mysql_enable_utf8mb4 mysql_local_infile mysql_multi_statements mysql_read_defau...
  {
    SKIP:
    {
      if($attr eq 'mysql_enable_utf8mb4' && 
          ($DBD::mysql::VERSION lt '4.032' or $DBD::mysql::VERSION eq '4.032_01'))
      {
        skip('mysql_enable_utf8mb4', 3);
      }

      $db = Rose::DB->new($attr => 1);
      is($db->$attr(), 1, "$attr 1");
      $db->connect;

      if($attr eq 'mysql_auto_reconnect') # can't read back the others?
      {
        is($db->$attr(), 1, "$attr 2");
        is($db->dbh->{$attr}, 1, "$attr 3");

t/mysql.t  view on Meta::CPAN

    my $dbh = Rose::DB->new->retain_dbh;
    $db = Rose::DB->new(dbh => $dbh);
  }

  $db->retain_dbh;
  $db->release_dbh;

  ok($db->{'dbh'}{'Active'}, 'retain stuffed dbh');

  $db->connect;
  $db->mysql_enable_utf8(1);
  is($db->mysql_enable_utf8, 1, 'mysql_enable_utf8 2');

  SKIP:
  {
    if($DBD::mysql::VERSION lt '4.032' || $DBD::mysql::VERSION eq '4.032_01')
    {
      skip ('mysql_enable_utf8mb4', 2);
    }

    $db->mysql_enable_utf8(0);
    $db->mysql_enable_utf8mb4(1);
    is($db->mysql_enable_utf8, 0, 'mysql_enable_utf8 3');
    is($db->mysql_enable_utf8mb4, 1, 'mysql_enable_utf8mb4 2');
  }

  if($db->isa('My::DB2'))
  {
    $My::DB2::Called{'init_dbh'} = 0;
    $db = Rose::DB->new('mysql');
    $db->dbh;
    is($My::DB2::Called{'init_dbh'}, 1, 'SUPER:: from driver');
  }
  else

t/subclass-mysql.t  view on Meta::CPAN


  $db->autocommit(0);

  is($db->autocommit + 0, 0, 'autocommit() 4');
  is($dbh->{'AutoCommit'} + 0, 0, 'autocommit() 5');

  my $dbh_copy = $db->retain_dbh;

  $db->disconnect;

  foreach my $attr (qw(mysql_auto_reconnect mysql_client_found_rows mysql_compression mysql_connect_timeout mysql_embedded_groups mysql_embedded_options mysql_enable_utf8 mysql_enable_utf8mb4 mysql_local_infile mysql_multi_statements mysql_read_defau...
  {
    SKIP:
    {
      if($attr eq 'mysql_enable_utf8mb4' && 
          ($DBD::mysql::VERSION lt '4.032' or $DBD::mysql::VERSION eq '4.032_01'))
      {
        skip('mysql_enable_utf8mb4', 3);
      }

      $db = My::DB2->new($attr => 1);
      is($db->$attr(), 1, "$attr 1");
      $db->connect;

      if($attr eq 'mysql_auto_reconnect') # can't read back the others?
      {
        is($db->$attr(), 1, "$attr 2");
        is($db->dbh->{$attr}, 1, "$attr 3");

t/subclass-mysql.t  view on Meta::CPAN

    my $dbh = My::DB2->new->retain_dbh;
    $db = My::DB2->new(dbh => $dbh);
  }

  $db->retain_dbh;
  $db->release_dbh;

  ok($db->{'dbh'}{'Active'}, 'retain stuffed dbh');

  $db->connect;
  $db->mysql_enable_utf8(1);
  is($db->mysql_enable_utf8, 1, 'mysql_enable_utf8 2');

  SKIP:
  {
    if($DBD::mysql::VERSION lt '4.032' || $DBD::mysql::VERSION eq '4.032_01')
    {
      skip ('mysql_enable_utf8mb4', 2);
    }

    $db->mysql_enable_utf8(0);
    $db->mysql_enable_utf8mb4(1);
    is($db->mysql_enable_utf8, 0, 'mysql_enable_utf8 3');
    is($db->mysql_enable_utf8mb4, 1, 'mysql_enable_utf8mb4 2');
  }

  if($db->isa('My::DB2'))
  {
    $My::DB2::Called{'init_dbh'} = 0;
    $db = My::DB2->new('mysql');
    $db->dbh;
    is($My::DB2::Called{'init_dbh'}, 1, 'SUPER:: from driver');
  }
  else



( run in 0.308 second using v1.01-cache-2.11-cpan-00829025b61 )