On Tue, Aug 28, 2018 at 5:13 AM, Vikas Prasad
<
vikaspras...@gmail.com> wrote:
> Just in case someone stumbles upon it in future.
> I am using Postgres and I got the following results:
>
> # This worked:
> `the_sample.end_date = func.now()`
> `db.session.commit()`
>
> # This too worked:
> `setattr(the_sample, 'end_date', func.now())`
> `db.session.commit()`
>
> # This didn't work though:
> `Sample.query.filter_by(...).update({'end_date': func.now()})`
> `db.session.commit()`
>
> When using `Flask-SQLAlchemy` and setting `SQLALCHEMY=True`, the first two
> cases logs the `UPDATE` query followed by logging `COMMIT`. The last case
> didn't even logs the `UDPATE` query but directly logs a `ROLLBACK` with no
> other info.
>
> Not sure of underlying cause, just recording it so that someone from future
> saves some time.
the last one should definitely emit an UPDATE or it should be raising
an error. that you only saw a ROLLBACK suggests it raised an error and
your flask setup is suppressing the logging of that error.
>>> > <mailto:
sqlalchemy+...@googlegroups.com>.
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
>
http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See
http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
sqlalchemy+...@googlegroups.com.
> To post to this group, send email to
sqlal...@googlegroups.com.