{"record":{"id":"61159bd0cb203891","repo":"tursodatabase/turso","slug":"unknown-column-column","errorCode":null,"errorMessage":"Unknown column: {column}","messagePattern":"Unknown column: (.+?)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Serverless.Client/TursoResultSet.cs","lineNumber":64,"sourceCode":"    public byte[]? GetBytes(int index) => (byte[]?)_values[index];\n\n    public byte[]? GetBytes(string column) => (byte[]?)this[column];\n\n    public IEnumerator<object?> GetEnumerator() => ((IEnumerable<object?>)_values).GetEnumerator();\n\n    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\n\n    private int IndexOf(string column)\n    {\n        for (var i = 0; i < _columns.Count; i++)\n        {\n            if (string.Equals(_columns[i], column, StringComparison.OrdinalIgnoreCase))\n            {\n                return i;\n            }\n        }\n\n        throw new ArgumentException($\"Unknown column: {column}\", nameof(column));\n    }\n}\n\n/// <summary>The fully materialized result of a SQL statement.</summary>\npublic sealed class TursoResultSet\n{\n    internal TursoResultSet(IReadOnlyList<string> columns, IReadOnlyList<string> columnTypes, IReadOnlyList<TursoRow> rows, long rowsAffected, long? lastInsertRowid)\n    {\n        Columns = columns;\n        ColumnTypes = columnTypes;\n        Rows = rows;\n        RowsAffected = rowsAffected;\n        LastInsertRowid = lastInsertRowid;\n    }\n\n    /// <summary>Result column names, in order.</summary>\n    public IReadOnlyList<string> Columns { get; }\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/dotnet/src/Turso.Serverless.Client/TursoResultSet.cs#L46-L82","documentation":"TursoRow resolves column access by name using a case-insensitive linear scan over the columns the server reported for that statement. If no reported column matches the requested name, IndexOf throws ArgumentException with 'Unknown column: <name>'.","triggerScenarios":"row[\"Name\"] when the statement selected name (case-insensitive match saves you, but 'Names' or ' name ' does not); row[\"id\"] on SELECT a, b; indexing a row from one result set with the column list of another; renamed schema columns.","commonSituations":"SELECT * over a JOIN where the expected column does not exist; schema drift between environments (column renamed in staging); copy-pasted accessors from a different query; trailing whitespace in aliased columns.","solutions":["Inspect the actual names via string.Join(\",\", result.Columns) and use the exact name returned","Alias columns in SQL to the name your code expects: SELECT user_id AS id FROM ...","Confirm you are reading rows from the statement whose columns you checked","Guard accessors with a helper that falls back to TryGetValue-style lookup during development builds"],"exampleFix":"// before\nvar id = row[\"userid\"]; // column is actually user_id\n\n// after\n// SELECT user_id AS userid ...  (alias in SQL)\nvar id = row[\"userid\"];","handlingStrategy":"validation","validationCode":"var names = result.Columns; // IReadOnlyList<string>\nif (!names.Contains(column, StringComparer.OrdinalIgnoreCase)) throw new InvalidOperationException($\"Column '{column}' not in [{string.Join(\",\", names)}]\");","typeGuard":"bool HasColumn(TursoResultSet rs, string name) => rs.Columns.Any(c => string.Equals(c, name, StringComparison.OrdinalIgnoreCase));","tryCatchPattern":"try { var v = row[column]; } catch (ArgumentException ex) when (ex.Message.StartsWith(\"Unknown column\")) { log.Info($\"Available: {string.Join(\",\", result.Columns)}\"); throw; }","preventionTips":["Derive accessors from the statement's SELECT list, not from memory","Alias columns in SQL to names your code owns","Log result.Columns once when onboarding a new query"],"tags":["csharp","dotnet","result-set","column-lookup"],"backgroundTag":"unknown-column-name","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}