Giter Site home page Giter Site logo

Comments (8)

arieltorti avatar arieltorti commented on May 22, 2024 1

Tried on MongoDB 4.2 and 4.4. I just validated Mongo 3.6 and it fails as you mentioned:

Error: error: {
	"ok" : 0,
	"errmsg" : "$not cannot have a regex",
	"code" : 2,
	"codeName" : "BadValue"
}

Is there a way to configure montydb in a Mongo 4 compatible way to emulate this behavior?

from montydb.

davidlatwe avatar davidlatwe commented on May 22, 2024 1

Yeah, and I think I can take a deeper look at this weekend.

I'll take the query from the first comment as test case, do add more failed cases if you could.

Pull requests are welcomed too, do let me know if you guys have any issue on fixing/improving montydb.

🍻

from montydb.

arieltorti avatar arieltorti commented on May 22, 2024

@davidlatwe I was about to work to fix this issue and I noticed that when given a regex instance the parser uses it, for example:

 { "field": {"$not": bson.Regex("(?i)Hello World") } }

Works as intended because of this:

def _parse_not(self, sub_spec):
. Internally that's being handled as a "$regex" node, so I don't understand why the "$regex" node is disallowed when used in the subdocument.

As a side note, in MongoDB the following is valid: { "field": { "$not": { "$regex": "(?i)Hello World" } }}

from montydb.

davidlatwe avatar davidlatwe commented on May 22, 2024

Hey @arieltorti and @dgutson

The reason it's being blocked might be because the MongoDB version at the time I was implementing didn't allow it.

Which MongoDB version are you using?

You may have a look at the bottom of montydb/configure.py, there's some function patching for adjusting the behavior of montydb to match against a specific mongodb version.

I was tended to make sure montydb behaves exactly the same as the targeted mongodb version to avoid any unexpected result when the production code switching back to a real mongodb. Hope that make sense. 😄

from montydb.

davidlatwe avatar davidlatwe commented on May 22, 2024

Yes, you need to call set_storage before getting a client, take in-memory storage as example:

from montydb import MontyClient, set_storage


set_storage(
    repository=":memory:",
    storage="memory",
    mongo_version="4.0",  # available version: "3.6", "4.0", "4.2", "4.4"
)

client = MontyClient(":memory:")
...

from montydb.

dgutson avatar dgutson commented on May 22, 2024

@davidlatwe meaning: a fix has to be done in order to restore the behavior for mongodb 4.x?

from montydb.

arieltorti avatar arieltorti commented on May 22, 2024

@davidlatwe let me know if you're happy with that fix or we need to change it

from montydb.

davidlatwe avatar davidlatwe commented on May 22, 2024

The fix has been merged and released in 2.5.1, closing this now.

from montydb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.