"Load as new layer" in QGIS database manager frequently refuses to recognize INT and REAL columns as such - they are converted to TEXT in the new layer. Is there a solution to this in the DB manager? I would prefer not to create new tables, etc. just to convert the field type for simple diagnostics. I've checked there are no strings or Nulls in the fields in question. I've also explicitly CAST fields as INT and REAL without success.

  • 1
    Can you provide more information, and possibly an example of the table definition and the query you are using where this behavior occurs? I tested this in QGIS 2.8 against a PostGIS 2.1 backend and did not observe this behavior. I tested it against a int and float columns as well as a text column cast to int using column_name::int. – Lee Hachadoorian Oct 9 '15 at 16:17
  • I have the same problem. I have a SQL query such as select value1, value2, (value2-value1) as dif from table. Value1 and value2 are REAL number but the expression is TEXT. I tried with cast((value2-value1) as REAL) as dif from table, but no run. Is it a possible bug? I have a Spatialite... Thank you – user61317 Nov 1 '15 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.