2017-09-05 73 views
1

當我試圖轉儲數據庫FixturesDBIx ::類錯誤「無法找到源XXX」

dbic-migration --schema_class App::Schema --database PostgreSQL -Ilib dump_all_sets 

我得到了錯誤:

DBIx::Class::Schema::source(): Can't find source for Schet at /home/xxx/lib/perl5/x86_64-linux/Moose/Meta/Method/Delegation.pm line 110 

在主應用程序,我沒有問題寫:

$schema->resultset('Schet') 

如何解決這個錯誤和轉儲數據到燈具?

+0

可能是一個多元化問題。 DBIx :: Class :: Schema :: Loader(也可能是自動數據轉儲的其他內容)根據將單詞轉換爲單數和複數的規則生成結果/表名。你經常看到一個's'。有時甚至更聰明,DBIC包含一系列模塊作爲各種語言的依賴關係,以便爲事物創建多個標記。但是,如果您的表格使用的語言不支持(如德語或俄語,特別是音譯),則可能會失敗。也許DCSL和夾具創造了不同的名字? – simbabque

+0

@simbabque:我發現[this](http://search.cpan.org/~ilmari/DBIx-Class-Schema-Loader/lib/DBIx/Class/Schema/Loader/Base.pm#naming)。今天我正在計劃對此進行試驗。 –

回答

1

DBIx::Class::Schema::Loader我們正在連接到臨時模式。

連接時出現的模式是cloned

但是因爲有隻schema name is passed什麼是cloned並且,作爲結果,具有空類的映射。這是錯誤的。

如果你仔細看,你會看到克隆發生兩次:herehere。這種額外的克隆是浪費的,應該重構。

隨着工作圍繞here應該傳遞reblessed成所需要的命名空間克隆模式:

sub _make_schema_at { 
    my ($self, $name, %extra_opts) = @_; 
    my $schema = $self->schema->clone; 
    bless $schema, $name; 
    DBIx::Class::Schema::Loader::make_schema_at 
    $schema, {_merge_opts(%extra_opts)}, [{_rearrange_connect_info($schema->storage)}]; 
} 

UPD

Lately,創建新的裝載機的情況下,naming被迫current,而不是通過論證,它又是從應用程序模式克隆而來的。 (我不檢查,但當應用程序將有自己的naming,這將導致數據傾倒時出現問題)和loader is invoked again。這裏加載器加載類based on table names,而不是包名(它是如何在__PACKAGE__->load_namespaces(...)完成)

最後@to_register名單有所不同:

Here

[ 
    Ip, 
    App::Schema0::Result::Ip, 
] 
[ 
    Scheta, 
    App::Schema0::Result::Scheta, 
] 

Here

[ 
    IP, 
    App::Schema::Result::IP, 
], 
[ 
    Schet, 
    App::Schema::Result::Schet, 
],