parameters: (self, data, **kwargs)
return_statement: return data
docstring: We need to validate that if group_by is used, all the field
              in the order_by must be in group_by fields.
              When using different order_by fields that are not in group by will cause
              an error on PostgreSQL
docstring_summary: We need to validate that if group_by is used, all the field
              in the order_by must be in group_by fields.
              When using different order_by fields that are not in group by will cause
              an error on PostgreSQL
docstring_tokens: We need to validate that if group_by is used all the field in the order_by must be in group_by fields . When using different order_by fields that are not in group by will cause an error on PostgreSQL
function: def validate_order_and_group_by(self, data, **kwargs):
          """
              We need to validate that if group_by is used, all the field
              in the order_by must be in group_by fields.
              When using different order_by fields that are not in group by will cause
              an error on PostgreSQL
          """
          if 'group_by' in data and 'order_by' in data:
              group_by_fields = {group_field['field'] for group_field in data['group_by']}
              order_by_fields = {order_field['field'] for order_field in data['order_by']}
              if not order_by_fields.issubset(group_by_fields):
                  logger.error(f'All order fields ({order_by_fields}) must be in group by {group_by_fields}.')
                  raise ValidationError(f'All order fields ({order_by_fields}) must be in group by {group_by_fields}.')
          return data
function_tokens: def validate_order_and_group_by ( self , data , * * kwargs ) : if 'group_by' in data and 'order_by' in data : group_by_fields = { group_field [ 'field' ] for group_field in data [ 'group_by' ] } order_by_fields = { order_field [ 'field' ] for order_field in data [ 'order_by' ] } if not order_by_fields . issubset ( group_by_fields ) : logger . error ( f'All order fields ({order_by_fields}) must be in group by {group_by_fields}.' ) raise ValidationError ( f'All order fields ({order_by_fields}) must be in group by {group_by_fields}.' ) return data