{"record":{"id":"53679fecdd130b4a","repo":"dotnet/orleans","slug":"expected-a-single-column","errorCode":null,"errorMessage":"Expected a single column","messagePattern":"Expected a single column","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/AdoNet/Shared/Storage/DbStoredQueries.cs","lineNumber":288,"sourceCode":"            internal static Uri GetGatewayUri(IDataRecord record)\n            {\n                return GetSiloAddress(record, nameof(Columns.ProxyPort)).ToGatewayUri();\n            }\n\n            private static SiloAddress GetSiloAddress(IDataRecord record, string portName)\n            {\n                //Use the GetInt32 method instead of the generic GetValue<TValue> version to retrieve the value from the data record\n                //GetValue<int> causes an InvalidCastException with orcale data provider. See https://github.com/dotnet/orleans/issues/3561\n                int port = record.GetInt32(portName);\n                int generation = record.GetInt32(nameof(Columns.Generation));\n                string address = record.GetValue<string>(nameof(Columns.Address));\n                var siloAddress = SiloAddress.New(IPAddress.Parse(address), port, generation);\n                return siloAddress;\n            }\n\n            internal static bool GetSingleBooleanValue(IDataRecord record)\n            {\n                if (record.FieldCount != 1) throw new InvalidOperationException(\"Expected a single column\");\n                return Convert.ToBoolean(record.GetValue(0));\n            }\n        }\n\n        internal class Columns\n        {\n            private readonly IDbCommand command;\n\n            internal Columns(IDbCommand cmd)\n            {\n                command = cmd;\n\n            }\n\n            private void Add<T>(string paramName, T paramValue, DbType? dbType = null)\n            {\n                command.AddParameter(paramName, paramValue, dbType: dbType);\n            }","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AdoNet/Shared/Storage/DbStoredQueries.cs#L270-L306","documentation":"Thrown by DbStoredQueries.Converters.GetSingleBooleanValue when the IDataRecord has a FieldCount other than 1. This helper expects a query that returns exactly one column holding a boolean-ish value (used to confirm inserts/updates succeeded). A multi-column (or zero-column) result indicates the query text is wrong for its intended use.","triggerScenarios":"Calling GetSingleBooleanValue(record) on a record whose FieldCount != 1. Reached when an OrleansQuery entry used for a single-boolean check (e.g. an INSERT/UPDATE confirmation query) was authored to SELECT more than one column, or no columns at all.","commonSituations":"A custom or hand-edited OrleansQuery row returns extra columns (e.g. SELECT * instead of SELECT 1); schema scripts from a mismatched version; a query that returns a row count column alongside the boolean.","solutions":["Correct the offending OrleansQuery QueryText so it returns exactly one column convertible to Boolean (e.g. 'SELECT CAST(@@ROWCOUNT AS BIT)' or 'SELECT 1').","Re-apply the canonical Orleans setup script for your version to restore the intended single-column query.","Inspect the OrleansQuery table for the relevant key and fix the QueryText."],"exampleFix":"-- before (returns two columns)\nUPDATE ... ; SELECT 1, @@ROWCOUNT;\n\n-- after (single boolean column)\nUPDATE ... ; SELECT CAST(@@ROWCOUNT AS BIT);","handlingStrategy":"validation","validationCode":"// For queries intended to return a single boolean, assert shape before reading.\nif (record.FieldCount != 1)\n    throw new InvalidOperationException($\"Query must return exactly one column, got {record.FieldCount}.\");","typeGuard":null,"tryCatchPattern":"try { var ok = DbStoredQueries.Converters.GetSingleBooleanValue(record); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"single column\")) { /* fix the OrleansQuery text */ throw; }","preventionTips":["Author single-boolean queries to SELECT exactly one convertible column.","Avoid SELECT * in confirmation queries.","Re-apply canonical Orleans scripts if queries were hand-edited."],"tags":["adonet","stored-queries","schema","query-contract","database","orleans"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}