-
-
Notifications
You must be signed in to change notification settings - Fork 778
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the SQLModel documentation, with the integrated search.
- I already searched in Google "How to X in SQLModel" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to SQLModel but to Pydantic.
- I already checked if it is not related to SQLModel but to SQLAlchemy.
Commit to Help
- I commit to help with one of those options 👆
Example Code
from pydantic import SecretStr
from sqlmodel import Field, Session, SQLModel, create_engine
class A(SQLModel, table=True):
id: int = Field(primary_key=True)
secret: SecretStr
engine = create_engine("sqlite://")
SQLModel.metadata.create_all(engine)
# sqlalchemy.exc.CompileError: (in table 'a', column 'secret'): Can't generate DDL for NullType(); did you forget to specify a type on this Column?Description
- Create a class with a
pydantic.SecretStrfield - Create the table
- Execution fails with
Can't generate DDL for NullType()exception
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.9.6
Additional Context
We can specify the column type manually, but it fails with another error:
from pydantic import SecretStr
from sqlmodel import Column, Field, Session, String, SQLModel, create_engine
class A(SQLModel, table=True):
id: int = Field(primary_key=True)
secret: SecretStr = Field(sa_column=Column(String))
engine = create_engine("sqlite://")
SQLModel.metadata.create_all(engine)
with Session(engine) as session:
a = A(id=1, secret="secret")
session.add(a)
session.commit()
# sqlalchemy.exc.InterfaceError: (sqlite3.InterfaceError) Error binding parameter 0 - probably unsupported type.
# [SQL: INSERT INTO a (secret, id) VALUES (?, ?)]
# [parameters: (SecretStr('**********'), 1)]Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested