Revision c9589610
Von Moritz Bunkus vor fast 10 Jahren hinzugefügt
SL/DB/Helper/CustomVariables.pm | ||
---|---|---|
244 | 244 |
die "invalid config_id in $caller_package\::cvar custom filter: expected module $params{module} - got @{[ $config->module ]}"; |
245 | 245 |
} |
246 | 246 |
|
247 |
my @filter; |
|
248 |
if ($config->type eq 'bool') { |
|
249 |
@filter = $value ? ($config->value_col => 1) : (or => [ $config->value_col => undef, $config->value_col => 0 ]); |
|
250 |
} else { |
|
251 |
@filter = ($config->value_col => $value); |
|
252 |
} |
|
253 |
|
|
247 | 254 |
my (%query, %bind_vals); |
248 | 255 |
($query{customized}, $bind_vals{customized}) = Rose::DB::Object::QueryBuilder::build_select( |
249 | 256 |
dbh => $config->dbh, |
... | ... | |
253 | 260 |
query => [ |
254 | 261 |
config_id => $config_id, |
255 | 262 |
sub_module => $params{sub_module}, |
256 |
$config->value_col => $value,
|
|
263 |
@filter,
|
|
257 | 264 |
], |
258 | 265 |
query_is_sql => 1, |
259 | 266 |
); |
260 | 267 |
|
268 |
if ($config->type eq 'bool') { |
|
269 |
if ($value) { |
|
270 |
@filter = ( |
|
271 |
'!default_value' => undef, |
|
272 |
'!default_value' => '', |
|
273 |
default_value => '1', |
|
274 |
); |
|
275 |
|
|
276 |
} else { |
|
277 |
@filter = ( |
|
278 |
or => [ |
|
279 |
default_value => '0', |
|
280 |
default_value => '', |
|
281 |
default_value => undef, |
|
282 |
], |
|
283 |
); |
|
284 |
} |
|
285 |
|
|
286 |
} else { |
|
287 |
@filter = ( |
|
288 |
'!default_value' => undef, |
|
289 |
'!default_value' => '', |
|
290 |
default_value => $value, |
|
291 |
); |
|
292 |
} |
|
293 |
|
|
294 |
|
|
261 | 295 |
my $conversion = $config->type =~ m{^(?:date|timestamp)$} ? $config->type |
262 | 296 |
: $config->type =~ m{^(?:customer|vendor|part)$} ? 'integer' |
263 |
: $config->type eq 'bool' ? 'boolean' |
|
264 | 297 |
: $config->type eq 'number' ? 'numeric' |
298 |
# : $config->type eq 'bool' ? 'boolean' |
|
265 | 299 |
: ''; |
266 | 300 |
|
267 | 301 |
($query{config}, $bind_vals{config}) = Rose::DB::Object::QueryBuilder::build_select( |
268 |
dbh => $config->dbh, |
|
269 |
select => 'id', |
|
270 |
tables => [ 'custom_variable_configs' ], |
|
271 |
columns => { custom_variable_configs => [ qw(id default_value) ] }, |
|
272 |
query => [ |
|
273 |
id => $config->id, |
|
274 |
default_value => $value,
|
|
302 |
dbh => $config->dbh,
|
|
303 |
select => 'id',
|
|
304 |
tables => [ 'custom_variable_configs' ],
|
|
305 |
columns => { custom_variable_configs => [ qw(id default_value) ] },
|
|
306 |
query => [
|
|
307 |
id => $config->id,
|
|
308 |
@filter,
|
|
275 | 309 |
], |
276 |
query_is_sql => 1, |
|
310 |
query_is_sql => 1,
|
|
277 | 311 |
); |
278 | 312 |
|
279 |
$query{config} =~ s{\bdefault_value\b}{default_value::${conversion}} if $conversion;
|
|
313 |
$query{config} =~ s{ \bdefault_value\b \s*=\s* (?!'') }{default_value::${conversion} = }x if $conversion;
|
|
280 | 314 |
|
281 | 315 |
($query{not_customized}, $bind_vals{not_customized}) = Rose::DB::Object::QueryBuilder::build_select( |
282 | 316 |
dbh => $config->dbh, |
Auch abrufbar als: Unified diff
GetModels-Filtered: benutzerdefinierte Variablen bool gefixt