Results 1 to 10 of 10

Thread: Possible bug when psSQLFilter is combined with DF_FILE_SQL_FILTER

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2019
    Location
    Cantabria, Spain
    Posts
    227

    Default Possible bug when psSQLFilter is combined with DF_FILE_SQL_FILTER

    Hello, I have detected a bug which is not new. It affects older DataFlex versions. If you set a SQL filter in a DataDictionary (pbUseDDSQLFilters enabled and psSQLFilter set) and you have a global SQL filter, the global SQL Filter might be bypassed. This might be quite bad specially if you use the global SQL Filter for user rights/multi tenancy/...
    Code:
    // Global SQL Filter code
    Set_Attribute DF_FILE_SQL_FILTER of iTable to "<SQL Filter>"
    Set_Attribute DF_FILE_SQL_FILTER_EQ of iTable to"<SQL Filter>"
    Set_Attribute DF_FILE_SQL_FILTER_ACTIVE of iTable to"<SQL Filter>"
    
    // DataDictionary filter that breaks the global filter
    Set psSQLFilter to "FIELD >=0 OR FIELD<=10"
    This breaks the global SQL filter. My guess is the psSQLFilter is appended to the global filter by the framework. It should always add "(" and ")" to the psSQLFilter when it has any content, otherwise you might find unexpedted results.
    This is easily fixed changing the line
    Code:
    Set psSQLFilter to "FIELD >=0 OR FIELD<=10"
    to
    Code:
    Set psSQLFilter to "(FIELD >=0 OR FIELD<=10)"
    but this should be handled correctly by the framework in my opinion.

    Note: This already happened in DF 19.1 and is still present in newer DataFlex versions, including DF23.
    Alberto Gutiérrez Arroyo
    A.T. Medtra, S.L.
    atmedtra.es

  2. #2
    Join Date
    Feb 2009
    Location
    Birmingham, UK
    Posts
    1,195

    Default Re: Possible bug when psSQLFilter is combined with DF_FILE_SQL_FILTER

    Are you using pbApplyGlobalSQLFilters here? This will control whether or not any global SQL filters will be combined with local DDO ones. If this is False, then any global ones will indeed be overwritten (or rather, not applied).
    "My wife thinks I over-analyse our marriage, which, to be frank completely contradicts the findings of my report." - @MooseAllain

  3. #3
    Join Date
    Aug 2019
    Location
    Cantabria, Spain
    Posts
    227

    Default Re: Possible bug when psSQLFilter is combined with DF_FILE_SQL_FILTER

    Peter: Indeed, I have pbApplyGlobalSQLFilters and pbUseDDSQLFilters enabled. The filter is applied but it breaks the global SQL filter. As I said, parenthesis should be added internally or at least it should be documented in the psSQLFilter DataDictionary page.
    Alberto Gutiérrez Arroyo
    A.T. Medtra, S.L.
    atmedtra.es

  4. #4
    Join Date
    Feb 2009
    Location
    Hengelo, Netherlands
    Posts
    10,687

    Default Re: Possible bug when psSQLFilter is combined with DF_FILE_SQL_FILTER

    Alberto,

    I am not sure if the framework should interfer with the filter conditions you wrote in the code. If it would results may be different and unwanted as well.
    Regards,
    Data Access Worldwide
    Vincent Oorsprong

  5. #5
    Join Date
    Aug 2019
    Location
    Cantabria, Spain
    Posts
    227

    Default Re: Possible bug when psSQLFilter is combined with DF_FILE_SQL_FILTER

    Vincent,
    I agree, changing this might be worse for existing applications. However, what about adding some lines in the psSQLFilter help page explaining this? Just a warning, something like "If global SQL Filters are also applied you should be careful with the psSQLFilter value. While using an OR clause it is advised to add parenthesis to the SQL filter...". It might help someone in the future.
    Alberto Gutiérrez Arroyo
    A.T. Medtra, S.L.
    atmedtra.es

  6. #6
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    5,280

    Default Re: Possible bug when psSQLFilter is combined with DF_FILE_SQL_FILTER

    +1

    a note on both pages would be very welcome! In the global and in the local filters
    Samuel Pizarro

  7. #7
    Join Date
    Nov 2008
    Location
    Round Rock, TX
    Posts
    8,770

    Default Re: Possible bug when psSQLFilter is combined with DF_FILE_SQL_FILTER

    Hi Samuel,

    done.

  8. #8
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    5,280

    Default Re: Possible bug when psSQLFilter is combined with DF_FILE_SQL_FILTER

    Thanks Dennis !
    Samuel Pizarro

  9. #9
    Join Date
    Nov 2008
    Location
    Round Rock, TX
    Posts
    8,770

    Default Re: Possible bug when psSQLFilter is combined with DF_FILE_SQL_FILTER

    Hi Alberto,

    done.

  10. #10
    Join Date
    Aug 2019
    Location
    Cantabria, Spain
    Posts
    227

    Default Re: Possible bug when psSQLFilter is combined with DF_FILE_SQL_FILTER

    Thanks Dennis!
    Alberto Gutiérrez Arroyo
    A.T. Medtra, S.L.
    atmedtra.es

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •