Skip to content

Commit

Permalink
add union test
Browse files Browse the repository at this point in the history
  • Loading branch information
beanpuppy committed Apr 26, 2021
1 parent a43b6ba commit fe0d42d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[![PyPI](https://img.shields.io/pypi/v/estoult)](https://pypi.org/project/estoult/)
[![PyPI - License](https://img.shields.io/pypi/l/estoult)](https://pypi.org/project/estoult/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/estoult)](https://pypi.org/project/estoult/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/estoult)](https://pypi.org/project/estoult/)
[![Documentation Status](https://readthedocs.org/projects/estoult/badge/?version=latest)](https://estoult.readthedocs.io/en/latest/?badge=latest)

Estoult is a Python toolkit for data mapping with an integrated query builder for SQL databases. It currently supports MySQL, PostgreSQL, and SQLite.
Expand All @@ -17,7 +16,7 @@ Features:
- Easy debugging by displaying any generated SQL in a readable format.
- Performant as raw SQL. Estoult is **NOT** an ORM.

Estoult only works with Python 3.6+ and is primarily tested on Python 3.8+.
Estoult only works with Python 3.6+ and is primarily tested on Python 3.9+.

## Installation

Expand Down
19 changes: 17 additions & 2 deletions tests/test_query.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from estoult import Query, QueryError
from estoult import Query, QueryError, fn
from .base import assertSQL, User, Organisation, Data


Expand Down Expand Up @@ -28,8 +28,23 @@ def test_left_join():
assertSQL(q, s)


def test_query_union():
s = (
"select * from users union select users.* from organisations "
"left join users on users.organisation_id = organisations.id"
)
q = (
Query(User)
.select()
.union(Organisation)
.select(fn.wild(User))
.left_join(User, on=[User.organisation_id, Organisation.id])
)
assertSQL(q, s)


def test_order_by():
s = "select * from users order by users.name desc, users.id " "limit 10 offset 2"
s = "select * from users order by users.name desc, users.id limit 10 offset 2"
q = Query(User).select().order_by({User.name: "desc"}, User.id).limit(10, 2)
assertSQL(q, s)

Expand Down

0 comments on commit fe0d42d

Please sign in to comment.