MemberJunction / MemberJunction/MJ

v6.x: Remove deprecated Query*Info classes, provider query getters, and MJ_Metadata dataset items

Open
#2,697 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TSQL
Stars
29
Forks
6
Avg merge
2d 1h
Merged PRs (30d)
323

Description

## Context

In the 5.37.x cycle, we migrated all query-data consumers from `QueryInfo` / `Metadata.Provider.Queries` to `QueryEngine` / `MJQueryEntityExtended` (PRs #2695). All external consumers have been migrated — the deprecated code is only used internally within MJCore.

This issue tracks the **final removal** of the deprecated query-loading infrastructure for the next major version (v6.x).

## What to Remove

### 1. Database Migration — Remove DatasetItem Rows

Create a migration to delete the query-related `DatasetItem` rows from the `MJ_Metadata` dataset. This stops the metadata dataset from loading query data at startup (QueryEngine handles it independently).

```sql
-- Remove query-related items from the MJ_Metadata dataset
-- Dataset ID: e4adccec-6a37-ef11-86d4-000d3a4e707e
DELETE FROM ${flyway:defaultSchema}.DatasetItem
WHERE DatasetID = 'E4ADCCEC-6A37-EF11-86D4-000D3A4E707E'
AND Code IN (
'Queries',
'QueryCategories',
'QueryFields',
'QueryPermissions',
'QueryEntities',
'QueryParameters'
);
```

**Note:** `QueryDependencies`, `QuerySQLs`, and `SQLDialects` were never added as DatasetItems — they were only in the code-side `AllMetadataArrays` mapping. No database rows to delete for those.

### 2. Remove `AllMetadataArrays` Entries (providerBase.ts)

**File:** `packages/MJCore/src/generic/providerBase.ts` (lines ~112-120)

Remove these 9 entries from the `AllMetadataArrays` array:
- `{ key: 'AllQueryCategories', class: QueryCategoryInfo }`
- `{ key: 'AllQueries', class: QueryInfo }`
- `{ key: 'AllQueryFields', class: QueryFieldInfo }`
- `{ key: 'AllQueryPermissions', class: QueryPermissionInfo }`
- `{ key: 'AllQueryEntities', class: QueryEntityInfo }`
- `{ key: 'AllQueryParameters', class: QueryParameterInfo }`
- `{ key: 'AllQueryDependencies', class: QueryDependencyInfo }`
- `{ key: 'AllSQLDialects', class: SQLDialectInfo }`
- `{ key: 'AllQuerySQLs', class: QuerySQLInfo }`

### 3. Remove `AllMetadata` Properties (interfaces.ts)

**File:** `packages/MJCore/src/generic/interfaces.ts` (lines ~1444-1452)

Remove these 9 properties from the `AllMetadata` class:
- `AllQueryCategories`, `AllQueries`, `AllQueryFields`, `AllQueryPermissions`
- `AllQueryEntities`, `AllQueryParameters`, `AllQueryDependencies`
- `AllSQLDialects`, `AllQuerySQLs`

### 4. Remove `IMetadataProvider` Query Getters (interfaces.ts)

**File:** `packages/MJCore/src/generic/interfaces.ts` (lines ~561-577)

Remove these 9 getter declarations from `IMetadataProvider`:
- `Queries`, `QueryFields`, `QueryCategories`, `QueryPermissions`
- `QueryEntities`, `QueryParameters`, `QueryDependencies`
- `SQLDialects`, `QuerySQLs`

### 5. Remove `ProviderBase` Query Getters (providerBase.ts)

**File:** `packages/MJCore/src/generic/providerBase.ts` (lines ~2950-3012)

Remove the 9 corresponding getter implementations.

### 6. Remove `Metadata` Delegation Methods (metadata.ts)

**File:** `packages/MJCore/src/generic/metadata.ts` (lines ~132-146)

Remove the 4 query delegation methods: `Queries`, `QueryFields`, `QueryCategories`, `QueryPermissions`.

### 7. Remove Query*Info Classes (queryInfo.ts)

**File:** `packages/MJCore/src/generic/queryInfo.ts`

Remove the entire file or relocate any classes still needed internally. All 9 classes are deprecated:
- `QueryInfo`, `QueryFieldInfo`, `QueryCategoryInfo`, `QueryPermissionInfo`
- `QueryEntityInfo`, `QueryParameterInfo`, `QueryDependencyInfo`
- `QuerySQLInfo`, `SQLDialectInfo`

### 8. Update Internal MJCore Consumers

These MJCore-internal files reference the deprecated types and will need updating:
- `queryExecutionSpec.ts` — `QueryExecutionSpec.CreateExecutionSpec()` takes `QueryInfo`
- `runQuery.ts` — uses `QueryExecutionSpec`
- `column-descriptors.ts` — references `QueryFieldInfo`
- Remaining MJCore tests

### 9. Remove Exports

**File:** `packages/MJCore/src/index.ts`

Remove the export of `queryInfo.ts` (and potentially `queryInfoInterfaces.ts` if the `IQueryInfoBase` interfaces are no longer needed — though they may be kept as cross-package data contracts).

## What to Keep

- **`IQueryInfoBase`** and related interfaces in `queryInfoInterfaces.ts` — clean data contracts used by `SkipTypes` and cross-package exchange
- **`QueryCacheConfig`** interface — used by `MJQueryEntityExtended.CacheConfig` and `GenericDatabaseProvider`
- **`QueryExecutionSpec`** and `RunQueryParams` — query execution infrastructure (may need refactoring to accept `MJQueryEntityExtended` instead of `QueryInfo`)
- **`QueryEngine`** and `MJQueryEntityExtended` — the replacements

## Impact

- **Startup performance:** Removing 6 DatasetItems from `MJ_Metadata` eliminates 6 SQL queries from the startup dataset fetch
- **Memory:** No longer storing duplicate query data in both `AllMetadata` and `QueryEngine`
- **Breaking change:** Any external consumer still using `Metadata.Provider.Queries` or `QueryInfo` types will break — this is why it's a major version bump

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.