<p dir="auto">The following syntax:</p>
<p dir="auto">Model.query.filter('table_name.column_name % 'query_string'').all()</p>
<p dir="auto">will generate a correct sql expression, except by the percentage sign, which will be duplicated, rendering: "model.column_name %% 'query_string'".</p>
<p dir="auto">This duplication is unavoidable so far as I know by the docs, but it should be possible to provide literal SQL to the filter clause, in order to not disturb code which dynamically relies on concatenation of filters.</p>
<p dir="auto">The above % syntax is compatible with posgres fuzzy search module.</p>
<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">Python 3.3 has added a <a href="http://docs.python.org/3.3/library/datetime.html#datetime.datetime.timestamp" rel="nofollow">timestamp() method to datetime.datetime objects</a>.</p>
<p dir="auto">In this example SettingDefaults.start_time is defined as Column(DateTime, default=datetime.now, nullable=False).</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    default_settings = session.query(SettingDefaults).\
        filter(SettingDefaults.start_time.timestamp() &lt;= start_timestamp)

gives:

	Traceback (most recent call last):
	  File &quot;/sites/metrics_dev/env/lib/python3.3/site-packages/SQLAlchemy-0.8.0-py3.3.egg/sqlalchemy/sql/expression.py&quot;, line 2267, in __getattr__
		return getattr(self.comparator, key)
	AttributeError: 'Comparator' object has no attribute 'timestamp'

	During handling of the above exception, another exception occurred:

	Traceback (most recent call last):
	  File &quot;/sites/metrics_dev/env/lib/python3.3/site-packages/SQLAlchemy-0.8.0-py3.3.egg/sqlalchemy/orm/attributes.py&quot;, line 262, in __getattr__
		return getattr(self.comparator, key)
	  File &quot;/sites/metrics_dev/env/lib/python3.3/site-packages/SQLAlchemy-0.8.0-py3.3.egg/sqlalchemy/orm/properties.py&quot;, line 209, in __getattr__
		return getattr(self.__clause_element__(), key)
	  File &quot;/sites/metrics_dev/env/lib/python3.3/site-packages/SQLAlchemy-0.8.0-py3.3.egg/sqlalchemy/sql/expression.py&quot;, line 2273, in __getattr__
		key)
	AttributeError: Neither 'AnnotatedColumn' object nor 'Comparator' object has an attribute 'timestamp'

	During handling of the above exception, another exception occurred:

	Traceback (most recent call last):
	  [SNIP ***](***)
		filter(SettingDefaults.start_time.timestamp() &lt;= start_timestamp)
	  File &quot;/sites/metrics_dev/env/lib/python3.3/site-packages/SQLAlchemy-0.8.0-py3.3.egg/sqlalchemy/orm/attributes.py&quot;, line 270, in __getattr__
		key)
	AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with SettingDefaults.start_time has an attribute 'timestamp'"><pre class="notranslate"><code class="notranslate">    default_settings = session.query(SettingDefaults).\
        filter(SettingDefaults.start_time.timestamp() &lt;= start_timestamp)

gives:

	Traceback (most recent call last):
	  File "/sites/metrics_dev/env/lib/python3.3/site-packages/SQLAlchemy-0.8.0-py3.3.egg/sqlalchemy/sql/expression.py", line 2267, in __getattr__
		return getattr(self.comparator, key)
	AttributeError: 'Comparator' object has no attribute 'timestamp'

	During handling of the above exception, another exception occurred:

	Traceback (most recent call last):
	  File "/sites/metrics_dev/env/lib/python3.3/site-packages/SQLAlchemy-0.8.0-py3.3.egg/sqlalchemy/orm/attributes.py", line 262, in __getattr__
		return getattr(self.comparator, key)
	  File "/sites/metrics_dev/env/lib/python3.3/site-packages/SQLAlchemy-0.8.0-py3.3.egg/sqlalchemy/orm/properties.py", line 209, in __getattr__
		return getattr(self.__clause_element__(), key)
	  File "/sites/metrics_dev/env/lib/python3.3/site-packages/SQLAlchemy-0.8.0-py3.3.egg/sqlalchemy/sql/expression.py", line 2273, in __getattr__
		key)
	AttributeError: Neither 'AnnotatedColumn' object nor 'Comparator' object has an attribute 'timestamp'

	During handling of the above exception, another exception occurred:

	Traceback (most recent call last):
	  [SNIP ***](***)
		filter(SettingDefaults.start_time.timestamp() &lt;= start_timestamp)
	  File "/sites/metrics_dev/env/lib/python3.3/site-packages/SQLAlchemy-0.8.0-py3.3.egg/sqlalchemy/orm/attributes.py", line 270, in __getattr__
		key)
	AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with SettingDefaults.start_time has an attribute 'timestamp'
</code></pre></div>