I've just deployed 1.98.2 and noticed that some of the with_alias
behaviour has changed.
With 1.89.1, if I defined my tables like this:

db.define_table(
        'tbl_site',
        Field('Code', 'integer'),
        Field('Name', 'string'),
        Field('Active', 'integer')
        ).with_alias('site')


db.define_table(
        'tbl_site_description',
        Field('SiteCode', 'integer'),
        Field('Description', 'string'),
        Field('ImageLarge', 'string'),
        Field('ImageSmall', 'string'),
        Field('LongName', 'string')
        ).with_alias('site_description')

and ran this query:

siteResults = db(db.site.Active==1).select(db.site.ALL,
            db.site_description.Description,
 
left=db.site_description.on(db.site.Code==db.site_description.SiteCode))

I would get a row structure that looked like this:


        <Row {'tbl_site': <Row {'update_record': <function <lambda> at
0xbd9c610c>, 'SiteCode': 55101L, 'delete_record': <function <lambda>
at 0xbd9c6144>, 'Active': 1, 'Name': 'Home'}>, 'tbl_site_description':
<Row {'Description': 'Where the heart is'}>}>

Now I get this row structure.

        <Row {'site': <Row {'update_record': <function <lambda> at
0x7fa453cad8c0>, 'SiteCode': 55101L 'delete_record': <function
<lambda> at 0x7fa453cad938>, 'Active': 1, 'Name': 'Home'}>,
'site_description': <Row {'Description': 'Where the heart is'}>}>


The simplest workaround for me is to define a helper function like
this:

def _getRowAttr(row, attr, attrAlias):
    return attr in row and row[attr] or row[attrAlias]

and call _getRowAttr(row, 'site', 'tbl_site') when I need to make my
code compatible with an older version.

This doesn't bother me too much, but I'm wondering if this behaviour
was intentional or an artefact of a new feature. Is it likely to stay
this way?

Reply via email to