From 55b7cc8452a58c51e642966dea55003240efd964 Mon Sep 17 00:00:00 2001 From: soham-bentley <177123878+soham-bentley@users.noreply.github.com> Date: Wed, 29 Jan 2025 23:41:20 +0530 Subject: [PATCH 1/5] Tests and documentation updated --- core/backend/src/test/ecdb/ECSqlQuery.test.ts | 8 +- .../backend/src/test/ecdb/ECSqlReader.test.ts | 2 +- .../src/test/ecdb/ECSqlStatement.test.ts | 4 +- .../test/ecsql/queries/IdSetVTTests.ecsql.md | 168 +++++++++++++++--- .../src/test/ecsql/queries/Misc.ecsql.md | 134 ++++++++++++++ .../test/ecsql/src/ECSqlTestRunner.test.ts | 2 +- docs/learning/ECSqlReference/IdSet.md | 10 +- 7 files changed, 294 insertions(+), 34 deletions(-) diff --git a/core/backend/src/test/ecdb/ECSqlQuery.test.ts b/core/backend/src/test/ecdb/ECSqlQuery.test.ts index deaa3256507c..b512e455c98e 100644 --- a/core/backend/src/test/ecdb/ECSqlQuery.test.ts +++ b/core/backend/src/test/ecdb/ECSqlQuery.test.ts @@ -556,7 +556,7 @@ describe("ECSql Query", () => { for await (const row of imodel1.createQueryReader("SELECT ECInstanceId FROM BisCore.Element LIMIT 23")) { ids.push(row[0]); } - const reader = imodel1.createQueryReader("SELECT * FROM BisCore.element, ECVLib.IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", QueryBinder.from([ids])); + const reader = imodel1.createQueryReader("SELECT * FROM BisCore.element, IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", QueryBinder.from([ids])); let props = await reader.getMetaData(); assert.equal(props.length, 12); // 11 for BisCore.element and 1 for IdSet let rows = 0; @@ -576,7 +576,7 @@ describe("ECSql Query", () => { ids = row[0]; // getting only the first id break; } - const reader = imodel1.createQueryReader("SELECT * FROM BisCore.element, ECVLib.IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", QueryBinder.from([ids])); + const reader = imodel1.createQueryReader("SELECT * FROM BisCore.element, IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", QueryBinder.from([ids])); let props = await reader.getMetaData(); assert.equal(props.length, 12); // 11 for BisCore.element and 1 for IdSet let rows = 0; // backend will fail to bind so no rows will be returned @@ -592,7 +592,7 @@ describe("ECSql Query", () => { it("concurrent query bind idset with invalid values in IdSet virtual table", async () => { const ids: string[] = ["0x1","ABC","YZ"]; - const reader = imodel1.createQueryReader("SELECT * FROM BisCore.element, ECVLib.IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", QueryBinder.from([ids])); + const reader = imodel1.createQueryReader("SELECT * FROM BisCore.element, IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", QueryBinder.from([ids])); let props = await reader.getMetaData(); assert.equal(props.length, 12); // 11 for BisCore.element and 1 for IdSet let rows = 0; // backend will bind successfully but some of the values are not valid for IdSet VT so those values will be ignored @@ -609,7 +609,7 @@ describe("ECSql Query", () => { const ids: string[] = ["ABC", "0x1","YZ"]; // as first value is not an Id so QueryBinder.from will throw error of "unsupported type" try{ - imodel1.createQueryReader("SELECT * FROM BisCore.element, ECVLib.IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", QueryBinder.from([ids])); + imodel1.createQueryReader("SELECT * FROM BisCore.element, IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", QueryBinder.from([ids])); }catch(err: any){ assert.equal(err.message, "unsupported type"); } diff --git a/core/backend/src/test/ecdb/ECSqlReader.test.ts b/core/backend/src/test/ecdb/ECSqlReader.test.ts index b89d8651688b..18be81c5201c 100644 --- a/core/backend/src/test/ecdb/ECSqlReader.test.ts +++ b/core/backend/src/test/ecdb/ECSqlReader.test.ts @@ -58,7 +58,7 @@ describe("ECSqlReader", (() => { params.bindIdSet(1, ["0x32"]); const optionBuilder = new QueryOptionsBuilder(); optionBuilder.setRowFormat(QueryRowFormat.UseJsPropertyNames); - reader = ecdb.createQueryReader("SELECT ECInstanceId, Name FROM meta.ECClassDef, ECVLib.IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", params, optionBuilder.getOptions()); + reader = ecdb.createQueryReader("SELECT ECInstanceId, Name FROM meta.ECClassDef, IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", params, optionBuilder.getOptions()); const rows = await reader.toArray(); assert.equal(rows[0].id, "0x32"); assert.equal(rows.length, 1); diff --git a/core/backend/src/test/ecdb/ECSqlStatement.test.ts b/core/backend/src/test/ecdb/ECSqlStatement.test.ts index 55ea050532c6..2de61322afed 100644 --- a/core/backend/src/test/ecdb/ECSqlStatement.test.ts +++ b/core/backend/src/test/ecdb/ECSqlStatement.test.ts @@ -1848,7 +1848,7 @@ describe("ECSqlStatement", () => { }); }); - ecdb.withPreparedStatement("SELECT ECInstanceId, ECClassId, Name from ecdbf.ExternalFileInfo, ECVLib.IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", (stmt: ECSqlStatement) => { + ecdb.withPreparedStatement("SELECT ECInstanceId, ECClassId, Name from ecdbf.ExternalFileInfo, IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", (stmt: ECSqlStatement) => { let idSet: Id64String[] = []; stmt.bindIdSet(1, idSet); let result = stmt.step(); @@ -1906,7 +1906,7 @@ describe("ECSqlStatement", () => { }); }); - ecdb.withPreparedStatement("SELECT ECInstanceId, ECClassId, Name from ecdbf.ExternalFileInfo, ECVLib.IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", (stmt: ECSqlStatement) => { + ecdb.withPreparedStatement("SELECT ECInstanceId, ECClassId, Name from ecdbf.ExternalFileInfo, IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", (stmt: ECSqlStatement) => { let idSet: Id64String[] = []; stmt.bindIdSet(1, idSet); let result = stmt.step(); diff --git a/core/backend/src/test/ecsql/queries/IdSetVTTests.ecsql.md b/core/backend/src/test/ecsql/queries/IdSetVTTests.ecsql.md index c2edf1a9da11..71d44163e943 100644 --- a/core/backend/src/test/ecsql/queries/IdSetVTTests.ecsql.md +++ b/core/backend/src/test/ecsql/queries/IdSetVTTests.ecsql.md @@ -5,7 +5,7 @@ Copyright © Bentley Systems, Incorporated. All rights reserved. See [LICENSE.md - dataset: AllProperties.bim ```sql -SELECT id from ECVLib.IdSet(?) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES +SELECT id from IdSet(?) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` - bindIdSet 1, [0x15, 0x18, 0x19] @@ -25,7 +25,7 @@ SELECT id from ECVLib.IdSet(?) ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES - dataset: AllProperties.bim ```sql -SELECT id a from ECVLib.IdSet(?) OPTIONS ENABLE_EXPERIMENTAL_FEATURES +SELECT id a from IdSet(?) OPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` - bindIdSet 1, [0x15, 0x18, 0x19] @@ -40,6 +40,132 @@ SELECT id a from ECVLib.IdSet(?) OPTIONS ENABLE_EXPERIMENTAL_FEATURES | 0x18 | | 0x19 | +# Testing one level subquery with IdSet for ConcurrentQuery + +- dataset: AllProperties.bim +- mode: ConcurrentQuery + +```sql +SELECT * FROM (SELECT id a from IdSet(?)) OPTIONS ENABLE_EXPERIMENTAL_FEATURES +``` + +- bindIdSet 1, [0x15, 0x18, 0x19] + +| className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | +| --------- | ------------ | --------- | ----- | -------- | ---- | ------------ | -------- | ---- | ------------------ | +| | a | true | 0 | a | a | Id | long | Id | id | + +| a | +| ---- | +| 0x15 | +| 0x18 | +| 0x19 | + +# Testing one level subquery with IdSet for Statement + +- dataset: AllProperties.bim +- mode: Statement + +```sql +SELECT * FROM (SELECT id a from IdSet(?)) OPTIONS ENABLE_EXPERIMENTAL_FEATURES +``` + +- bindIdSet 1, [0x15, 0x18, 0x19] + +| className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | +| --------- | ------------ | --------- | ----- | -------- | ---- | ------------ | -------- | ---- | ------------------ | +| | a | true | 0 | a | a | Id | long | Id | undefined | + +| a | +| ---- | +| 0x15 | +| 0x18 | +| 0x19 | + +# Testing TWO level subquery with IdSet for ConcurrentQuery + +- dataset: AllProperties.bim +- mode: ConcurrentQuery + +```sql +SELECT * FROM (SELECT * FROM (SELECT id a from IdSet(?))) OPTIONS ENABLE_EXPERIMENTAL_FEATURES +``` + +- bindIdSet 1, [0x15, 0x18, 0x19] + +| className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | +| --------- | ------------ | --------- | ----- | -------- | ---- | ------------ | -------- | ---- | ------------------ | +| | a | true | 0 | a | a | Id | long | Id | id | + +| a | +| ---- | +| 0x15 | +| 0x18 | +| 0x19 | + +# Testing TWO level subquery with IdSet for Statement + +- dataset: AllProperties.bim +- mode: Statement + +```sql +SELECT * FROM (SELECT * FROM (SELECT id a from IdSet(?))) OPTIONS ENABLE_EXPERIMENTAL_FEATURES +``` + +- bindIdSet 1, [0x15, 0x18, 0x19] + +| className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | +| --------- | ------------ | --------- | ----- | -------- | ---- | ------------ | -------- | ---- | ------------------ | +| | a | true | 0 | a | a | Id | long | Id | undefined | + +| a | +| ---- | +| 0x15 | +| 0x18 | +| 0x19 | + +# Testing TWO level subquery with IdSet with column alias for Concurrent Query + +- dataset: AllProperties.bim +- mode: ConcurrentQuery + +```sql +SELECT a FROM (SELECT * FROM (SELECT id a from IdSet(?))) OPTIONS ENABLE_EXPERIMENTAL_FEATURES +``` + +- bindIdSet 1, [0x15, 0x18, 0x19] + +| className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | +| --------- | ------------ | --------- | ----- | -------- | ---- | ------------ | -------- | ---- | ------------------ | +| | a | true | 0 | a | a | Id | long | Id | id | + +| a | +| ---- | +| 0x15 | +| 0x18 | +| 0x19 | + +# Testing TWO level subquery with IdSet with column alias for Statement + +- dataset: AllProperties.bim +- mode: Statement + +```sql +SELECT a FROM (SELECT * FROM (SELECT id a from IdSet(?))) OPTIONS ENABLE_EXPERIMENTAL_FEATURES +``` + +- bindIdSet 1, [0x15, 0x18, 0x19] + +| className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | +| --------- | ------------ | --------- | ----- | -------- | ---- | ------------ | -------- | ---- | ------------------ | +| | a | true | 0 | a | a | id | long | Id | undefined | + +| a | +| ---- | +| 0x15 | +| 0x18 | +| 0x19 | + # Testing with hard coded json string with hex ids - dataset: AllProperties.bim @@ -63,7 +189,7 @@ SELECT i FROM aps.TestElement,ECVLib.IdSet('["0x15", "0x18", "0x19"]') where id - dataset: AllProperties.bim ```sql -SELECT i FROM aps.TestElement,ECVLib.IdSet('[21, 24, "25"]') where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES = TRUE +SELECT i FROM aps.TestElement,IdSet('[21, 24, "25"]') where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES = TRUE ``` | className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | @@ -82,7 +208,7 @@ SELECT i FROM aps.TestElement,ECVLib.IdSet('[21, 24, "25"]') where id = ECInstan - bindIdSet 1, [0x15, 0x18, 0x19] ```sql -SELECT e.i FROM aps.TestElement e INNER JOIN ECVLib.IdSet(?) v ON e.ECInstanceId = v.id ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES = 1 +SELECT e.i FROM aps.TestElement e INNER JOIN IdSet(?) v ON e.ECInstanceId = v.id ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES = 1 ``` | className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | @@ -106,7 +232,7 @@ SELECT v.id FROM aps.TestElement e - INNER JOIN ECVLib.IdSet (?) v ON v.id = e.ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES = true + INNER JOIN IdSet (?) v ON v.id = e.ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES = true ``` | className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | @@ -132,7 +258,7 @@ SELECT v.id FROM aps.TestElement e - JOIN ECVLib.IdSet (?) v ON e.ECInstanceId = v.id OPTIONS ENABLE_EXPERIMENTAL_FEATURES + JOIN IdSet (?) v ON e.ECInstanceId = v.id OPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` | className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | @@ -158,7 +284,7 @@ SELECT e.i, v.id FROM - ECVLib.IdSet (?) v + IdSet (?) v LEFT OUTER JOIN aps.TestElement e ON e.ECInstanceId = v.id ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` @@ -186,7 +312,7 @@ SELECT v.id FROM aps.TestElement e - LEFT OUTER JOIN ECVLib.IdSet (?) v ON e.ECInstanceId = v.id OPTIONS ENABLE_EXPERIMENTAL_FEATURES + LEFT OUTER JOIN IdSet (?) v ON e.ECInstanceId = v.id OPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` | className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | @@ -220,7 +346,7 @@ SELECT v.id FROM aps.TestElement e - CROSS JOIN ECVLib.IdSet (?) v ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES + CROSS JOIN IdSet (?) v ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` | className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | @@ -274,7 +400,7 @@ SELECT v.id FROM aps.TestElement e - FULL JOIN ECVLib.IdSet (?) v ON e.ECInstanceId = v.id OPTIONS ENABLE_EXPERIMENTAL_FEATURES = TRUE + FULL JOIN IdSet (?) v ON e.ECInstanceId = v.id OPTIONS ENABLE_EXPERIMENTAL_FEATURES = TRUE ``` | className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | @@ -303,7 +429,7 @@ FROM - errorDuringPrepare: true ```sql -SELECT e.S, e.i, v.id FROM aps.TestElement e NATURAL JOIN ECVLib.IdSet(?) v ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES = True +SELECT e.S, e.i, v.id FROM aps.TestElement e NATURAL JOIN IdSet(?) v ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES = True ``` # Testing JOIN @@ -318,7 +444,7 @@ SELECT v.id FROM aps.TestElement e - JOIN ECVLib.IdSet (?) v ON e.ECInstanceId = v.id ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES + JOIN IdSet (?) v ON e.ECInstanceId = v.id ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` | className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | @@ -339,7 +465,7 @@ FROM - bindIdSet 1, [0x15, 0x18, 0x19] ```sql -SELECT i FROM aps.TestElement,ECVLib.IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES +SELECT i FROM aps.TestElement,IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` | className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | @@ -359,7 +485,7 @@ SELECT i FROM aps.TestElement,ECVLib.IdSet(?) where id = ECInstanceId ECSQLOPTIO - mode: Statement ```sql -SELECT i FROM aps.TestElement,ECVLib.IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES +SELECT i FROM aps.TestElement,IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` | className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | @@ -405,7 +531,7 @@ FROM cte (a, b) AS ( SELECT ECInstanceId, i FROM aps.TestElement ) SELECT * FROM cte ), - ECVLib.IdSet (?) + IdSet (?) WHERE id = a ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` @@ -429,7 +555,7 @@ WHERE SELECT b FROM -ECVLib.IdSet (?), +IdSet (?), ( WITH cte (a, b) AS ( @@ -492,7 +618,7 @@ FROM cte (a, b) AS ( SELECT ECInstanceId, i FROM aps.TestElement ) SELECT * FROM cte )), -ECVLib.IdSet (?) +IdSet (?) WHERE id = a ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` @@ -521,7 +647,7 @@ FROM cte AS ( SELECT ECInstanceId, i FROM aps.TestElement ) SELECT * FROM cte )), -ECVLib.IdSet (?) +IdSet (?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` @@ -545,7 +671,7 @@ WHERE SELECT i FROM -ECVLib.IdSet (?), +IdSet (?), ( WITH cte AS ( @@ -572,7 +698,7 @@ WHERE - errorDuringPrepare: true ```sql -SELECT i FROM aps.TestElement,ECVLib.IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES = False +SELECT i FROM aps.TestElement,IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES = False ``` # Testing IdSet without ENABLE_EXPERIMENTAL_FEATURES @@ -582,5 +708,5 @@ SELECT i FROM aps.TestElement,ECVLib.IdSet(?) where id = ECInstanceId ECSQLOPTIO - errorDuringPrepare: true ```sql -SELECT i FROM aps.TestElement,ECVLib.IdSet(?) where id = ECInstanceId +SELECT i FROM aps.TestElement,IdSet(?) where id = ECInstanceId ``` diff --git a/core/backend/src/test/ecsql/queries/Misc.ecsql.md b/core/backend/src/test/ecsql/queries/Misc.ecsql.md index b98f2e91ebd0..eef423c88f78 100644 --- a/core/backend/src/test/ecsql/queries/Misc.ecsql.md +++ b/core/backend/src/test/ecsql/queries/Misc.ecsql.md @@ -968,3 +968,137 @@ SELECT 0,0 | 0_1 | | --- | | 0 | + +# Testing json_tree without schema name + +- dataset: AllProperties.bim + +```sql +SELECT + * +FROM + json_tree( + '{ "planet": "mars", "gravity": "3.721 m/s²", "surface_area": "144800000 km²", "distance_from_sun":"227900000 km", "radius" : "3389.5 km","orbital_period" : "687 days", "moons": ["Phobos", "Deimos"]}' + ) s +WHERE + s.key = 'gravity' +``` + +| className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | +| --------------- | ------------ | --------- | ----- | -------- | ------- | ------------ | -------- | ------ | ------------------ | +| json1:json_tree | key | false | 0 | key | key | undefined | string | String | key | +| json1:json_tree | value | false | 1 | value | value | undefined | string | String | value | +| json1:json_tree | type | false | 2 | type | type | undefined | string | String | type | +| json1:json_tree | atom | false | 3 | atom | atom | undefined | string | String | atom | +| json1:json_tree | parent | false | 4 | parent | parent | undefined | int | Int | parent | +| json1:json_tree | fullkey | false | 5 | fullkey | fullkey | undefined | string | String | fullkey | +| json1:json_tree | path | false | 6 | path | path | undefined | string | String | path | + +| key | value | type | atom | parent | fullkey | path | +| ------- | ---------- | ---- | ---------- | ------ | --------- | ---- | +| gravity | 3.721 m/s² | text | 3.721 m/s² | 0 | $.gravity | $ | + +# Testing json_tree with schema name + +- dataset: AllProperties.bim + +```sql +SELECT + * +FROM + json1.json_tree( + '{ "planet": "mars", "gravity": "3.721 m/s²", "surface_area": "144800000 km²", "distance_from_sun":"227900000 km", "radius" : "3389.5 km","orbital_period" : "687 days", "moons": ["Phobos", "Deimos"]}' + ) s +WHERE + s.key = 'gravity' +``` + +| className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | +| --------------- | ------------ | --------- | ----- | -------- | ------- | ------------ | -------- | ------ | ------------------ | +| json1:json_tree | key | false | 0 | key | key | undefined | string | String | key | +| json1:json_tree | value | false | 1 | value | value | undefined | string | String | value | +| json1:json_tree | type | false | 2 | type | type | undefined | string | String | type | +| json1:json_tree | atom | false | 3 | atom | atom | undefined | string | String | atom | +| json1:json_tree | parent | false | 4 | parent | parent | undefined | int | Int | parent | +| json1:json_tree | fullkey | false | 5 | fullkey | fullkey | undefined | string | String | fullkey | +| json1:json_tree | path | false | 6 | path | path | undefined | string | String | path | + +| key | value | type | atom | parent | fullkey | path | +| ------- | ---------- | ---- | ---------- | ------ | --------- | ---- | +| gravity | 3.721 m/s² | text | 3.721 m/s² | 0 | $.gravity | $ | + +# Testing json_each without schema name + +- dataset: AllProperties.bim + +```sql +SELECT + * +FROM + json_each( + '{ "planet": "mars", "gravity": "3.721 m/s²", "surface_area": "144800000 km²", "distance_from_sun":"227900000 km", "radius" : "3389.5 km","orbital_period" : "687 days", "moons": ["Phobos", "Deimos"]}' + ) s +WHERE + s.key = 'gravity' +``` + +| className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | +| --------------- | ------------ | --------- | ----- | -------- | ------- | ------------ | -------- | ------ | ------------------ | +| json1:json_each | key | false | 0 | key | key | undefined | string | String | key | +| json1:json_each | value | false | 1 | value | value | undefined | string | String | value | +| json1:json_each | type | false | 2 | type | type | undefined | string | String | type | +| json1:json_each | atom | false | 3 | atom | atom | undefined | string | String | atom | +| json1:json_each | parent | false | 4 | parent | parent | undefined | int | Int | parent | +| json1:json_each | fullkey | false | 5 | fullkey | fullkey | undefined | string | String | fullkey | +| json1:json_each | path | false | 6 | path | path | undefined | string | String | path | + +| key | value | type | atom | fullkey | path | +| ------- | ---------- | ---- | ---------- | --------- | ---- | +| gravity | 3.721 m/s² | text | 3.721 m/s² | $.gravity | $ | + +# Testing json_each with schema name + +- dataset: AllProperties.bim + +```sql +SELECT + * +FROM + json1.json_each( + '{ "planet": "mars", "gravity": "3.721 m/s²", "surface_area": "144800000 km²", "distance_from_sun":"227900000 km", "radius" : "3389.5 km","orbital_period" : "687 days", "moons": ["Phobos", "Deimos"]}' + ) s +WHERE + s.key = 'gravity' +``` + +| className | accessString | generated | index | jsonName | name | extendedType | typeName | type | originPropertyName | +| --------------- | ------------ | --------- | ----- | -------- | ------- | ------------ | -------- | ------ | ------------------ | +| json1:json_each | key | false | 0 | key | key | undefined | string | String | key | +| json1:json_each | value | false | 1 | value | value | undefined | string | String | value | +| json1:json_each | type | false | 2 | type | type | undefined | string | String | type | +| json1:json_each | atom | false | 3 | atom | atom | undefined | string | String | atom | +| json1:json_each | parent | false | 4 | parent | parent | undefined | int | Int | parent | +| json1:json_each | fullkey | false | 5 | fullkey | fullkey | undefined | string | String | fullkey | +| json1:json_each | path | false | 6 | path | path | undefined | string | String | path | + +| key | value | type | atom | fullkey | path | +| ------- | ---------- | ---- | ---------- | --------- | ---- | +| gravity | 3.721 m/s² | text | 3.721 m/s² | $.gravity | $ | + +# Select ECDb schemas from ECDbMeta without schema name + +- dataset: AllProperties.bim +- errorDuringPrepare: true + +```sql +Select s.Name, s.Alias from ECSchemaDef s WHERE s.Name LIKE 'ECDb%' LIMIT 4; +``` + +# Select Test elements from sample dataset without schema name + +- dataset: AllProperties.bim +- errorDuringPrepare: true + +```sql +SELECT e.ECClassId, e.DirectStr FROM TestElement e WHERE e.DirectLong > 1005 ORDER BY e.DirectLong LIMIT 2 +``` diff --git a/core/backend/src/test/ecsql/src/ECSqlTestRunner.test.ts b/core/backend/src/test/ecsql/src/ECSqlTestRunner.test.ts index 6e6bb53fe614..ca13d33bb783 100644 --- a/core/backend/src/test/ecsql/src/ECSqlTestRunner.test.ts +++ b/core/backend/src/test/ecsql/src/ECSqlTestRunner.test.ts @@ -190,7 +190,7 @@ function runECSqlStatementTest(test: ECDbTestProps, dataset: TestDataset) { if (expectedColInfo.type !== undefined) assert.strictEqual(ECSqlValueType[colInfo.getType()], expectedColInfo.type, `Expected type ${expectedColInfo.type} but got ${ECSqlValueType[colInfo.getType()]} for column index ${i}`); if (expectedColInfo.originPropertyName !== undefined) - assert.strictEqual(colInfo.getOriginPropertyName(), expectedColInfo.originPropertyName, `Expected extended type ${expectedColInfo.originPropertyName} but got ${colInfo.getOriginPropertyName()} for column index ${i}`); + assert.strictEqual(colInfo.getOriginPropertyName(), expectedColInfo.originPropertyName, `Expected Origin PropertyName ${expectedColInfo.originPropertyName} but got ${colInfo.getOriginPropertyName()} for column index ${i}`); } } diff --git a/docs/learning/ECSqlReference/IdSet.md b/docs/learning/ECSqlReference/IdSet.md index 723b0398911b..fea8286f57bd 100644 --- a/docs/learning/ECSqlReference/IdSet.md +++ b/docs/learning/ECSqlReference/IdSet.md @@ -1,17 +1,17 @@ # IdSet Virtual Table -`IdSet` is an ECSQl built in virtual table which takes in a valid JSON array string of hex or decimal ids and stores the ids as a virtual table. It can be used as an alternative to `InVirtualSet`. The column retuned by `IdSet` virtual table will always be named `id` by default but can be aliased as per choice. `IdSet` virtual table is defined under the schema named `ECVLib`. It is an experimental feature, so the ECSql Option `ENABLE_EXPERIMENTAL_FEATURES` should be passed with the query in order for it to work. +`IdSet` is an ECSQl built in virtual table which takes in a valid JSON array string of hex or decimal ids and stores the ids as a virtual table. It can be used as an alternative to `InVirtualSet`. The column retuned by `IdSet` virtual table will always be named `id` by default but can be aliased as per choice. `IdSet` virtual table is defined under the schema named `ECVLib`. But schema name is optional in case of Table Valued Functions so `IdSet` virtual table works fine even when the schema named `ECVLib` is not mentioned in the ECSql query. It is an experimental feature, so the ECSql Option `ENABLE_EXPERIMENTAL_FEATURES` should be passed with the query in order for it to work. ## Syntax ```sql -SELECT i FROM aps.TestElement, ECVLib.IdSet('["0x15", "0x18", "0x19"]') where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES +SELECT i FROM aps.TestElement, IdSet('["0x15", "0x18", "0x19"]') where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` OR ```sql -SELECT i FROM aps.TestElement, ECVLib.IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES +SELECT i FROM aps.TestElement, IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` ## Arguments accepted @@ -25,7 +25,7 @@ SELECT i FROM aps.TestElement, ECVLib.IdSet(?) where id = ECInstanceId ECSQLOPTI As `IdSet` is an alternative to `InVirtualSet()`, `bindIdSet` also works with `IdSet` virtual table ```sql -SELECT i FROM aps.TestElement,ECVLib.IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES +SELECT i FROM aps.TestElement, IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` - bindIdSet 1, [0x15, 0x18, 0x19] @@ -41,7 +41,7 @@ SELECT i FROM aps.TestElement where InVirtualSet(?, ECInstanceId) can be translated using `IdSet` as follows ```sql -SELECT i FROM aps.TestElement,ECVLib.IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES +SELECT i FROM aps.TestElement, IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES ``` [ECSql Syntax](./index.md) From 37c268192a30cbf01e34e7da346f17a0b1216fbf Mon Sep 17 00:00:00 2001 From: soham-bentley <177123878+soham-bentley@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:51:24 +0530 Subject: [PATCH 2/5] Tests updated --- .../test/ecsql/queries/IdSetVTTests.ecsql.md | 40 +++++++++++++++++++ .../src/test/ecsql/queries/Misc.ecsql.md | 32 +++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/core/backend/src/test/ecsql/queries/IdSetVTTests.ecsql.md b/core/backend/src/test/ecsql/queries/IdSetVTTests.ecsql.md index 71d44163e943..86efb6cfe319 100644 --- a/core/backend/src/test/ecsql/queries/IdSetVTTests.ecsql.md +++ b/core/backend/src/test/ecsql/queries/IdSetVTTests.ecsql.md @@ -710,3 +710,43 @@ SELECT i FROM aps.TestElement,IdSet(?) where id = ECInstanceId ECSQLOPTIONS ENAB ```sql SELECT i FROM aps.TestElement,IdSet(?) where id = ECInstanceId ``` + +# Testing Abstract syntax with IdSet with space as schema name + +- dataset: AllProperties.bim +- bindIdSet 1, [0x15, 0x18, 0x19] +- errorDuringPrepare: true + +```sql +SELECT id FROM .IdSet(?) OPTIONS ENABLE_EXPERIMENTAL_FEATURES +``` + +# Testing Abstract syntax with IdSet with empty schema name + +- dataset: AllProperties.bim +- bindIdSet 1, [0x15, 0x18, 0x19] +- errorDuringPrepare: true + +```sql +SELECT id FROM .IdSet(?) OPTIONS ENABLE_EXPERIMENTAL_FEATURES +``` + +# Testing Abstract syntax with IdSet with no arg list + +- dataset: AllProperties.bim +- bindIdSet 1, [0x15, 0x18, 0x19] +- errorDuringPrepare: true + +```sql +SELECT id FROM IdSet OPTIONS ENABLE_EXPERIMENTAL_FEATURES +``` + +# Testing Abstract syntax with IdSet with schema name but with no arg list + +- dataset: AllProperties.bim +- bindIdSet 1, [0x15, 0x18, 0x19] +- errorDuringPrepare: true + +```sql +SELECT id FROM ECVLib.IdSet OPTIONS ENABLE_EXPERIMENTAL_FEATURES +``` diff --git a/core/backend/src/test/ecsql/queries/Misc.ecsql.md b/core/backend/src/test/ecsql/queries/Misc.ecsql.md index eef423c88f78..3424bdcc556b 100644 --- a/core/backend/src/test/ecsql/queries/Misc.ecsql.md +++ b/core/backend/src/test/ecsql/queries/Misc.ecsql.md @@ -1027,6 +1027,22 @@ WHERE | ------- | ---------- | ---- | ---------- | ------ | --------- | ---- | | gravity | 3.721 m/s² | text | 3.721 m/s² | 0 | $.gravity | $ | +# Testing json_tree with empty schema name + +- dataset: AllProperties.bim +- errorDuringPrepare: true + +```sql +SELECT + * +FROM + .json_tree( + '{ "planet": "mars", "gravity": "3.721 m/s²", "surface_area": "144800000 km²", "distance_from_sun":"227900000 km", "radius" : "3389.5 km","orbital_period" : "687 days", "moons": ["Phobos", "Deimos"]}' + ) s +WHERE + s.key = 'gravity' +``` + # Testing json_each without schema name - dataset: AllProperties.bim @@ -1085,6 +1101,22 @@ WHERE | ------- | ---------- | ---- | ---------- | --------- | ---- | | gravity | 3.721 m/s² | text | 3.721 m/s² | $.gravity | $ | +# Testing json_each with schema name as space + +- dataset: AllProperties.bim +- errorDuringPrepare: true + +```sql +SELECT + * +FROM + .json_each( + '{ "planet": "mars", "gravity": "3.721 m/s²", "surface_area": "144800000 km²", "distance_from_sun":"227900000 km", "radius" : "3389.5 km","orbital_period" : "687 days", "moons": ["Phobos", "Deimos"]}' + ) s +WHERE + s.key = 'gravity' +``` + # Select ECDb schemas from ECDbMeta without schema name - dataset: AllProperties.bim From e8b13205be8f710fd9354f72f739795670b2eef0 Mon Sep 17 00:00:00 2001 From: soham-bentley <177123878+soham-bentley@users.noreply.github.com> Date: Thu, 30 Jan 2025 15:52:10 +0530 Subject: [PATCH 3/5] ChangeLogs Updated --- ...sts_for_schema_names_optional_2025-01-30-10-21.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@itwin/core-backend/Soham-Updated_Tests_for_schema_names_optional_2025-01-30-10-21.json diff --git a/common/changes/@itwin/core-backend/Soham-Updated_Tests_for_schema_names_optional_2025-01-30-10-21.json b/common/changes/@itwin/core-backend/Soham-Updated_Tests_for_schema_names_optional_2025-01-30-10-21.json new file mode 100644 index 000000000000..99b35bb89b62 --- /dev/null +++ b/common/changes/@itwin/core-backend/Soham-Updated_Tests_for_schema_names_optional_2025-01-30-10-21.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@itwin/core-backend", + "comment": "", + "type": "none" + } + ], + "packageName": "@itwin/core-backend" +} \ No newline at end of file From a572a4b516790b1bbe1a6f68c5ecdc3a96084816 Mon Sep 17 00:00:00 2001 From: imodeljs-admin <38288322+imodeljs-admin@users.noreply.github.com> Date: Thu, 30 Jan 2025 17:15:03 +0000 Subject: [PATCH 4/5] @bentley/imodeljs-native 5.0.47 --- common/config/rush/pnpm-lock.yaml | 10 +++++----- core/backend/package.json | 2 +- .../android/imodeljs-test-app/app/build.gradle | 2 +- .../imodeljs-test-app.xcodeproj/project.pbxproj | 2 +- .../core-test-runner.xcodeproj/project.pbxproj | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 0b2b6c57480b..149259f78fd7 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -16,8 +16,8 @@ importers: ../../core/backend: dependencies: '@bentley/imodeljs-native': - specifier: 5.0.44 - version: 5.0.44 + specifier: 5.0.47 + version: 5.0.47 '@itwin/cloud-agnostic-core': specifier: ^2.2.4 version: 2.2.4(inversify@6.0.1)(reflect-metadata@0.1.13) @@ -4661,8 +4661,8 @@ packages: '@bentley/icons-generic@1.0.34': resolution: {integrity: sha512-IIs1wDcY2oZ8tJ3EZRw0U51M+0ZL3MvwoDYYmhUXaa9/UZqpFoOyLBGaxjirQteWXqTIMm3mFvmC+Nbn1ok4Iw==} - '@bentley/imodeljs-native@5.0.44': - resolution: {integrity: sha512-cJQ+YReRBSacH2aBoalyCf27g4XE5RcC7eppUTTUB9AoQsaaFfoYrahiGK8+Pbo6qvXzptzR1RH5HsEtM4iNcQ==} + '@bentley/imodeljs-native@5.0.47': + resolution: {integrity: sha512-6FcYKNKTc7t2zfRgPB0fzhNMG6BnO0CWgs6TvnyH41qlRjj5Cbg7ZlZOkXgF+Gn5SnyI/hD9GoqIc5he/O4O+Q==} '@bentley/linear-referencing-schema@2.0.3': resolution: {integrity: sha512-2pFIEN4BS7alIDhGous6N2icKAS8ZhVBfoWB8WvSFaYnneGv5YwbbXl46qATDdPO5jUFezkW6uVxdpp1eOgUHQ==} @@ -11088,7 +11088,7 @@ snapshots: '@bentley/icons-generic@1.0.34': {} - '@bentley/imodeljs-native@5.0.44': {} + '@bentley/imodeljs-native@5.0.47': {} '@bentley/linear-referencing-schema@2.0.3': {} diff --git a/core/backend/package.json b/core/backend/package.json index ce437ddf6c03..9d6b16fee9a3 100644 --- a/core/backend/package.json +++ b/core/backend/package.json @@ -99,7 +99,7 @@ "webpack": "^5.97.1" }, "dependencies": { - "@bentley/imodeljs-native": "5.0.44", + "@bentley/imodeljs-native": "5.0.47", "@itwin/cloud-agnostic-core": "^2.2.4", "@itwin/object-storage-azure": "^2.2.5", "@itwin/object-storage-core": "^2.2.5", diff --git a/test-apps/display-test-app/android/imodeljs-test-app/app/build.gradle b/test-apps/display-test-app/android/imodeljs-test-app/app/build.gradle index fe866002c8b7..9fc4ea79464a 100644 --- a/test-apps/display-test-app/android/imodeljs-test-app/app/build.gradle +++ b/test-apps/display-test-app/android/imodeljs-test-app/app/build.gradle @@ -41,7 +41,7 @@ dependencies { implementation 'com.google.android.material:material:1.7.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.navigation:navigation-ui:2.5.3' - implementation 'com.github.itwin:mobile-native-android:5.0.44' + implementation 'com.github.itwin:mobile-native-android:5.0.47' implementation 'androidx.webkit:webkit:1.5.0' } diff --git a/test-apps/display-test-app/ios/imodeljs-test-app/imodeljs-test-app.xcodeproj/project.pbxproj b/test-apps/display-test-app/ios/imodeljs-test-app/imodeljs-test-app.xcodeproj/project.pbxproj index c005fd3ba167..7bebebc73ef7 100644 --- a/test-apps/display-test-app/ios/imodeljs-test-app/imodeljs-test-app.xcodeproj/project.pbxproj +++ b/test-apps/display-test-app/ios/imodeljs-test-app/imodeljs-test-app.xcodeproj/project.pbxproj @@ -455,7 +455,7 @@ repositoryURL = "https://github.com/iTwin/mobile-native-ios"; requirement = { kind = exactVersion; - version = 5.0.44; + version = 5.0.47; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/tools/internal/ios/core-test-runner/core-test-runner.xcodeproj/project.pbxproj b/tools/internal/ios/core-test-runner/core-test-runner.xcodeproj/project.pbxproj index 1c08f1153a7b..40ac31285da9 100644 --- a/tools/internal/ios/core-test-runner/core-test-runner.xcodeproj/project.pbxproj +++ b/tools/internal/ios/core-test-runner/core-test-runner.xcodeproj/project.pbxproj @@ -554,7 +554,7 @@ repositoryURL = "https://github.com/iTwin/mobile-native-ios"; requirement = { kind = exactVersion; - version = 5.0.44; + version = 5.0.47; }; }; /* End XCRemoteSwiftPackageReference section */ From 664c90a66c4193fb957df86935e8347ac9483cad Mon Sep 17 00:00:00 2001 From: soham-bentley <177123878+soham-bentley@users.noreply.github.com> Date: Thu, 30 Jan 2025 23:16:57 +0530 Subject: [PATCH 5/5] pnpm-lock.yaml updated --- common/config/rush/pnpm-lock.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 095e481754aa..5d0d9886007c 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -16,8 +16,8 @@ importers: ../../core/backend: dependencies: '@bentley/imodeljs-native': - specifier: 5.0.44 - version: 5.0.44 + specifier: 5.0.47 + version: 5.0.47 '@itwin/cloud-agnostic-core': specifier: ^2.2.4 version: 2.2.4(inversify@6.0.1)(reflect-metadata@0.1.13) @@ -4640,8 +4640,8 @@ packages: '@bentley/icons-generic@1.0.34': resolution: {integrity: sha512-IIs1wDcY2oZ8tJ3EZRw0U51M+0ZL3MvwoDYYmhUXaa9/UZqpFoOyLBGaxjirQteWXqTIMm3mFvmC+Nbn1ok4Iw==} - '@bentley/imodeljs-native@5.0.44': - resolution: {integrity: sha512-cJQ+YReRBSacH2aBoalyCf27g4XE5RcC7eppUTTUB9AoQsaaFfoYrahiGK8+Pbo6qvXzptzR1RH5HsEtM4iNcQ==} + '@bentley/imodeljs-native@5.0.47': + resolution: {integrity: sha512-6FcYKNKTc7t2zfRgPB0fzhNMG6BnO0CWgs6TvnyH41qlRjj5Cbg7ZlZOkXgF+Gn5SnyI/hD9GoqIc5he/O4O+Q==} '@bentley/linear-referencing-schema@2.0.3': resolution: {integrity: sha512-2pFIEN4BS7alIDhGous6N2icKAS8ZhVBfoWB8WvSFaYnneGv5YwbbXl46qATDdPO5jUFezkW6uVxdpp1eOgUHQ==} @@ -11045,7 +11045,7 @@ snapshots: '@bentley/icons-generic@1.0.34': {} - '@bentley/imodeljs-native@5.0.44': {} + '@bentley/imodeljs-native@5.0.47': {} '@bentley/linear-referencing-schema@2.0.3': {}