Well bug was closed because it fixed the issue back then. I suspect that internals of query has been changed between 1.3 and 1.4 that causes now a new problem.

Main issue is that when inserting or updating value cx_Oracle interpreted NULL value for OBJECT field when placeholder (%s) as a CHAR. (since it's Oracle user type actually). And insertion or update failed.

As a solution it was implemented so that when ever encountering None value for geometry field placeholder and actual value was removed from the whole insert clause.

Now I think that internals how to figure out position of parameter and it's value was changed and there is not stuff that small if-part requires to work. It just requires someone with deeper knowledge of ORM than me to update that fix so it will work in newer versions of Django as well.

If someone else is encountering this issue I raised ticket https://code.djangoproject.com/ticket/19058


2.10.2012 15:55, George Silva kirjoitti:
Well, the bug was closed. You can try inserting empty geometries, but
then, you would need to recheck them if they are something before using.
A property might suit you well in this case.

    if self.geometry.empty:
         return None


Hackish, but it's Oracle Spatial :o

And even that might work that is not an option for two reasons:
1) Models were working fine with previous version of Django (1.3)
2) I've more than 300 models which I really won't modify

On Tue, Oct 2, 2012 at 9:49 AM, Jani Tiainen <rede...@gmail.com
<mailto:rede...@gmail.com>> wrote:

    I guess all this is related to special munging required by Oracle:

    https://code.djangoproject.__com/ticket/10888
    <https://code.djangoproject.com/ticket/10888>


    2.10.2012 15:12, George Silva kirjoitti:

        Then it's probably Oracle, which is riddled with bugs on the
        spatial part.

        I'm using PostGIS.

        On Tue, Oct 2, 2012 at 8:38 AM, Jani Tiainen <rede...@gmail.com
        <mailto:rede...@gmail.com>
        <mailto:rede...@gmail.com <mailto:rede...@gmail.com>>> wrote:


             2.10.2012 14:34, Jani Tiainen kirjoitti:

                 2.10.2012 14:06, George Silva kirjoitti:

                     This is puzzling. I'm on 1.4.1 and I have models
        with two
                     geometric
                     columns, without a hitch.

                     The only interesting thing I can see is that you
        are using
                     SRID =
                     settings.4326 on extent. Is that correct?


                 Nope. Normally it's something totally different
        depending on
                 customer
                 (and picked from settings file). I just tried qicly
        replace it
                 by more
                 common WGS84...

                 Maybe it's Oracle spesific or are you using Oracle as well?


             It might be Oracle spesific since I recall that there was
        something
             done long time ago for Oracle and NULL values... And it
        only happens
             if one or both fields are None (NULL) but if I provide data
        for both
             fields it works.


                     On Tue, Oct 2, 2012 at 7:52 AM, Jani Tiainen
                     <rede...@gmail.com <mailto:rede...@gmail.com>
        <mailto:rede...@gmail.com <mailto:rede...@gmail.com>>
                     <mailto:rede...@gmail.com
        <mailto:rede...@gmail.com> <mailto:rede...@gmail.com
        <mailto:rede...@gmail.com>>>> wrote:

                          Hi,

                          I've several models that contains two geometry
        fields
                     (following is
                          simplified example):

                          class NetDiagram(models.Model):
                               # Columns
                               name = models.CharField(max_length=______60,
                     blank=True, null=True)

                               location =
        models.GeometryField(_("______Center"),

                          db_column='location', srid=4326, null=True,
        blank=True)
                               extent =
        models.GeometryField(_("______Extent"),

                          db_column='extent', srid=settings.4326, null=True,
                     blank=True)

                               objects = models.GeoManager()


                          Now when trying to save model like that I get:

                          Traceback (most recent call last):
                             File


        
"c:\users\jtiai\work\keycom-______dev-std\prj\keycom\keycom___net_____diagram\diagram\__entity_____diagram_builder.py"__,


                          line 134, in _save_to_database
                               netdiagram.save()
                             File


        
"C:\Users\jtiai\Work\keycom-______dev-std\lib\site-packages\______django\db\models\base.py",


                          line 463, in save
                               self.save_base(using=using,
        force_insert=force_insert,
                          force_update=force_update)
                             File


        
"C:\Users\jtiai\Work\keycom-______dev-std\lib\site-packages\______django\db\models\base.py",


                          line 551, in save_base
                               result = manager._insert([self],
        fields=fields,
                          return_id=update_pk, using=using, raw=raw)
                             File


        
"C:\Users\jtiai\Work\keycom-______dev-std\lib\site-packages\______django\db\models\manager.py"__,


                          line 203, in _insert
                               return insert_query(self.model, objs, fields,
                     **kwargs)
                             File


        
"C:\Users\jtiai\Work\keycom-______dev-std\lib\site-packages\______django\db\models\query.py",


                          line 1576, in insert_query
                               return

        query.get_compiler(using=______using).execute_sql(return_id)
                             File


        
"C:\Users\jtiai\Work\keycom-______dev-std\lib\site-packages\______django\db\models\sql\__compiler.____py",


                          line 909, in execute_sql
                               for sql, params in self.as_sql():
                             File


        
"C:\Users\jtiai\Work\keycom-______dev-std\lib\site-packages\______django\db\models\sql\__compiler.____py",


                          line 886, in as_sql
                               for val in values
                             File


        
"C:\Users\jtiai\Work\keycom-______dev-std\lib\site-packages\______django\contrib\gis\db\______backends\oracle\compiler.py",

                          line 25, in placeholder
                               param_idx =
        self.query.columns.index(______field.column)

                          AttributeError: 'InsertQuery' object has no
        attribute
                     'columns'


                          Error is consistent and happens when there is
        two or
                     more geometry
                          fields on a single model.

                          Same code worked on 1.3 flawlessly.

                          --
                          Jani Tiainen

                          - Well planned is half done and a half done
        has been
                     sufficient
                          before...

                          --
                          You received this message because you are
        subscribed to
                     the Google
                          Groups "Django users" group.
                          To post to this group, send email to
        django-users@googlegroups.com <mailto:django-users@googlegroups.com>
                     <mailto:django-users@__googlegroups.com
        <mailto:django-users@googlegroups.com>>
                          <mailto:django-users@
        <mailto:django-users@>__googleg__roups.com <http://googlegroups.com>

                     <mailto:django-users@__googlegroups.com
        <mailto:django-users@googlegroups.com>>>.
                          To unsubscribe from this group, send email to

          django-users+unsubscribe@__goo____glegroups.com
        <http://goo__glegroups.com>
                     <http://googlegroups.com>

          <mailto:django-users%____2bunsubscr...@googlegroups.com
        <mailto:django-users%25__2bunsubscr...@googlegroups.com>

        <mailto:django-users%__252Bunsubscribe@googlegroups.__com
        <mailto:django-users%25252bunsubscr...@googlegroups.com>>__>.

                          For more options, visit this group at
        http://groups.google.com/______group/django-users?hl=en
        <http://groups.google.com/____group/django-users?hl=en>

        <http://groups.google.com/____group/django-users?hl=en
        <http://groups.google.com/__group/django-users?hl=en>>


          <http://groups.google.com/____group/django-users?hl=en
        <http://groups.google.com/__group/django-users?hl=en>

        <http://groups.google.com/__group/django-users?hl=en
        <http://groups.google.com/group/django-users?hl=en>>>.




                     --
                     George R. C. Silva

                     Desenvolvimento em GIS
        http://geoprocessamento.net
        http://blog.geoprocessamento.____net

                     <http://blog.geoprocessamento.__net
        <http://blog.geoprocessamento.net>>

                     --
                     You received this message because you are
        subscribed to the
                     Google
                     Groups "Django users" group.
                     To post to this group, send email to
        django-users@googlegroups.com <mailto:django-users@googlegroups.com>
                     <mailto:django-users@__googlegroups.com
        <mailto:django-users@googlegroups.com>>.
                     To unsubscribe from this group, send email to
                     django-users+unsubscribe@__goo__glegroups.com
        <http://googlegroups.com>

        <mailto:django-users%__2bunsubscr...@googlegroups.com
        <mailto:django-users%252bunsubscr...@googlegroups.com>__>.
                     For more options, visit this group at
        http://groups.google.com/____group/django-users?hl=en
        <http://groups.google.com/__group/django-users?hl=en>

        <http://groups.google.com/__group/django-users?hl=en
        <http://groups.google.com/group/django-users?hl=en>>.





             --
             Jani Tiainen

             - Well planned is half done and a half done has been sufficient
             before...

             --
             You received this message because you are subscribed to the
        Google
             Groups "Django users" group.
             To post to this group, send email to
        django-users@googlegroups.com <mailto:django-users@googlegroups.com>
             <mailto:django-users@__googlegroups.com
        <mailto:django-users@googlegroups.com>>.
             To unsubscribe from this group, send email to
             django-users+unsubscribe@__goo__glegroups.com
        <http://googlegroups.com>
             <mailto:django-users%__2bunsubscr...@googlegroups.com
        <mailto:django-users%252bunsubscr...@googlegroups.com>__>.
             For more options, visit this group at
        http://groups.google.com/____group/django-users?hl=en
        <http://groups.google.com/__group/django-users?hl=en>
             <http://groups.google.com/__group/django-users?hl=en
        <http://groups.google.com/group/django-users?hl=en>>.




        --
        George R. C. Silva

        Desenvolvimento em GIS
        http://geoprocessamento.net
        http://blog.geoprocessamento.__net
        <http://blog.geoprocessamento.net>

        --
        You received this message because you are subscribed to the Google
        Groups "Django users" group.
        To post to this group, send email to
        django-users@googlegroups.com
        <mailto:django-users@googlegroups.com>.
        To unsubscribe from this group, send email to
        django-users+unsubscribe@__googlegroups.com
        <mailto:django-users%2bunsubscr...@googlegroups.com>.
        For more options, visit this group at
        http://groups.google.com/__group/django-users?hl=en
        <http://groups.google.com/group/django-users?hl=en>.



    --
    Jani Tiainen

    - Well planned is half done and a half done has been sufficient
    before...

    --
    You received this message because you are subscribed to the Google
    Groups "Django users" group.
    To post to this group, send email to django-users@googlegroups.com
    <mailto:django-users@googlegroups.com>.
    To unsubscribe from this group, send email to
    django-users+unsubscribe@__googlegroups.com
    <mailto:django-users%2bunsubscr...@googlegroups.com>.
    For more options, visit this group at
    http://groups.google.com/__group/django-users?hl=en
    <http://groups.google.com/group/django-users?hl=en>.




--
George R. C. Silva

Desenvolvimento em GIS
http://geoprocessamento.net
http://blog.geoprocessamento.net

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to