2013-04-25 2 views
0

직장에서 프로젝트 작업 중이 문제가 발견되었지만 Breeze의 DocCode 샘플을 사용하여 복제 할 수있었습니다. 나는 최신 1.3.0을 사용하고있다. 기본적으로 잘못된 레코드는 'expand', 'orderby'및 'take'를 사용할 때 쿼리에서 반환됩니다. 문제는 queryTests.js에서 시험을 '내림차순 관련 카테고리로 분류 제품'으로 설명 될 수 있습니다 :.expand .orderby .take를 사용할 때 Breeze/EntityFramework 버그가 발생할 수 있음

쿼리를 테스트에서 것은 다음 SQL 원인

var query = EntityQuery.from("Products") 
     .expand("Category") 
     .orderBy("Category.CategoryName desc, ProductName"); 

SQL Server에 발행하는 :

SELECT 
[Extent1].[ProductID] AS [ProductID], 
[Extent1].[ProductName] AS [ProductName], 
[Extent1].[SupplierID] AS [SupplierID], 
[Extent1].[CategoryID] AS [CategoryID], 
[Extent1].[QuantityPerUnit] AS [QuantityPerUnit], 
[Extent1].[UnitPrice] AS [UnitPrice], 
[Extent1].[UnitsInStock] AS [UnitsInStock], 
[Extent1].[UnitsOnOrder] AS [UnitsOnOrder], 
[Extent1].[ReorderLevel] AS [ReorderLevel], 
[Extent1].[Discontinued] AS [Discontinued], 
[Extent2].[CategoryID] AS [CategoryID1], 
[Extent2].[CategoryName] AS [CategoryName], 
[Extent2].[Description] AS [Description], 
[Extent2].[Picture] AS [Picture] 
FROM [dbo].[Products] AS [Extent1] 
LEFT OUTER JOIN [dbo].[Categories] AS [Extent2] ON [Extent1].[CategoryID] = [Extent2].[CategoryID] 
ORDER BY [Extent2].[CategoryName] DESC, [Extent1].[ProductName] ASC 

어떤 것이 좋으며 올바른 결과가 CategoryName별로 정렬되어 있습니다. 그러나 쿼리를 다음과 같이 변경하면 :

var query = EntityQuery.from("Products") 
     .expand("Category") 
     .orderBy("Category.CategoryName desc, ProductName").take(10); 

'.take (10)'을 추가했습니다. 는 SQL이된다 : Extent1가 잘못된 레코드가 반환되는 리드 대신 범주의 제품 ID에 의해 지시되고 있기 때문에 잘못

exec sp_executesql N'SELECT 
[Limit1].[ProductID] AS [ProductID], 
[Limit1].[ProductName] AS [ProductName], 
[Limit1].[SupplierID] AS [SupplierID], 
[Limit1].[CategoryID1] AS [CategoryID], 
[Limit1].[QuantityPerUnit] AS [QuantityPerUnit], 
[Limit1].[UnitPrice] AS [UnitPrice], 
[Limit1].[UnitsInStock] AS [UnitsInStock], 
[Limit1].[UnitsOnOrder] AS [UnitsOnOrder], 
[Limit1].[ReorderLevel] AS [ReorderLevel], 
[Limit1].[Discontinued] AS [Discontinued], 
[Extent3].[CategoryID] AS [CategoryID1], 
[Extent3].[CategoryName] AS [CategoryName], 
[Extent3].[Description] AS [Description], 
[Extent3].[Picture] AS [Picture] 
FROM (SELECT TOP (@p__linq__0) [Extent1].[ProductID] AS [ProductID], [Extent1].[ProductName] AS [ProductName]\, [Extent1].[SupplierID] AS [SupplierID], [Extent1].[CategoryID] AS [CategoryID1], [Extent1].[QuantityPerUnit] AS [QuantityPerUnit], [Extent1].[UnitPrice] AS [UnitPrice], [Extent1].[UnitsInStock] AS [UnitsInStock], [Extent1].[UnitsOnOrder] AS [UnitsOnOrder], [Extent1].[ReorderLevel] AS [ReorderLevel], [Extent1].[Discontinued] AS [Discontinued], [Extent2].[CategoryName] AS [CategoryName] 
    FROM [dbo].[Products] AS [Extent1] 
    LEFT OUTER JOIN [dbo].[Categories] AS [Extent2] ON [Extent1].[CategoryID] = [Extent2].[CategoryID] 
    ORDER BY [Extent1].[ProductID] ASC) AS [Limit1] 
LEFT OUTER JOIN [dbo].[Categories] AS [Extent3] ON [Limit1].[CategoryID1] = [Extent3].[CategoryID] 
ORDER BY [Limit1].[CategoryName] DESC, [Limit1].[ProductName] ASC',N'@p__linq__0 int',@p__linq__0=10 

합니다.

버그입니까? 제가 잘못 했나요?

답변

0

편집 : v 1.3.2부터 수정해야합니다. 문제가 계속되면 여기에 다시 게시하십시오.


좋아, 이제 막 repro'd했습니다. 이것은 버그입니다. 발견하고보고 해 주셔서 감사합니다. 나는 다음 릴리스에서 문제를 해결하려고 노력할 것이다. 들어가면 여기에 다시 게시 해 드리겠습니다.

+0

감사합니다. Jay, 다음 주에 언젠가는 업데이트를 테스트 할 수 있어야합니다. –

+0

v1.4를 사용 중이며 비슷한 시나리오에서이 동작이 계속 표시됩니다. 나는 이것이 정말로 오래된 스레드라는 것을 알고 있습니다 - 누군가가 여전히 그것을보고 싶어하면 – Nick

+0

위의 쿼리 또는 다른 것을 실행하고 있습니까? –

관련 문제