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

Exception due to double-resolution of values with Enums in pagination #47

Closed
dilbernd opened this issue Feb 7, 2021 · 1 comment · Fixed by #50
Closed

Exception due to double-resolution of values with Enums in pagination #47

dilbernd opened this issue Feb 7, 2021 · 1 comment · Fixed by #50
Assignees

Comments

@dilbernd
Copy link

dilbernd commented Feb 7, 2021

I have an enum value in a table:

class AddressFamily(enum.Enum):
    IPv4 = 4
    IPv6 = 6
    Column('address_family', Enum(AddressFamily)),

When I paginate a core query, sqlakeyset removes some columns in paging.py:

        N = len(row._row) - len(extra_columns)
        row = row[:N]

__getitem__ on BaseRowProxy however applies processing to the values, which resolves the enum from its string name to the actual enum value:

                            l.append(processor(value))

When I then try to read the value from the row I received out of pagination:

row[prefixes.c.address_family]

Here, the value gets resolved again, using the str() of the already resolved enum as a lookup key, and I get an exception: 'AddressFamily.IPv4' is not among the defined enum values. Enum name: addressfamily. Possible values: IPv4, IPv6

@acarapetis
Copy link
Collaborator

Thanks for your thorough bug report! I'm super busy at the moment, but I'll try to fix this soon; in the mean time, PRs are welcome! Should just be a matter of accessing the guts of BaseRowProxy rather than using its public getitemn when we trim off the extra columns.

acarapetis added a commit to acarapetis/sqlakeyset that referenced this issue Feb 26, 2021
One test uses an Enum directly, the other one uses a custom
TypeDecorator that specifically raises when results are
double-processed.
acarapetis added a commit to acarapetis/sqlakeyset that referenced this issue Feb 26, 2021
One test uses an Enum directly, the other one uses a custom
TypeDecorator that specifically raises when results are
double-processed.
@acarapetis acarapetis self-assigned this Mar 15, 2021
acarapetis added a commit to acarapetis/sqlakeyset that referenced this issue Mar 15, 2021
One test uses an Enum directly, the other one uses a custom
TypeDecorator that specifically raises when results are
double-processed.
acarapetis added a commit to acarapetis/sqlakeyset that referenced this issue Mar 16, 2021
One test uses an Enum directly, the other one uses a custom
TypeDecorator that specifically raises when results are
double-processed.
acarapetis added a commit that referenced this issue Mar 21, 2021
One test uses an Enum directly, the other one uses a custom
TypeDecorator that specifically raises when results are
double-processed.
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

Successfully merging a pull request may close this issue.

2 participants