{"record":{"id":"13efe60c0b09ff2d","repo":"OrchardCMS/OrchardCore","slug":"missing-table-alias-for-path-alias-alias","errorCode":null,"errorMessage":"Missing table alias for path {alias.alias}.","messagePattern":"Missing table alias for path (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Predicates/PredicateQuery.cs","lineNumber":137,"sourceCode":"                }\n\n                return EnsureQuotes(tableAlias, alias.alias);\n            }\n\n            return EnsureQuotes(alias.alias);\n        }\n\n        var index = IndexOfUnquoted(propertyPath, '.');\n\n        // if empty prefix, use default (empty alias)\n        var aliasPath = index == -1 ? string.Empty : propertyPath[..index];\n\n        // get the actual index from the alias\n        if (_aliases.TryGetValue(aliasPath, out alias))\n        {\n            if (!_tableAliases.TryGetValue(alias.alias, out var tableAlias))\n            {\n                throw new InvalidOperationException($\"Missing table alias for path {alias.alias}.\");\n            }\n\n            // get the index property provider fore the alias\n            var propertyProvider = _propertyProviders.FirstOrDefault(x => x.IndexName.Equals(alias.alias, StringComparison.OrdinalIgnoreCase));\n\n            if (propertyProvider != null)\n            {\n                if (propertyProvider.TryGetValue(propertyPath[(index + 1)..], out var columnName))\n                {\n                    // Switch the given alias in the path with the mapped alias.\n                    // aliasPart.alias -> AliasPartIndex.Alias\n                    return EnsureQuotes(tableAlias, columnName);\n                }\n            }\n            else\n            {\n                // no property provider exists; hope sql is case-insensitive (will break postgres; property providers must be supplied for postgres)\n                // Switch the given alias in the path with the mapped alias.","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/Predicates/PredicateQuery.cs#L119-L155","documentation":"PredicateQuery.GetColumnName resolves an alias path to its physical column: after finding the alias it must look up the corresponding table alias in _tableAliases. When the alias record exists but its 'alias' key is absent from _tableAliases — the table join was never registered for that predicate path — the method throws InvalidOperationException so the query does not generate SQL against a missing table.","triggerScenarios":"Building a predicate/where clause for a path whose alias was added to _aliases but whose table alias was never registered (e.g. a filter path referencing an index/table that was not joined, or aliases registered out of order when composing the query).","commonSituations":"Custom GraphQL/Queries predicate referencing a field whose index table is not part of the query; typo in alias path so it resolves to a different alias; index profile changed after the query was saved.","solutions":["Register the table alias (via SetTableAlias/join logic) for the path before evaluating predicates.","Fix the alias path in the query so it matches a registered alias+table pair.","Recreate/refresh the index profile so alias and table registrations agree."],"exampleFix":"// before\npredicateQuery.SetAlias(\"SomePath\", \"SomeIndex\"); // alias added, but table alias never set\n// after\npredicateQuery.SetTableAlias(\"SomeIndex\", \"SomeTable\"); // register the table join too\npredicateQuery.SetAlias(\"SomePath\", \"SomeIndex\");","handlingStrategy":"validation","validationCode":"// before resolving columns, ensure every alias path has a table alias\nforeach (var (path, alias) in aliases)\n    if (!predicateQuery.HasTableAlias(alias.alias)) throw new InvalidOperationException($\"Path '{path}' has no registered table alias '{alias.alias}'.\");","typeGuard":null,"tryCatchPattern":"try { var column = predicateQuery.GetColumnName(aliasPath); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Missing table alias\")) { _logger.LogError(ex, \"Unjoined table for predicate path {Path}\", aliasPath); throw; }","preventionTips":["Always call SetTableAlias for an index before adding predicates on it.","Centralize alias registration so joins and aliases are added together.","Validate saved queries against current index profiles after schema changes."],"tags":["graphql","query","sql","aliasing"],"backgroundTag":"internal-invariant-violation","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}