I am using QGIS 3.4 and when I finish drawing a feature (line), I try to add a negative value (-1) in the attribute dialog and it is automatically changed to NULL. The field is integer.

Even if I leave it NULL and then open the attribute table and try to edit it there, it still does not let me use a negative number - automatically changes to NULL. The only way is to change it using Field Calculator and update the existing field to -1.

I tried the same in version 2.18.17 and it works fine.

I haven't used QGIS for years and I am not entirely familiar with the changes in the latest versions. Is there a new setting/option that I don't know of?


I have reported the bug and it has now been fixed.

PostGIS/geojson: Cannot input negative numbers in int fields

The new QGIS versions won't have this issue

  • 1
    What format is the feature you are trying to create? e.g. shapefile or PostGIS. I cannot seem to replicate this.
    – AWGIS
    Jun 11, 2019 at 10:06
  • PostGIS. I will check if it's the same with shp
    – Gunganis
    Jun 11, 2019 at 10:30
  • The same happens with shp
    – Gunganis
    Jun 14, 2019 at 15:10

2 Answers 2


You can use the Integer64 field type to store negative integers.

Although I can't find any specific reference to this.

  • 1
    You're right, int64 allows me to add negative numbers manually. I don't understand though why I cannot do the same with int.
    – Gunganis
    Jun 14, 2019 at 15:18
  • it's bug (thanks @fing-lixon). I have tested with QGIS 3.10, it's works, also with int Jan 26, 2020 at 11:06

This is a bug. Both in the attribute dialog and the attribute table itself, attempting to enter a negative integer yields a NULL value when focus is moved off the value. Using the field calculator allows the entry of negative integers.

  • 1
    I have reported the bug in github and they have fixed it (please see my edit in the original post). Hopefully in the new releases this will be fixed.
    – Gunganis
    Oct 22, 2019 at 8:08
  • 1
    As for your workaround, yes this is a solution (exactly how I am working right now) but is a damn waste of time to create features leaving the negative fields blank and then going back to the attribute table to use the calculator to fill them!
    – Gunganis
    Oct 22, 2019 at 8:10
  • @Gunganis thank you. I've edited my answer to reference your issue report. Oct 23, 2019 at 0:05
  • @Gunganis also thank you for reporting the bug. Oct 23, 2019 at 0:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.