Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create the schema with DBIx::Class instead of doing it manually
As for the hack here's why: I have this in a Schema::Result::*.pm: sub add_tokenN_id { my ($self, $n) = @_; __PACKAGE__->add_columns( "token${n}_id", { data_type => "INTEGER", default_value => undef, is_foreign_key => 1, is_nullable => 0, size => undef, }, ); __PACKAGE__->belongs_to( "token${n}", "Hailo::Storage::Schema::Result::Token", { id => "token${n}_id" }, {}, ); } If I later do this: for (0 .. $self->order - 1) { Hailo::Storage::Schema::Result::Expr->add_tokenN_id($_); } $schema->deploy; I get this when using the table: DBIx::Class::ResultSet::find(): DBI Exception: DBD::SQLite::db prepare_cached failed: no such column: me.token0_id [for Statement "SELECT me.id FROM expr me WHERE ( ( me.token0_id = ? AND me.token1_id = ? ) )"] at /home/avar/g/hailo/lib/Hailo/Storage/DBD.pm line 449 But if I instead add this right before the add_tokenN_id() definition (so it's called at BEGIN time) everything works, but obviously isn't configurable: add_tokenN_id(undef, 0); add_tokenN_id(undef, 1); Alternatively I could do this as pointed out in #dbix-class: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/0.08/trunk/maint/joint_deps.pl
- Loading branch information