SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Minor popup bug when sub-queries are involed

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Minor popup bug when sub-queries are involed
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Minor popup bug when sub-queries are involed Reply with quote
There is a minor glitch affecting column popup for sub-queries. Take a look at the following code piece:
Code:


DECLARE   
   @start_date     DATE = '2013-02-01'
   ,@end_date      DATE = '2013-02-01'

SELECT
   sq|
FROM
   (
      SELECT
         dp.name
         ,dp.principal_id
         ,dp.[type]
         ,dp.type_desc
         ,dp.default_schema_name
         ,dp.create_date
         ,dp.modify_date
         ,dp.owning_principal_id
         ,dp.[sid]
         ,dp.is_fixed_role
      FROM
         sys.database_principals         AS dp
      INNER JOIN
         sys.database_principal_aliases  AS dpa
            ON   dpa.name = dp.name
            AND   dpa.[sid] = dp.[sid]
      WHERE   1 = 1
              --#1      AND dp.create_date = @start_date
              --#2      AND dp.create_date BETWEEN @start_date AND @end_date
   ) AS sq


Typing '.' at the location of '|' will result in popup for the selected columns of the sub-query.
After uncommenting condition #1 the popup will still appear, but uncommenting #2 will make the popup no longer available.
Wed Feb 13, 2013 7:36 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7852

Post Reply with quote
Thank you. that's really weird. I can reproduce that too and it occurs even after flipping #1 and #2. I'm unsure why it behaves that way . I'm going to submit a bug report and ask to investigate this issue.
Wed Feb 13, 2013 8:46 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7852

Post Reply with quote
It looks like the issue is caused by use of BETWEEN @var1 AND @var2 construct with 2 variables in a sub-query defining derived table.

The following code seems to work


Code:
DECLARE   
   @start_date     DATE = '2013-02-01'
   ,@end_date      DATE = '2013-02-01'

SELECT
   sq|
FROM
   (
      SELECT
         dp.name
         ,dp.principal_id
         ,dp.[type]
         ,dp.type_desc
         ,dp.default_schema_name
         ,dp.create_date
         ,dp.modify_date
         ,dp.owning_principal_id
         ,dp.[sid]
         ,dp.is_fixed_role
      FROM
         sys.database_principals         AS dp
      INNER JOIN
         sys.database_principal_aliases  AS dpa
            ON   dpa.name = dp.name
            AND   dpa.[sid] = dp.[sid]
      WHERE   1 = 1
              AND dp.create_date = @start_date
              AND dp.create_date BETWEEN (@start_date) AND (@end_date)
   ) AS sq

Wed Feb 13, 2013 8:57 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Reply with quote
Yes, it does with this example. Unfortunately, it does not work with the user created tables and sub-queries where I met this issue the first time. I don't know what makes it so special to resist this workaround but it's rather large, hence it'll take some time to analyze it. I'll have to postpone it. Meanwhile, I'm commenting the conditions containing variables for the time of juggling with SELECT part and removing the comments after. This method works but it is very cumbersome and prone to errors. Could you fix this issue, please?

EDIT: I'll probably replace BETWEEN's with 'a <= b AND b <=c' structures to avoid this in the future :) I took me ages to sort out it was BETWEEN causing the problem.
Wed Feb 13, 2013 9:37 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.