diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-03-03 13:10:37 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-03-03 13:10:37 -0500 |
| commit | 66377aaeafee34767c34e14d9e354aa3bd41372f (patch) | |
| tree | ed79ef5170db79274f758b21fc976e8014e84969 /lib/sqlalchemy | |
| parent | fb83ddaff977554b5afde6a3e56ef00cd1eced36 (diff) | |
| download | sqlalchemy-66377aaeafee34767c34e14d9e354aa3bd41372f.tar.gz | |
fix typos, SQL server also needs union all
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/expression.py | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 5b7f7c9af..aa3dd0173 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -472,8 +472,8 @@ class Query(object): class Part(Base): __tablename__ = 'part' - part = Column(String) - sub_part = Column(String) + part = Column(String, primary_key=True) + sub_part = Column(String, primary_key=True) quantity = Column(Integer) included_parts = session.query( @@ -485,7 +485,7 @@ class Query(object): incl_alias = aliased(included_parts, name="pr") parts_alias = aliased(Part, name="p") - included_parts = included_parts.union( + included_parts = included_parts.union_all( session.query( parts_alias.part, parts_alias.sub_part, @@ -496,7 +496,7 @@ class Query(object): q = session.query( included_parts.c.sub_part, func.sum(included_parts.c.quantity).label('total_quantity') - ).\ + ).\\ group_by(included_parts.c.sub_part) See also: diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 22fe6c420..50b7375bf 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -4353,7 +4353,7 @@ class _SelectBase(Executable, FromClause): compile time. :param recursive: if ``True``, will render ``WITH RECURSIVE``. A recursive common table expression is intended to be used in - conjunction with UNION or UNION ALL in order to derive rows + conjunction with UNION ALL in order to derive rows from those already selected. The following examples illustrate two examples from @@ -4422,7 +4422,7 @@ class _SelectBase(Executable, FromClause): incl_alias = included_parts.alias() parts_alias = parts.alias() - included_parts = included_parts.union( + included_parts = included_parts.union_all( select([ parts_alias.c.part, parts_alias.c.sub_part, |
