diff --git a/indexedDb/impl/channels/implementation.go b/indexedDb/impl/channels/implementation.go index 3657d634dad2e600f0def746abba74329a465740..803331357caa122fe00aaca7c77c296e21d4e3df 100644 --- a/indexedDb/impl/channels/implementation.go +++ b/indexedDb/impl/channels/implementation.go @@ -419,8 +419,7 @@ func (w *wasmModel) receiveHelper( result, err := impl.Put(w.db, messageStoreName, messageObj) // FIXME: The following is almost certainly causing a bug // where all of our upsert operations are failing. - if err != nil && !strings.Contains(err.Error(), - "at least one key does not satisfy the uniqueness requirements") { + if err != nil && !strings.Contains(err.Error(), impl.ErrUniqueConstraint) { // Only return non-unique constraint errors so that the case // below this one can be hit and handle duplicate entries properly. return 0, errors.Errorf("Unable to put Message: %+v", err) diff --git a/indexedDb/impl/dm/implementation.go b/indexedDb/impl/dm/implementation.go index 592719ad79cbe2972510c396444cd80e2754b4fe..d7582ea6b3d2268c0ce42d949ec743ae0d0db287 100644 --- a/indexedDb/impl/dm/implementation.go +++ b/indexedDb/impl/dm/implementation.go @@ -290,8 +290,7 @@ func (w *wasmModel) receiveHelper( result, err := impl.Put(w.db, messageStoreName, messageObj) // FIXME: The following is almost certainly causing a bug // where all of our upsert operations are failing. - if err != nil && !strings.Contains(err.Error(), - "at least one key does not satisfy the uniqueness requirements") { + if err != nil && !strings.Contains(err.Error(), impl.ErrUniqueConstraint) { // Only return non-unique constraint errors so that the case // below this one can be hit and handle duplicate entries properly. return 0, errors.Errorf("Unable to put Message: %+v", err) diff --git a/indexedDb/impl/utils.go b/indexedDb/impl/utils.go index 0fdb2315a1f580a675d7ebb93a257fd153056aae..93446fc101c94bbffe5c31427fa6c93b9142a3a2 100644 --- a/indexedDb/impl/utils.go +++ b/indexedDb/impl/utils.go @@ -30,6 +30,9 @@ const ( // ErrDoesNotExist is an error string for got undefined on Get operations. ErrDoesNotExist = "result is undefined" + + // ErrUniqueConstraint is an error string for failed uniqueness inserts. + ErrUniqueConstraint = "at least one key does not satisfy the uniqueness requirements" ) // NewContext builds a context for indexedDb operations.