my test detail:
mysql> show create table test;
Table,Create Table
'test','CREATE TABLE `test` ( `id` int(11) NOT NULL, `text`
varchar(5) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT
CHARSET=utf8'
# and I insert a row with a Chinese words( 5 chinese characters) as 'text'.
#!/usr/bin/perl
use Rose::DB::Object::Loader;
my $loader = Rose::DB::Object::Loader->new(
db_dsn => 'dbi:mysql:dbname=test;host=127.0.0.1',
db_username => "root",
db_password => "wodemysqlmima",
db_options => { AutoCommit => 1, ChopBlanks => 1, RaiseError => 1 },
class_prefix => 'My'
);
$loader->make_modules;
##
############ My::Test
package My::Test;
use strict;
use base qw(My::DB::Object::AutoBase2);
__PACKAGE__->meta->setup(
table => 'test',
columns => [
id => { type => 'integer', not_null => 1 },
text => { type => 'varchar', length => 5 },
],
primary_key_columns => [ 'id' ],
);
1;
######## autobase2
package My::DB::Object::AutoBase2;
use base 'Rose::DB::Object';
use My::DB::AutoBase1;
my $db = My::DB::AutoBase1->new;
$db->dbh->do("set names 'utf8'"); ### added by me
sub init_db { $db }
1;
###### test.pl
use lib ".";
use My::Test;
use My::Test::Manager;
use Encode qw(encode decode);
#my $test = My::Test::Manager->get_test();
my $test = My::Test->new( id => 1 );
$test->load();
print $test->text, "\n";
#### result:
load() - My::Test: Value for text() is too long. Maximum length is 5
character. Value is 15 characters:
is this a bug ?
http://search.cpan.org/dist/Rose-DB/lib/Rose/DB/MySQL.pm#mysql_enable_utf8
The load() call in your example works when I do that.
-John
thanks!
2011/11/29 John Siracusa <sira...@gmail.com>:
> --
> CPAN: http://search.cpan.org/dist/Rose-DB-Object
> SVN: http://rose.googlecode.com/svn/trunk/modules/Rose-DB-Object
> SVN Instructions: http://code.google.com/p/rose/source/checkout
> Unsubscribe: rose-db-objec...@googlegroups.com
> List Options: http://groups.google.com/group/rose-db-object