Skip to content

search response does not include datetime when null #158

@duckontheweb

Description

@duckontheweb

Description

The STAC Spec requires that Items have a datetime property even when the value of that property is null. However, in the return value of the search function removes the datetime property when it is null, resulting in an invalid STAC Item.

Steps to reproduce

  1. Start up the development server
  2. In a psql console, add an item with start_datetime and end_datetime values and a null datetime value:
    SELECT *
    FROM create_item('
    {
      "type": "Feature",
      "stac_version": "1.0.0",
      "id": "datetime_range_test",
      "properties": {
         "start_datetime": "2009-10-15T00:00:00Z",
         "end_datetime": "2010-03-01T23:59:59.999999Z",
         "datetime": null
       },
       "geometry": {
         "type": "Polygon",
         "coordinates": [
           [
             [-101, 36],
             [-101, 37],
             [-102, 37],
             [-102, 36],
             [-101, 36]
           ]
         ]
       },
       "links": [],
       "assets": {},
       "collection": "pgstac-test-collection"
    }
    '::jsonb);
  3. Use the search function to fetch the Item and examine the properties:
    SELECT "search" -> 'features' -> 0 -> 'properties'
    FROM search('{"ids": ["datetime_range_test"]}');

The resulting properties JSON is missing the datetime property:

{
  "end_datetime": "2010-03-01T23:59:59.999999Z",
  "start_datetime": "2009-10-15T00:00:00Z"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions