Unexpected composed query behavior

Abierto
#732 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
sql
Área
databases

Línea de trabajo

Comienza reproduciendo los ejemplos de consultas compuestas usando DataContext, expresiones entre comillas y el join mostrado en el issue. Compara los valores generados o devueltos para la consulta con join con las variantes sin join y con retorno de tupla; se considera terminado cuando la consulta compuesta con join devuelve los mismos valores de ParameterId y ParameterName que la consulta directa.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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]

Lenguaje dominante
F#
Estrellas
627
Forks
147
Merge medio
2 h 2 min
PR fusionados (30 d)
1

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de fsprojects/SQLProvider

Todos los issues de fsprojects/SQLProvider

Issues similares

Más issues de Databases

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.