Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(11)  |  Call(10)  |  Derive(0)  |  Import(1)
Returns a SQLAlchemy query object on the given `model` where the search
for the query is defined by `searchparams`.

The returned query matches the set of all instances of `model` which meet
the parameters of the search given by `searchparams`. For more information
on search parameters, see :ref:`search`.

`model` is a SQLAlchemy declarative model representing the database model
to query.
(more...)

        def create_query(session, model, searchparams):
    """Returns a SQLAlchemy query object on the given `model` where the search
    for the query is defined by `searchparams`.

    The returned query matches the set of all instances of `model` which meet
    the parameters of the search given by `searchparams`. For more information
    on search parameters, see :ref:`search`.

    `model` is a SQLAlchemy declarative model representing the database model
    to query.

    `searchparams` is either a dictionary (as parsed from a JSON request from
    the client, for example) or a :class:`SearchParameters` instance defining
    the parameters of the query (as returned by
    :func:`SearchParameters.from_dictionary`, for example).

    """
    if isinstance(searchparams, dict):
        searchparams = SearchParameters.from_dictionary(searchparams)
    return QueryBuilder.create_query(session, model, searchparams)
        


src/f/l/flask-restless-HEAD/tests/test_search.py   flask-restless(Download)
from sqlalchemy.orm.exc import NoResultFound
 
from flask.ext.restless.search import create_query
from flask.ext.restless.search import search
from flask.ext.restless.search import SearchParameters
    def test_empty_search(self):
        """Tests that a query with no search parameters returns everything."""
        query = create_query(self.session, self.Person, {})
        assert query.all() == self.people
 
        d = {'filters': [{'name': 'name', 'val': u'%y%', 'op': 'like'}]}
        s = SearchParameters.from_dictionary(d)
        query_d = create_query(self.session, self.Person, d)
        query_s = create_query(self.session, self.Person, s)
        assert query_d.all() == query_s.all()
 
    def test_basic_query(self):
        """Tests for basic query correctness."""
        d = {'filters': [{'name': 'name', 'val': u'%y%', 'op': 'like'}]}
        query = create_query(self.session, self.Person, d)