<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">Hello everyone,</p>
<p dir="auto">picture a common code location within a company, outside of any application, where database entities would be stored for common use in different applications within that company. In that common area you would store base objects of database entities such as a base object for a contract. That contract base object would be declared using declarative base and would use table information previously gathered through sqlautocode. Also it would include manual relation setups, such as the product this contract is bound to. Optionally it may also contain common logic.</p>
<p dir="auto">In your application you would inherit from this contract base object and add your application-specific logic to it. The goals of this setup would be: Keep your company wide-used objects in a common place, avoid redundancies.</p>
<p dir="auto">This pretty much works with SA, as declarative base was designed with inheritance in mind. (kudos!) What does not work, however, is using a custom polymorphic map, when this map would be set up on first inheriting from the base object (you wouldn't want to set up polymorphic mapping in your base object if you don't need this kind of differentiation of your contract objects in all of your applications).</p>
<p dir="auto">Example scenario:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="class ContractBase(Base):
    &quot;&quot;&quot; Contract base &quot;&quot;&quot;
    __tablename__ = 'schema.contract'

    product_list = relation(...)


class Contract(ContractBase):
    &quot;&quot;&quot; Contract &quot;&quot;&quot;
    __mapper_args__ = {'polymorphic_on': contract_table.c.contract_status_id,
                       '_polymorphic_map': ContractStatusPolymorphicMap()}


class ActiveContract(Contract):
    &quot;&quot;&quot; Active contract &quot;&quot;&quot;


class InactiveContract(Contract):
    &quot;&quot;&quot; Inactive contract &quot;&quot;&quot;"><pre class="notranslate"><code class="notranslate">class ContractBase(Base):
    """ Contract base """
    __tablename__ = 'schema.contract'

    product_list = relation(...)


class Contract(ContractBase):
    """ Contract """
    __mapper_args__ = {'polymorphic_on': contract_table.c.contract_status_id,
                       '_polymorphic_map': ContractStatusPolymorphicMap()}


class ActiveContract(Contract):
    """ Active contract """


class InactiveContract(Contract):
    """ Inactive contract """
</code></pre></div>
<p dir="auto">(This is a fictional scenario. Please don't care about its use in general and use of a custom polymorphic map in particular.)</p>
<p dir="auto">In this scenario the polymorphic_on mapper argument is being used. The polymorphic_map argument, however, is "ignored", as it is being overwritten in the _configure_inheritance() call:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="            self.polymorphic_map = self.inherits.polymorphic_map"><pre class="notranslate"><code class="notranslate">            self.polymorphic_map = self.inherits.polymorphic_map
</code></pre></div>
<p dir="auto">I guess we should only overwrite self.polymorphic_map in _configure_inheritance() if self.inherits.polymorphic_map is not the default (f.e. self.inherits.polymorphic_map is not None and self.polymorphic_map is only being set in the constructor if self.polymorphic_on is not None).</p>
<p dir="auto">Best Regards,<br>
Thomas Wiebe</p>
<p dir="auto"><strong>Migrated issue, originally created by Shengjing Zhu (<a href="https://github.com/zhsj">@zhsj</a>)</strong></p>
<p dir="auto">sqlalchemy.types.JSON only supports PostgreSQL and MySQL. But since SQLite 3.9, it has json support, <a href="https://sqlite.org/json1.html" rel="nofollow">https://sqlite.org/json1.html</a></p>
<p dir="auto">I hope sqlalchemy can support json1 too.</p>