wreis / DBIx-Class-ParseError

Extensible database error handler
Other
2 stars 3 forks source link

Add error types for MySQL in strict mode #4

Open pplu opened 3 years ago

pplu commented 3 years ago

When using a schema with MySQL in strict mode:

  return Schema->connect(
    $dsn,
    $user,
    $pass,
    {
      on_connect_call => 'set_strict_mode'  
    }
  );

DBIx::Class:::ParseError fails to parse errors from MySQL. I have collected the exception objects thrown by DBIx::Class for each one of the types of error in this PR:

$VAR1 = bless( {
                 'msg' => 'DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Data too long for column \'name\' at row 1 [for Statement "INSERT INTO table ( name) VALUES ( ? )" with ParamValues: 0=\'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\'] at Module.pm line 108
'
               }, 'DBIx::Class::Exception' );
$VAR1 = bless( {
                 'msg' => 'DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Data truncated for column \'enum\' at row 1 [for Statement "INSERT INTO table ( date, number, id, name, enum) VALUES ( ?, ?, ?, ?, ? )" with ParamValues: 0=undef, 1=0, 2=1, 3=\'test\', 4=\'Invalid\'] at Module.pm line 76
'
               }, 'DBIx::Class::Exception' );
$VAR1 = bless( {
                 'msg' => 'DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Out of range value for column \'number\' at row 1 [for Statement "INSERT INTO table ( date, number, id, name, enum) VALUES ( ?, ?, ?, ?, ? )" with ParamValues: 0=undef, 1=80000, 2=1, 3=\'test\', 4=\'Yes\'] at Module.pm line 76
'
               }, 'DBIx::Class::Exception' );
$VAR1 = bless( {
                 'msg' => 'DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Incorrect date value: \'3099-14-31\' for column `database`.`table`.`date` at row 1 [for Statement "INSERT INTO table ( date, number, id, name, enum) VALUES ( ?, ?, ?, ?, ? )" with ParamValues: 0=\'3099-14-31\', 1=1, 2=1, 3=\'test\', 4=\'Yes\'] at Module.pm line 76
'
               }, 'DBIx::Class::Exception' );