@itwin/core-backend 4.4.0-dev.10 → 4.4.0-dev.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +2 -2
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangedElementsManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +241 -229
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.js +5 -5
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeometrySummary.js +47 -47
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.js +8 -8
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.js +1 -1
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +44 -44
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
- package/lib/cjs/assets/Settings/backend.setting.json5 +132 -132
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +13 -5
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +10 -5
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/package.json +12 -12
|
@@ -16,14 +16,14 @@ class ECDbMap {
|
|
|
16
16
|
this._cacheTables = new Map();
|
|
17
17
|
}
|
|
18
18
|
getAllDerivedClasses(classFullName) {
|
|
19
|
-
const sql = `
|
|
20
|
-
SELECT format('0x%x', ch.ClassId)
|
|
21
|
-
FROM [ec_cache_ClassHierarchy] [ch]
|
|
22
|
-
JOIN [ec_Class] [cs] ON [cs].[Id] = [ch].[BaseClassId]
|
|
23
|
-
JOIN [ec_Schema] [sc] ON [sc].[Id] = [cs].[SchemaId]
|
|
24
|
-
WHERE (([sc].[Alias] = :schemaNameOrAlias
|
|
25
|
-
OR [sc].[Name] = :schemaNameOrAlias)
|
|
26
|
-
AND ([cs].[Name] = :className))
|
|
19
|
+
const sql = `
|
|
20
|
+
SELECT format('0x%x', ch.ClassId)
|
|
21
|
+
FROM [ec_cache_ClassHierarchy] [ch]
|
|
22
|
+
JOIN [ec_Class] [cs] ON [cs].[Id] = [ch].[BaseClassId]
|
|
23
|
+
JOIN [ec_Schema] [sc] ON [sc].[Id] = [cs].[SchemaId]
|
|
24
|
+
WHERE (([sc].[Alias] = :schemaNameOrAlias
|
|
25
|
+
OR [sc].[Name] = :schemaNameOrAlias)
|
|
26
|
+
AND ([cs].[Name] = :className))
|
|
27
27
|
`;
|
|
28
28
|
return this.db.withPreparedSqliteStatement(sql, (stmt) => {
|
|
29
29
|
const parts = classFullName.indexOf(".") !== -1 ? classFullName.split(".") : classFullName.split(":");
|
|
@@ -38,34 +38,34 @@ class ECDbMap {
|
|
|
38
38
|
getTable(tableName) {
|
|
39
39
|
if (this._cacheTables.has(tableName))
|
|
40
40
|
return this._cacheTables.get(tableName);
|
|
41
|
-
const sql = `
|
|
42
|
-
SELECT
|
|
43
|
-
JSON_OBJECT (
|
|
44
|
-
'id', FORMAT ('0x%x', [t].[id]),
|
|
45
|
-
'name', [t].[Name],
|
|
46
|
-
'type', (
|
|
47
|
-
CASE
|
|
48
|
-
[t].[type]
|
|
49
|
-
WHEN 0 THEN 'Primary'
|
|
50
|
-
WHEN 1 THEN 'Joined'
|
|
51
|
-
WHEN 2 THEN 'Existing'
|
|
52
|
-
WHEN 3 THEN 'Overflow'
|
|
53
|
-
WHEN 4 THEN 'Virtual'
|
|
54
|
-
END
|
|
55
|
-
),
|
|
56
|
-
'exclusiveRootClassId', FORMAT ('0x%x', [t].[ExclusiveRootClassId]),
|
|
57
|
-
'isClassIdVirtual', (
|
|
58
|
-
SELECT
|
|
59
|
-
[c].[IsVirtual]
|
|
60
|
-
FROM
|
|
61
|
-
[ec_Column] [c]
|
|
62
|
-
WHERE
|
|
63
|
-
[c].[Name] = 'ECClassId' AND [c].[TableId] = [t].[Id]
|
|
64
|
-
)
|
|
65
|
-
)
|
|
66
|
-
FROM [ec_Table] [t]
|
|
67
|
-
WHERE
|
|
68
|
-
[t].[Name] = ?;
|
|
41
|
+
const sql = `
|
|
42
|
+
SELECT
|
|
43
|
+
JSON_OBJECT (
|
|
44
|
+
'id', FORMAT ('0x%x', [t].[id]),
|
|
45
|
+
'name', [t].[Name],
|
|
46
|
+
'type', (
|
|
47
|
+
CASE
|
|
48
|
+
[t].[type]
|
|
49
|
+
WHEN 0 THEN 'Primary'
|
|
50
|
+
WHEN 1 THEN 'Joined'
|
|
51
|
+
WHEN 2 THEN 'Existing'
|
|
52
|
+
WHEN 3 THEN 'Overflow'
|
|
53
|
+
WHEN 4 THEN 'Virtual'
|
|
54
|
+
END
|
|
55
|
+
),
|
|
56
|
+
'exclusiveRootClassId', FORMAT ('0x%x', [t].[ExclusiveRootClassId]),
|
|
57
|
+
'isClassIdVirtual', (
|
|
58
|
+
SELECT
|
|
59
|
+
[c].[IsVirtual]
|
|
60
|
+
FROM
|
|
61
|
+
[ec_Column] [c]
|
|
62
|
+
WHERE
|
|
63
|
+
[c].[Name] = 'ECClassId' AND [c].[TableId] = [t].[Id]
|
|
64
|
+
)
|
|
65
|
+
)
|
|
66
|
+
FROM [ec_Table] [t]
|
|
67
|
+
WHERE
|
|
68
|
+
[t].[Name] = ?;
|
|
69
69
|
`;
|
|
70
70
|
return this.db.withPreparedSqliteStatement(sql, (stmt) => {
|
|
71
71
|
stmt.bindString(1, tableName);
|
|
@@ -86,186 +86,186 @@ class ECDbMap {
|
|
|
86
86
|
getClassMap(classId) {
|
|
87
87
|
if (this._cachedClassMaps.has(classId))
|
|
88
88
|
return this._cachedClassMaps.get(classId);
|
|
89
|
-
const sql = `
|
|
90
|
-
SELECT
|
|
91
|
-
JSON_OBJECT(
|
|
92
|
-
'id', format('0x%x', cs.id),
|
|
93
|
-
'name', format('%s
|
|
94
|
-
'mapStrategy',
|
|
95
|
-
(
|
|
96
|
-
CASE cm.MapStrategy
|
|
97
|
-
WHEN 0 THEN 'NotMapped'
|
|
98
|
-
WHEN 1 THEN 'OwnTable'
|
|
99
|
-
WHEN 2 THEN 'TablePerHierarchy'
|
|
100
|
-
WHEN 3 THEN 'ExistingTable'
|
|
101
|
-
WHEN 10 THEN 'ForeignKeyInTargetTable'
|
|
102
|
-
WHEN 11 THEN 'ForeignKeyInSourceTable'
|
|
103
|
-
END
|
|
104
|
-
),
|
|
105
|
-
'type',
|
|
106
|
-
(
|
|
107
|
-
CASE cs.Type
|
|
108
|
-
WHEN 0 THEN 'Entity'
|
|
109
|
-
WHEN 1 THEN 'Relationship'
|
|
110
|
-
WHEN 2 THEN 'Struct'
|
|
111
|
-
WHEN 3 THEN 'CustomAttribute'
|
|
112
|
-
END
|
|
113
|
-
),
|
|
114
|
-
'modifier',
|
|
115
|
-
(
|
|
116
|
-
CASE cs.Modifier
|
|
117
|
-
WHEN 0 THEN 'None'
|
|
118
|
-
WHEN 1 THEN 'Abstract'
|
|
119
|
-
WHEN 2 THEN 'Sealed'
|
|
120
|
-
END
|
|
121
|
-
),
|
|
122
|
-
'properties',
|
|
123
|
-
(
|
|
124
|
-
SELECT
|
|
125
|
-
JSON_GROUP_ARRAY(JSON(propJson))
|
|
126
|
-
FROM
|
|
127
|
-
(
|
|
128
|
-
SELECT
|
|
129
|
-
JSON_OBJECT(
|
|
130
|
-
'id', format('0x%x', pt.id),
|
|
131
|
-
'name', pt.Name,
|
|
132
|
-
'kind',
|
|
133
|
-
(
|
|
134
|
-
CASE pt.Kind
|
|
135
|
-
WHEN 0 THEN 'Primitive'
|
|
136
|
-
WHEN 1 THEN 'Struct'
|
|
137
|
-
WHEN 2 THEN 'PrimitiveArray'
|
|
138
|
-
WHEN 3 THEN 'StructArray'
|
|
139
|
-
WHEN 4 THEN 'Navigation'
|
|
140
|
-
END
|
|
141
|
-
),
|
|
142
|
-
'primitiveType',
|
|
143
|
-
(
|
|
144
|
-
CASE pt.PrimitiveType
|
|
145
|
-
WHEN 0x101 THEN 'Binary'
|
|
146
|
-
WHEN 0x201 THEN 'Boolean'
|
|
147
|
-
WHEN 0x301 THEN 'DateTime'
|
|
148
|
-
WHEN 0x401 THEN 'Double'
|
|
149
|
-
WHEN 0x501 THEN 'Integer'
|
|
150
|
-
WHEN 0x601 THEN 'Long'
|
|
151
|
-
WHEN 0x701 THEN 'Point2d'
|
|
152
|
-
WHEN 0x801 THEN 'Point3d'
|
|
153
|
-
WHEN 0x901 THEN 'String'
|
|
154
|
-
WHEN 0xa01 THEN 'IGeometry'
|
|
155
|
-
END
|
|
156
|
-
),
|
|
157
|
-
'extendedTypeName', ExtendedTypeName,
|
|
158
|
-
'navigationRelationship',
|
|
159
|
-
(
|
|
160
|
-
SELECT
|
|
161
|
-
JSON_OBJECT(
|
|
162
|
-
'classId', format('0x%x', nc.Id),
|
|
163
|
-
'
|
|
164
|
-
)
|
|
165
|
-
FROM ec_Class nc
|
|
166
|
-
JOIN ec_Schema ns ON ns.Id = nc.SchemaId
|
|
167
|
-
WHERE
|
|
168
|
-
nc.Id = pt.NavigationRelationshipClassId
|
|
169
|
-
),
|
|
170
|
-
'structClass',
|
|
171
|
-
(
|
|
172
|
-
SELECT
|
|
173
|
-
JSON_OBJECT(
|
|
174
|
-
'classId', format('0x%x', nc.Id),
|
|
175
|
-
'
|
|
176
|
-
)
|
|
177
|
-
FROM ec_Class nc
|
|
178
|
-
JOIN ec_Schema ns ON ns.Id = nc.SchemaId
|
|
179
|
-
WHERE
|
|
180
|
-
nc.Id = pt.StructClassId
|
|
181
|
-
),
|
|
182
|
-
'dateTimeInfo', (
|
|
183
|
-
SELECT
|
|
184
|
-
JSON_OBJECT (
|
|
185
|
-
'dateTimeKind', (
|
|
186
|
-
CASE
|
|
187
|
-
WHEN [ca].[Instance] LIKE '%<DateTimeKind>Utc</DateTimeKind>%' COLLATE [NoCase] THEN 'Utc'
|
|
188
|
-
WHEN [ca].[Instance] LIKE '%<DateTimeKind>Local</DateTimeKind>%' COLLATE [NoCase] THEN 'Local'
|
|
189
|
-
ELSE 'Unspecified'
|
|
190
|
-
END
|
|
191
|
-
),
|
|
192
|
-
'dateTimeComponent', (
|
|
193
|
-
CASE
|
|
194
|
-
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>DateTime</DateTimeComponent>%' COLLATE [NoCase] THEN 'DateTime'
|
|
195
|
-
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>Date</DateTimeComponent>%' COLLATE [NoCase] THEN 'Date'
|
|
196
|
-
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>TimeOfDay</DateTimeComponent>%' COLLATE [NoCase] THEN 'TimeOfDay'
|
|
197
|
-
ELSE 'DateTime'
|
|
198
|
-
END
|
|
199
|
-
)
|
|
200
|
-
)
|
|
201
|
-
FROM
|
|
202
|
-
[ec_CustomAttribute] [ca]
|
|
203
|
-
JOIN [ec_Class] [cl] ON [cl].[Id] = [ca].[ClassId]
|
|
204
|
-
JOIN [ec_Schema] [sc] ON [sc].[Id] = [cl].[SchemaId]
|
|
205
|
-
WHERE
|
|
206
|
-
[ca].[ContainerType] = 992
|
|
207
|
-
AND [cl].[Name] = 'DateTimeInfo'
|
|
208
|
-
AND [sc].[Name] = 'CoreCustomAttributes'
|
|
209
|
-
AND [ca].[ContainerId] = [pt].[Id]
|
|
210
|
-
),
|
|
211
|
-
'columns',
|
|
212
|
-
(
|
|
213
|
-
SELECT
|
|
214
|
-
JSON_GROUP_ARRAY(JSON(columnJson))
|
|
215
|
-
FROM
|
|
216
|
-
(
|
|
217
|
-
SELECT
|
|
218
|
-
JSON_OBJECT(
|
|
219
|
-
'table', tb.Name,
|
|
220
|
-
'column', cc.Name,
|
|
221
|
-
'type',
|
|
222
|
-
(
|
|
223
|
-
CASE cc.Type
|
|
224
|
-
WHEN 0 THEN 'Any'
|
|
225
|
-
WHEN 1 THEN 'Boolean'
|
|
226
|
-
WHEN 2 THEN 'Blob'
|
|
227
|
-
WHEN 3 THEN 'Timestamp'
|
|
228
|
-
WHEN 4 THEN 'Real'
|
|
229
|
-
WHEN 5 THEN 'Integer'
|
|
230
|
-
WHEN 6 THEN 'Text'
|
|
231
|
-
END
|
|
232
|
-
),
|
|
233
|
-
'columnKind',
|
|
234
|
-
(
|
|
235
|
-
CASE cc.ColumnKind
|
|
236
|
-
WHEN 0 THEN 'Default'
|
|
237
|
-
WHEN 1 THEN 'Id'
|
|
238
|
-
WHEN 2 THEN 'ClassId'
|
|
239
|
-
WHEN 4 THEN 'SharedData'
|
|
240
|
-
END
|
|
241
|
-
),
|
|
242
|
-
'accessString', pp0.AccessString,
|
|
243
|
-
'isVirtual', cc.IsVirtual OR tb.Type = 4
|
|
244
|
-
) columnJson
|
|
245
|
-
FROM [ec_PropertyMap] [pm0]
|
|
246
|
-
JOIN [ec_Column] [cc] ON [cc].[Id] = [pm0].[ColumnId]
|
|
247
|
-
JOIN [ec_Table] [tb] ON [tb].[Id] = [cc].[TableId]
|
|
248
|
-
JOIN [ec_PropertyPath] [pp0] ON [pp0].[Id] = [pm0].[PropertyPathId]
|
|
249
|
-
WHERE
|
|
250
|
-
[pp0].[RootPropertyId] = pt.Id AND pm0.ClassId = cs.Id
|
|
251
|
-
)
|
|
252
|
-
)
|
|
253
|
-
) propJson
|
|
254
|
-
FROM [ec_PropertyMap] [pm]
|
|
255
|
-
JOIN [ec_PropertyPath] [pp] ON [pp].[Id] = [pm].[PropertyPathId]
|
|
256
|
-
JOIN [ec_Property] [pt] ON [pt].[Id] = [pp].[RootPropertyId]
|
|
257
|
-
WHERE
|
|
258
|
-
pm.ClassId = cs.Id
|
|
259
|
-
GROUP BY
|
|
260
|
-
pt.Id
|
|
261
|
-
)
|
|
262
|
-
)
|
|
263
|
-
) classDef
|
|
264
|
-
FROM [ec_Class] [cs]
|
|
265
|
-
JOIN [ec_ClassMap] [cm] ON [cm].[ClassId] = [cs].[Id]
|
|
266
|
-
JOIN [ec_Schema] [ss] ON [ss].[Id] = [cs].[SchemaId]
|
|
267
|
-
WHERE
|
|
268
|
-
[cs].[Id] = ?
|
|
89
|
+
const sql = `
|
|
90
|
+
SELECT
|
|
91
|
+
JSON_OBJECT(
|
|
92
|
+
'id', format('0x%x', cs.id),
|
|
93
|
+
'name', format('%s:%s', ss.Name, cs.Name),
|
|
94
|
+
'mapStrategy',
|
|
95
|
+
(
|
|
96
|
+
CASE cm.MapStrategy
|
|
97
|
+
WHEN 0 THEN 'NotMapped'
|
|
98
|
+
WHEN 1 THEN 'OwnTable'
|
|
99
|
+
WHEN 2 THEN 'TablePerHierarchy'
|
|
100
|
+
WHEN 3 THEN 'ExistingTable'
|
|
101
|
+
WHEN 10 THEN 'ForeignKeyInTargetTable'
|
|
102
|
+
WHEN 11 THEN 'ForeignKeyInSourceTable'
|
|
103
|
+
END
|
|
104
|
+
),
|
|
105
|
+
'type',
|
|
106
|
+
(
|
|
107
|
+
CASE cs.Type
|
|
108
|
+
WHEN 0 THEN 'Entity'
|
|
109
|
+
WHEN 1 THEN 'Relationship'
|
|
110
|
+
WHEN 2 THEN 'Struct'
|
|
111
|
+
WHEN 3 THEN 'CustomAttribute'
|
|
112
|
+
END
|
|
113
|
+
),
|
|
114
|
+
'modifier',
|
|
115
|
+
(
|
|
116
|
+
CASE cs.Modifier
|
|
117
|
+
WHEN 0 THEN 'None'
|
|
118
|
+
WHEN 1 THEN 'Abstract'
|
|
119
|
+
WHEN 2 THEN 'Sealed'
|
|
120
|
+
END
|
|
121
|
+
),
|
|
122
|
+
'properties',
|
|
123
|
+
(
|
|
124
|
+
SELECT
|
|
125
|
+
JSON_GROUP_ARRAY(JSON(propJson))
|
|
126
|
+
FROM
|
|
127
|
+
(
|
|
128
|
+
SELECT
|
|
129
|
+
JSON_OBJECT(
|
|
130
|
+
'id', format('0x%x', pt.id),
|
|
131
|
+
'name', pt.Name,
|
|
132
|
+
'kind',
|
|
133
|
+
(
|
|
134
|
+
CASE pt.Kind
|
|
135
|
+
WHEN 0 THEN 'Primitive'
|
|
136
|
+
WHEN 1 THEN 'Struct'
|
|
137
|
+
WHEN 2 THEN 'PrimitiveArray'
|
|
138
|
+
WHEN 3 THEN 'StructArray'
|
|
139
|
+
WHEN 4 THEN 'Navigation'
|
|
140
|
+
END
|
|
141
|
+
),
|
|
142
|
+
'primitiveType',
|
|
143
|
+
(
|
|
144
|
+
CASE pt.PrimitiveType
|
|
145
|
+
WHEN 0x101 THEN 'Binary'
|
|
146
|
+
WHEN 0x201 THEN 'Boolean'
|
|
147
|
+
WHEN 0x301 THEN 'DateTime'
|
|
148
|
+
WHEN 0x401 THEN 'Double'
|
|
149
|
+
WHEN 0x501 THEN 'Integer'
|
|
150
|
+
WHEN 0x601 THEN 'Long'
|
|
151
|
+
WHEN 0x701 THEN 'Point2d'
|
|
152
|
+
WHEN 0x801 THEN 'Point3d'
|
|
153
|
+
WHEN 0x901 THEN 'String'
|
|
154
|
+
WHEN 0xa01 THEN 'IGeometry'
|
|
155
|
+
END
|
|
156
|
+
),
|
|
157
|
+
'extendedTypeName', ExtendedTypeName,
|
|
158
|
+
'navigationRelationship',
|
|
159
|
+
(
|
|
160
|
+
SELECT
|
|
161
|
+
JSON_OBJECT(
|
|
162
|
+
'classId', format('0x%x', nc.Id),
|
|
163
|
+
'classFullName', format('%s:%s', ns.Name, nc.Name)
|
|
164
|
+
)
|
|
165
|
+
FROM ec_Class nc
|
|
166
|
+
JOIN ec_Schema ns ON ns.Id = nc.SchemaId
|
|
167
|
+
WHERE
|
|
168
|
+
nc.Id = pt.NavigationRelationshipClassId
|
|
169
|
+
),
|
|
170
|
+
'structClass',
|
|
171
|
+
(
|
|
172
|
+
SELECT
|
|
173
|
+
JSON_OBJECT(
|
|
174
|
+
'classId', format('0x%x', nc.Id),
|
|
175
|
+
'classFullName', format('%s:%s', ns.Name, nc.Name)
|
|
176
|
+
)
|
|
177
|
+
FROM ec_Class nc
|
|
178
|
+
JOIN ec_Schema ns ON ns.Id = nc.SchemaId
|
|
179
|
+
WHERE
|
|
180
|
+
nc.Id = pt.StructClassId
|
|
181
|
+
),
|
|
182
|
+
'dateTimeInfo', (
|
|
183
|
+
SELECT
|
|
184
|
+
JSON_OBJECT (
|
|
185
|
+
'dateTimeKind', (
|
|
186
|
+
CASE
|
|
187
|
+
WHEN [ca].[Instance] LIKE '%<DateTimeKind>Utc</DateTimeKind>%' COLLATE [NoCase] THEN 'Utc'
|
|
188
|
+
WHEN [ca].[Instance] LIKE '%<DateTimeKind>Local</DateTimeKind>%' COLLATE [NoCase] THEN 'Local'
|
|
189
|
+
ELSE 'Unspecified'
|
|
190
|
+
END
|
|
191
|
+
),
|
|
192
|
+
'dateTimeComponent', (
|
|
193
|
+
CASE
|
|
194
|
+
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>DateTime</DateTimeComponent>%' COLLATE [NoCase] THEN 'DateTime'
|
|
195
|
+
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>Date</DateTimeComponent>%' COLLATE [NoCase] THEN 'Date'
|
|
196
|
+
WHEN [ca].[Instance] LIKE '%<DateTimeComponent>TimeOfDay</DateTimeComponent>%' COLLATE [NoCase] THEN 'TimeOfDay'
|
|
197
|
+
ELSE 'DateTime'
|
|
198
|
+
END
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
FROM
|
|
202
|
+
[ec_CustomAttribute] [ca]
|
|
203
|
+
JOIN [ec_Class] [cl] ON [cl].[Id] = [ca].[ClassId]
|
|
204
|
+
JOIN [ec_Schema] [sc] ON [sc].[Id] = [cl].[SchemaId]
|
|
205
|
+
WHERE
|
|
206
|
+
[ca].[ContainerType] = 992
|
|
207
|
+
AND [cl].[Name] = 'DateTimeInfo'
|
|
208
|
+
AND [sc].[Name] = 'CoreCustomAttributes'
|
|
209
|
+
AND [ca].[ContainerId] = [pt].[Id]
|
|
210
|
+
),
|
|
211
|
+
'columns',
|
|
212
|
+
(
|
|
213
|
+
SELECT
|
|
214
|
+
JSON_GROUP_ARRAY(JSON(columnJson))
|
|
215
|
+
FROM
|
|
216
|
+
(
|
|
217
|
+
SELECT
|
|
218
|
+
JSON_OBJECT(
|
|
219
|
+
'table', tb.Name,
|
|
220
|
+
'column', cc.Name,
|
|
221
|
+
'type',
|
|
222
|
+
(
|
|
223
|
+
CASE cc.Type
|
|
224
|
+
WHEN 0 THEN 'Any'
|
|
225
|
+
WHEN 1 THEN 'Boolean'
|
|
226
|
+
WHEN 2 THEN 'Blob'
|
|
227
|
+
WHEN 3 THEN 'Timestamp'
|
|
228
|
+
WHEN 4 THEN 'Real'
|
|
229
|
+
WHEN 5 THEN 'Integer'
|
|
230
|
+
WHEN 6 THEN 'Text'
|
|
231
|
+
END
|
|
232
|
+
),
|
|
233
|
+
'columnKind',
|
|
234
|
+
(
|
|
235
|
+
CASE cc.ColumnKind
|
|
236
|
+
WHEN 0 THEN 'Default'
|
|
237
|
+
WHEN 1 THEN 'Id'
|
|
238
|
+
WHEN 2 THEN 'ClassId'
|
|
239
|
+
WHEN 4 THEN 'SharedData'
|
|
240
|
+
END
|
|
241
|
+
),
|
|
242
|
+
'accessString', pp0.AccessString,
|
|
243
|
+
'isVirtual', cc.IsVirtual OR tb.Type = 4
|
|
244
|
+
) columnJson
|
|
245
|
+
FROM [ec_PropertyMap] [pm0]
|
|
246
|
+
JOIN [ec_Column] [cc] ON [cc].[Id] = [pm0].[ColumnId]
|
|
247
|
+
JOIN [ec_Table] [tb] ON [tb].[Id] = [cc].[TableId]
|
|
248
|
+
JOIN [ec_PropertyPath] [pp0] ON [pp0].[Id] = [pm0].[PropertyPathId]
|
|
249
|
+
WHERE
|
|
250
|
+
[pp0].[RootPropertyId] = pt.Id AND pm0.ClassId = cs.Id
|
|
251
|
+
)
|
|
252
|
+
)
|
|
253
|
+
) propJson
|
|
254
|
+
FROM [ec_PropertyMap] [pm]
|
|
255
|
+
JOIN [ec_PropertyPath] [pp] ON [pp].[Id] = [pm].[PropertyPathId]
|
|
256
|
+
JOIN [ec_Property] [pt] ON [pt].[Id] = [pp].[RootPropertyId]
|
|
257
|
+
WHERE
|
|
258
|
+
pm.ClassId = cs.Id
|
|
259
|
+
GROUP BY
|
|
260
|
+
pt.Id
|
|
261
|
+
)
|
|
262
|
+
)
|
|
263
|
+
) classDef
|
|
264
|
+
FROM [ec_Class] [cs]
|
|
265
|
+
JOIN [ec_ClassMap] [cm] ON [cm].[ClassId] = [cs].[Id]
|
|
266
|
+
JOIN [ec_Schema] [ss] ON [ss].[Id] = [cs].[SchemaId]
|
|
267
|
+
WHERE
|
|
268
|
+
[cs].[Id] = ?
|
|
269
269
|
`;
|
|
270
270
|
return this.db.withPreparedSqliteStatement(sql, (stmt) => {
|
|
271
271
|
stmt.bindId(1, classId);
|
|
@@ -330,7 +330,7 @@ class PartialECChangeUnifier {
|
|
|
330
330
|
* Combine partial instance with instance with same key if already exists.
|
|
331
331
|
* @param rhs partial instance
|
|
332
332
|
*/
|
|
333
|
-
combine(rhs) {
|
|
333
|
+
combine(rhs, db) {
|
|
334
334
|
if (!rhs.$meta) {
|
|
335
335
|
throw new Error("PartialECChange being combine must have '$meta' property");
|
|
336
336
|
}
|
|
@@ -342,6 +342,21 @@ class PartialECChangeUnifier {
|
|
|
342
342
|
if (lhs.$meta && rhs.$meta) {
|
|
343
343
|
lhs.$meta.tables = [...rhs.$meta?.tables, ...lhs.$meta?.tables];
|
|
344
344
|
lhs.$meta.changeIndexes = [...rhs.$meta?.changeIndexes, ...lhs.$meta?.changeIndexes];
|
|
345
|
+
// we preserve child class name & id when merging instance.
|
|
346
|
+
if (rhs.$meta.fallbackClassId && lhs.$meta.fallbackClassId && db && rhs.$meta.fallbackClassId !== lhs.$meta.fallbackClassId) {
|
|
347
|
+
const lhsClassId = lhs.$meta.fallbackClassId;
|
|
348
|
+
const rhsClassId = rhs.$meta.fallbackClassId;
|
|
349
|
+
const isRhsIsSubClassOfLhs = db.withPreparedStatement("SELECT ec_instanceof(?,?)", (stmt) => {
|
|
350
|
+
stmt.bindId(1, rhsClassId);
|
|
351
|
+
stmt.bindId(2, lhsClassId);
|
|
352
|
+
stmt.step();
|
|
353
|
+
return stmt.getValue(0).getInteger() === 1;
|
|
354
|
+
});
|
|
355
|
+
if (isRhsIsSubClassOfLhs) {
|
|
356
|
+
lhs.$meta.fallbackClassId = rhs.$meta.fallbackClassId;
|
|
357
|
+
lhs.$meta.classFullName = rhs.$meta.classFullName;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
345
360
|
}
|
|
346
361
|
}
|
|
347
362
|
else {
|
|
@@ -371,14 +386,14 @@ class PartialECChangeUnifier {
|
|
|
371
386
|
throw new Error("this instance is marked as readonly.");
|
|
372
387
|
}
|
|
373
388
|
if (adaptor.op === "Updated" && adaptor.inserted && adaptor.deleted) {
|
|
374
|
-
this.combine(adaptor.inserted);
|
|
375
|
-
this.combine(adaptor.deleted);
|
|
389
|
+
this.combine(adaptor.inserted, adaptor.reader.db);
|
|
390
|
+
this.combine(adaptor.deleted, adaptor.reader.db);
|
|
376
391
|
}
|
|
377
392
|
else if (adaptor.op === "Inserted" && adaptor.inserted) {
|
|
378
|
-
this.combine(adaptor.inserted);
|
|
393
|
+
this.combine(adaptor.inserted, adaptor.reader.db);
|
|
379
394
|
}
|
|
380
395
|
else if (adaptor.op === "Deleted" && adaptor.deleted) {
|
|
381
|
-
this.combine(adaptor.deleted);
|
|
396
|
+
this.combine(adaptor.deleted, adaptor.reader.db);
|
|
382
397
|
}
|
|
383
398
|
}
|
|
384
399
|
/**
|
|
@@ -591,7 +606,7 @@ class ChangesetECAdaptor {
|
|
|
591
606
|
throw new Error(`unable to get change from changeset reader`);
|
|
592
607
|
}
|
|
593
608
|
let ecClassId = this.reader.op === "Inserted" ? change.inserted?.ECClassId : change.deleted?.ECClassId;
|
|
594
|
-
const
|
|
609
|
+
const classIdPresentInChange = !ecClassId;
|
|
595
610
|
let classMap;
|
|
596
611
|
let fallbackClassId;
|
|
597
612
|
if (table.isClassIdVirtual) {
|
|
@@ -604,12 +619,9 @@ class ChangesetECAdaptor {
|
|
|
604
619
|
if (primaryKeys.length === 1) {
|
|
605
620
|
ecClassId = this.getClassIdFromDb(this.reader.tableName, this.reader.primaryKeyValues[0]);
|
|
606
621
|
}
|
|
607
|
-
// this is update and does not include ECClassId and it was also not found from db
|
|
608
|
-
// so its unrecoverable error. Call can skip updates to ignore this error.
|
|
609
|
-
if (!ecClassId)
|
|
610
|
-
throw new Error(`change arg must contain 'ECClassId' property.`);
|
|
611
622
|
}
|
|
612
|
-
|
|
623
|
+
if (ecClassId)
|
|
624
|
+
classMap = this._mapCache.getClassMap(ecClassId);
|
|
613
625
|
if (!classMap) {
|
|
614
626
|
// fallback to root map for table.
|
|
615
627
|
classMap = this._mapCache.getClassMap(table.exclusiveRootClassId);
|
|
@@ -619,7 +631,7 @@ class ChangesetECAdaptor {
|
|
|
619
631
|
}
|
|
620
632
|
if (!classMap)
|
|
621
633
|
throw new Error(`unable to load class map`);
|
|
622
|
-
if (!
|
|
634
|
+
if (!classIdPresentInChange && !ecClassId)
|
|
623
635
|
ecClassId = classMap.id;
|
|
624
636
|
if (this._allowedClasses.size !== 0) {
|
|
625
637
|
if (!this._allowedClasses.has(classMap.id))
|
|
@@ -628,7 +640,7 @@ class ChangesetECAdaptor {
|
|
|
628
640
|
const $meta = {
|
|
629
641
|
tables: [this.reader.tableName],
|
|
630
642
|
op: this.reader.op,
|
|
631
|
-
|
|
643
|
+
classFullName: classMap.name,
|
|
632
644
|
fallbackClassId,
|
|
633
645
|
changeIndexes: [this.reader.changeIndex],
|
|
634
646
|
};
|