Thursday, January 31, 2013

Re: Special SELECT and UPDATE for a field

In the end,
what i did is, i added a conversion type to MySQLDB for my Corrdinates object to convert it to a non literal string.
and for the selecting part, i had to copy and alter db/sql/compiler's get_columns and get_default_columns to wrap my field selection with the AsText function. a very bad solution. but it worked.
this was really difficult to do, there is no reason for django not to let me tell django to put in NOW() or AsText or any non literal string.

On Wednesday, January 30, 2013 10:14:57 PM UTC+2, Yarden Sachs wrote:
i want to create a field class for geometry (not using geodjango).
here's the field code:

i want 2 things i can't seem to do:
1. I want the select to wrap the column with MySql AsText() Function
e.x. SELECT AsText(location) FROM addresses

2. I want to be able to save the value wrapped with a function e.x. GeomFromText('POINT(0.0 0.0)')
but is seems that django will wrap that function with quotes, and so mysql thinks its a string.

I found that in order to fix these, i will have to write an SQLCompiler, Query, QuerySet, QuerySetManager. (or modify the get_columns and get_default_columns methods of the SQLCompiler)
I am sure there is a simpler way.

What can I do?


You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment