Skip to content

Method parser.columns_dict do not take into account subqueries. #528

@cmistiloglou

Description

@cmistiloglou

I have the below sql query in MSSQL.

SELECT 
    ap.[AccountId], 
    (SELECT COUNT(*) FROM [Transactions] t WHERE t.[AccountId] = ap.[AccountId]) AS TransactionCount
FROM 
    [AccountProfiles] ap

I am using the Parser class and the columns_dict method contains the SELECT sql clause which do not take into account the subqueries.

parser = Parser(subquery)

tables = parser.tables
columns_dict = parser.columns_dict

As you can see from the sql query and the final output below in json format, in the Tables section registers the table from the subquery. In Select clause it does not contain the TransactionCount and it also takes the Where clause which is contained inside the subquery.

{
      "Tables": [
          "[Transactions]",
          "[AccountProfiles]"
      ],
      "Select": [
          "[AccountProfiles].[AccountId]"
      ],
      "Where": [
          "[Transactions].[AccountId]",
          "[AccountProfiles].[AccountId]",
          "*"
      ]
  }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions