Skip to content
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

pydal-20241204.1 with_alias + as_list broke backward compatibilty with old code. #727

Open
mbelletti opened this issue Dec 12, 2024 · 0 comments

Comments

@mbelletti
Copy link
Contributor

mbelletti commented Dec 12, 2024

The latest versions of pydal introduced a breaking change in the behavior of the with_alias method used with as_list. In the previous version (20241111.2), when using with_alias with as_list, the aliased fields were returned as keys of the dict representing the record, but in the latest version, they are only available in the _extra dict.

It seems the bug is introduced here: 16c9395

This change breaks backward compatibility with existing code that relied on the old behavior.

from pydal import DAL, Field
db = DAL('sqlite:memory')
db.define_table('test',
                Field('a'),
               )
for i in range(3):
    db.test.insert(a=str(i))
db.commit()  
print(db(db.test.id).select(db.test.a.with_alias('my_col_name')).as_list())

pydal-20241111.2

[{'my_col_name': '0', '_extra': {'"test"."a" AS my_col_name': '0'}},
 {'my_col_name': '1', '_extra': {'"test"."a" AS my_col_name': '1'}},
 {'my_col_name': '2', '_extra': {'"test"."a" AS my_col_name': '2'}},

pydal-20241204.1

[{'_extra': {'my_col_name': '0'}},
 {'_extra': {'my_col_name': '1'}},
 {'_extra': {'my_col_name': '2'}},
@mbelletti mbelletti changed the title pydal-20241204.1 with_alias broke backward compatibilty with old code. pydal-20241204.1 with_alias + as_list broke backward compatibilty with old code. Dec 12, 2024
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

1 participant