db.table.long_field[20:100] is an Expression -- the key used to store it is 
the actual SQL it generates. The best way to access it is to store the 
expression:

substring = db.table.long_field[20:100]
ss = db(db.table.id==1).select(db.table.id, substring).first()
ss[substring]

Regarding accessing the "id" field, I think whenever the results include 
expressions, you can no longer use the compact notation for accessing 
fields and must instead use "tablename.fieldname" notation.

Anthony

On Friday, November 25, 2016 at 5:13:27 PM UTC-5, lucas wrote:
>
> hey one and all,
>
> ss = db(db.table.id==1).select(db.table.id, 
> db.table.long_field[20:100]).first()
>
> returns weird results.
>
> ss = db(db.table.id==1).select(db.table.id, db.table.long_field).first()
>
> if you do it without the slicing of the field, you can access it as normal 
> like ss.id or ss.long_field.  but with the slice version, you have to do 
> ss.table.id and i can't figure a way to access the sliced long_field.
>
> can you rename or alias the field name with the DAL?
>
> bug maybe?  lucas
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to