プロジェクト

全般

プロフィール

Vote #77729

未完了

Query class inheritance

Admin Redmine さんが約4年前に追加.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
-
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
0
version_id:
0
issue_org_id:
23581
author_id:
95427
assigned_to_id:
0
comments:
0
status_id:
1
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

I have a class inherited from query to perform filters and query jobs of my plugin. It works but some functions could be improved for better inheritance capability and extended functionality. Here some thin places:

some filters are desired to be not used for database requests.

some filters are desired to be a list value - suppose to have no operators.

filters could have its own operators.

There first problem is solved by overriding @validate_query_filters@ method and playing with @query.filters@ hash and writing @sql_for_XXXX_field@ that returns empty string.

Here's the thin place for custom operators


    add_filter_error(field, :blank) unless
          # filter requires one or more values
          (values_for(field) and !values_for(field).first.blank?) or
          # filter doesn't require any value
          ["o", "c", "!*", "*", "t", "ld", "w", "lw", "l2w", "m", "lm", "y", "*o", "!o"].include? operator_for(field)
    end if filters

@["o", "c", "!", "", "t", "ld", "w", "lw", "l2w", "m", "lm", "y", "*o", "!o"].include? operator_for(field)@ is better to be replaced with something like this @unary_operators.include? operator_for(field)@

Even more @validate_query_filters@ should support validation of each filter separately. This should give availability of overriding filter validation independently.

表示するデータがありません

他の形式にエクスポート: Atom PDF

いいね!0