Skip to content

Commit

Permalink
make sure dates can be used in check constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Feb 1, 2025
1 parent b712fb1 commit f49edf0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions piccolo/querystring.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import typing as t
from abc import ABCMeta, abstractmethod
from dataclasses import dataclass
from datetime import datetime
from datetime import date, datetime
from importlib.util import find_spec
from string import Formatter

Expand Down Expand Up @@ -138,6 +138,10 @@ def __str__(self):
"""
The SQL returned by the ``__str__`` method isn't used directly in
queries - it's just a usability feature.
The only exception to this is CHECK constraints, where we use this to
convert simple querystrings into strings.
"""
_, bundled, combined_args = self.bundle(
start_index=1, bundled=[], combined_args=[]
Expand All @@ -153,7 +157,7 @@ def __str__(self):
_type = type(arg)
if _type == str:
converted_args.append(f"'{arg}'")
elif _type == datetime:
elif _type == datetime or _type == date:
dt_string = arg.isoformat()
converted_args.append(f"'{dt_string}'")
elif _type == UUID or _type == apgUUID:
Expand Down

0 comments on commit f49edf0

Please sign in to comment.