.. changelog::
:version: 1.1.5
+ .. change:: pg_timestamp_zero_prec
+ :tags: bug, postgresql
+
+ The :class:`.postgresql.TIME` and :class:`.postgresql.TIMESTAMP`
+ datatypes now support a setting of zero for "precision"; previously
+ a zero would be ignored. Pull request courtesy Ionuț Ciocîrlan.
+
.. change:: 3859
:tags: bug, sql
:tickets: 3859
def visit_TIMESTAMP(self, type_, **kw):
return "TIMESTAMP%s %s" % (
- getattr(type_, 'precision', None) and "(%d)" %
- type_.precision or "",
+ "(%d)" % type_.precision
+ if getattr(type_, 'precision', None) is not None else "",
(type_.timezone and "WITH" or "WITHOUT") + " TIME ZONE"
)
def visit_TIME(self, type_, **kw):
return "TIME%s %s" % (
- getattr(type_, 'precision', None) and "(%d)" %
- type_.precision or "",
+ "(%d)" % type_.precision
+ if getattr(type_, 'precision', None) is not None else "",
(type_.timezone and "WITH" or "WITHOUT") + " TIME ZONE"
)
'TIMESTAMP(5) WITHOUT TIME ZONE'),
(postgresql.TIMESTAMP(timezone=True, precision=5),
'TIMESTAMP(5) WITH TIME ZONE'),
+ (postgresql.TIME(precision=0),
+ 'TIME(0) WITHOUT TIME ZONE'),
+ (postgresql.TIMESTAMP(precision=0),
+ 'TIMESTAMP(0) WITHOUT TIME ZONE'),
]:
self.assert_compile(type_, expected)