Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Object identifier values function not parsing correctly path parameters when a field is DateTime #859

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions sqladmin/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import re
import unicodedata
from abc import ABC, abstractmethod
from datetime import timedelta
from datetime import datetime, timedelta
from typing import (
Any,
AsyncGenerator,
Expand Down Expand Up @@ -224,7 +224,11 @@ def object_identifier_values(id_string: str, model: Any) -> tuple:
pks = get_primary_keys(model)
for pk, part in zip(pks, _object_identifier_parts(id_string, model)):
type_ = get_column_python_type(pk)
value = False if type_ is bool and part == "False" else type_(part)
if type_ is datetime:
value = datetime.strptime(part, "%Y-%m-%d %H:%M:%S")
else:
print(part)
value = False if part == "False" else type_(part)
values.append(value)
return tuple(values)

Expand Down
Loading