Massimo, what would that traceback be referring to?

Would you need some code to look at?

I still get the traceback when attempting to update a record using appadmin.

-Thadeus




On Sat, Oct 31, 2009 at 11:13 PM, mdipierro <mdipie...@cs.depaul.edu> wrote:

>
> No but you have a good point. it should. In trunk now. Please give it
> a try.
>
> Massimo
>
>
>
>
> On Oct 31, 11:58 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
> > Yes I was in a rush to get to a Halloween party, ok here is sample code.
> >
> > db.define_table('person', Field('name'), Field('address'),
> > Field('referred_by', 'reference person'))
> >
> > So when a person fills out a form, they enter the name of the person that
> > referred them, I do a query, and insert that record in the field
> >
> > .....
> >
> > SQLFORM.factory(db.person.fields....)
> >
> > if form.accepts(....):
> >      referrer = db(db.person.name ==
> > request.vars.referred_by.capitalize()).select().first()
> >      db.person.insert(name=request.vars.name,
> address=request.vars.address,
> > referred_by=referrer)
> >
> > WIth this code, that exception is thrown, every single time.
> >
> > However if i did
> >
> >     if referrer:
> >          referrer = referrer.id
> >     else: referrer = None
> >
> > It works correctly.
> >
> > I was under the assumption that with the new DAL features in 1.70.1 that
> the
> > former code would have worked? Am I mistaken and still have to reference
> it
> > by id when inserting new records?
> >
> > -Thadeus
> >
> > On Sat, Oct 31, 2009 at 11:44 PM, mdipierro <mdipie...@cs.depaul.edu>
> wrote:
> >
> > > I do not understand your test.
> >
> > > On Oct 31, 7:15 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
> > > > I am attempting to use the new DAL feature, where you can do a
> select,
> > > > and take the first row and insert that row into the reference column
> > > > of the database as a reference.
> >
> > > > I get the following error. This is fixed by just referencing row.id.
> >
> > > > Did I misunderstand, this new feature was for inserts as well as just
> > > selecting?
> >
> > > > Traceback (most recent call last):
> >
> > > >   File "gluon/restricted.py", line 184, in restricted
> >
> > > >     exec ccode in environment
> > > >   File line 238, in <module>
> >
> > > >   File ** "gluon/globals.py", line 103, in <lambda>
> >
> > > >     self._caller = lambda f: f()
> >
> > > >   File ** line 214, in controller
> >
> > > >     referred_by=referred_by, ### THIS IS THE ROW RETURNED BY
> > > > db...select().first(), this is fixed by just referencing .id
> > > >   File "gluon/sql.py", line 1681, in insert
> >
> > > >     self._db._execute(query)
> >
> > > >   File "gluon/sql.py", line 838, in <lambda>
> >
> > > >     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> > > > DataError: value too long for type character varying(1)
> >
> > > > -Thadeus
> >
> >
> >
>

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

Reply via email to