Skip to content

Commit

Permalink
remove constrainst of fields that use defaultValueClauses from provid…
Browse files Browse the repository at this point in the history
…er on original

fixes #28122
  • Loading branch information
signedav authored and nyalldawson committed Jun 20, 2019
1 parent 3b02d3d commit 4ac0f69
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -838,6 +838,15 @@ QgsVectorLayer *QgsOfflineEditing::copyVectorLayer( QgsVectorLayer *layer, sqlit
// copy style
copySymbology( layer, newLayer );

//remove constrainst of fields that use defaultValueClauses from provider on original
for ( const QgsField &field : layer->fields() )
{
if ( !layer->dataProvider()->defaultValueClause( layer->fields().fieldOriginIndex( layer->fields().indexOf( field.name() ) ) ).isEmpty() )
{
newLayer->removeFieldConstraint( newLayer->fields().indexOf( field.name() ), QgsFieldConstraints::ConstraintNotNull );
}
}

QgsLayerTreeGroup *layerTreeRoot = QgsProject::instance()->layerTreeRoot();
// Find the parent group of the original layer
QgsLayerTreeLayer *layerTreeLayer = layerTreeRoot->findLayer( layer->id() );
Expand Down

0 comments on commit 4ac0f69

Please sign in to comment.