filter has this code: sub queryforfiltering { my $self = shift; my %args = ( @_, );…
- User
filter has this code: sub query_for_filtering { my $self = shift; my %args = ( @_, );
return undef unless $self->can('structure'); my %structure = %{ $self->structure }; my %where; for my $key ( keys %args ) { if ( my $field = $structure{ $key } ) { if ( $field->{type} eq 'key' || $field->{type} eq 'number' ) { $args{ $key } =~s/%//g; $where{ $key } = $args{ $key }; } elsif ( $field->{type} eq 'json' ) { if ( ref $args{ $key } eq 'HASH' ) { # Check value in the key in a json object $where{ sprintf("%s->'\$.%s'", $key, $_) } = $args{ $key }->{ $_ } for keys %{ $args{ $key } }; } else { # Check exists key in a json object $where{ sprintf("JSON_EXTRACT(%s, '\$.%s')", $key, $args{ $key }) } = { '!=', undef }; } } else { # for type=(`text`, `now`, ``, ...) $where{ $key }{'-like'} = $args{ $key }; } } } return \%where;}
url?filter={"user_id":"7144749799"} is working how i can using filter for nested object, like: settings.telegram.user_id?
- Assistant
To filter a nested object like
settings.telegram.user_idusing the structure you've shown, you need to follow a special convention for JSON fields in Perl, especially when dealing with objects stored as JSON in a database. Your current code handles JSON fields by allowing both specific key-value checks and existence checks.To filter by a nested JSON field such as
settings.telegram.user_id, your URL filter parameter should be structured in a way that matches your JSON extraction logic in the function. Here’s how you might format your filter parameter for a nested JSON object:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.