Skip to content

Passing types.NullType to schema.Column constructor can lead to infinite recursion #1907

Closed
@sqlalchemy-bot

Description

@sqlalchemy-bot
Collaborator

Migrated issue, originally created by Anonymous

Introduced in 0.6beta2, present in 0.6.4.

Even though the documentation for schema.Column.init() states that a type's class can be passed for the type if no arguments are required, passing the NullType type (instead of the NULLTYPE instance) results in infinite recursion if both sides of an expression are null-typed.

Minimal reproduction of issue:

import sqlalchemy
qux = sqlalchemy.schema.Column('foo', sqlalchemy.types.NullType) + sqlalchemy.schema.Column('bar', sqlalchemy.types.NullType)

Tail of output:

/var/lib/python-support/python2.5/sqlalchemy/types.py in _adapt_expression(self, op, othertype)
    640 
    641     def _adapt_expression(self, op, othertype):
--> 642         if othertype is NULLTYPE or not operators.is_commutative(op):
    643             return op, self
    644         else:

<type 'exceptions.RuntimeError'>: maximum recursion depth exceeded

The issue can be fixed by changing the following line in types.py (from the definition of class NullType) from:

if othertype is NULLTYPE or not operators.is_commutative(op):

to:

if type(othertype) == NullType or not operators.is_commutative(op):

(The original failure was due to the Column constructor creating another NullType instance which is not the same instance as types.NULLTYPE, and thus the "is" check fails.)

Activity

sqlalchemy-bot

sqlalchemy-bot commented on Sep 8, 2010

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

seems simple enough, will try to get it for the next go-around, thanks

sqlalchemy-bot

sqlalchemy-bot commented on Sep 8, 2010

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • set milestone to "0.6.5"
sqlalchemy-bot

sqlalchemy-bot commented on Sep 25, 2010

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

a4a09a6

sqlalchemy-bot

sqlalchemy-bot commented on Sep 25, 2010

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
added
schemathings related to the DDL related objects like Table, Column, CreateIndex, etc.
bugSomething isn't working
on Nov 27, 2018
added this to the 0.6.5 milestone on Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingschemathings related to the DDL related objects like Table, Column, CreateIndex, etc.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sqlalchemy-bot

        Issue actions

          Passing types.NullType to schema.Column constructor can lead to infinite recursion · Issue #1907 · sqlalchemy/sqlalchemy