Fix broken filtering through discriminator
This commit is contained in:
@@ -11,6 +11,10 @@ import (
|
||||
func (c *MongoClient) DiscriminatorCheckAndApplyToData(ctx context.Context, name string, data map[string]any) error {
|
||||
cdef, ok := c.Registry[name]
|
||||
if ok && cdef.Discriminator != nil {
|
||||
if data == nil {
|
||||
data = map[string]any{}
|
||||
}
|
||||
|
||||
log.Printf("Discriminator found for %s; will use it", name)
|
||||
|
||||
// get from context
|
||||
@@ -30,6 +34,10 @@ func (c *MongoClient) DiscriminatorCheckAndApplyToData(ctx context.Context, name
|
||||
func (c *MongoClient) DiscriminatorCheckAndApplyToFilter(ctx context.Context, name string, filter bson.M) error {
|
||||
cdef, ok := c.Registry[name]
|
||||
if ok && cdef.Discriminator != nil {
|
||||
if filter == nil {
|
||||
filter = bson.M{}
|
||||
}
|
||||
|
||||
log.Printf("Discriminator found for %s; will use it", name)
|
||||
|
||||
// get from context
|
||||
|
||||
Reference in New Issue
Block a user