Hello,

I'd like to implement soft delete so I have to take into account when 
creating constraints
the softdelete boolean column. The trick i want to implement is to get null 
for the column
when the row is supposed to be deleted. When creating the index by hand in 
SQL it works
just nice but in sqlalchemy i get an exception. SQLAlchemy is at 1.2.15.

This is how i define the contstraint:

class Foo(sa.Model):

   __table_args__ = (
        sa.UniqueConstraint('foobar_id', sa.func.nullif('deleted', True)),
    )


When i try to create a migration with alembic i get the following 
(stripped) stack trace:

  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/schema.py", 
line 2670, in _set_parent
    self.columns.add(col)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/base.py", 
line 503, in add
    "Can't add unnamed column to column collection")
sqlalchemy.exc.ArgumentError: Can't add unnamed column to column collection

Any hint on what could be wrong?

Thanks in advance,
Riccardo


-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to