1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10
— SQLAlchemy 0.7 Documentation</title>
12
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
13
<link rel="stylesheet" href="../_static/docs.css" type="text/css" />
15
<script type="text/javascript">
16
var DOCUMENTATION_OPTIONS = {
19
COLLAPSE_MODINDEX: false,
23
<script type="text/javascript" src="../_static/jquery.js"></script>
24
<script type="text/javascript" src="../_static/underscore.js"></script>
25
<script type="text/javascript" src="../_static/doctools.js"></script>
26
<script type="text/javascript" src="../_static/init.js"></script>
27
<link rel="index" title="Index" href="../genindex.html" />
28
<link rel="search" title="Search" href="../search.html" />
29
<link rel="copyright" title="Copyright" href="../copyright.html" />
30
<link rel="top" title="SQLAlchemy 0.7 Documentation" href="../index.html" />
31
<link rel="up" title="SQLAlchemy ORM" href="index.html" />
32
<link rel="next" title="SQLAlchemy Core" href="../core/index.html" />
33
<link rel="prev" title="ORM Exceptions" href="exceptions.html" />
41
<h1>SQLAlchemy 0.7 Documentation</h1>
45
<form class="search" action="../search.html" method="get">
46
<input type="text" name="q" size="18" /> <input type="submit" value="Search" />
47
<input type="hidden" name="check_keywords" value="yes" />
48
<input type="hidden" name="area" value="default" />
52
<div class="versionheader">
53
Release: <span class="versionnum">0.7.2</span> | Release Date: July 31, 2011
55
<div class="clearboth"></div>
58
<div id="pagecontrol">
61
<a href="exceptions.html" title="previous chapter">ORM Exceptions</a>
64
<a href="../core/index.html" title="next chapter">SQLAlchemy Core</a>
68
<a href="../contents.html">Table of Contents</a> |
69
<a href="../genindex.html">Index</a>
70
| <a href="../_sources/orm/internals.txt">view source
75
<a class="totoc" href="../index.html">SQLAlchemy 0.7 Documentation</a>
76
» <a href="index.html" title="SQLAlchemy ORM">SQLAlchemy ORM</a>
87
<div class="clearboth"></div>
90
<div class="document">
93
<div class="section" id="orm-internals">
94
<span id="orm-internal-toplevel"></span><h1>ORM Internals<a class="headerlink" href="#orm-internals" title="Permalink to this headline">¶</a></h1>
95
<p>Some key internal constructs are listed here.</p>
97
<dt id="sqlalchemy.orm.instrumentation.ClassManager">
98
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.instrumentation.</tt><tt class="descname">ClassManager</tt><big>(</big><em>class_</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.instrumentation.ClassManager" title="Permalink to this definition">¶</a></dt>
99
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></p>
100
<p>tracks state information at the class level.</p>
102
<dt id="sqlalchemy.orm.instrumentation.ClassManager.dispose">
103
<tt class="descname">dispose</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.orm.instrumentation.ClassManager.dispose" title="Permalink to this definition">¶</a></dt>
104
<dd><p>Dissasociate this manager from its class.</p>
108
<dt id="sqlalchemy.orm.instrumentation.ClassManager.has_parent">
109
<tt class="descname">has_parent</tt><big>(</big><em>state</em>, <em>key</em>, <em>optimistic=False</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.instrumentation.ClassManager.has_parent" title="Permalink to this definition">¶</a></dt>
114
<dt id="sqlalchemy.orm.instrumentation.ClassManager.manage">
115
<tt class="descname">manage</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.orm.instrumentation.ClassManager.manage" title="Permalink to this definition">¶</a></dt>
116
<dd><p>Mark this instance as the manager for its class.</p>
119
<dl class="attribute">
120
<dt id="sqlalchemy.orm.instrumentation.ClassManager.original_init">
121
<tt class="descname">original_init</tt><a class="headerlink" href="#sqlalchemy.orm.instrumentation.ClassManager.original_init" title="Permalink to this definition">¶</a></dt>
122
<dd><p>x.__init__(...) initializes x; see help(type(x)) for signature</p>
126
<dt id="sqlalchemy.orm.instrumentation.ClassManager.state_getter">
127
<tt class="descname">state_getter</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.orm.instrumentation.ClassManager.state_getter" title="Permalink to this definition">¶</a></dt>
128
<dd><p>Return a (instance) -> InstanceState callable.</p>
129
<p>“state getter” callables should raise either KeyError or
130
AttributeError if no InstanceState could be found for the
135
<dt id="sqlalchemy.orm.instrumentation.ClassManager.unregister">
136
<tt class="descname">unregister</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.orm.instrumentation.ClassManager.unregister" title="Permalink to this definition">¶</a></dt>
137
<dd><p>remove all instrumentation established by this ClassManager.</p>
143
<dt id="sqlalchemy.orm.properties.ColumnProperty">
144
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.properties.</tt><tt class="descname">ColumnProperty</tt><big>(</big><em>*columns</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.ColumnProperty" title="Permalink to this definition">¶</a></dt>
145
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.orm.interfaces.StrategizedProperty</span></tt></p>
146
<p>Describes an object attribute that corresponds to a table column.</p>
147
<p>Public constructor is the <a class="reference internal" href="mapper_config.html#sqlalchemy.orm.column_property" title="sqlalchemy.orm.column_property"><tt class="xref py py-func docutils literal"><span class="pre">orm.column_property()</span></tt></a> function.</p>
149
<dt id="sqlalchemy.orm.properties.ColumnProperty.__init__">
150
<tt class="descname">__init__</tt><big>(</big><em>*columns</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.ColumnProperty.__init__" title="Permalink to this definition">¶</a></dt>
151
<dd><p>Construct a ColumnProperty.</p>
152
<p>Note the public constructor is the <a class="reference internal" href="mapper_config.html#sqlalchemy.orm.column_property" title="sqlalchemy.orm.column_property"><tt class="xref py py-func docutils literal"><span class="pre">orm.column_property()</span></tt></a> function.</p>
153
<table class="docutils field-list" frame="void" rules="none">
154
<col class="field-name" />
155
<col class="field-body" />
157
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
158
<li><strong>*columns</strong> – The list of <cite>columns</cite> describes a single
159
object property. If there are multiple tables joined
160
together for the mapper, this list represents the equivalent
161
column as it appears across each table.</li>
162
<li><strong>group</strong> – </li>
163
<li><strong>deferred</strong> – </li>
164
<li><strong>comparator_factory</strong> – </li>
165
<li><strong>descriptor</strong> – </li>
166
<li><strong>extension</strong> – </li>
177
<dt id="sqlalchemy.orm.descriptor_props.CompositeProperty">
178
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.descriptor_props.</tt><tt class="descname">CompositeProperty</tt><big>(</big><em>class_</em>, <em>*attrs</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.descriptor_props.CompositeProperty" title="Permalink to this definition">¶</a></dt>
179
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.orm.descriptor_props.DescriptorProperty</span></tt></p>
181
<dt id="sqlalchemy.orm.descriptor_props.CompositeProperty.do_init">
182
<tt class="descname">do_init</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.orm.descriptor_props.CompositeProperty.do_init" title="Permalink to this definition">¶</a></dt>
183
<dd><p>Initialization which occurs after the <a class="reference internal" href="#sqlalchemy.orm.descriptor_props.CompositeProperty" title="sqlalchemy.orm.descriptor_props.CompositeProperty"><tt class="xref py py-class docutils literal"><span class="pre">CompositeProperty</span></tt></a>
184
has been associated with its parent mapper.</p>
188
<dt id="sqlalchemy.orm.descriptor_props.CompositeProperty.get_history">
189
<tt class="descname">get_history</tt><big>(</big><em>state</em>, <em>dict_</em>, <em>passive=<symbol 'PASSIVE_OFF></em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.descriptor_props.CompositeProperty.get_history" title="Permalink to this definition">¶</a></dt>
190
<dd><p>Provided for userland code that uses attributes.get_history().</p>
196
<dt id="sqlalchemy.orm.state.InstanceState">
197
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.state.</tt><tt class="descname">InstanceState</tt><big>(</big><em>obj</em>, <em>manager</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState" title="Permalink to this definition">¶</a></dt>
198
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
199
<p>tracks state information at the instance level.</p>
201
<dt id="sqlalchemy.orm.state.InstanceState.commit">
202
<tt class="descname">commit</tt><big>(</big><em>dict_</em>, <em>keys</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState.commit" title="Permalink to this definition">¶</a></dt>
203
<dd><p>Commit attributes.</p>
204
<p>This is used by a partial-attribute load operation to mark committed
205
those attributes which were refreshed from the database.</p>
206
<p>Attributes marked as “expired” can potentially remain “expired” after
207
this step if a value was not populated in state.dict.</p>
211
<dt id="sqlalchemy.orm.state.InstanceState.commit_all">
212
<tt class="descname">commit_all</tt><big>(</big><em>dict_</em>, <em>instance_dict=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState.commit_all" title="Permalink to this definition">¶</a></dt>
213
<dd><p>commit all attributes unconditionally.</p>
214
<p>This is used after a flush() or a full load/refresh
215
to remove all pending state from the instance.</p>
217
<div><ul class="simple">
218
<li>all attributes are marked as “committed”</li>
219
<li>the “strong dirty reference” is removed</li>
220
<li>the “modified” flag is set to False</li>
221
<li>any “expired” markers/callables for attributes loaded are removed.</li>
224
<p>Attributes marked as “expired” can potentially remain “expired” after this step
225
if a value was not populated in state.dict.</p>
229
<dt id="sqlalchemy.orm.state.InstanceState.expire_attribute_pre_commit">
230
<tt class="descname">expire_attribute_pre_commit</tt><big>(</big><em>dict_</em>, <em>key</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState.expire_attribute_pre_commit" title="Permalink to this definition">¶</a></dt>
231
<dd><p>a fast expire that can be called by column loaders during a load.</p>
232
<p>The additional bookkeeping is finished up in commit_all().</p>
233
<p>This method is actually called a lot with joined-table
234
loading, when the second table isn’t present in the result.</p>
237
<dl class="attribute">
238
<dt id="sqlalchemy.orm.state.InstanceState.expired_attributes">
239
<tt class="descname">expired_attributes</tt><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState.expired_attributes" title="Permalink to this definition">¶</a></dt>
240
<dd><p>Return the set of keys which are ‘expired’ to be loaded by
241
the manager’s deferred scalar loader, assuming no pending
243
<p>see also the <tt class="docutils literal"><span class="pre">unmodified</span></tt> collection which is intersected
244
against this set when a refresh operation occurs.</p>
248
<dt id="sqlalchemy.orm.state.InstanceState.initialize">
249
<tt class="descname">initialize</tt><big>(</big><em>key</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState.initialize" title="Permalink to this definition">¶</a></dt>
250
<dd><p>Set this attribute to an empty value or collection,
251
based on the AttributeImpl in use.</p>
255
<dt id="sqlalchemy.orm.state.InstanceState.reset">
256
<tt class="descname">reset</tt><big>(</big><em>dict_</em>, <em>key</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState.reset" title="Permalink to this definition">¶</a></dt>
257
<dd><p>Remove the given attribute and any
258
callables associated with it.</p>
262
<dt id="sqlalchemy.orm.state.InstanceState.set_callable">
263
<tt class="descname">set_callable</tt><big>(</big><em>dict_</em>, <em>key</em>, <em>callable_</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState.set_callable" title="Permalink to this definition">¶</a></dt>
264
<dd><p>Remove the given attribute and set the given callable
268
<dl class="attribute">
269
<dt id="sqlalchemy.orm.state.InstanceState.unloaded">
270
<tt class="descname">unloaded</tt><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState.unloaded" title="Permalink to this definition">¶</a></dt>
271
<dd><p>Return the set of keys which do not have a loaded value.</p>
272
<p>This includes expired attributes and any other attribute that
273
was never populated or modified.</p>
276
<dl class="attribute">
277
<dt id="sqlalchemy.orm.state.InstanceState.unmodified">
278
<tt class="descname">unmodified</tt><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState.unmodified" title="Permalink to this definition">¶</a></dt>
279
<dd><p>Return the set of keys which have no uncommitted changes</p>
283
<dt id="sqlalchemy.orm.state.InstanceState.unmodified_intersection">
284
<tt class="descname">unmodified_intersection</tt><big>(</big><em>keys</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState.unmodified_intersection" title="Permalink to this definition">¶</a></dt>
285
<dd><p>Return self.unmodified.intersection(keys).</p>
289
<dt id="sqlalchemy.orm.state.InstanceState.value_as_iterable">
290
<tt class="descname">value_as_iterable</tt><big>(</big><em>dict_</em>, <em>key</em>, <em>passive=<symbol 'PASSIVE_OFF></em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.state.InstanceState.value_as_iterable" title="Permalink to this definition">¶</a></dt>
291
<dd><p>Return a list of tuples (state, obj) for the given
293
<p>returns an empty list if the value is None/empty/PASSIVE_NO_RESULT</p>
299
<dt id="sqlalchemy.orm.interfaces.MapperProperty">
300
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.interfaces.</tt><tt class="descname">MapperProperty</tt><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty" title="Permalink to this definition">¶</a></dt>
301
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
302
<p>Manage the relationship of a <tt class="docutils literal"><span class="pre">Mapper</span></tt> to a single class
303
attribute, as well as that attribute as it appears on individual
304
instances of the class, including attribute instrumentation,
305
attribute access, loading behavior, and dependency calculations.</p>
306
<dl class="attribute">
307
<dt id="sqlalchemy.orm.interfaces.MapperProperty.cascade">
308
<tt class="descname">cascade</tt><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty.cascade" title="Permalink to this definition">¶</a></dt>
309
<dd><p>The set of ‘cascade’ attribute names.</p>
310
<p>This collection is checked before the ‘cascade_iterator’ method is called.</p>
314
<dt id="sqlalchemy.orm.interfaces.MapperProperty.cascade_iterator">
315
<tt class="descname">cascade_iterator</tt><big>(</big><em>type_</em>, <em>state</em>, <em>visited_instances=None</em>, <em>halt_on=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty.cascade_iterator" title="Permalink to this definition">¶</a></dt>
316
<dd><p>Iterate through instances related to the given instance for
317
a particular ‘cascade’, starting with this MapperProperty.</p>
318
<p>Return an iterator3-tuples (instance, mapper, state).</p>
319
<p>Note that the ‘cascade’ collection on this MapperProperty is
320
checked first for the given type before cascade_iterator is called.</p>
321
<p>See PropertyLoader for the related instance implementation.</p>
324
<dl class="attribute">
325
<dt id="sqlalchemy.orm.interfaces.MapperProperty.class_attribute">
326
<tt class="descname">class_attribute</tt><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty.class_attribute" title="Permalink to this definition">¶</a></dt>
327
<dd><p>Return the class-bound descriptor corresponding to this
332
<dt id="sqlalchemy.orm.interfaces.MapperProperty.compare">
333
<tt class="descname">compare</tt><big>(</big><em>operator</em>, <em>value</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty.compare" title="Permalink to this definition">¶</a></dt>
334
<dd><p>Return a compare operation for the columns represented by
335
this <tt class="docutils literal"><span class="pre">MapperProperty</span></tt> to the given value, which may be a
336
column value or an instance. ‘operator’ is an operator from
337
the operators module, or from sql.Comparator.</p>
338
<p>By default uses the PropComparator attached to this MapperProperty
339
under the attribute name “comparator”.</p>
343
<dt id="sqlalchemy.orm.interfaces.MapperProperty.create_row_processor">
344
<tt class="descname">create_row_processor</tt><big>(</big><em>context</em>, <em>path</em>, <em>reduced_path</em>, <em>mapper</em>, <em>row</em>, <em>adapter</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty.create_row_processor" title="Permalink to this definition">¶</a></dt>
345
<dd><p>Return a 3-tuple consisting of three row processing functions.</p>
349
<dt id="sqlalchemy.orm.interfaces.MapperProperty.do_init">
350
<tt class="descname">do_init</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty.do_init" title="Permalink to this definition">¶</a></dt>
351
<dd><p>Perform subclass-specific initialization post-mapper-creation
353
<p>This is a template method called by the <tt class="docutils literal"><span class="pre">MapperProperty</span></tt>
354
object’s init() method.</p>
358
<dt id="sqlalchemy.orm.interfaces.MapperProperty.init">
359
<tt class="descname">init</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty.init" title="Permalink to this definition">¶</a></dt>
360
<dd><p>Called after all mappers are created to assemble
361
relationships between mappers and perform other post-mapper-creation
362
initialization steps.</p>
366
<dt id="sqlalchemy.orm.interfaces.MapperProperty.is_primary">
367
<tt class="descname">is_primary</tt><big>(</big><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty.is_primary" title="Permalink to this definition">¶</a></dt>
368
<dd><p>Return True if this <tt class="docutils literal"><span class="pre">MapperProperty</span></tt>‘s mapper is the
369
primary mapper for its class.</p>
370
<p>This flag is used to indicate that the <tt class="docutils literal"><span class="pre">MapperProperty</span></tt> can
371
define attribute instrumentation for the class at the class
372
level (as opposed to the individual instance level).</p>
376
<dt id="sqlalchemy.orm.interfaces.MapperProperty.merge">
377
<tt class="descname">merge</tt><big>(</big><em>session</em>, <em>source_state</em>, <em>source_dict</em>, <em>dest_state</em>, <em>dest_dict</em>, <em>load</em>, <em>_recursive</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty.merge" title="Permalink to this definition">¶</a></dt>
378
<dd><p>Merge the attribute represented by this <tt class="docutils literal"><span class="pre">MapperProperty</span></tt>
379
from source to destination object</p>
383
<dt id="sqlalchemy.orm.interfaces.MapperProperty.post_instrument_class">
384
<tt class="descname">post_instrument_class</tt><big>(</big><em>mapper</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty.post_instrument_class" title="Permalink to this definition">¶</a></dt>
385
<dd><p>Perform instrumentation adjustments that need to occur
386
after init() has completed.</p>
390
<dt id="sqlalchemy.orm.interfaces.MapperProperty.setup">
391
<tt class="descname">setup</tt><big>(</big><em>context</em>, <em>entity</em>, <em>path</em>, <em>reduced_path</em>, <em>adapter</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.MapperProperty.setup" title="Permalink to this definition">¶</a></dt>
392
<dd><p>Called by Query for the purposes of constructing a SQL statement.</p>
393
<p>Each MapperProperty associated with the target mapper processes the
394
statement referenced by the query context, adding columns and/or
395
criterion as appropriate.</p>
401
<dt id="sqlalchemy.orm.interfaces.PropComparator">
402
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.interfaces.</tt><tt class="descname">PropComparator</tt><big>(</big><em>prop</em>, <em>mapper</em>, <em>adapter=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.PropComparator" title="Permalink to this definition">¶</a></dt>
403
<dd><p>Bases: <a class="reference internal" href="../core/expression_api.html#sqlalchemy.sql.operators.ColumnOperators" title="sqlalchemy.sql.operators.ColumnOperators"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.sql.operators.ColumnOperators</span></tt></a></p>
404
<p>Defines comparison operations for MapperProperty objects.</p>
405
<p>User-defined subclasses of <a class="reference internal" href="#sqlalchemy.orm.interfaces.PropComparator" title="sqlalchemy.orm.interfaces.PropComparator"><tt class="xref py py-class docutils literal"><span class="pre">PropComparator</span></tt></a> may be created. The
406
built-in Python comparison and math operator methods, such as
407
<tt class="docutils literal"><span class="pre">__eq__()</span></tt>, <tt class="docutils literal"><span class="pre">__lt__()</span></tt>, <tt class="docutils literal"><span class="pre">__add__()</span></tt>, can be overridden to provide
408
new operator behavior. The custom <a class="reference internal" href="#sqlalchemy.orm.interfaces.PropComparator" title="sqlalchemy.orm.interfaces.PropComparator"><tt class="xref py py-class docutils literal"><span class="pre">PropComparator</span></tt></a> is passed to
409
the mapper property via the <tt class="docutils literal"><span class="pre">comparator_factory</span></tt> argument. In each case,
410
the appropriate subclass of <a class="reference internal" href="#sqlalchemy.orm.interfaces.PropComparator" title="sqlalchemy.orm.interfaces.PropComparator"><tt class="xref py py-class docutils literal"><span class="pre">PropComparator</span></tt></a> should be used:</p>
411
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sqlalchemy.orm.properties</span> <span class="kn">import</span> \
412
<span class="n">ColumnProperty</span><span class="p">,</span>\
413
<span class="n">CompositeProperty</span><span class="p">,</span>\
414
<span class="n">RelationshipProperty</span>
416
<span class="k">class</span> <span class="nc">MyColumnComparator</span><span class="p">(</span><span class="n">ColumnProperty</span><span class="o">.</span><span class="n">Comparator</span><span class="p">):</span>
417
<span class="k">pass</span>
419
<span class="k">class</span> <span class="nc">MyCompositeComparator</span><span class="p">(</span><span class="n">CompositeProperty</span><span class="o">.</span><span class="n">Comparator</span><span class="p">):</span>
420
<span class="k">pass</span>
422
<span class="k">class</span> <span class="nc">MyRelationshipComparator</span><span class="p">(</span><span class="n">RelationshipProperty</span><span class="o">.</span><span class="n">Comparator</span><span class="p">):</span>
423
<span class="k">pass</span></pre></div>
426
<dt id="sqlalchemy.orm.interfaces.PropComparator.adapted">
427
<tt class="descname">adapted</tt><big>(</big><em>adapter</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.PropComparator.adapted" title="Permalink to this definition">¶</a></dt>
428
<dd><p>Return a copy of this PropComparator which will use the given
429
adaption function on the local side of generated expressions.</p>
433
<dt id="sqlalchemy.orm.interfaces.PropComparator.any">
434
<tt class="descname">any</tt><big>(</big><em>criterion=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.PropComparator.any" title="Permalink to this definition">¶</a></dt>
435
<dd><p>Return true if this collection contains any member that meets the
437
<dl class="docutils">
439
<dd>an optional ClauseElement formulated against the member class’ table
442
<dd>key/value pairs corresponding to member class attribute names which
443
will be compared via equality to the corresponding values.</dd>
448
<dt id="sqlalchemy.orm.interfaces.PropComparator.has">
449
<tt class="descname">has</tt><big>(</big><em>criterion=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.PropComparator.has" title="Permalink to this definition">¶</a></dt>
450
<dd><p>Return true if this element references a member which meets the
452
<dl class="docutils">
454
<dd>an optional ClauseElement formulated against the member class’ table
457
<dd>key/value pairs corresponding to member class attribute names which
458
will be compared via equality to the corresponding values.</dd>
463
<dt id="sqlalchemy.orm.interfaces.PropComparator.of_type">
464
<tt class="descname">of_type</tt><big>(</big><em>class_</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.interfaces.PropComparator.of_type" title="Permalink to this definition">¶</a></dt>
465
<dd><p>Redefine this object in terms of a polymorphic subclass.</p>
466
<p>Returns a new PropComparator from which further criterion can be
469
<div class="highlight-python"><div class="highlight"><pre><span class="n">query</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">Company</span><span class="o">.</span><span class="n">employees</span><span class="o">.</span><span class="n">of_type</span><span class="p">(</span><span class="n">Engineer</span><span class="p">))</span><span class="o">.</span>\
470
<span class="nb">filter</span><span class="p">(</span><span class="n">Engineer</span><span class="o">.</span><span class="n">name</span><span class="o">==</span><span class="s">'foo'</span><span class="p">)</span></pre></div>
472
<dl class="docutils">
474
<dd>a class or mapper indicating that criterion will be against
475
this specific subclass.</dd>
482
<dt id="sqlalchemy.orm.properties.RelationshipProperty">
483
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.properties.</tt><tt class="descname">RelationshipProperty</tt><big>(</big><em>argument</em>, <em>secondary=None</em>, <em>primaryjoin=None</em>, <em>secondaryjoin=None</em>, <em>foreign_keys=None</em>, <em>uselist=None</em>, <em>order_by=False</em>, <em>backref=None</em>, <em>back_populates=None</em>, <em>post_update=False</em>, <em>cascade=False</em>, <em>extension=None</em>, <em>viewonly=False</em>, <em>lazy=True</em>, <em>collection_class=None</em>, <em>passive_deletes=False</em>, <em>passive_updates=True</em>, <em>remote_side=None</em>, <em>enable_typechecks=True</em>, <em>join_depth=None</em>, <em>comparator_factory=None</em>, <em>single_parent=False</em>, <em>innerjoin=False</em>, <em>doc=None</em>, <em>active_history=False</em>, <em>cascade_backrefs=True</em>, <em>load_on_pending=False</em>, <em>strategy_class=None</em>, <em>_local_remote_pairs=None</em>, <em>query_class=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty" title="Permalink to this definition">¶</a></dt>
484
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.orm.interfaces.StrategizedProperty</span></tt></p>
485
<p>Describes an object property that holds a single item or list
486
of items that correspond to a related database table.</p>
487
<p>Public constructor is the <a class="reference internal" href="relationships.html#sqlalchemy.orm.relationship" title="sqlalchemy.orm.relationship"><tt class="xref py py-func docutils literal"><span class="pre">orm.relationship()</span></tt></a> function.</p>
488
<p>Of note here is the <a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator"><tt class="xref py py-class docutils literal"><span class="pre">RelationshipProperty.Comparator</span></tt></a>
489
class, which implements comparison operations for scalar-
490
and collection-referencing mapped attributes.</p>
492
<dt id="sqlalchemy.orm.properties.RelationshipProperty.Comparator">
493
<em class="property">class </em><tt class="descname">Comparator</tt><big>(</big><em>prop</em>, <em>mapper</em>, <em>of_type=None</em>, <em>adapter=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator" title="Permalink to this definition">¶</a></dt>
494
<dd><p>Bases: <a class="reference internal" href="#sqlalchemy.orm.interfaces.PropComparator" title="sqlalchemy.orm.interfaces.PropComparator"><tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.orm.interfaces.PropComparator</span></tt></a></p>
495
<p>Produce comparison operations for <a class="reference internal" href="relationships.html#sqlalchemy.orm.relationship" title="sqlalchemy.orm.relationship"><tt class="xref py py-func docutils literal"><span class="pre">relationship()</span></tt></a>-based
498
<dt id="sqlalchemy.orm.properties.RelationshipProperty.Comparator.__eq__">
499
<tt class="descname">__eq__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.__eq__" title="Permalink to this definition">¶</a></dt>
500
<dd><p>Implement the <tt class="docutils literal"><span class="pre">==</span></tt> operator.</p>
501
<p>In a many-to-one context, such as:</p>
502
<div class="highlight-python"><pre>MyClass.some_prop == <some object></pre>
504
<p>this will typically produce a
506
<div class="highlight-python"><pre>mytable.related_id == <some id></pre>
508
<p>Where <tt class="docutils literal"><span class="pre"><some</span> <span class="pre">id></span></tt> is the primary key of the given
510
<p>The <tt class="docutils literal"><span class="pre">==</span></tt> operator provides partial functionality for non-
511
many-to-one comparisons:</p>
513
<li>Comparisons against collections are not supported.
514
Use <a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains"><tt class="xref py py-meth docutils literal"><span class="pre">contains()</span></tt></a>.</li>
515
<li>Compared to a scalar one-to-many, will produce a
516
clause that compares the target columns in the parent to
517
the given target.</li>
518
<li>Compared to a scalar many-to-many, an alias
519
of the association table will be rendered as
520
well, forming a natural join that is part of the
521
main body of the query. This will not work for
522
queries that go beyond simple AND conjunctions of
523
comparisons, such as those which use OR. Use
524
explicit joins, outerjoins, or
525
<a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.has" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.has"><tt class="xref py py-meth docutils literal"><span class="pre">has()</span></tt></a> for
526
more comprehensive non-many-to-one scalar
527
membership tests.</li>
528
<li>Comparisons against <tt class="xref docutils literal"><span class="pre">None</span></tt> given in a one-to-many
529
or many-to-many context produce a NOT EXISTS clause.</li>
534
<dt id="sqlalchemy.orm.properties.RelationshipProperty.Comparator.__init__">
535
<tt class="descname">__init__</tt><big>(</big><em>prop</em>, <em>mapper</em>, <em>of_type=None</em>, <em>adapter=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.__init__" title="Permalink to this definition">¶</a></dt>
536
<dd><p>Construction of <a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator"><tt class="xref py py-class docutils literal"><span class="pre">RelationshipProperty.Comparator</span></tt></a>
537
is internal to the ORM’s attribute mechanics.</p>
541
<dt id="sqlalchemy.orm.properties.RelationshipProperty.Comparator.__ne__">
542
<tt class="descname">__ne__</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.__ne__" title="Permalink to this definition">¶</a></dt>
543
<dd><p>Implement the <tt class="docutils literal"><span class="pre">!=</span></tt> operator.</p>
544
<p>In a many-to-one context, such as:</p>
545
<div class="highlight-python"><pre>MyClass.some_prop != <some object></pre>
547
<p>This will typically produce a clause such as:</p>
548
<div class="highlight-python"><pre>mytable.related_id != <some id></pre>
550
<p>Where <tt class="docutils literal"><span class="pre"><some</span> <span class="pre">id></span></tt> is the primary key of the
552
<p>The <tt class="docutils literal"><span class="pre">!=</span></tt> operator provides partial functionality for non-
553
many-to-one comparisons:</p>
555
<li>Comparisons against collections are not supported.
557
<a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains"><tt class="xref py py-meth docutils literal"><span class="pre">contains()</span></tt></a>
558
in conjunction with <a class="reference internal" href="../core/expression_api.html#sqlalchemy.sql.expression.not_" title="sqlalchemy.sql.expression.not_"><tt class="xref py py-func docutils literal"><span class="pre">not_()</span></tt></a>.</li>
559
<li>Compared to a scalar one-to-many, will produce a
560
clause that compares the target columns in the parent to
561
the given target.</li>
562
<li>Compared to a scalar many-to-many, an alias
563
of the association table will be rendered as
564
well, forming a natural join that is part of the
565
main body of the query. This will not work for
566
queries that go beyond simple AND conjunctions of
567
comparisons, such as those which use OR. Use
568
explicit joins, outerjoins, or
569
<a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.has" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.has"><tt class="xref py py-meth docutils literal"><span class="pre">has()</span></tt></a> in
570
conjunction with <a class="reference internal" href="../core/expression_api.html#sqlalchemy.sql.expression.not_" title="sqlalchemy.sql.expression.not_"><tt class="xref py py-func docutils literal"><span class="pre">not_()</span></tt></a> for
571
more comprehensive non-many-to-one scalar
572
membership tests.</li>
573
<li>Comparisons against <tt class="xref docutils literal"><span class="pre">None</span></tt> given in a one-to-many
574
or many-to-many context produce an EXISTS clause.</li>
579
<dt id="sqlalchemy.orm.properties.RelationshipProperty.Comparator.adapted">
580
<tt class="descname">adapted</tt><big>(</big><em>adapter</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.adapted" title="Permalink to this definition">¶</a></dt>
581
<dd><p>Return a copy of this PropComparator which will use the
582
given adaption function on the local side of generated
587
<dt id="sqlalchemy.orm.properties.RelationshipProperty.Comparator.any">
588
<tt class="descname">any</tt><big>(</big><em>criterion=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.any" title="Permalink to this definition">¶</a></dt>
589
<dd><p>Produce an expression that tests a collection against
590
particular criterion, using EXISTS.</p>
591
<p>An expression like:</p>
592
<div class="highlight-python"><div class="highlight"><pre><span class="n">session</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">MyClass</span><span class="p">)</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
593
<span class="n">MyClass</span><span class="o">.</span><span class="n">somereference</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="n">SomeRelated</span><span class="o">.</span><span class="n">x</span><span class="o">==</span><span class="mi">2</span><span class="p">)</span>
594
<span class="p">)</span></pre></div>
596
<p>Will produce a query like:</p>
597
<div class="highlight-python"><pre>SELECT * FROM my_table WHERE
598
EXISTS (SELECT 1 FROM related WHERE related.my_id=my_table.id
599
AND related.x=2)</pre>
601
<p>Because <a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.any" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.any"><tt class="xref py py-meth docutils literal"><span class="pre">any()</span></tt></a> uses
602
a correlated subquery, its performance is not nearly as
603
good when compared against large target tables as that of
605
<p><a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.any" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.any"><tt class="xref py py-meth docutils literal"><span class="pre">any()</span></tt></a> is particularly
606
useful for testing for empty collections:</p>
607
<div class="highlight-python"><div class="highlight"><pre><span class="n">session</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">MyClass</span><span class="p">)</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
608
<span class="o">~</span><span class="n">MyClass</span><span class="o">.</span><span class="n">somereference</span><span class="o">.</span><span class="n">any</span><span class="p">()</span>
609
<span class="p">)</span></pre></div>
612
<div class="highlight-python"><pre>SELECT * FROM my_table WHERE
613
NOT EXISTS (SELECT 1 FROM related WHERE related.my_id=my_table.id)</pre>
615
<p><a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.any" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.any"><tt class="xref py py-meth docutils literal"><span class="pre">any()</span></tt></a> is only
616
valid for collections, i.e. a <a class="reference internal" href="relationships.html#sqlalchemy.orm.relationship" title="sqlalchemy.orm.relationship"><tt class="xref py py-func docutils literal"><span class="pre">relationship()</span></tt></a>
617
that has <tt class="docutils literal"><span class="pre">uselist=True</span></tt>. For scalar references,
618
use <a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.has" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.has"><tt class="xref py py-meth docutils literal"><span class="pre">has()</span></tt></a>.</p>
622
<dt id="sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains">
623
<tt class="descname">contains</tt><big>(</big><em>other</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains" title="Permalink to this definition">¶</a></dt>
624
<dd><p>Return a simple expression that tests a collection for
625
containment of a particular item.</p>
626
<p><a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains"><tt class="xref py py-meth docutils literal"><span class="pre">contains()</span></tt></a> is
627
only valid for a collection, i.e. a
628
<a class="reference internal" href="relationships.html#sqlalchemy.orm.relationship" title="sqlalchemy.orm.relationship"><tt class="xref py py-func docutils literal"><span class="pre">relationship()</span></tt></a> that implements
629
one-to-many or many-to-many with <tt class="docutils literal"><span class="pre">uselist=True</span></tt>.</p>
630
<p>When used in a simple one-to-many context, an
632
<div class="highlight-python"><div class="highlight"><pre><span class="n">MyClass</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">other</span><span class="p">)</span></pre></div>
634
<p>Produces a clause like:</p>
635
<div class="highlight-python"><pre>mytable.id == <some id></pre>
637
<p>Where <tt class="docutils literal"><span class="pre"><some</span> <span class="pre">id></span></tt> is the value of the foreign key
638
attribute on <tt class="docutils literal"><span class="pre">other</span></tt> which refers to the primary
639
key of its parent object. From this it follows that
640
<a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains"><tt class="xref py py-meth docutils literal"><span class="pre">contains()</span></tt></a> is
641
very useful when used with simple one-to-many
643
<p>For many-to-many operations, the behavior of
644
<a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains"><tt class="xref py py-meth docutils literal"><span class="pre">contains()</span></tt></a>
645
has more caveats. The association table will be
646
rendered in the statement, producing an “implicit”
647
join, that is, includes multiple tables in the FROM
648
clause which are equated in the WHERE clause:</p>
649
<div class="highlight-python"><div class="highlight"><pre><span class="n">query</span><span class="p">(</span><span class="n">MyClass</span><span class="p">)</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">MyClass</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">other</span><span class="p">))</span></pre></div>
651
<p>Produces a query like:</p>
652
<div class="highlight-python"><pre>SELECT * FROM my_table, my_association_table AS
653
my_association_table_1 WHERE
654
my_table.id = my_association_table_1.parent_id
655
AND my_association_table_1.child_id = <some id></pre>
657
<p>Where <tt class="docutils literal"><span class="pre"><some</span> <span class="pre">id></span></tt> would be the primary key of
658
<tt class="docutils literal"><span class="pre">other</span></tt>. From the above, it is clear that
659
<a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains"><tt class="xref py py-meth docutils literal"><span class="pre">contains()</span></tt></a>
660
will <strong>not</strong> work with many-to-many collections when
661
used in queries that move beyond simple AND
662
conjunctions, such as multiple
663
<a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.contains"><tt class="xref py py-meth docutils literal"><span class="pre">contains()</span></tt></a>
664
expressions joined by OR. In such cases subqueries or
665
explicit “outer joins” will need to be used instead.
666
See <a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.any" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.any"><tt class="xref py py-meth docutils literal"><span class="pre">any()</span></tt></a> for
667
a less-performant alternative using EXISTS, or refer
668
to <a class="reference internal" href="query.html#sqlalchemy.orm.query.Query.outerjoin" title="sqlalchemy.orm.query.Query.outerjoin"><tt class="xref py py-meth docutils literal"><span class="pre">Query.outerjoin()</span></tt></a> as well as <a class="reference internal" href="tutorial.html#ormtutorial-joins"><em>Querying with Joins</em></a>
669
for more details on constructing outer joins.</p>
673
<dt id="sqlalchemy.orm.properties.RelationshipProperty.Comparator.has">
674
<tt class="descname">has</tt><big>(</big><em>criterion=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.has" title="Permalink to this definition">¶</a></dt>
675
<dd><p>Produce an expression that tests a scalar reference against
676
particular criterion, using EXISTS.</p>
677
<p>An expression like:</p>
678
<div class="highlight-python"><div class="highlight"><pre><span class="n">session</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">MyClass</span><span class="p">)</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span>
679
<span class="n">MyClass</span><span class="o">.</span><span class="n">somereference</span><span class="o">.</span><span class="n">has</span><span class="p">(</span><span class="n">SomeRelated</span><span class="o">.</span><span class="n">x</span><span class="o">==</span><span class="mi">2</span><span class="p">)</span>
680
<span class="p">)</span></pre></div>
682
<p>Will produce a query like:</p>
683
<div class="highlight-python"><pre>SELECT * FROM my_table WHERE
684
EXISTS (SELECT 1 FROM related WHERE related.id==my_table.related_id
685
AND related.x=2)</pre>
687
<p>Because <a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.has" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.has"><tt class="xref py py-meth docutils literal"><span class="pre">has()</span></tt></a> uses
688
a correlated subquery, its performance is not nearly as
689
good when compared against large target tables as that of
691
<p><a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.has" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.has"><tt class="xref py py-meth docutils literal"><span class="pre">has()</span></tt></a> is only
692
valid for scalar references, i.e. a <a class="reference internal" href="relationships.html#sqlalchemy.orm.relationship" title="sqlalchemy.orm.relationship"><tt class="xref py py-func docutils literal"><span class="pre">relationship()</span></tt></a>
693
that has <tt class="docutils literal"><span class="pre">uselist=False</span></tt>. For collection references,
694
use <a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.any" title="sqlalchemy.orm.properties.RelationshipProperty.Comparator.any"><tt class="xref py py-meth docutils literal"><span class="pre">any()</span></tt></a>.</p>
698
<dt id="sqlalchemy.orm.properties.RelationshipProperty.Comparator.in_">
699
<tt class="descname">in_</tt><big>(</big><em>other</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.in_" title="Permalink to this definition">¶</a></dt>
700
<dd><p>Produce an IN clause - this is not implemented
701
for <a class="reference internal" href="relationships.html#sqlalchemy.orm.relationship" title="sqlalchemy.orm.relationship"><tt class="xref py py-func docutils literal"><span class="pre">relationship()</span></tt></a>-based attributes at this time.</p>
705
<dt id="sqlalchemy.orm.properties.RelationshipProperty.Comparator.of_type">
706
<tt class="descname">of_type</tt><big>(</big><em>cls</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.Comparator.of_type" title="Permalink to this definition">¶</a></dt>
707
<dd><p>Produce a construct that represents a particular ‘subtype’ of
708
attribute for the parent class.</p>
709
<p>Currently this is usable in conjunction with <a class="reference internal" href="query.html#sqlalchemy.orm.query.Query.join" title="sqlalchemy.orm.query.Query.join"><tt class="xref py py-meth docutils literal"><span class="pre">Query.join()</span></tt></a>
710
and <a class="reference internal" href="query.html#sqlalchemy.orm.query.Query.outerjoin" title="sqlalchemy.orm.query.Query.outerjoin"><tt class="xref py py-meth docutils literal"><span class="pre">Query.outerjoin()</span></tt></a>.</p>
715
<dl class="attribute">
716
<dt id="sqlalchemy.orm.properties.RelationshipProperty.mapper">
717
<tt class="descclassname">RelationshipProperty.</tt><tt class="descname">mapper</tt><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.mapper" title="Permalink to this definition">¶</a></dt>
718
<dd><p>Return the targeted <a class="reference internal" href="mapper_config.html#sqlalchemy.orm.mapper.Mapper" title="sqlalchemy.orm.mapper.Mapper"><tt class="xref py py-class docutils literal"><span class="pre">Mapper</span></tt></a> for this
719
<a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty" title="sqlalchemy.orm.properties.RelationshipProperty"><tt class="xref py py-class docutils literal"><span class="pre">RelationshipProperty</span></tt></a>.</p>
720
<p>This is a lazy-initializing static attribute.</p>
723
<dl class="attribute">
724
<dt id="sqlalchemy.orm.properties.RelationshipProperty.table">
725
<tt class="descclassname">RelationshipProperty.</tt><tt class="descname">table</tt><a class="headerlink" href="#sqlalchemy.orm.properties.RelationshipProperty.table" title="Permalink to this definition">¶</a></dt>
726
<dd><p>Return the selectable linked to this</p>
727
<p class="deprecated">
728
<span class="versionmodified">Deprecated since version 0.7: </span>Use .target</p>
729
<p><a class="reference internal" href="#sqlalchemy.orm.properties.RelationshipProperty" title="sqlalchemy.orm.properties.RelationshipProperty"><tt class="xref py py-class docutils literal"><span class="pre">RelationshipProperty</span></tt></a> object’s target
730
<a class="reference internal" href="mapper_config.html#sqlalchemy.orm.mapper.Mapper" title="sqlalchemy.orm.mapper.Mapper"><tt class="xref py py-class docutils literal"><span class="pre">Mapper</span></tt></a>.</p>
736
<dt id="sqlalchemy.orm.descriptor_props.SynonymProperty">
737
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.descriptor_props.</tt><tt class="descname">SynonymProperty</tt><big>(</big><em>name</em>, <em>map_column=None</em>, <em>descriptor=None</em>, <em>comparator_factory=None</em>, <em>doc=None</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.descriptor_props.SynonymProperty" title="Permalink to this definition">¶</a></dt>
738
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">sqlalchemy.orm.descriptor_props.DescriptorProperty</span></tt></p>
742
<dt id="sqlalchemy.orm.query.QueryContext">
743
<em class="property">class </em><tt class="descclassname">sqlalchemy.orm.query.</tt><tt class="descname">QueryContext</tt><big>(</big><em>query</em><big>)</big><a class="headerlink" href="#sqlalchemy.orm.query.QueryContext" title="Permalink to this definition">¶</a></dt>
744
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
753
<div class="bottomnav">
755
<a href="exceptions.html" title="previous chapter">ORM Exceptions</a>
757
<a href="../core/index.html" title="next chapter">SQLAlchemy Core</a>
758
<div class="doc_copyright">
759
© <a href="../copyright.html">Copyright</a> 2007-2011, the SQLAlchemy authors and contributors.
760
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.