Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support some extra operators #255

Closed
wants to merge 1 commit into from
Closed

Support some extra operators #255

wants to merge 1 commit into from

Conversation

giganteous
Copy link

Hi Jeffrey,

I've added a few operators through the .op() function that SQLalchemy provides.

I'd be delighted to create some working tests for this, but I'm afraid I don't interpret the current workings of the search test.

Thanks

@jfinkels
Copy link
Owner

jfinkels commented Dec 1, 2013

To write a test, add a method to tests.test_search.TestOperators that has the basic structure

d = dict(filters=[dict(name='age', op='<>', val=20)])
result = search(self.session, self.Person, d)
assert result.count() == 3

The Person table is pre-filled with some dummy instances; see tests.helpers.TestSupportPrefilled.

I'm not familiar with the extra operators you've provided---for what are they used?

@giganteous
Copy link
Author

I needed support for the network operators in PostgreSQL. They are
postgresql specific, see [1].

On the testing subject: I've been pondering on how to effectively test
the wrapping that your software does. The only thing that sounds
reasonable is to use some kind of mockup sqlalchemy that doesn't connect
with a real database, but is configured for (eg) postgres.

The remaining thing that needs to be tested is looking if your
documented operators are translated (roughly) to the equivalent SQL.

Its hard to test though, if SQLalchemy decides to fix something, your
tests will lag behind again.

I wonder if no one has fixed this issue, and I suppose you must've
walked into the same problem :)

[1] http://www.postgresql.org/docs/9.2/interactive/functions-net.html

}


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't delete this new line.

@jfinkels
Copy link
Owner

Ok. Well I'd least like to see a test case that shows some sort of error response from the server if the backend is sqlite but the client has requested some of these network address operators.

@jfinkels
Copy link
Owner

jfinkels commented Feb 3, 2015

It should certainly be possible to write a test that uses PostgreSQL with SQLAlchemy; Flask-Restless (should be) backend-agnostic beyond the requirement of SQLAlchemy. Take a look at FlaskTestBase and its subclass DatabaseTestBase in tests/helpers.py: start by copying that code, but instead of creating a SQLite database connection, simply create a PostgreSQL connection. After that, I can modify the testing requirements to check for PostgreSQL and skip those tests unless it is installed.

@jfinkels
Copy link
Owner

See pull request #502 which includes the suggestions here in addition to tests and documentation.

@jfinkels jfinkels closed this Mar 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants