Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -115,6 +115,11 @@ func GetAllProductPricingRows(ctx context.Context, chunkSize int, filters Produc
|
||||
orderExpr = "rc.ProductCode"
|
||||
orderDir = "ASC"
|
||||
}
|
||||
orderBySQL := orderExpr + ` ` + orderDir
|
||||
if !strings.EqualFold(strings.TrimSpace(orderExpr), "rc.ProductCode") {
|
||||
orderBySQL += `,
|
||||
rc.ProductCode ASC`
|
||||
}
|
||||
|
||||
baseQuery := `
|
||||
IF OBJECT_ID('tempdb..#req_codes') IS NOT NULL DROP TABLE #req_codes;
|
||||
@@ -230,8 +235,7 @@ func GetAllProductPricingRows(ctx context.Context, chunkSize int, filters Produc
|
||||
LEFT JOIN #disp_base db
|
||||
ON db.ItemCode = rc.ProductCode
|
||||
ORDER BY
|
||||
` + orderExpr + ` ` + orderDir + `,
|
||||
rc.ProductCode ASC;
|
||||
` + orderBySQL + `;
|
||||
`
|
||||
|
||||
rows, err := db.MssqlDB.QueryContext(ctx, baseQuery, args...)
|
||||
@@ -740,6 +744,11 @@ func GetProductPricingPage(ctx context.Context, page int, limit int, filters Pro
|
||||
orderExpr = "rc.ProductCode"
|
||||
orderDir = "ASC"
|
||||
}
|
||||
orderBySQL := orderExpr + ` ` + orderDir
|
||||
if !strings.EqualFold(strings.TrimSpace(orderExpr), "rc.ProductCode") {
|
||||
orderBySQL += `,
|
||||
rc.ProductCode ASC`
|
||||
}
|
||||
productQuery := `
|
||||
IF OBJECT_ID('tempdb..#req_codes') IS NOT NULL DROP TABLE #req_codes;
|
||||
IF OBJECT_ID('tempdb..#stock_base') IS NOT NULL DROP TABLE #stock_base;
|
||||
@@ -806,8 +815,7 @@ func GetProductPricingPage(ctx context.Context, page int, limit int, filters Pro
|
||||
LEFT JOIN #stock_base sb
|
||||
ON sb.ItemCode = rc.ProductCode
|
||||
ORDER BY
|
||||
` + orderExpr + ` ` + orderDir + `,
|
||||
rc.ProductCode ASC
|
||||
` + orderBySQL + `
|
||||
OFFSET ` + strconv.Itoa(offset) + ` ROWS
|
||||
FETCH NEXT ` + strconv.Itoa(limit) + ` ROWS ONLY;
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user