def test_select_count(engine): statement = s.Select( c.Select(f.Count(n.star)), c.From(e.Identifier('person')), c.GroupBy(e.Identifier('age')), ) assert statement.__sql__(engine) == Sql(''' SELECT COUNT(*) FROM "person" GROUP BY "age" '''.strip())
def test_count_as(engine): sql = m.As( f.Count(e.Identifier('person', 'name')), e.Identifier('name_count'), ) assert sql.__sql__(engine) == Sql('COUNT("person"."name") AS "name_count"')
def test_count(engine): sql = f.Count() assert sql.__sql__(engine) == Sql('COUNT()'), sql
def test_count_expression(engine): sql = f.Count(e.Equal(e.Identifier('name'), 'Mosky')) assert sql.__sql__(engine) == Sql('''COUNT("name" = 'Mosky')'''), sql
def test_count_identifier(engine): sql = f.Count(e.Identifier('name')) assert sql.__sql__(engine) == Sql('COUNT("name")'), sql
def test_count_value(engine): sql = f.Count('Mosky') assert sql.__sql__(engine) == Sql("COUNT('Mosky')"), sql
def test_count_star(engine): sql = f.Count(n.star) assert sql.__sql__(engine) == Sql('COUNT(*)'), sql
def test_select_function(engine): sql = c.Select(f.Count()) assert sql.__sql__(engine) == Sql('SELECT COUNT()')