diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-08-02 15:45:04 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-08-02 15:45:04 +0000 |
| commit | b673bdb02e7f7e6aa52f042f1bf4a09beef2ad21 (patch) | |
| tree | fec551c9607f09d36c00b0462020b7688f2e9490 /lib | |
| parent | b8b51fe4379936fe142c875ea0f17da14a12c27d (diff) | |
| download | sqlalchemy-b673bdb02e7f7e6aa52f042f1bf4a09beef2ad21.tar.gz | |
- fixed autoflush with count(), aggregates
- doc formatting bonanza
- delete() section to orm tutorial
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 6d7e55af3..bf16cb699 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -419,6 +419,9 @@ class Query(object): ops = {'distinct':self._distinct, 'order_by':self._order_by or None, 'from_obj':self._from_obj} + if self._autoflush and not self._populate_existing: + self.session._autoflush() + if self._order_by is not False: s1 = sql.select([col], self._criterion, **ops).alias('u') return self.session.execute(sql.select([func(s1.corresponding_column(col))]), mapper=self.mapper).scalar() @@ -791,6 +794,8 @@ class Query(object): else: primary_key = self.primary_key_columns s = sql.select([sql.func.count(list(primary_key)[0])], whereclause, from_obj=from_obj, **context.select_args()) + if self._autoflush and not self._populate_existing: + self.session._autoflush() return self.session.scalar(s, params=self._params, mapper=self.mapper) def compile(self): |
