Unexpected composed query behavior
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by reproducing the composed query examples using DataContext, quoted expressions, and the join shown in the issue. Compare the generated or returned values for the joined query with the non-joined and tuple-returning variants; done means the composed joined query returns the same ParameterId and ParameterName values as the direct query.
Written by the indexing model from the issue text.
Description
Describe the bug
When using composed queries an unexpected behavior occurs when a join is involved in a query. This results in a select with wrong values. See code examples below.
To Reproduce
let ctx = DataContext.getDataContextWithLog()
// === normal query with expected result
query {
for p in ctx.Dbo.Parameters do
join c in ctx.Dbo.ParametersCategories on
(p.CategoryId = c.CategoryId)
select p
}
|> Seq.toList
|> List.take 3
|> List.map (fun p -> p.ParameterId, p.ParameterName)
// Result:
// val it : (int16 * string) list =
// [(3743s, "Allerg (T1) IgE-totaal"); (3744s, "Allerg (T1) Tryptase");
// (3745s, "Allerg (T1) Huisstofmijt")]
// === composed query with unexpected result
let get (ctx : DataContext.sql.dataContext) =
<@ fun _ ->
query {
for p in ctx.Dbo.Parameters do
join c in ctx.Dbo.ParametersCategories on
(p.CategoryId = c.CategoryId)
select (p)
} @>
query {
for (p) in ((%get ctx) ()) do
select (p.ParameterId, p.ParameterName)
}
|> Seq.toList
|> List.take 3
// Result:
// val get :
// ctx:FSharp.Data.Sql.SqlDataProvider<...>.dataContext ->
// Quotations.Expr<('a ->
// Linq.IQueryable<FSharp.Data.Sql.SqlDataProvider<...>.dataContext.dbo.ParametersEntity>)>
// val it : (int16 * string) list = [(0s, ""); (0s, ""); (0s, "")]
// == composed query without join with expected result
let get (ctx : DataContext.sql.dataContext) =
<@ fun _ ->
query {
for p in ctx.Dbo.Parameters do
// join c in ctx.Dbo.ParametersCategories on
// (p.CategoryId = c.CategoryId)
select (p)
} @>
query {
for (p) in ((%get ctx) ()) do
select (p.ParameterId, p.ParameterName)
}
|> Seq.toList
|> List.take 3
// Result:
// val get :
// ctx:FSharp.Data.Sql.SqlDataProvider<...>.dataContext ->
// Quotations.Expr<('a ->
// Linq.IQueryable<FSharp.Data.Sql.SqlDataProvider<...>.dataContext.dbo.ParametersEntity>)>
// val it : (int16 * string) list =
// [(3743s, "Allerg (T1) IgE-totaal"); (3744s, "Allerg (T1) Tryptase");
// (3745s, "Allerg (T1) Huisstofmijt")]
// == composed query with a tuple return with a 'dummy' unit value returns expected result!?
let get (ctx : DataContext.sql.dataContext) =
<@ fun _ ->
query {
for p in ctx.Dbo.Parameters do
join c in ctx.Dbo.ParametersCategories on
(p.CategoryId = c.CategoryId)
select (p, ())
} @>
query {
for (p, _) in ((%get ctx) ()) do
select (p.ParameterId, p.ParameterName)
}
|> Seq.toList
|> List.take 3
// Result:
// val it : (int16 * string) list =
// [(3743s, "Allerg (T1) IgE-totaal"); (3744s, "Allerg (T1) Tryptase");
// (3745s, "Allerg (T1) Huisstofmijt")]
Expected behavior
Clearly the second query result is inconsistent with the other queries.
Desktop (please complete the following information):
.NET SDK (reflecting any global.json):
Version: 5.0.202
Commit: db7cc87d51
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.202\
Host (useful for support):
Version: 5.0.5
Commit: 2f740adc14
.NET SDKs installed:
5.0.200-preview.21077.7 [C:\Program Files\dotnet\sdk]
5.0.201 [C:\Program Files\dotnet\sdk]
5.0.202 [C:\Program Files\dotnet\sdk]
- Dominant language
- F#
- Stars
- 627
- Forks
- 147
- Avg merge
- 2h 2m
- Merged PRs (30d)
- 1
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.
More from fsprojects/SQLProvider
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 55/100
fsprojects/SQLProvider#872 · 2 comments ·
-
Repo Assist? Openenhancement
Difficulty 5/5 Over a week Newbie friendliness 10/100
fsprojects/SQLProvider#870 · 1 comment ·
-
postgresql
Difficulty 4/5 3-5 days Newbie friendliness 58/100
fsprojects/SQLProvider#869 · 2 comments ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
fsprojects/SQLProvider#868 · 2 comments ·
-
sql server
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fsprojects/SQLProvider#851 · 1 comment ·
All issues in fsprojects/SQLProvider
Similar issues
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
[BUG] A column whose default is the empty string is drawn in the ER diagram as having no default Openbug database-provider good first issue hacktoberfest
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
libredb/libredb-studio#1030 · 6 comments ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug redshift
Difficulty 2/5 1-3 hours Newbie friendliness 88/100