Skip to content

Commit 3f39a19

Browse files
Merge branch 'master' into MichelD/DefaultGoogleMapsOnly
2 parents 510a7d6 + 2548a65 commit 3f39a19

File tree

5 files changed

+39
-9
lines changed

5 files changed

+39
-9
lines changed

packages/itwin/grouping-mapping-widget/CHANGELOG.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
{
22
"name": "@itwin/grouping-mapping-widget",
33
"entries": [
4+
{
5+
"date": "Fri, 27 Jun 2025 03:45:17 GMT",
6+
"version": "0.35.3",
7+
"tag": "@itwin/grouping-mapping-widget_v0.35.3",
8+
"comments": {
9+
"patch": [
10+
{
11+
"author": "Guillar1@users.noreply.github.com",
12+
"package": "@itwin/grouping-mapping-widget",
13+
"commit": "73a4ca6f89a8ea401dc2aff68d60ac8b09f18242",
14+
"comment": "Fix Model property query generation."
15+
}
16+
]
17+
}
18+
},
419
{
520
"date": "Mon, 28 Apr 2025 11:04:44 GMT",
621
"version": "0.35.2",

packages/itwin/grouping-mapping-widget/CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
# Change Log - @itwin/grouping-mapping-widget
22

3-
This log was last generated on Mon, 28 Apr 2025 11:04:44 GMT and should not be manually modified.
3+
<!-- This log was last generated on Fri, 27 Jun 2025 03:45:17 GMT and should not be manually modified. -->
44

55
<!-- Start content -->
66

7+
## 0.35.3
8+
9+
Fri, 27 Jun 2025 03:45:17 GMT
10+
11+
### Patches
12+
13+
- Fix Model property query generation. ([#1357](https://github.com/iTwin/viewer-components-react/pull/1357))
14+
715
## 0.35.2
816

917
Mon, 28 Apr 2025 11:04:44 GMT

packages/itwin/grouping-mapping-widget/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@itwin/grouping-mapping-widget",
3-
"version": "0.35.2",
3+
"version": "0.35.3",
44
"description": "An iTwin.js 3D Viewer Widget that interfaces with the iTwin Reporting Platform.",
55
"keywords": [
66
"Bentley",

packages/itwin/grouping-mapping-widget/src/components/Groups/QueryBuilder/QueryBuilder.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ export class QueryBuilder {
164164
if (!isAspect && pathToPrimaryClass && pathToPrimaryClass.length > 0) {
165165
this.addRelatedToQuery(i, propertiesField, propertyName, propertyValue);
166166
} else {
167-
this.addPropertyToQuery(i, className, propertyName, propertyValue, this.needsQuote(propertiesField), isCategory, modeledElement, isAspect);
167+
// Model properties with display values always need quotes
168+
const needsQuote = !!modeledElement || this.needsQuote(propertiesField);
169+
this.addPropertyToQuery(i, className, propertyName, propertyValue, needsQuote, isCategory, modeledElement, isAspect);
168170
}
169171
}
170172
return true;
@@ -271,7 +273,12 @@ export class QueryBuilder {
271273
return;
272274
}
273275

274-
const foundPropertyClass = this.query.unions[unionIndex].properties.find((p) => p.className === className);
276+
// Model properties should be kept separate to ensure proper JOIN generation
277+
const foundPropertyClass = this.query.unions[unionIndex].properties.find((p) => {
278+
// Don't merge Model properties with regular properties
279+
if (!!modeledElementClass !== !!p.modeledElementClass) return false;
280+
return p.className === className;
281+
});
275282

276283
if (foundPropertyClass) {
277284
const foundJoin = foundPropertyClass?.classProperties.find((join) => join.name === propertyName);
@@ -316,9 +323,9 @@ export class QueryBuilder {
316323
whereSegments.push(this.categoryWhereQuery(property.classProperties[0].value.toString()));
317324
continue;
318325
} else if (property.modeledElementClass) {
319-
querySegments.set(property.modeledElementClass, [`${property.modeledElementClass}.ECInstanceId = BisCore.Element.Model.id`]);
326+
querySegments.set(property.modeledElementClass, [`${property.modeledElementClass}.ECInstanceId = ${baseClassName}.Model.id`]);
320327
whereSegments.push(
321-
`${property.modeledElementClass}.UserLabel = '${property.classProperties[0].value.toString()}' OR ${property.modeledElementClass}.CodeValue = '${property.classProperties[0].value.toString()}'`,
328+
`(${property.modeledElementClass}.UserLabel = '${property.classProperties[0].value.toString()}' OR ${property.modeledElementClass}.CodeValue = '${property.classProperties[0].value.toString()}')`,
322329
);
323330
continue;
324331
}
@@ -342,8 +349,8 @@ export class QueryBuilder {
342349

343350
unionSegments.push([selectClause, ...joinClauses, whereClause].join(" "));
344351
}
345-
346-
return unionSegments.join(" UNION ");
352+
const result = unionSegments.join(" UNION ");
353+
return result;
347354
}
348355

349356
private selectClause(baseProperty: QueryProperty | undefined, baseClass: QueryClass | undefined) {

packages/itwin/grouping-mapping-widget/src/test/QueryBuilder.testdata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ export const testCases: QueryBuilderTestData = {
12641264
{
12651265
name: "when property is a model, return a model query string",
12661266
expectedResult:
1267-
"SELECT BisCore.B.ECInstanceId, BisCore.B.ECClassId FROM BisCore.B JOIN mockModeledElement ON mockModeledElement.ECInstanceId = BisCore.Element.Model.id WHERE mockModeledElement.UserLabel = 'displayValueString' OR mockModeledElement.CodeValue = 'displayValueString'",
1267+
"SELECT BisCore.B.ECInstanceId, BisCore.B.ECClassId FROM BisCore.B JOIN mockModeledElement ON mockModeledElement.ECInstanceId = BisCore.B.Model.id WHERE (mockModeledElement.UserLabel = 'displayValueString' OR mockModeledElement.CodeValue = 'displayValueString')",
12681268
operations: [
12691269
{
12701270
expectedResult: true,

0 commit comments

Comments
 (0)