Exemplo n.º 1
0
def query_article_nested():
    query = Article.query(
        ndb.AND(
            Article.tags == 'python',
            ndb.OR(Article.tags.IN(['ruby', 'jruby']),
                   ndb.AND(Article.tags == 'php', Article.tags != 'perl'))))
    return query
def test_print_query_keys(testbed, capsys):
    for i in range(3):
        Article(title='title {}'.format(i)).put()

    snippets.print_query_keys(Article.query())

    stdout, _ = capsys.readouterr()
    assert "Key('Article'" in stdout
Exemplo n.º 3
0
def test_print_query_keys(testbed, capsys):
    for i in range(3):
        Article(title='title {}'.format(i)).put()

    snippets.print_query_keys(Article.query())

    stdout, _ = capsys.readouterr()
    assert "Key('Article'" in stdout
def query_article_in():
    query = Article.query(Article.tags.IN(['python', 'ruby', 'php']))
    return query
def query_article_inequality_explicit():
    query = Article.query(ndb.OR(Article.tags < 'perl',
                                 Article.tags > 'perl'))
    return query
def query_article_inequality():
    query = Article.query(Article.tags != 'perl')
    return query
def order_query_results_by_property(keyword):
    expando_query = FlexEmployee.query().order(ndb.GenericProperty('location'))

    property_query = Article.query().order(Article._properties[keyword])

    return expando_query, property_query
def query_properties_named_by_string_using_getattr(keyword, value):
    query = Article.query(getattr(Article, keyword) == value)
    return query
def query_properties_named_by_string_for_defined_properties(keyword, value):
    query = Article.query(Article._properties[keyword] == value)
    return query
Exemplo n.º 10
0
def query_properties_named_by_string_using_getattr(keyword, value):
    query = Article.query(getattr(Article, keyword) == value)
    return query
Exemplo n.º 11
0
def query_article_in_equivalent():
    query = Article.query(
        ndb.OR(Article.tags == 'python', Article.tags == 'ruby',
               Article.tags == 'php'))
    return query
Exemplo n.º 12
0
def query_article_in():
    query = Article.query(Article.tags.IN(['python', 'ruby', 'php']))
    return query
Exemplo n.º 13
0
def query_article_inequality_explicit():
    query = Article.query(ndb.OR(Article.tags < 'perl', Article.tags > 'perl'))
    return query
Exemplo n.º 14
0
def query_article_inequality():
    query = Article.query(Article.tags != 'perl')
    return query
Exemplo n.º 15
0
def order_query_results_by_property(keyword):
    expando_query = FlexEmployee.query().order(ndb.GenericProperty('location'))

    property_query = Article.query().order(Article._properties[keyword])

    return expando_query, property_query
Exemplo n.º 16
0
def query_article_in_equivalent():
    query = Article.query(ndb.OR(Article.tags == 'python',
                                 Article.tags == 'ruby',
                                 Article.tags == 'php'))
    return query
Exemplo n.º 17
0
def query_article_nested():
    query = Article.query(ndb.AND(Article.tags == 'python',
                                  ndb.OR(Article.tags.IN(['ruby', 'jruby']),
                                         ndb.AND(Article.tags == 'php',
                                                 Article.tags != 'perl'))))
    return query
Exemplo n.º 18
0
def query_properties_named_by_string_for_defined_properties(keyword, value):
    query = Article.query(Article._properties[keyword] == value)
    return query