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

Added and updated test cases for alias support in CTE subquery #7522

Merged
merged 10 commits into from
Jan 10, 2025
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-backend",
"comment": "Added and updated test cases for alias support in CTE subquery",
pmconne marked this conversation as resolved.
Show resolved Hide resolved
"type": "none"
}
],
"packageName": "@itwin/core-backend"
}
120 changes: 117 additions & 3 deletions core/backend/src/test/ecsql/queries/CteTests.ecsql.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,13 +577,127 @@ WITH RECURSIVE cte (x) AS ( SELECT e.i FROM aps.TestElement e WHERE e.i = 100 UN
| 103 |
| 104 |

# Expected table aliasing to fail in CTE subquery due to prop name being wrong
# CTE subquery with alias

- dataset: AllProperties.bim

```sql
SELECT
a.x
FROM
(
WITH
tmp (x) AS (
SELECT
e.i
FROM
aps.TestElement e
ORDER BY
e.i
LIMIT
1
)
SELECT
x
FROM
tmp
) a
```

| className | accessString | generated | index | jsonName | name | extendedType | typeName | type |
| --------- | ------------ | --------- | ----- | -------- | ---- | ------------ | -------- | ---- |
| | x | true | 0 | x | x | undefined | int | Int |

| x |
| --- |
| 100 |

# CTE Without subcolumns subquery with alias

- dataset: AllProperties.bim
- errorDuringPrepare: true

```sql
select a.x from (with tmp(x) as (SELECT e.i FROM aps.TestElement e order by e.i LIMIT 1) select x from tmp) a;
SELECT
a.i
FROM
(
WITH
tmp AS (
SELECT
e.i
FROM
aps.TestElement e
ORDER BY
e.i
LIMIT
1
)
SELECT
i
FROM
tmp
) a
```

| className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName |
| ------------------------ | ------------ | --------- | ----- | -------- | ---- | ------------ | -------- | ---- | ------------------ |
| AllProperties:IPrimitive | i | false | 0 | i | i | undefined | int | Int | i |

| i |
| --- |
| 100 |

# CTE Without subcolumns subquery with alias for array property

- dataset: AllProperties.bim

```sql
SELECT
a.array_i
FROM
(
WITH
tmp AS (
SELECT
e.array_i
FROM
aps.TestElement e
ORDER BY
e.i
LIMIT
1
)
SELECT
array_i
FROM
tmp
) a
```

```json
{
"columns": [
{
"className": "AllProperties:IPrimitiveArray",
"accessString": "array_i",
"generated": false,
"index": 0,
"jsonName": "array_i",
"name": "array_i",
"typeName": "int",
"type": "PrimitiveArray",
"originPropertyName": "array_i"
}
]
}
```

```json
[
{
"array_i": [0, 1, 2]
}
]
```

# Expected table aliasing for inner and outer tables to fail in CTE subquery due to prop name being wrong
Expand Down
Loading