Column parsing error on a coalesced integer value in a view where the coalesce values are from different tables.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
With the following 2 tables and view in an SQLite database:
CREATE TABLE table01 (
id INTEGER NOT NULL PRIMARY KEY,
name TEXT NOT NULL,
code TEXT NULL,
ranking INTEGER NULL,
table02id INTEGER NULL REFERENCES table02(id)
);
CREATE TABLE table02 (
id INTEGER NOT NULL PRIMARY KEY,
name TEXT NOT NULL,
code TEXT NULL,
ranking INTEGER NULL
);
CREATE VIEW view01 AS
SELECT
t1.id
, t1.name
, COALESCE(t2.code, t1.code) AS code
, COALESCE(t2.ranking, t1.ranking) AS ranking
FROM table01 t1 LEFT OUTER JOIN table02 t2 ON t1.table02id = t2.id;
After populating table01 with records that all have null code/ranking values and then creating 1 or 2 records in table02 with values in all columns and linking them to a couple of records in table01 I then try to fetch the data using the view into the following class:
public class TestModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Code { get; set; }
public int? Ranking { get; set; }
}
in batches using the query: "SELECT id, name, code, ranking FROM view01 ORDER BY id LIMIT @offset,@take"
The error "Error parsing column 3 (ranking=4 - Int64)" is thrown when a table02 ranking value is present. I tried replacing coalesce with a CASE statement, I have cast the COALESCE expression to an integer, i have replaced the column ranking with a cast to integer expression in the data select query, I also tried using the joined tables rather than the view - all give the same cast error.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the SQLite schema, view, TestModel, and paginated SELECT shown in the issue, including rows where table02.ranking is populated. Trace the resulting column-parsing failure and verify the fix against the same view query; done means ranking maps to int? without an exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sqlite
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100