Skip to content

Commit

Permalink
add type annotation for id (#197)
Browse files Browse the repository at this point in the history
* add type annotation for `id`

* do the same for `TokenAuth` table
  • Loading branch information
dantownsend committed Oct 18, 2022
1 parent 99077f5 commit aa6fadb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion piccolo_api/session_auth/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import typing as t
from datetime import datetime, timedelta

from piccolo.columns import Integer, Timestamp, Varchar
from piccolo.columns import Integer, Serial, Timestamp, Varchar
from piccolo.columns.defaults.timestamp import TimestampOffset
from piccolo.table import Table
from piccolo.utils.sync import run_sync
Expand All @@ -15,6 +15,8 @@ class SessionsBase(Table, tablename="sessions"):
Use this table, or inherit from it, to create a session store.
"""

id: Serial

#: Stores the session token.
token: Varchar = Varchar(length=100, null=False)

Expand Down
3 changes: 2 additions & 1 deletion piccolo_api/token_auth/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import uuid

from piccolo.apps.user.tables import BaseUser
from piccolo.columns.column_types import ForeignKey, Varchar
from piccolo.columns.column_types import ForeignKey, Serial, Varchar
from piccolo.table import Table
from piccolo.utils.sync import run_sync

Expand All @@ -24,6 +24,7 @@ class TokenAuth(Table):
web usage.
"""

id: Serial
token = Varchar(default=generate_token)
user = ForeignKey(references=BaseUser)

Expand Down

0 comments on commit aa6fadb

Please sign in to comment.