Browse Source

Highlight SQL errors in console, fix SQL

Vova Tkach 5 years ago
parent
commit
b97fa04715
2 changed files with 3 additions and 2 deletions
  1. 2 1
      engine/fetdata/shop.go
  2. 1 1
      engine/sqlw/log.go

+ 2 - 1
engine/fetdata/shop.go

@@ -294,7 +294,8 @@ func (this *Shop) load() *Shop {
 				shop_products.active = 1 AND
 				shop_cat_product_rel.category_id IN (` + strings.Join(cat_ids, ", ") + `)
 			GROUP BY
-				shop_products.id
+				shop_products.id,
+				cats.parent_id
 			ORDER BY
 				shop_products.id DESC
 			LIMIT ?, ?;

+ 1 - 1
engine/sqlw/log.go

@@ -20,7 +20,7 @@ func log(query string, s time.Time, e error, transaction bool) {
 	}
 	eStr := " (nil)"
 	if e != nil {
-		eStr = " (" + e.Error() + ") "
+		eStr = " \033[0m\033[0;31m(" + e.Error() + ")"
 	}
 	if consts.IS_WIN {
 		fmt.Fprintln(os.Stdout, "[SQL] "+msg+eStr+fmt.Sprintf(" %.3f ms", time.Now().Sub(s).Seconds()))