Skip to content

Commit

Permalink
Refined tests
Browse files Browse the repository at this point in the history
Updated on_value and on_null tests to prove that an 'on' (aka column comparison) is not actually required
  • Loading branch information
circulon committed Aug 21, 2021
1 parent 00a2bec commit ad97d58
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/masoniteorm/testing/BaseTestCaseSelectGrammar.py
Expand Up @@ -293,7 +293,6 @@ def test_can_compile_join_clause(self):
def test_can_compile_join_clause_with_value(self):
clause = (
JoinClause("report_groups as rg")
.on("bgt.fund", "=", "rg.fund")
.on_value("bgt.active", "=", "1")
.or_on_value("bgt.acct", "=", "1234")
)
Expand All @@ -307,7 +306,6 @@ def test_can_compile_join_clause_with_value(self):
def test_can_compile_join_clause_with_null(self):
clause = (
JoinClause("report_groups as rg")
.on("bgt.fund", "=", "rg.fund")
.on_null("bgt.acct")
.or_on_not_null("bgt.dept")
)
Expand Down
4 changes: 2 additions & 2 deletions tests/mssql/grammar/test_mssql_select_grammar.py
Expand Up @@ -312,14 +312,14 @@ def can_compile_join_clause_with_value(self):
builder = self.get_builder()
builder.where("age", "not like", "%name%").to_sql()
"""
return "SELECT * FROM [users] INNER JOIN [report_groups] AS [rg] ON [bgt].[fund] = [rg].[fund] AND [bgt].[active] = '1' OR [bgt].[acct] = '1234'"
return "SELECT * FROM [users] INNER JOIN [report_groups] AS [rg] ON [bgt].[active] = '1' OR [bgt].[acct] = '1234'"

def can_compile_join_clause_with_null(self):
"""
builder = self.get_builder()
builder.where("age", "not like", "%name%").to_sql()
"""
return "SELECT * FROM [users] INNER JOIN [report_groups] AS [rg] ON [bgt].[fund] = [rg].[fund] AND [acct] IS NULL OR [dept] IS NOT NULL"
return "SELECT * FROM [users] INNER JOIN [report_groups] AS [rg] ON [acct] IS NULL OR [dept] IS NOT NULL"

def can_compile_join_clause_with_lambda(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/mysql/grammar/test_mysql_select_grammar.py
Expand Up @@ -306,14 +306,14 @@ def can_compile_join_clause_with_value(self):
builder = self.get_builder()
builder.where("age", "not like", "%name%").to_sql()
"""
return "SELECT * FROM `users` INNER JOIN `report_groups` AS `rg` ON `bgt`.`fund` = `rg`.`fund` AND `bgt`.`active` = '1' OR `bgt`.`acct` = '1234'"
return "SELECT * FROM `users` INNER JOIN `report_groups` AS `rg` ON `bgt`.`active` = '1' OR `bgt`.`acct` = '1234'"

def can_compile_join_clause_with_null(self):
"""
builder = self.get_builder()
builder.where("age", "not like", "%name%").to_sql()
"""
return "SELECT * FROM `users` INNER JOIN `report_groups` AS `rg` ON `bgt`.`fund` = `rg`.`fund` AND `acct` IS NULL OR `dept` IS NOT NULL"
return "SELECT * FROM `users` INNER JOIN `report_groups` AS `rg` ON `acct` IS NULL OR `dept` IS NOT NULL"

def can_compile_join_clause_with_lambda(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/postgres/grammar/test_select_grammar.py
Expand Up @@ -308,14 +308,14 @@ def can_compile_join_clause_with_value(self):
builder = self.get_builder()
builder.where("age", "not like", "%name%").to_sql()
"""
return """SELECT * FROM "users" INNER JOIN "report_groups" AS "rg" ON "bgt"."fund" = "rg"."fund" AND "bgt"."active" = '1' OR "bgt"."acct" = '1234'"""
return """SELECT * FROM "users" INNER JOIN "report_groups" AS "rg" ON "bgt"."active" = '1' OR "bgt"."acct" = '1234'"""

def can_compile_join_clause_with_null(self):
"""
builder = self.get_builder()
builder.where("age", "not like", "%name%").to_sql()
"""
return """SELECT * FROM "users" INNER JOIN "report_groups" AS "rg" ON "bgt"."fund" = "rg"."fund" AND "acct" IS NULL OR "dept" IS NOT NULL"""
return """SELECT * FROM "users" INNER JOIN "report_groups" AS "rg" ON "acct" IS NULL OR "dept" IS NOT NULL"""

def can_compile_join_clause_with_lambda(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/sqlite/grammar/test_sqlite_select_grammar.py
Expand Up @@ -308,14 +308,14 @@ def can_compile_join_clause_with_value(self):
builder = self.get_builder()
builder.where("age", "not like", "%name%").to_sql()
"""
return """SELECT * FROM "users" INNER JOIN "report_groups" AS "rg" ON "bgt"."fund" = "rg"."fund" AND "bgt"."active" = '1' OR "bgt"."acct" = '1234'"""
return """SELECT * FROM "users" INNER JOIN "report_groups" AS "rg" ON "bgt"."active" = '1' OR "bgt"."acct" = '1234'"""

def can_compile_join_clause_with_null(self):
"""
builder = self.get_builder()
builder.where("age", "not like", "%name%").to_sql()
"""
return """SELECT * FROM "users" INNER JOIN "report_groups" AS "rg" ON "bgt"."fund" = "rg"."fund" AND "acct" IS NULL OR "dept" IS NOT NULL"""
return """SELECT * FROM "users" INNER JOIN "report_groups" AS "rg" ON "acct" IS NULL OR "dept" IS NOT NULL"""

def can_compile_join_clause_with_lambda(self):
"""
Expand Down

0 comments on commit ad97d58

Please sign in to comment.