Skip to content
Permalink
Browse files

[FEATURE]postgres provider: add support for timestamp types

  • Loading branch information
jef-n committed Nov 18, 2015
1 parent 7b0815b commit f6e4e75cd6257a2fa6a59beb9892d7517bbbd39d
@@ -136,7 +136,3 @@ void QgsDateTimeEdit::resizeEvent( QResizeEvent * event )
mNullLabel->setMinimumSize( rect().adjusted( 0, 0, -spinButtonWidth(), 0 ).size() );
mNullLabel->setMaximumSize( rect().adjusted( 0, 0, -spinButtonWidth(), 0 ).size() );
}




@@ -106,6 +106,18 @@ QVariant QgsDateTimeEditWrapper::value()
if ( !mQDateTimeEdit )
return QVariant( field().type() );

if ( field().type() == QVariant::DateTime )
{
if ( mQgsDateTimeEdit )
{
return mQgsDateTimeEdit->dateTime();
}
else
{
return mQDateTimeEdit->dateTime();
}
}

const QString fieldFormat = config( "field_format", QGSDATETIMEEDIT_DATEFORMAT ).toString();

if ( mQgsDateTimeEdit )
@@ -124,7 +136,7 @@ void QgsDateTimeEditWrapper::setValue( const QVariant &value )
return;

const QString fieldFormat = config( "field_format", QGSDATETIMEEDIT_DATEFORMAT ).toString();
const QDateTime date = QDateTime::fromString( value.toString(), fieldFormat );
const QDateTime date = field().type() == QVariant::DateTime ? value.toDateTime() : QDateTime::fromString( value.toString(), fieldFormat );

if ( mQgsDateTimeEdit )
{
@@ -878,6 +878,11 @@ bool QgsPostgresProvider::loadFields()
fieldType = QVariant::Date;
fieldSize = -1;
}
else if ( fieldTypeName == "timestamp" )
{
fieldType = QVariant::DateTime;
fieldSize = -1;
}
else if ( fieldTypeName == "text" ||
fieldTypeName == "bool" ||
fieldTypeName == "geometry" ||

0 comments on commit f6e4e75

Please sign in to comment.
You can’t perform that action at this time.