Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HstoreField over escaping strings #159

Open
perrohunter opened this issue Jan 13, 2017 · 1 comment
Open

HstoreField over escaping strings #159

perrohunter opened this issue Jan 13, 2017 · 1 comment

Comments

@perrohunter
Copy link

Hi, I'm trying to store a record history on an hstore field, however every time I retrieve the field and save to it, things start getting over escaped.

My custom models.Manager defer's the retrieval of history field (of type hstore) so every time there's an update I retrieve the field in the following manner

objHistory = self.__class__.objects.values_list('history', flat=True).get(pk=self.pk)

after that, I update the history and store it.

history_update = str(userId) + ":update:" + key + ":" + str(getattr(self, key))
self.history['%s' % now()] = history_update
super(EspBase, self).save(*args, **kwargs)

even after the first save, the key is stored fine but the string is already over escaped

"2017-01-13 05:01:39.684107+00:00" => "\":update:product:lol2 /3\""

Here's a sample run of what happens after a few save calls

>>> eci.save()
None
>>> eci.product = prod2
>>> eci.save()
{}
>>> eci.product = prod
>>> eci.save()
{u'2017-01-13 04:57:10.932450+00:00': u'":update:product:lol2 /3"'}
>>> eci.product = prod2
>>> eci.save()
{u'2017-01-13 04:57:10.932450+00:00': u'"\\":update:product:lol2 /3\\""', u'2017-01-13 04:57:10.937826+00:00': u'":update:product:lol /2"'}
>>> eci.product = prod
>>> eci.save()
{u'2017-01-13 04:57:10.943229+00:00': u'":update:product:lol2 /3"', u'2017-01-13 04:57:10.932450+00:00': u'"\\"\\\\\\":update:product:lol2 /3\\\\\\"\\""', u'2017-01-13 04:57:10.937826+00:00': u'"\\":update:product:lol /2\\""'}

any idea on what could be causing this over escaping?

@nemesifier
Copy link
Member

please read #161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants