Created
June 6, 2009 00:42
-
-
Save zpmorgan/124602 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DBIx::Class::ResultSet::all(): DBI Exception: DBD::SQLite::db prepare_cached failed: | |
ambiguous column name: ruleset.phase_description [for Statement " | |
SELECT me.entity as entity, phase, game.id as gid, ruleset.phase_description as pd | |
FROM Player_to_game me | |
JOIN Game game ON game.id = me.gid | |
JOIN Ruleset ruleset ON ruleset.id = game.ruleset | |
LEFT JOIN Player_to_game player_to_game ON player_to_game.gid = game.id | |
LEFT JOIN Player_to_game player_to_game_2 ON player_to_game_2.gid = game.id | |
JOIN Ruleset ruleset ON ruleset.id = game.ruleset | |
LEFT JOIN Player_to_game player_to_game ON player_to_game.gid = game.id | |
WHERE ( ( ( phase = ? AND status = ? ) AND me.pid = ? ) )"] | |
at /home/zach/projects/basilisk/script/../lib/basilisk/Schema/Player.pm line 72 | |
Offending code: | |
sub games_to_move { | |
my $self = shift; | |
my $name = $self->name; | |
my $relevant_p2g = $self->search_related('player_to_game', | |
{ | |
},{ | |
select => ['entity as my_entity'], | |
}); | |
my $games = $relevant_p2g->search_related ('game', | |
{ | |
status => GAME_RUNNING, | |
phase => 'p2g.entity', | |
}, | |
{ | |
join => ['ruleset', 'player_to_game'], | |
select => ['me.entity as entity', 'phase', 'game.id as gid', 'ruleset.phase_description as pd'], | |
as => ['entity', 'phase', 'gid', 'pd'], | |
}); | |
$games->all(); | |
} | |
RELATIONS: | |
package basilisk::Schema::Player; | |
__PACKAGE__->load_components(qw/PK::Auto Core/); | |
__PACKAGE__->table('Player'); | |
__PACKAGE__->add_columns( | |
'id' => { data_type => 'INTEGER', is_auto_increment => 1 }, | |
'name' => { data_type => 'TEXT'}, | |
'pass' => { data_type => 'BLOB' }, #hashed | |
'current_rating' => { data_type => 'INTEGER', is_nullable => 1 }, | |
); | |
__PACKAGE__->set_primary_key('id'); | |
__PACKAGE__->has_many(player_to_game => 'basilisk::Schema::Player_to_game', 'pid'); | |
__PACKAGE__->many_to_many( games => 'player_to_game', 'game'); | |
__PACKAGE__->has_many(proposed_games => 'basilisk::Schema::Game_proposal', 'proposer'); | |
__PACKAGE__->might_have (rating => 'basilisk::Schema::Rating', {'foreign.id' => 'self.current_rating'}); | |
__PACKAGE__->has_many(all_ratings => 'basilisk::Schema::Rating', 'pid'); | |
__PACKAGE__->has_many (comments => 'basilisk::Schema::Comment', 'sayeth'); | |
__PACKAGE__->has_many (invites => 'basilisk::Schema::Invite', 'inviter'); | |
package basilisk::Schema::Game; | |
__PACKAGE__->load_components(qw/PK::Auto Core/); | |
__PACKAGE__->table('Game'); | |
__PACKAGE__->add_columns( | |
'id' => { data_type => 'INTEGER', is_auto_increment => 1 }, | |
'ruleset' => { data_type => 'INTEGER'}, | |
'status' => { data_type => 'INTEGER', default_value => GAME_RUNNING }, | |
'result' => { data_type => 'TEXT', is_nullable => 1}, | |
#'num_moves' => { data_type => 'INTEGER', default_value => 0 }, | |
'initial_position' => { data_type => 'INTEGER', is_nullable => 1 }, | |
#phase-- rule description is in ruleset | |
'phase' => { data_type => 'INTEGER', default_value => 0 }, | |
#to sort by most recently active, this stores a time. | |
#'perturbation' => { data_type => 'INTEGER', default_value => 0 }, | |
); | |
__PACKAGE__->set_primary_key('id'); | |
__PACKAGE__->belongs_to(ruleset => 'basilisk::Schema::Ruleset', 'ruleset'); | |
__PACKAGE__->has_many(player_to_game => 'basilisk::Schema::Player_to_game', 'gid'); | |
__PACKAGE__->many_to_many( players => 'player_to_game', 'player'); | |
__PACKAGE__->has_many(moves => 'basilisk::Schema::Move', 'gid'); | |
__PACKAGE__->belongs_to (initial_pos => 'basilisk::Schema::Position', 'initial_position'); | |
__PACKAGE__->has_many(comments => 'basilisk::Schema::Comment', 'gid'); | |
package basilisk::Schema::Player_to_game; | |
use base qw/DBIx::Class/; | |
__PACKAGE__->load_components(qw/PK::Auto Core/); | |
__PACKAGE__->table('Player_to_game'); | |
__PACKAGE__->add_columns( | |
'pid' => { data_type => 'INTEGER'}, | |
'gid' => { data_type => 'INTEGER'}, | |
'entity' => { data_type => 'INTEGER'}, #typically either 0 or 1 | |
#time remaining: store a time of a player's 'expiration', 0=nolimit | |
#TODO: implement | |
'expiration' => { data_type => 'INTEGER', default_value => 0}, | |
); | |
__PACKAGE__->set_primary_key('gid', 'entity'); | |
__PACKAGE__->belongs_to (player => 'basilisk::Schema::Player', 'pid'); | |
__PACKAGE__->belongs_to (game => 'basilisk::Schema::Game', 'gid'); | |
package basilisk::Schema::Ruleset; | |
__PACKAGE__->load_components(qw/PK::Auto Core/); | |
__PACKAGE__->table('Ruleset'); | |
__PACKAGE__->add_columns( | |
'id' => { data_type => 'INTEGER', is_auto_increment => 1 }, | |
'h' => { data_type => 'INTEGER', default_value => '19'}, | |
'w' => { data_type => 'INTEGER', default_value => '19'}, | |
'handicap' => { data_type => 'INTEGER', default_value => '0'}, | |
'initial_time' => { data_type => 'INTEGER', default_value => '0'}, | |
'byo' => { data_type => 'INTEGER', default_value => '0'}, | |
'byo_periods' => { data_type => 'INTEGER', default_value => '0'}, | |
'rules_description' => { data_type => 'TEXT', is_nullable => 1 }, #just for humans to read | |
#for machines to read & shift phase: #like '0b 1w 2r' | |
'phase_description' => { data_type => 'TEXT', default_value => '0b 1w'}, | |
#replacing extra_rules table: | |
'other_rules' => { data_type => 'TEXT', is_nullable => 1}, #json, {topo:torus},etc. | |
'komi' => { data_type => 'INTEGER', default_value => 0}, | |
); | |
__PACKAGE__->set_primary_key('id'); | |
__PACKAGE__->has_many (positions => 'basilisk::Schema::Position', 'ruleset'); | |
__PACKAGE__->has_many (games => 'basilisk::Schema::Game', 'ruleset'); | |
__PACKAGE__->has_many (proposed_games => 'basilisk::Schema::Game_proposal', 'ruleset'); | |
__PACKAGE__->has_many (extra_rules => 'basilisk::Schema::Extra_rule', 'ruleset'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment