Menu

#18 Expose method for getting _isDistinct or improve hook

sqlbuilder-2.1.3
closed
nobody
None
1
2016-03-16
2016-03-10
Anonymous
No

Need to implement some Customization on SelectQuery to support "TOP" clause (MSSQL), issue I am facing is in the event of both DISTINCT and TOP, order matters (SELECT DISTINCT TOP 100 * FROM X is correct)

Using the hook SelectQuery.Hook.DISTINCT with HookType.SUFFIX only works if distinct is set for the query prior to adding customization for TOP, only other option is to use SelectQuery.Hook.SELECT, but this breaks the order.

Right now I have a conditional check for if the query has been set distinct (if so, use DISTINCT hook), otherwise using SELECT hook.

Ideally, a way to add customization to a hook even if it doesn't exist (because of priority order), such that we get:

With two states SELECT DISTINCT * FROM X or SELECT * FROM X, using the distinct hook/suffix will result in something like SELECT DISTINCT TOP 100 * FROM X or SELECT TOP 100 * FROM X

or at the very least a method to expose the isDistincted property (but order of which these are set/unset will still be an issue).

Discussion

  • James Ahlborn

    James Ahlborn - 2016-03-16

    So i added an AFTER hook which does the right thing for this kind of customization. while i was at it, i went ahead and added MssTopClause to implement the sqlserver TOP clause.

    changes are in trunk, will be in the 2.1.3 release.

     
  • James Ahlborn

    James Ahlborn - 2016-03-16
    • status: open --> closed
    • Group: sqlbuilder-2.0.5 --> sqlbuilder-2.1.3
     

Log in to post a comment.