Skip to content

rows.as_csv doesn't work when using with_alias #733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mbelletti opened this issue May 2, 2025 · 1 comment
Closed

rows.as_csv doesn't work when using with_alias #733

mbelletti opened this issue May 2, 2025 · 1 comment

Comments

@mbelletti
Copy link
Contributor

pydal version: 20250501.2

When using a field with with_alias, rows.as_csv() fail with a KeyError, so also printing rows as:

print(rows)  

will fail.

How to reproduce:

from random import random
db = DAL('sqlite:memory')
db.define_table('test',
                Field('a'),
                Field('b'),
               )
for i in range(10):
    db.test.insert(a=str(i), b=str(random()))
db.commit()  

f = [
    db.test.a.with_alias('a'),    
    db.test.b,    
]
rows= db(db.test.id).select(*f)
print(rows.as_csv())
...
KeyError: '"test"."a" AS a'
@mdipierro
Copy link
Contributor

Fixed in c834be1, thanks Massimiliano

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants