Browse Source

update pk docs for sql databases to avoid confusion

pull/14120/head
Flavius Raducu 10 months ago
parent
commit
120bbfce25
Failed to extract signature
  1. 4
      docs/en/docs/tutorial/sql-databases.md

4
docs/en/docs/tutorial/sql-databases.md

@ -67,6 +67,10 @@ There are a few differences:
By having the type as `int | None`, SQLModel will know that this column should be an `INTEGER` in the SQL database and that it should be `NULLABLE`.
But inside the SQL database, the `id` is always required and can't be `NULL`. So, why should we declare it with `int | None`?
The `id` will be required in the database, but it will be generated by the database, not by our code.
* `Field(index=True)` tells SQLModel that it should create a **SQL index** for this column, that would allow faster lookups in the database when reading data filtered by this column.
SQLModel will know that something declared as `str` will be a SQL column of type `TEXT` (or `VARCHAR`, depending on the database).

Loading…
Cancel
Save