Ticket 2144

On 6/12/06, Ian Holsman <[EMAIL PROTECTED]> wrote:
>
> Hi mh.
> I had a similar issue, and my work around was to put the category
> into the defaults section (as well)
>
> e2, created = Foo.objects.get_or_create(name=name, category=c,
> defaults={ display_name=.., category=c } )
>
> but you should probably raise a bug for this.
>
> regards
> Ian.
>
> On 13/06/2006, at 9:24 AM, m h wrote:
>
> >
> > FYI...
> >
> > I'm having an issue with the get_or_create helper method.  Apparently
> > it isn't coercing parameters properly.
> >
> > I've got some code that looks like this:
> >
> > e = Foo(name=name, category=c, display_name=name.capitalize())
> >
> > e2, created = Foo.objects.get_or_create(name=name, category=c,
> > display_name=name.capitalize())
> >
> > The first one will work and the second fails.  The issue being that
> > the category is a foreign key and when creating the Foo object it uses
> > the id of category.  When using the get_or_create method, it passes in
> > the Category object as the SQL query parameter instead of the id.
> > Thus giving the following error:
> >
> >   File "scanfoo.py", line 60, in pop_db
> >     e2, created = Foo.objects.get_or_create(name=name, category=c,
> > display_name=name.capitalize())
> >   File "/home/matt/work/vpython/lib/python2.4/site-packages/
> > Django-0.95-py2.4.egg/django/db/models/manager.py",
> > line 69, in get_or_create
> >     return self.get_query_set().get_or_create(*args, **kwargs)
> >   File "/home/matt/work/vpython/lib/python2.4/site-packages/
> > Django-0.95-py2.4.egg/django/db/models/query.py",
> > line 217, in get_or_create
> >     return self.get(**kwargs), False
> >   File "/home/matt/work/vpython/lib/python2.4/site-packages/
> > Django-0.95-py2.4.egg/django/db/models/query.py",
> > line 202, in get
> >     obj_list = list(clone)
> >   File "/home/matt/work/vpython/lib/python2.4/site-packages/
> > Django-0.95-py2.4.egg/django/db/models/query.py",
> > line 94, in __iter__
> >     return iter(self._get_data())
> >   File "/home/matt/work/vpython/lib/python2.4/site-packages/
> > Django-0.95-py2.4.egg/django/db/models/query.py",
> > line 412, in _get_data
> >     self._result_cache = list(self.iterator())
> >   File "/home/matt/work/vpython/lib/python2.4/site-packages/
> > Django-0.95-py2.4.egg/django/db/models/query.py",
> > line 163, in iterator
> >     cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "")
> > + ",".join(select) + sql, params)
> >   File "/home/matt/work/vpython/lib/python2.4/site-packages/
> > Django-0.95-py2.4.egg/django/db/backends/util.py",
> > line 12, in execute
> >     return self.cursor.execute(sql, params)
> >   File "/home/matt/work/vpython/lib/python2.4/site-packages/
> > Django-0.95-py2.4.egg/django/db/backends/sqlite3/base.py",
> > line 79, in execute
> >     return Database.Cursor.execute(self, query, params)
> > pysqlite2.dbapi2.InterfaceError: Error binding parameter 0 - probably
> > unsupported type.
> >
> > I've put some debugging statements in to confirm this.
> >
> > The problem is in query.py line 877 where field.get_db_prep_lookup
> > is called.
> >
> > I'll dig in more.  But I figured you guys would be able to whip out
> > this bug fix a lot faster.
> >
> > Let me know if I should file a bug.
> >
> > thanks
> >
> > matt
> >
> > >
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to