Skip to content

[Bug]: Unexpected Behavior using the vcol of AutoAPI #3915

@MichaelDecent

Description

@MichaelDecent

Describe the Bug

Declared a table field with vcol (virtual column) but column ended up being create on the database

Steps to Reproduce

  1. Declaring a a table field using vcol :
@alias_ctx(create="add", read="get", list="browse")
class Book(Base):
    __tablename__ = "books"
     
   ...
    # Virtual, read-only derived field
    slug: Mapped[str] = vcol(
        field=F(py_type=str, constraints={"max_length": 256}),
        io=IO(out_verbs=("read","list")),
        read_producer=lambda obj, ctx: f"{(obj.title or '').strip().lower().replace(' ','-')}-{(obj.author or '').strip().lower().replace(' ','-')}"
    )
  1. Make a Create api request call.
  2. Results to a SQL related error

Software Version

<0.4.0

Python Version

Python 3.8

Environment Details

No response

Relevant Logs or Error Output

{
  "detail": "<class 'sqlalchemy.exc.IntegrityError'>: (sqlite3.IntegrityError) NOT NULL constraint failed: books.slug\n[SQL: INSERT INTO books (title, author, price, published_at, slug) VALUES (?, ?, ?, ?, ?)]\n[parameters: ('string', 'string', 0.0, None, None)]\n(Background on this error at: https://sqlalche.me/e/20/gkpj)"
}

Additional Context (Optional)

No response

Confirmation

  • I have searched the existing issues for this bug.
  • I have provided all necessary information to reproduce the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions