Revision 45119ead
Von Sven Schöling vor mehr als 13 Jahren hinzugefügt
SL/Helper/Csv/Dispatcher.pm | ||
---|---|---|
87 | 87 |
for my $step_index ( split /\.(?!\d)/, $path ) { |
88 | 88 |
my ($step, $index) = split /\./, $step_index; |
89 | 89 |
if ($cur_class->can($step)) { |
90 |
if ($cur_class->meta->relationship($step)) { #a |
|
91 |
my $next_class = $cur_class->meta->relationship($step)->class; |
|
92 |
push @{ $spec->{steps} }, [ $step, $next_class, $index ]; |
|
93 |
$cur_class = $next_class; |
|
90 |
if (my $rel = $cur_class->meta->relationship($step)) { #a |
|
91 |
if ($index && ! $rel->isa('Rose::DB::Object::Metadata::Relationship::OneToMany')) { |
|
92 |
$self->_push_error([ |
|
93 |
$path, |
|
94 |
undef, |
|
95 |
"Profile path error. Indexed relationship is not OneToMany around here: '$step_index'", |
|
96 |
undef, |
|
97 |
0, |
|
98 |
]); |
|
99 |
return; |
|
100 |
} else { |
|
101 |
my $next_class = $cur_class->meta->relationship($step)->class; |
|
102 |
push @{ $spec->{steps} }, [ $step, $next_class, $index ]; |
|
103 |
$cur_class = $next_class; |
|
104 |
} |
|
94 | 105 |
} else { # simple dispatch |
95 | 106 |
push @{ $spec->{steps} }, [ $step ]; |
96 | 107 |
last; |
t/helper/csv.t | ||
---|---|---|
1 |
use Test::More tests => 29;
|
|
1 |
use Test::More tests => 31;
|
|
2 | 2 |
use SL::Dispatcher; |
3 | 3 |
use Data::Dumper; |
4 | 4 |
use utf8; |
... | ... | |
208 | 208 |
is $csv->get_objects->[0]->makemodels->[1]->model, 'Table 15', '...check 3'; |
209 | 209 |
is $csv->get_objects->[0]->makemodels->[1]->make, '523', '...check 4'; |
210 | 210 |
|
211 |
###### |
|
212 |
|
|
213 |
$csv = SL::Helper::Csv->new( |
|
214 |
file => \<<EOL, |
|
215 |
description;partnumber;sellprice;lastcost_as_number;buchungsgruppe; |
|
216 |
EOL |
|
217 |
numberformat => '1,000.00', |
|
218 |
class => 'SL::DB::Part', |
|
219 |
profile => { |
|
220 |
buchungsgruppe => "buchungsgruppen.1.description", |
|
221 |
} |
|
222 |
); |
|
223 |
is $csv->parse, undef, 'wrong profile gets rejected'; |
|
224 |
is_deeply $csv->errors, [ 'buchungsgruppen.1.description', undef, "Profile path error. Indexed relationship is not OneToMany around here: 'buchungsgruppen.1'", undef ,0 ], 'error indicates wrong header'; |
|
225 |
|
|
211 | 226 |
# vim: ft=perl |
Auch abrufbar als: Unified diff
Indices auf OneToOne relationships werden jetzt mit Fehler quittiert.