Skip to content

Exclude tempdb from the user -> login relationship query - #6

Open
quinten-elimity wants to merge 1 commit into
mainfrom
exclude-tempdb-in-user-login-query
Open

quinten-elimity wants to merge 1 commit into
mainfrom
exclude-tempdb-in-user-login-query

Conversation

@quinten-elimity

@quinten-elimity quinten-elimity commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

What changed

One line in config.hjson — the user -> login relationship query was the only query in the config that did not filter out tempdb:

     FROM sys.databases d
-    WHERE d.state_desc = 'ONLINE'
+    WHERE d.database_id <> 2
       AND d.state_desc = 'ONLINE'
       AND d.is_read_only = 0

Every other entity type and relationship query already carries d.database_id <> 2. Because this one didn't, it emitted relationships pointing at tempdb database principals that are never imported as user entities, and the import failed.

Reference files

Two files added alongside the config, as a readable record of the queries that were run and verified against the customer's instance:

  • entity_types.json — all 9 entity type queries. Verified identical to config.hjson; no change was needed.
  • relationships.json — all 12 relationship queries, including the fix above.

Both are generated straight from config.hjson, so the queries are guaranteed to match the ones that actually ship.

Verification

Every query in both files was diffed against config.hjson one by one, plus the attribute lists per entity type. The tempdb filter is the only functional difference. The original export also carried stray newlines inside the column aliases [dbname_objectid], [name] and [DatabaseName]; regenerating from the config removed them.

The user -> login query was the only query in the config that did not
filter out tempdb (database_id 2). Every other entity and relationship
query already carries `d.database_id <> 2`, so tempdb principals leaked
into this one relationship, pointing at users that are never imported as
entities, and the import failed.

Also adds entity_types.json and relationships.json as a readable record
of the queries that were run and verified against the customer's
instance. Both are generated from config.hjson, so the queries are
guaranteed to match the ones that ship.
@quinten-elimity
quinten-elimity force-pushed the exclude-tempdb-in-user-login-query branch from fb7c635 to 53b7f62 Compare September 15, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant