mirror of
https://github.com/evennia/evennia.git
synced 2026-04-07 00:45:22 +02:00
Updated HTML docs.
This commit is contained in:
parent
fc7925142d
commit
59fe09ee6b
32 changed files with 111 additions and 111 deletions
|
|
@ -295,7 +295,7 @@ possible.</p>
|
|||
<aside class="sidebar">
|
||||
<p class="sidebar-title">Attributes vs database fields</p>
|
||||
<p>Don’t confuse database fields with <a class="reference internal" href="../../../Components/Attributes.html"><span class="doc std std-doc">Attributes</span></a> you set via <code class="docutils literal notranslate"><span class="pre">obj.db.attr</span> <span class="pre">=</span> <span class="pre">'foo'</span></code> or <code class="docutils literal notranslate"><span class="pre">obj.attributes.add()</span></code>. Attributes are custom database entities <em>linked</em> to an object. They are not separate fields <em>on</em> that object like <code class="docutils literal notranslate"><span class="pre">db_key</span></code> or <code class="docutils literal notranslate"><span class="pre">db_location</span></code> are.</p>
|
||||
<p>While an Attribute’s <code class="docutils literal notranslate"><span class="pre">db_key</span></code> is just a normal string, their <code class="docutils literal notranslate"><span class="pre">db_value</span></code> is in fact a serialized piece of data. This means that cannot query this with additional operators. So if you use e.g. <code class="docutils literal notranslate"><span class="pre">db_attributes__db_value__iexact=2</span></code>, you’ll get an error. While Attributes are very flexible, this is their drawback - their stored value is not possible to directly query with advanced query methods beyond finding the exact match.</p>
|
||||
<p>While an Attribute’s <code class="docutils literal notranslate"><span class="pre">db_key</span></code> is just a normal string, theor <code class="docutils literal notranslate"><span class="pre">db_value</span></code> is in fact a serialized piece of data. This means that cannot query this with additional operators. So if you use e.g. <code class="docutils literal notranslate"><span class="pre">db_attributes__db_value__iexact=2</span></code>, you’ll get an error. While Attributes are very flexible, this is their drawback - their stored value is not possible to directly query with advanced query methods beyond finding the exact match.</p>
|
||||
</aside>
|
||||
<ul class="simple">
|
||||
<li><p><strong>Line 4</strong> We want to find <code class="docutils literal notranslate"><span class="pre">Character</span></code>s, so we access <code class="docutils literal notranslate"><span class="pre">.objects</span></code> on the <code class="docutils literal notranslate"><span class="pre">Character</span></code> typeclass.</p></li>
|
||||
|
|
@ -316,7 +316,7 @@ that we can treat like an object for this purpose; it references all Tags on the
|
|||
<p>Running this query makes our newly lycanthropic Character appear in <code class="docutils literal notranslate"><span class="pre">will_transform</span></code> so we know to transform it. Success!</p>
|
||||
<div class="admonition important">
|
||||
<p class="admonition-title">Important</p>
|
||||
<p>You can’t query for an Attribute <code class="docutils literal notranslate"><span class="pre">db_value</span></code> quite as freely as other data-types. This is because Attributes can store any Python entity and is actually stored as <em>strings</em> on the database side. So while you can use <code class="docutils literal notranslate"><span class="pre">__eq=2</span></code> in the above example, you will not be able to <code class="docutils literal notranslate"><span class="pre">__gt=2</span></code> or <code class="docutils literal notranslate"><span class="pre">__lt=2</span></code> because these operations don’t make sense for strings. See <a class="reference internal" href="../../../Components/Attributes.html#querying-by-attribute"><span class="std std-doc">Attributes</span></a> for more information on dealing with Attributes.</p>
|
||||
<p>You can’t query for an Attribute <code class="docutils literal notranslate"><span class="pre">db_value</span></code> quite as freely as other data-types. This is because Attributes can store any Python entity and is actually stored as <em>strings</em> on the database side. So while you can use <code class="docutils literal notranslate"><span class="pre">db_value=2</span></code> in the above example, you will not be able to use <code class="docutils literal notranslate"><span class="pre">dbvalue__eq=2</span></code> or <code class="docutils literal notranslate"><span class="pre">__lt=2</span></code>. See <a class="reference internal" href="../../../Components/Attributes.html#querying-by-attribute"><span class="std std-doc">Attributes</span></a> for more information on dealing with Attributes.</p>
|
||||
</div>
|
||||
</section>
|
||||
<section id="queries-with-or-or-not">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue