瀏覽代碼

db.ProductOptions

- fix bug of undefined `opt` column
Alexey Kim 2 年之前
父節點
當前提交
b0955b8555
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      db/clickhouse.go

+ 2 - 2
db/clickhouse.go

@@ -239,11 +239,11 @@ func (db *clickhouse) ProductOptions(ln model.LanguageCode, id string) ([]*gener
 		l       = ttlcache.LoaderFunc[string, any](
 			func(ttl *ttlcache.Cache[string, any], _ string) *ttlcache.Item[string, any] {
 				var o []relation.ProductOption
-				rows, err := db.session.SelectBySql("SELECT "+
+				rows, err := db.session.SelectBySql("SELECT tuple('', 1) as opt, "+
 					strings.Join(key.Selection(), ", ")+
 					" FROM `"+key.Table()+"`"+
 					" ARRAY JOIN (SELECT `options` FROM `product` WHERE `id` = ?) AS oid"+
-					" WHERE `id` = oid", key.Args()).
+					" WHERE `id` = oid ORDER BY `position`;", key.Args()).
 					Load(&o)
 				if rows < 1 || err != nil {
 					return nil