Skip to content

Commit

Permalink
Fix failing test with ancient SQLite versions (3.8).
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed Apr 26, 2018
1 parent 9d90b3c commit b938147
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,30 +603,25 @@ def test_join_subquery_2(self):
.select(User.id, User.username)
.where(User.username.in_(['huey', 'zaizee'])))
query = (Tweet
.select(Tweet.content, users.c.username)
.select(Tweet.content.alias('content'),
users.c.username.alias('username'))
.join(users, on=(Tweet.user == users.c.id))
.order_by(Tweet.id))

self.assertSQL(query, (
'SELECT "t1"."content", "t2"."username" '
'FROM "tweet" AS "t1" '
'SELECT "t1"."content" AS "content", "t2"."username" AS "username"'
' FROM "tweet" AS "t1" '
'INNER JOIN (SELECT "t3"."id", "t3"."username" '
'FROM "users" AS "t3" '
'WHERE ("t3"."username" IN (?, ?))) AS "t2" '
'ON ("t1"."user_id" = "t2"."id") '
'ORDER BY "t1"."id"'), ['huey', 'zaizee'])
with self.assertQueryCount(1):
results = [(t.content, t.user.username) for t in query]
if IS_SQLITE_OLD:
self.assertEqual(results, [
('meow', None),
('purr', None),
('hiss', None)])
else:
self.assertEqual(results, [
('meow', 'huey'),
('purr', 'huey'),
('hiss', 'huey')])
self.assertEqual(results, [
('meow', 'huey'),
('purr', 'huey'),
('hiss', 'huey')])

@requires_models(User, Tweet)
@skip_if(IS_SQLITE_OLD or (IS_MYSQL and not IS_MYSQL_ADVANCED_FEATURES))
Expand Down

0 comments on commit b938147

Please sign in to comment.