diff --git a/plugins/input/sqlite/sqlite_utils.hpp b/plugins/input/sqlite/sqlite_utils.hpp index e3cc9f6cb..27758e6ec 100644 --- a/plugins/input/sqlite/sqlite_utils.hpp +++ b/plugins/input/sqlite/sqlite_utils.hpp @@ -700,6 +700,7 @@ public: { // "Column Affinity" says default to "Numeric" but for now we pass.. //desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Double)); + desc.add_descriptor(mapnik::attribute_descriptor(fld_name, mapnik::String)); #ifdef MAPNIK_LOG // Do not fail when we specify geometry_field in XML file @@ -707,8 +708,9 @@ public: { MAPNIK_LOG_DEBUG(sqlite) << "Column '" << std::string(fld_name) - << "' unhandled due to unknown type: " - << fld_type; + << "' unhandled due to unknown type: '" + << fld_type + << "', using String"; } #endif } diff --git a/tests/python_tests/sqlite_test.py b/tests/python_tests/sqlite_test.py index f384fccae..270f350cd 100644 --- a/tests/python_tests/sqlite_test.py +++ b/tests/python_tests/sqlite_test.py @@ -368,6 +368,44 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names(): eq_(len(feat.geometries()),1) eq_(feat.geometries()[0].to_wkt(),'Point(0 0)') + def test_db_with_one_untyped_column(): + # form up an in-memory test db + wkb = '010100000000000000000000000000000000000000' + ds = mapnik.SQLite(file=':memory:', + table='test1', + initdb=''' + create table test1 (geometry BLOB, untyped); + insert into test1 values (x'%s', 'untyped'); + ''' % wkb, + extent='-180,-60,180,60', + use_spatial_index=False, + key_field='rowid' + ) + + # ensure the untyped column is found + eq_(len(ds.fields()),2) + eq_(ds.fields(),['rowid', 'untyped']) + eq_(ds.field_types(),['int', 'str']) + + def test_db_with_one_untyped_column_using_subquery(): + # form up an in-memory test db + wkb = '010100000000000000000000000000000000000000' + ds = mapnik.SQLite(file=':memory:', + table='(SELECT rowid, geometry, untyped FROM test1)', + initdb=''' + create table test1 (geometry BLOB, untyped); + insert into test1 values (x'%s', 'untyped'); + ''' % wkb, + extent='-180,-60,180,60', + use_spatial_index=False, + key_field='rowid' + ) + + # ensure the untyped column is found + eq_(len(ds.fields()),3) + eq_(ds.fields(),['rowid', 'untyped', 'rowid']) + eq_(ds.field_types(),['int', 'str', 'int']) + def test_that_64bit_int_fields_work(): ds = mapnik.SQLite(file='../data/sqlite/64bit_int.sqlite',