-
-
Notifications
You must be signed in to change notification settings - Fork 785
Closed
Labels
bugSomething isn't workingSomething isn't working
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 typing import Optional
from sqlmodel import SQLModel, Field, create_engine
class Test(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
a: str
b: Optional[str] = None
c: str = Field(default="Hey")
d: str = "hey"
sqlite_url = "" # define a path here
engine = create_engine(sqlite_url, echo=True)
SQLModel.metadata.create_all(engine)Description
The above code example issues the following create table sql command:
CREATE TABLE test (
id INTEGER,
a VARCHAR NOT NULL,
b VARCHAR,
c VARCHAR,
d VARCHAR,
PRIMARY KEY (id)
)whereas I would expect columns c and d to be marked as NOT NULL as well.
I think the documentation also points to my point of view as stated here.
Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.8.5
Additional Context
No response
christosvar, relsunkaev, skykasko, ChielWH, l1b3r and 1 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working