Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECSQL: Specific query fails to prepare #6508

Open
grigasp opened this issue Mar 12, 2024 · 0 comments
Open

ECSQL: Specific query fails to prepare #6508

grigasp opened this issue Mar 12, 2024 · 0 comments
Assignees
Labels
bug Something isn't working ecdb ECDb and ECSQL related issues

Comments

@grigasp
Copy link
Member

grigasp commented Mar 12, 2024

Describe the bug

The following ECSQL query fails to prepare:

WITH FilteringInfo(ECInstanceId, FilteredChildrenPaths) AS (
  VALUES (0x13, '[]')
)
SELECT [q].*
FROM (
  SELECT childModel.*
  FROM (
    SELECT 
      ec_ClassName(model.ECClassId) AS FullClassName,
      model.ECInstanceId AS ECInstanceId
    FROM BisCore.GeometricModel3d model
  ) childModel
  JOIN BisCore.GeometricModel3d this ON this.ECInstanceId = childModel.ECInstanceId
) [q]
JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]

with an error BE_SQLITE_ERROR ambiguous column name: ECInstanceId.

To Reproduce
Steps to reproduce the behavior:

  1. Open any iModel in iModelConsole
  2. Run the ECSQL query provided above
  3. See the error

Expected behavior

The query is prepared and executed successfully

Desktop:

  • iTwin.js Version: 4.4.x

Additional context

  • The given query is simplified version of a much larger query - it's not expected to make much sense in this form.

  • This workaround seems to solve the issue:

WITH FilteringInfo(ECInstanceId, FilteredChildrenPaths) AS (
  VALUES (0x13, '[]')
)
SELECT [q].*
FROM (
  SELECT childModel.ECInstanceId AS ECInstanceId, childModel.*
  FROM (
    SELECT 
      ec_ClassName(model.ECClassId) AS FullClassName,
      model.ECInstanceId AS ECInstanceId
    FROM BisCore.GeometricModel3d model
  ) childModel
  JOIN BisCore.GeometricModel3d this ON this.ECInstanceId = childModel.ECInstanceId
) [q]
JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]
@grigasp grigasp added bug Something isn't working ecdb ECDb and ECSQL related issues labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ecdb ECDb and ECSQL related issues
Projects
None yet
Development

No branches or pull requests

2 participants