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

Rename extendType to extendedType and deprecate extendType #7372

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions common/api/core-common.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7513,6 +7513,8 @@ export enum QueryParamType {
export interface QueryPropertyMetaData {
accessString?: string;
className: string;
extendedType?: string;
// @deprecated
extendType: string;
generated: boolean;
index: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-backend",
"comment": "Added test case to document the behaviour of properties extendType and extendedType of QueryPropertyMetaData",
"type": "none"
}
],
"packageName": "@itwin/core-backend"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-common",
"comment": "Deprecated the property extendType of QueryPropertyMetaData and added new property extendedType to QueryPropertyMetaData",
"type": "none"
}
],
"packageName": "@itwin/core-common"
}
58 changes: 58 additions & 0 deletions core/backend/src/test/ecdb/ECSqlReader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,5 +551,63 @@ describe("ECSqlReader", (() => {
});

});

describe("Tests for extendedType and extendType property behaviour of QueryPropertyMetaData", () => {

it("Id type column with alias", async () => {
reader = iModel.createQueryReader("SELECT ECInstanceId customColumnName FROM meta.ECSchemaDef ORDER BY ECInstanceId ASC");
const metaData = await reader.getMetaData();
assert.equal("Id", metaData[0].extendedType);
assert.equal("Id", metaData[0].extendType);
assert.equal(metaData[0].extendedType, metaData[0].extendType);
});

it("Id type column without alias", async () => {
reader = iModel.createQueryReader("SELECT ECInstanceId FROM meta.ECSchemaDef ORDER BY ECInstanceId ASC");
const metaData = await reader.getMetaData();
assert.equal("Id", metaData[0].extendedType);
assert.equal("Id", metaData[0].extendType);
assert.equal(metaData[0].extendedType, metaData[0].extendType);
});

it("ClassId type column", async () => {
reader = iModel.createQueryReader("SELECT ECClassId FROM bis.Element ORDER BY ECClassId ASC");
const metaData = await reader.getMetaData();
assert.equal("ClassId", metaData[0].extendedType);
assert.equal("ClassId", metaData[0].extendType);
assert.equal(metaData[0].extendedType, metaData[0].extendType);
});

it("Column without extended type", async () => {
reader = iModel.createQueryReader("SELECT s.Name FROM meta.ECSchemaDef s ORDER BY s.Name ASC");
const metaData = await reader.getMetaData();
assert.equal(undefined, metaData[0].extendedType);
assert.equal("", metaData[0].extendType);
});

it("Column without extended type with alias", async () => {
reader = iModel.createQueryReader("SELECT s.Name a FROM meta.ECSchemaDef s ORDER BY a ASC");
const metaData = await reader.getMetaData();
assert.equal(undefined, metaData[0].extendedType);
assert.equal("", metaData[0].extendType);
});

it("Geometric type column with alias", async () => {
reader = iModel.createQueryReader("select GeometryStream A from bis.GeometricElement3d LIMIT 1");
const metaData = await reader.getMetaData();
assert.equal("Json", metaData[0].extendedType);
assert.equal("Json", metaData[0].extendType);
assert.equal(metaData[0].extendedType, metaData[0].extendType);
});

it("Geometric type column without alias", async () => {
reader = iModel.createQueryReader("select GeometryStream from bis.GeometricElement3d LIMIT 1");
const metaData = await reader.getMetaData();
assert.equal("Json", metaData[0].extendedType);
assert.equal("Json", metaData[0].extendType);
assert.equal(metaData[0].extendedType, metaData[0].extendType);
});

});
});
}));
6 changes: 5 additions & 1 deletion core/common/src/ConcurrentQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ export interface QueryPropertyMetaData {
jsonName: string;
/** The name is the property's alias if the property is a generated one, otherwise, it is the name of the property. */
name: string;
/** If this property is a PrimitiveECProperty, extend type is the extended type name of this property, if it is not defined locally will be inherited from base property if one exists, otherwise extended type is set to an empty string. */
/** If this property is a PrimitiveECProperty, extend type is the extended type name of this property, if it is not defined locally will be inherited from base property if one exists, otherwise extend type is set to an empty string.
* @deprecated in 4.10 Use extendedType instead
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have written @deprecated in 4.10 Is the version number okay? Or should I write something else?
@khanaffan

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4.10 is already released. It'll have to go in 4.11

*/
extendType: string;
/** If this property is a PrimitiveECProperty, extended type is the extended type name of this property, if it is not defined locally will be inherited from base property if one exists, otherwise extended type will be undefined. */
extendedType?: string;
/** The type name is set to 'navigation' if the property is a navigation property, otherwise, it is the type name for the property. */
typeName: string;
}
Expand Down
2 changes: 2 additions & 0 deletions core/common/src/ECSqlReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export class PropertyMetaDataMap implements Iterable<QueryPropertyMetaData> {

public constructor(public readonly properties: QueryPropertyMetaData[]) {
for (const property of this.properties) {
property.extendType = property.extendedType !== undefined ? property.extendedType : ""; // eslint-disable-line @typescript-eslint/no-deprecated
property.extendedType = property.extendedType === "" ? undefined : property.extendedType;
this._byPropName.set(property.name, property.index);
this._byJsonName.set(property.jsonName, property.index);
this._byNoCase.set(property.name.toLowerCase(), property.index);
Expand Down
Loading