Skip to content

Commit

Permalink
added a unit test for the new join syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Dec 22, 2023
1 parent 071dea9 commit 92fb265
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/table/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def test_create_join(self):


class TestJoin(TestCase):

tables = [Manager, Band, Venue, Concert, Ticket]

def setUp(self):
Expand Down Expand Up @@ -98,6 +97,29 @@ def test_join(self):
response = select_query.run_sync()
self.assertEqual(response, [{"band_1.manager.name": "Guido"}])

def test_underscore_syntax(self):
"""
Make sure that queries work with the ``._.`` syntax for joins.
"""
response = Concert.select(
Concert.band_1._.name,
Concert.band_1._.manager._.name,
Concert.band_2._.name,
Concert.band_2._.manager._.name,
).run_sync()

self.assertListEqual(
response,
[
{
"band_1.name": "Pythonistas",
"band_1.manager.name": "Guido",
"band_2.name": "Rustaceans",
"band_2.manager.name": "Graydon",
}
],
)

def test_select_all_columns(self):
"""
Make sure you can retrieve all columns from a related table, without
Expand Down

0 comments on commit 92fb265

Please sign in to comment.