@@ -54,7 +54,7 @@ func (m *Miniredis) cmdHset(c *server.Peer, cmd string, args []string) {
5454 return
5555 }
5656
57- if t , ok := db .keys [key ]; ok && t != "hash" {
57+ if t , ok := db .keys [key ]; ok && t != keyTypeHash {
5858 c .WriteError (msgWrongType )
5959 return
6060 }
@@ -91,14 +91,14 @@ func (m *Miniredis) cmdHsetnx(c *server.Peer, cmd string, args []string) {
9191 withTx (m , c , func (c * server.Peer , ctx * connCtx ) {
9292 db := m .db (ctx .selectedDB )
9393
94- if t , ok := db .keys [opts .key ]; ok && t != "hash" {
94+ if t , ok := db .keys [opts .key ]; ok && t != keyTypeHash {
9595 c .WriteError (msgWrongType )
9696 return
9797 }
9898
9999 if _ , ok := db .hashKeys [opts .key ]; ! ok {
100100 db .hashKeys [opts .key ] = map [string ]string {}
101- db .keys [opts .key ] = "hash"
101+ db .keys [opts .key ] = keyTypeHash
102102 }
103103 _ , ok := db.hashKeys [opts.key ][opts.field ]
104104 if ok {
@@ -135,7 +135,7 @@ func (m *Miniredis) cmdHmset(c *server.Peer, cmd string, args []string) {
135135 withTx (m , c , func (c * server.Peer , ctx * connCtx ) {
136136 db := m .db (ctx .selectedDB )
137137
138- if t , ok := db .keys [key ]; ok && t != "hash" {
138+ if t , ok := db .keys [key ]; ok && t != keyTypeHash {
139139 c .WriteError (msgWrongType )
140140 return
141141 }
@@ -173,7 +173,7 @@ func (m *Miniredis) cmdHget(c *server.Peer, cmd string, args []string) {
173173 c .WriteNull ()
174174 return
175175 }
176- if t != "hash" {
176+ if t != keyTypeHash {
177177 c .WriteError (msgWrongType )
178178 return
179179 }
@@ -217,7 +217,7 @@ func (m *Miniredis) cmdHdel(c *server.Peer, cmd string, args []string) {
217217 c .WriteInt (0 )
218218 return
219219 }
220- if t != "hash" {
220+ if t != keyTypeHash {
221221 c .WriteError (msgWrongType )
222222 return
223223 }
@@ -270,7 +270,7 @@ func (m *Miniredis) cmdHexists(c *server.Peer, cmd string, args []string) {
270270 c .WriteInt (0 )
271271 return
272272 }
273- if t != "hash" {
273+ if t != keyTypeHash {
274274 c .WriteError (msgWrongType )
275275 return
276276 }
@@ -307,7 +307,7 @@ func (m *Miniredis) cmdHgetall(c *server.Peer, cmd string, args []string) {
307307 c .WriteMapLen (0 )
308308 return
309309 }
310- if t != "hash" {
310+ if t != keyTypeHash {
311311 c .WriteError (msgWrongType )
312312 return
313313 }
@@ -343,7 +343,7 @@ func (m *Miniredis) cmdHkeys(c *server.Peer, cmd string, args []string) {
343343 c .WriteLen (0 )
344344 return
345345 }
346- if db .t (key ) != "hash" {
346+ if db .t (key ) != keyTypeHash {
347347 c .WriteError (msgWrongType )
348348 return
349349 }
@@ -380,7 +380,7 @@ func (m *Miniredis) cmdHstrlen(c *server.Peer, cmd string, args []string) {
380380 c .WriteInt (0 )
381381 return
382382 }
383- if t != "hash" {
383+ if t != keyTypeHash {
384384 c .WriteError (msgWrongType )
385385 return
386386 }
@@ -414,7 +414,7 @@ func (m *Miniredis) cmdHvals(c *server.Peer, cmd string, args []string) {
414414 c .WriteLen (0 )
415415 return
416416 }
417- if t != "hash" {
417+ if t != keyTypeHash {
418418 c .WriteError (msgWrongType )
419419 return
420420 }
@@ -451,7 +451,7 @@ func (m *Miniredis) cmdHlen(c *server.Peer, cmd string, args []string) {
451451 c .WriteInt (0 )
452452 return
453453 }
454- if t != "hash" {
454+ if t != keyTypeHash {
455455 c .WriteError (msgWrongType )
456456 return
457457 }
@@ -479,7 +479,7 @@ func (m *Miniredis) cmdHmget(c *server.Peer, cmd string, args []string) {
479479 withTx (m , c , func (c * server.Peer , ctx * connCtx ) {
480480 db := m .db (ctx .selectedDB )
481481
482- if t , ok := db .keys [key ]; ok && t != "hash" {
482+ if t , ok := db .keys [key ]; ok && t != keyTypeHash {
483483 c .WriteError (msgWrongType )
484484 return
485485 }
@@ -530,7 +530,7 @@ func (m *Miniredis) cmdHincrby(c *server.Peer, cmd string, args []string) {
530530 withTx (m , c , func (c * server.Peer , ctx * connCtx ) {
531531 db := m .db (ctx .selectedDB )
532532
533- if t , ok := db .keys [opts .key ]; ok && t != "hash" {
533+ if t , ok := db .keys [opts .key ]; ok && t != keyTypeHash {
534534 c .WriteError (msgWrongType )
535535 return
536536 }
@@ -577,7 +577,7 @@ func (m *Miniredis) cmdHincrbyfloat(c *server.Peer, cmd string, args []string) {
577577 withTx (m , c , func (c * server.Peer , ctx * connCtx ) {
578578 db := m .db (ctx .selectedDB )
579579
580- if t , ok := db .keys [opts .key ]; ok && t != "hash" {
580+ if t , ok := db .keys [opts .key ]; ok && t != keyTypeHash {
581581 c .WriteError (msgWrongType )
582582 return
583583 }
@@ -662,7 +662,7 @@ func (m *Miniredis) cmdHscan(c *server.Peer, cmd string, args []string) {
662662 c .WriteLen (0 ) // no elements
663663 return
664664 }
665- if db .exists (opts .key ) && db .t (opts .key ) != "hash" {
665+ if db .exists (opts .key ) && db .t (opts .key ) != keyTypeHash {
666666 c .WriteError (ErrWrongType .Error ())
667667 return
668668 }
0 commit comments