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

Extra returning fields in UpdateRequest.apply #730

Open
kigawas opened this issue Oct 13, 2020 · 0 comments · May be fixed by #767
Open

Extra returning fields in UpdateRequest.apply #730

kigawas opened this issue Oct 13, 2020 · 0 comments · May be fixed by #767

Comments

@kigawas
Copy link
Contributor

kigawas commented Oct 13, 2020

Sometimes there is need to retrieve some server updated fields in the in-memory instance:

user = await User.create()
print(user.updated_at)  #  updated_at_1
await user.update(balance=User.balance + 100).apply()
print(user.updated_at)  # updated_at_2, and it should not be equal to updated_at_1

Unfortunately, gino only retrieves updated fields like

        # in `crud.py`
        clause = (
            type(self._instance)
            .update.where(
                self._locator,
            )
            .values(
                **self._instance._get_sa_values(values),
            )
            .returning(
                *[getattr(cls, key) for key in values], # <- only updated values will return
            )
            .execution_options(**opts)
        )

I'd like to specify some "extra fields" here, maybe in this form:

user = await User.create()
print(user.updated_at)  #  updated_at_1
await user.update(balance=User.balance + 100).apply(extra_returning_fields=['updated_at'])
print(user.updated_at)  # expected: updated_at_2 > updated_at_1
@kigawas kigawas linked a pull request Mar 17, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants