Sfoglia il codice sorgente

db.ProductOptions

- fix bug of undefined `opt` column
Alexey Kim 2 anni fa
parent
commit
b0955b8555
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  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