Grokbase
x

Ivan Fomichev (ifom...@gmail.com)

Profile | Posts (15)

User Information

Display Name:Ivan Fomichev
Partial Email Address:ifom...@gmail.com
Posts:
15 total
2 in Catalyst Framework
12 in DBIx::Class
1 in dbix-class@lists.scsys.co.uk

5 Most Recent

All Posts
1) Ivan Fomichev Re: [Dbix-class] Force LEFT JOIN bug?
| +1 vote
2007/9/3, Matt S Trout <dbix-class@trout.me.uk>: I found no forced left joins in DBIC test classes...
dbix-class@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2007/9/3, Matt S Trout <dbix-class@trout.me.uk>:
> Looks like a bug to me.
>
> Can you reproduce it against the DBIC test classes? A patch against t/*.t
> would make this a lot easier to fix.

I found no forced left joins in DBIC test classes :-(
$ fgrep -R 'join_type' t/lib/DBICTest/Schema/*

What test case could I base the test on? I believe that when forced
join was introduced (revision 3502), a test for it was introduced as
well. Though I'm not able to identify it easily  among other diffs for
this revision in the tests directory :-(

Regards,
Ivan
2) Ivan Fomichev Re: [Catalyst] Test server as a child process
| +1 vote
2007/7/31, Peter Edwards <peter@dragonstaff.com>: I've found the root of the evil. IPC::Run won't...
Catalyst Framework
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2007/7/31, Peter Edwards <peter@dragonstaff.com>:
> Try using IPC::Run. I can see the "You can connect" message when using it to
> run scripts/myapp_server.pl (I guess it goes through ptys?)

I've found the root of the evil.
IPC::Run won't help here :-(
The pipe is not autoflushed.
If you put '$|++' in script/myapp_server.pl, everything works all right.
BTW, is there a way to force autoflush for a Perl script executed in a
child process, e. g. through environment variables, command line
options or whatever?

Regards,
Ivan

_______________________________________________
List: [email protected: Cat...@lists.rawmode.org]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/
3) Ivan Fomichev [Catalyst] Test server as a child process
| +1 vote
Hello, I intend to write a script, that would start the test server as a child process and then run...
Catalyst Framework
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Hello,

I intend to write a script, that would start the test server as a
child process and then run tests. The thing I'm failing to do is to
get output from the test server in order to determine, when the server
has started.

The problem is that test server doesn't print its prompt ("You can
connect to your server at http://localhost:3000") when run as a child
process :-(

I dug Catalyst's sources, but didn't understood much. I put 'sleep' in
parent process for now, but I don't like it. Could anyone suggest an
adequate work-around? Thank you in advance.

8<------------------------script/myapp_regtest.pl--------------------------
#!/usr/bin/perl
use strict;
use warnings;

use Config::IniFiles;
use File::Spec::Functions;
use FindBin;
use POSIX qw/ :signal_h /;

my $ini = Config::IniFiles->new( -file => catfile( $FindBin::Bin,
updir, 'myapp_regtest.ini' ) );
$ENV{MYAPP_DSN} = $ini->val( 'database', 'dsn' );

defined ( my $catalyst_pid = open(CHILD, '-|') )
    or die "cannot fork: $!";

if ( !$catalyst_pid ) {
    my $port = $ini->val( 'catalyst', 'port' );
    exec( catfile( $FindBin::Bin, 'myapp_server.pl' ), '-p', $port );
}

print scalar <CHILD>;

my $lib = catdir( $FindBin::Bin, updir, 'lib' );
chdir catdir( $FindBin::Bin, updir );
system( 'prove', '--lib', $lib, 't' );

kill SIGINT, $catalyst_pid;
8<----------------------------------END------------------------------------

Regards,
Ivan

_______________________________________________
List: [email protected: Cat...@lists.rawmode.org]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/
4) Ivan Fomichev [Dbix-class] Insert using a result set with 'where' produces weird result
| +1 vote
Hello, I've got a weird result when trying to insert a row using a result set with 'where'. Here's...
DBIx::Class
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Hello,

I've got a weird result when trying to insert a row using a result set
with 'where'.
Here's a sample code:

8<--------------------------ifomichev_test.sql-----------------------------
DROP TABLE IF EXISTS `records`;
CREATE TABLE `records` (
  `record_id` int(10) unsigned NOT NULL auto_increment,
  `value` varchar(255) default NULL,
  PRIMARY KEY  (`record_id`)
);

INSERT INTO `records` VALUES (1,'baba'),(2,'dada'),(3,'kaka'),(4,NULL);
8<-------------------------------Schema.pm---------------------------------
package Schema;

use base qw/DBIx::Class::Schema/;

__PACKAGE__->load_classes();

1;
8<---------------------------Schema/Record.pm------------------------------
package Schema::Record;

use base qw/DBIx::Class/;

__PACKAGE__->load_components( qw/ Core PK::Auto / );
__PACKAGE__->table( 'records' );
__PACKAGE__->add_columns( qw/ record_id value / );
__PACKAGE__->set_primary_key( qw/ record_id / );

1;
8<-----------------------------test_dbic.pl--------------------------------
#!/usr/bin/perl
use strict;
use warnings;

use Schema;

my $schema = Schema->connect( 'DBI:mysql:ifomichev_test', 'root' );
$schema->storage()->debug( 1 );

my $rs = $schema->resultset('Record')->search(
    { value => { '!=' => undef } },
);

$rs->create( { value => 'papa' } );
#$rs->result_source()->resultset()->create( { value => 'papa' } );
8<----------------------------------END------------------------------------

Result:

8<----------------------------CURRENT RESULT-------------------------------
INSERT INTO records (value) VALUES (?): 'HASH(0xa3d50cc)'
8<----------------------------------END------------------------------------

'HASH(0xa3d50cc)' appears because a new result is being created with
'value' equal to a structure passed to search method ( { '!=' => undef
} ), though I would expect 'value' be overriden with what I passed to
the create method (i. e., 'papa'). I worked this around with taking a
result source from the result set and then making a new result set
(see a commented line above):

8<----------------------------EXPECTED RESULT------------------------------
INSERT INTO records (value) VALUES (?): 'papa'
8<----------------------------------END------------------------------------

Regards,
Ivan
5) Ivan Fomichev Re: [Dbix-class] Strange result when joining with the same alias twice
| +1 vote
2007/7/24, Matt S Trout <dbix-class@trout.me.uk>: Ticket #28451. If it were 'people', then it...
DBIx::Class
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2007/7/24, Matt S Trout <dbix-class@trout.me.uk>:
> Yeah, it's a bug. Could you file on rt.cpan please?

Ticket #28451.

> Note that whatever you end up calling your rels I'd advise plural names
> for has_many rels for clarity - so 'people' rather than 'person' (I
> actually think 'members' is a better name anyway, albeit I can't use that
> in the test case :)

If it were 'people', then it wouldn't collide with 'person' for
belongs_to relationship in Schema::Account. To get a more beautiful
test case, you could invent a schema with has_one relationship instead
of has_many ;-)

Regards,
Ivan

spacer
Profile | Posts (15)
Home > People > Ivan Fomichev