diff --git a/retrieval_service/datastore/providers/spanner_postgres.py b/retrieval_service/datastore/providers/spanner_postgres.py index c35af8c2..8ebdd347 100644 --- a/retrieval_service/datastore/providers/spanner_postgres.py +++ b/retrieval_service/datastore/providers/spanner_postgres.py @@ -828,9 +828,6 @@ async def validate_ticket( departure_airport: str, departure_time: str, ) -> tuple[Optional[models.Flight], Optional[str]]: - departure_time_datetime = datetime.datetime.strptime( - departure_time, "%Y-%m-%d %H:%M:%S" - ) with self.__database.snapshot() as snapshot: # Spread SQL query for readability results = snapshot.execute_sql( @@ -845,7 +842,7 @@ async def validate_ticket( "p1": airline, "p2": flight_number, "p3": departure_airport, - "p4": departure_time_datetime, + "p4": departure_time, }, param_types={ "p1": param_types.STRING, @@ -865,6 +862,8 @@ async def validate_ticket( for a in results ] + if not flights: + return None, None return flights[0], None async def insert_ticket( diff --git a/retrieval_service/datastore/providers/spanner_postgres_test.py b/retrieval_service/datastore/providers/spanner_postgres_test.py index 1c043d79..0dcd7648 100644 --- a/retrieval_service/datastore/providers/spanner_postgres_test.py +++ b/retrieval_service/datastore/providers/spanner_postgres_test.py @@ -661,7 +661,7 @@ async def test_policies_search( departure_gate="C38", arrival_gate="D30", ), - 'SELECT *
FROM flights
WHERE airline ILIKE UA
AND flight_number ILIKE 1158
AND departure_airport ILIKE SFO
AND departure_time = 2024-01-01 05:57:00', + None, ), pytest.param( {