Open ricardogsilva opened 9 years ago
This proposal breaks backward compatibility to our existing deployments, so it is not that easy to handle. Similar discussion has happened in the early days of pycsw and we chose text representation as a simple/safe way to implement things. It would require something more than a PR, it would need an RFC and a vote from the steering committee to do such a change.
OK, I will investigate a bit more on alternative solutions and look at how other projects are doing this. I'll prepare an RFC if it will seem to be a worthy change
I would recommend to post the above to the pycsw-devel mailing list for further discussion.
Currently pycsw sets up a database using the
sqlalchemy.Text
type for most columns.In my opinion it would be nicer if we could use other sqlalchemy types, specially the
sqlalchemy.DateTime
type when creating the database. This would make the transition from python datetimes to the database smoother. The current situation gets around this by trying not to use python datetime and using strings instead.For an example, the
pycsw.core.metadata._parse_sos
method actually converts a python datetime object (as returned byowslib.sos.SensorObservationService.contents[...].begin_position
) into a string (lines number 718 and 719), so that it can be manipulated further down the road.There is also a safeguard in
pycsw.core.util.getqattr
to always convert adatetime.date
ordatetime.datetime
to a string. This function is used whenever something is to be written to the database.I propose that we change this around:
sqlalchemy.DateTime
type.Benefits:
I have an initial draft with the changes necessary for implementing this proposal in my local repository. It seems to work OK with sqlite and postgis, but I can only test with normal records. I will prepare a pull request so that it may be evaluated.