Merge pull request #2580 from StevenLooman/master

Tests and fix for SQLite datasource missing column
This commit is contained in:
Artem Pavlenko 2014-11-24 12:51:55 +01:00
commit db4b74e8bb
2 changed files with 42 additions and 2 deletions

View File

@ -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
}

View File

@ -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',