Skip to content

Cannot save CharField and TextField with values starting with $Β #444

@artyom-smushkov

Description

@artyom-smushkov

String values that start with dollar sign seem to be interpreted as expressions and are skipped on save since expression is invalid. Here are some details:

django-mongodb-backend version:

> pip freeze | rg django-mon
django-mongodb-backend==5.2.2

Model to reproduce issue on:

class TestModel(models.Model):
    text = models.TextField()

    class Meta:
        managed = False

Copypasta from django shell:

In [1]: t = TestModel.objects.first()

In [2]: t.text
Out[2]: 'foobar'

In [3]: t.text = '$foobar'

In [4]: t.save()

In [5]: t = TestModel.objects.first()

In [6]: t.text

In [7]:

Copypasta from mongosh:

bash-5.1$ mongosh
Current Mongosh Log ID: 69133a82deb5b3f796ce5f46
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.5.8
Using MongoDB:          8.0.15
Using Mongosh:          2.5.8

...

test> use test_db
switched to db test_db
test_db> db.general_testmodel.find()
[ { _id: ObjectId('6913390be4279c73e5889747') } ]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions