mongoose icon indicating copy to clipboard operation
mongoose copied to clipboard

Field names with '.' needs some sort of escaping

Open dagolden opened this issue 12 years ago • 3 comments

MongoDB doesn't allow '.' in keys within a hash. This needs to be detected and either get escaped somehow or else a sensible error get thrown.

The problem with escaping is that it makes searches more difficult, but it may be the least worst option.

dagolden avatar Apr 04 '13 23:04 dagolden

Could you submit a test case?

rodrigolive avatar Apr 05 '13 11:04 rodrigolive

This link suggests replacing with Unicode full-width equivalent could be OK: http://docs.mongodb.org/manual/faq/developers/#faq-dollar-sign-escaping

The issue is whether that should be a default behavior or optional. I can't imagine keys having full-width equivalents very often, so it might be a safe and useful default -- but would need to happen in queries as well. Or at least a helper function to escape keys used in queries would let users do it more easily.

dagolden avatar Apr 05 '13 16:04 dagolden

I'll check with the new driver that its yours and will close in some way this issue on a further release that will force the upgrade to the 1.x driver as it was almost a year since I've released the optional support for it 👍

diegok avatar Jul 08 '16 10:07 diegok