Re: [Django] #27213: PostgreSQL-9.4 ArrayField with null throws ProgrammingError but not ValidationError on Linux but not Windows

2016-09-17 Thread Django
#27213: PostgreSQL-9.4 ArrayField with null throws ProgrammingError but not
ValidationError on Linux but not Windows
-+-
 Reporter:  mikofski |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  contrib.postgres |  Version:  1.9
 Severity:  Normal   |   Resolution:
 |  worksforme
 Keywords:  postgres,| Triage Stage:
  arrayfield, programmingerror   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by mikofski):

 My mistake, `blank=True` is also a property of the field. We are still
 experiencing this discrepency.
 Which version of Django, postgresql and psycopg2 were you using to test
 this issue? What version of Linux?
 I have a feeling this is psycopg2 because the Linux distro I'm using has a
 very old version (psycopg2-2.5.3).

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.8ff2449f8a57b72c6c63501fc4ea7347%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #27213: PostgreSQL-9.4 ArrayField with null throws ProgrammingError but not ValidationError on Linux but not Windows

2016-09-14 Thread Django
#27213: PostgreSQL-9.4 ArrayField with null throws ProgrammingError but not
ValidationError on Linux but not Windows
-+-
 Reporter:  mikofski |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  contrib.postgres |  Version:  1.9
 Severity:  Normal   |   Resolution:
 |  worksforme
 Keywords:  postgres,| Triage Stage:
  arrayfield, programmingerror   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * status:  new => closed
 * needs_better_patch:   => 0
 * component:  Database layer (models, ORM) => contrib.postgres
 * needs_tests:   => 0
 * needs_docs:   => 0
 * resolution:   => worksforme


Old description:

> Python-2.7.10
> PostgreSQL-9.4
> psycopg2-2.5.1 (linux) and psycopg2-2.6.1 (windows) (*)
> Django-1.9
> OS: Oracle7 vs. Windows 7
>
> given a model:
> {{{#!python
> from django.contrib.postgres.fields import ArrayField
> from django.db import models
>

> class MyModel(models.Model):
> my_array_field = ArrayField(base_field=models.FloatField(null=True))
> }}}
>
> If you try to save an array of `None` Django will validate it, but on
> Linux PostgreSQL will not insert the row, but on windows it does.
>
> {{{#!python
> from my_app.models import MyModel
>
> test_model = MyModel(my_array_field=[None])  # make a test instance of
> model
>
> test_model.full_clean()  # check for ValidationError
> # everything is okay!
>
> test_model_full.save()  # insert model instance into PostgreSQL database
> # Windows: Success!
> # Linux:   Failure!
> }}}
>
> here is the stacktrace from Linux:
> {{{
> In [59]: rtest.save()
> ---
> ProgrammingError  Traceback (most recent call
> last)
>  in ()
> > 1 rtest.save()
>
> ~/.local/lib/python2.7/site-packages/django/db/models/base.pyc in
> save(self, force_insert, force_update, using, update_fields)
> 706
> 707 self.save_base(using=using, force_insert=force_insert,
> --> 708force_update=force_update,
> update_fields=update_fields)
> 709 save.alters_data = True
> 710
>
> ~/.local/lib/python2.7/site-packages/django/db/models/base.pyc in
> save_base(self, raw, force_insert, force_update, using, update_fields)
> 734 if not raw:
> 735 self._save_parents(cls, using, update_fields)
> --> 736 updated = self._save_table(raw, cls, force_insert,
> force_update, using, update_fields)
> 737 # Store the database on which the object was saved
> 738 self._state.db = using
>
> ~/.local/lib/python2.7/site-packages/django/db/models/base.pyc in
> _save_table(self, raw, cls, force_insert, force_update, using,
> update_fields)
> 818
> 819 update_pk = bool(meta.has_auto_field and not pk_set)
> --> 820 result = self._do_insert(cls._base_manager, using,
> fields, update_pk, raw)
> 821 if update_pk:
> 822 setattr(self, meta.pk.attname, result)
>
> ~/.local/lib/python2.7/site-packages/django/db/models/base.pyc in
> _do_insert(self, manager, using, fields, update_pk, raw)
> 857 """
> 858 return manager._insert([self], fields=fields,
> return_id=update_pk,
> --> 859using=using, raw=raw)
> 860
> 861 def delete(self, using=None, keep_parents=False):
>
> ~/.local/lib/python2.7/site-packages/django/db/models/manager.pyc in
> manager_method(self, *args, **kwargs)
> 120 def create_method(name, method):
> 121 def manager_method(self, *args, **kwargs):
> --> 122 return getattr(self.get_queryset(), name)(*args,
> **kwargs)
> 123 manager_method.__name__ = method.__name__
> 124 manager_method.__doc__ = method.__doc__
>
> ~/.local/lib/python2.7/site-packages/django/db/models/query.pyc in
> _insert(self, objs, fields, return_id, raw, using)
>1037 query = sql.InsertQuery(self.model)
>1038 query.insert_values(fields, objs, raw=raw)
> -> 1039 return
> query.get_compiler(using=using).execute_sql(return_id)
>1040 _insert.alters_data = True
>1041 _insert.queryset_only = False
>
> ~/.local/lib/python2.7/site-packages/django/db/models/sql/compiler.pyc in
> execute_sql(self, return_id)
>1058 with self.connection.cursor() as cursor:
>1059 for sql, params in self.as_sql():
> -> 1060