Exemple #1
0
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())
Exemple #2
0
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"')
Exemple #3
0
def test_count(engine):
    sql = f.Count()
    assert sql.__sql__(engine) == Sql('COUNT()'), sql
Exemple #4
0
def test_count_expression(engine):
    sql = f.Count(e.Equal(e.Identifier('name'), 'Mosky'))
    assert sql.__sql__(engine) == Sql('''COUNT("name" = 'Mosky')'''), sql
Exemple #5
0
def test_count_identifier(engine):
    sql = f.Count(e.Identifier('name'))
    assert sql.__sql__(engine) == Sql('COUNT("name")'), sql
Exemple #6
0
def test_count_value(engine):
    sql = f.Count('Mosky')
    assert sql.__sql__(engine) == Sql("COUNT('Mosky')"), sql
Exemple #7
0
def test_count_star(engine):
    sql = f.Count(n.star)
    assert sql.__sql__(engine) == Sql('COUNT(*)'), sql
Exemple #8
0
def test_select_function(engine):
    sql = c.Select(f.Count())
    assert sql.__sql__(engine) == Sql('SELECT COUNT()')