The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Catalyst::Controller::DBIC::API::RequestArguments - Provides Request argument validation

VERSION

version 2.009000

DESCRIPTION

RequestArguments embodies those arguments that are provided as part of a request or effect validation on request arguments. This Role can be consumed in one of two ways. As this is a parameterized Role, it accepts a single argument at composition time: 'static'. This indicates that those parameters should be stored statically and used as a fallback when the current request doesn't provide them.

PUBLIC_ATTRIBUTES

count

The number of rows to be returned during paging.

page

What page to return while paging.

offset

Specifies where to start the paged result (think SQL LIMIT).

ordered_by

Is passed to ->search to determine sorting.

grouped_by

Is passed to ->search to determine aggregate results.

prefetch

Is passed to ->search to optimize the number of database fetches for joins.

search_exposes

Limits what can actually be searched. If a certain column isn't indexed or perhaps a BLOB, you can explicitly say which columns can be search to exclude that one.

Like the synopsis in DBIC::API shows, you can declare a "template" of what is allowed (by using '*'). Each element passed in, will be converted into a Data::DPath and added to the validator.

Contains the raw search parameters. Upon setting, a trigger will fire to format them, set search_parameters and search_attributes.

Please see "generate_parameters_attributes" for details on how the format works.

search_parameters

Stores the formatted search parameters that will be passed to ->search.

search_attributes

Stores the formatted search attributes that will be passed to ->search.

search_total_entries

Stores the total number of entries in a paged search result.

select_exposes

Limits what can actually be selected. Use this to whitelist database functions (such as COUNT).

Like the synopsis in DBIC::API shows, you can declare a "template" of what is allowed (by using '*'). Each element passed in, will be converted into a Data::DPath and added to the validator.

select

Is the search attribute that allows you to both limit what is returned in the result set and also make use of database functions like COUNT.

Please see "select" in DBIx::Class::ResultSet for more details.

as

Is the search attribute compliment to "select" that allows you to label columns for object inflaction and actually reference database functions like COUNT.

Please see "as" in DBIx::Class::ResultSet for more details.

joins

Holds the top level JoinBuilder object used to keep track of joins automagically while formatting complex search parameters.

Provides the method 'build_joins' which returns the 'join' attribute for search_attributes.

request_data

Holds the raw (but deserialized) data for this request.

PRIVATE_ATTRIBUTES

search_validator

A Catalyst::Controller::DBIC::API::Validator instance used solely to validate search parameters.

select_validator

A Catalyst::Controller::DBIC::API::Validator instance used solely to validate select parameters.

prefetch_validator

A Catalyst::Controller::DBIC::API::Validator instance used solely to validate prefetch parameters.

PROTECTED_METHODS

format_search_parameters

Iterates through the provided arrayref calling generate_column_parameters on each one.

generate_column_parameters

Recursively generates properly aliased parameters for search building a new JoinBuilder each layer of recursion.

generate_parameters_attributes

Takes the raw search arguments and formats them by calling format_search_parameters. Then builds the related attributes, preferring request-provided arguments for things like grouped_by over statically configured options. Finally tacking on the appropriate joins.

Returns a list of both formatted search parameters and attributes.

AUTHORS

  • Nicholas Perez <nperez@cpan.org>

  • Luke Saunders <luke.saunders@gmail.com>

  • Alexander Hartmaier <abraxxa@cpan.org>

  • Florian Ragwitz <rafl@debian.org>

  • Oleg Kostyuk <cub.uanic@gmail.com>

  • Samuel Kaufman <sam@socialflow.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by Luke Saunders, Nicholas Perez, Alexander Hartmaier, et al.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.