title: Querying for floating point values in SQLAlchemy
body: <p>To summarize the problem, I can not select any entity against a floating point value using SQLAlchemy. </p>
  
  <p>For example:</p>
  
  <pre><code>m = session.query(Model).get(1);
  all_m = session.query(Model).filter(Model.some_float_value, m.some_float_value)
  </code></pre>
  
  <p>all_m is empty while I would expect it to always have at least one!</p>
  
  <p>How can I filter a float value in SQLAlchemy, based on an arbitrary precision (EG. some I may want to match to 0.01 or others I may filter with a precision of 0.0005). </p>
  
  <p>For example, I want to be able to write a generic function so I can write queries like this in my code:</p>
  
  <pre><code>session.query(Model)\
      .filter(Model.foo == "bar",
              match_float(Model.some_float_value, float_val, 0.025)).all()
  </code></pre>
  
  <p>Where there tolerance of the matches anything within an approximate tolerance of 0.025. </p>
  
  <p>However, I am not very familiar with SQLAlchemy, and was unable to locate documentation on how to create custom compare function, or any built in functions that would do what I need. </p>
  
  <p>Is there a built in function I can use, a way to provide a custom compare function for the filter method, or do I a way to write a raw query/procedure for this? </p>
  
  <p>Aditional Info:</p>
  
  <p>Postgres 9.2</p>
  
  <p>SQLAlchemy 0.9</p>
  
  <p>Values are stored as double precision floating point</p>
  
  <p>All Models were defined like so (there are a lot of them, which makes a solution with explicit column definitions less than desirable):</p>
  
  <pre><code>engine = create_engine('postgresql://user:pass@localhost:1234/database')
  Base = declarative_base()
  metadata = MetaData(bind=engine)
  
  class Model(Base):
      __table__ = Table('model', metadata, autoload=True)
  </code></pre>
  
  <p><em>edit</em></p>
  
  <p>Iv'e completely reworded my question for clarity. Sorry for the confusion, I fail at communicating with humans...</p>