Revision 93618a69
Von Sven Schöling vor etwa 15 Jahren hinzugefügt
SL/IC.pm | ||
---|---|---|
829 | 829 |
# column name, prefix, joins_needed |
830 | 830 |
[ 'description', 'ioi.', 'invoice_oi' ], |
831 | 831 |
[ 'deliverydate', 'ioi.', 'invoice_oi' ], |
832 |
[ 'transdate' , 'apoe.', 'apoe' ],
|
|
833 |
[ 'unit' , 'ioi.', 'invoice_oi' ],
|
|
832 |
[ 'transdate', 'apoe.', 'apoe' ],
|
|
833 |
[ 'unit', 'ioi.', 'invoice_oi' ],
|
|
834 | 834 |
); |
835 | 835 |
|
836 | 836 |
# careful with renames. these are HARD, and any filters done on the original column will break |
... | ... | |
846 | 846 |
my $make_token_builder = sub { |
847 | 847 |
my $joins_needed = shift; |
848 | 848 |
sub { |
849 |
my ($col, $group) = @_;
|
|
849 |
my ($col, $alias) = @_;
|
|
850 | 850 |
my @coalesce_tokens = |
851 | 851 |
map { ($_->[1] || 'p.') . $_->[0] } |
852 | 852 |
grep { !$_->[2] || $joins_needed->{$_->[2]} } |
853 |
grep { $_->[0] eq $col } |
|
853 |
grep { $_->[0] eq $col }
|
|
854 | 854 |
@column_override, [ $col, $table_prefix{$col} ]; |
855 | 855 |
|
856 | 856 |
my $coalesce = scalar @coalesce_tokens > 1; |
857 | 857 |
return ($coalesce |
858 | 858 |
? sprintf 'COALESCE(%s)', join ', ', @coalesce_tokens |
859 | 859 |
: shift @coalesce_tokens) |
860 |
. ($group && ($coalesce || $renamed_columns{$col})
|
|
860 |
. ($alias && ($coalesce || $renamed_columns{$col})
|
|
861 | 861 |
? " AS " . ($renamed_columns{$col} || $col) |
862 | 862 |
: ''); |
863 | 863 |
} |
Auch abrufbar als: Unified diff
Kosmetik