diff options
author | Yorhel <git@yorhel.nl> | 2019-09-27 11:06:56 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-09-27 11:07:05 +0200 |
commit | da2ee73149aade8bc88bc4f87a424dc60348c7fc (patch) | |
tree | 457d8512112c58c45ccb72822e7bc617228db111 /lib/VNWeb/DB.pm | |
parent | 092158fee02c3516ae08f7efcef8f1774bf823e5 (diff) |
v2rw: Convert history listings
And I changed the filter selection into a more form-like thing. It's
slightly more powerful, but not sure it's such a huge improvement in
terms of UI. Everything should be identical apart from that.
Diffstat (limited to 'lib/VNWeb/DB.pm')
-rw-r--r-- | lib/VNWeb/DB.pm | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/VNWeb/DB.pm b/lib/VNWeb/DB.pm index 7ef2e161..0d5616e0 100644 --- a/lib/VNWeb/DB.pm +++ b/lib/VNWeb/DB.pm @@ -10,7 +10,7 @@ use VNDB::Schema; our @EXPORT = qw/ sql - sql_join sql_comma sql_and sql_array sql_func sql_fromhex sql_tohex sql_fromtime sql_totime + sql_join sql_comma sql_and sql_or sql_array sql_func sql_fromhex sql_tohex sql_fromtime sql_totime enrich enrich_merge enrich_flatten db_entry db_edit /; @@ -49,15 +49,15 @@ $Carp::Internal{ (__PACKAGE__) }++; sub sql_join { my $sep = shift; my @args = map +($sep, $_), @_; - shift @args; - return @args; + sql @args[1..$#args]; } # Join multiple arguments together with a comma, for use in a SELECT or IN # clause or function arguments. sub sql_comma { sql_join ',', @_ } -sub sql_and { sql_join 'AND', map sql('(', $_, ')'), @_ } +sub sql_and { @_ ? sql_join 'AND', map sql('(', $_, ')'), @_ : sql '1=1' } +sub sql_or { @_ ? sql_join 'OR', map sql('(', $_, ')'), @_ : sql '1=0' } # Construct a PostgreSQL array type from the function arguments. sub sql_array { 'ARRAY[', sql_join(',', map \$_, @_), ']' } |