tests: add simple tests for postgis 'bbox' token replacement
This commit is contained in:
parent
d9cb76f7a1
commit
a7e150a593
2 changed files with 41 additions and 9 deletions
|
@ -548,23 +548,31 @@ featureset_ptr sqlite_datasource::features(query const& q) const
|
|||
|
||||
std::ostringstream s;
|
||||
mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
|
||||
std::set<std::string> const& props = q.property_names();
|
||||
std::set<std::string>::const_iterator pos = props.begin();
|
||||
std::set<std::string>::const_iterator end = props.end();
|
||||
|
||||
s << "SELECT " << geometry_field_;
|
||||
if (!key_field_.empty())
|
||||
{
|
||||
s << "," << key_field_;
|
||||
ctx->push(key_field_);
|
||||
for ( ;pos != end;++pos)
|
||||
{
|
||||
if (*pos != key_field_)
|
||||
{
|
||||
s << ",[" << *pos << "]";
|
||||
ctx->push(*pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
std::set<std::string> const& props = q.property_names();
|
||||
std::set<std::string>::const_iterator pos = props.begin();
|
||||
std::set<std::string>::const_iterator end = props.end();
|
||||
|
||||
for ( ;pos != end;++pos)
|
||||
else
|
||||
{
|
||||
// TODO - should we restrict duplicate key query?
|
||||
//if (*pos != key_field_)
|
||||
s << ",[" << *pos << "]";
|
||||
ctx->push(*pos);
|
||||
for ( ;pos != end;++pos)
|
||||
{
|
||||
s << ",[" << *pos << "]";
|
||||
ctx->push(*pos);
|
||||
}
|
||||
}
|
||||
|
||||
s << " FROM ";
|
||||
|
|
|
@ -359,6 +359,30 @@ if 'postgis' in mapnik.DatasourceCache.instance().plugin_names() \
|
|||
eq_(fs.next().id(),4)
|
||||
eq_(fs.next(),None)
|
||||
|
||||
def test_bbox_token_in_subquery1():
|
||||
ds = mapnik.PostGIS(dbname=MAPNIK_TEST_DBNAME,table='''
|
||||
(SeLeCt * FrOm "tableWithMixedCase" where geom && !bbox! ) as MixedCaseQuery''',
|
||||
geometry_field='geom',
|
||||
require_key=True)
|
||||
fs = ds.featureset()
|
||||
eq_(fs.next().id(),1)
|
||||
eq_(fs.next().id(),2)
|
||||
eq_(fs.next().id(),3)
|
||||
eq_(fs.next().id(),4)
|
||||
eq_(fs.next(),None)
|
||||
|
||||
def test_bbox_token_in_subquery2():
|
||||
ds = mapnik.PostGIS(dbname=MAPNIK_TEST_DBNAME,table='''
|
||||
(SeLeCt * FrOm "tableWithMixedCase" where ST_Intersects(geom,!bbox!) ) as MixedCaseQuery''',
|
||||
geometry_field='geom',
|
||||
require_key=True)
|
||||
fs = ds.featureset()
|
||||
eq_(fs.next().id(),1)
|
||||
eq_(fs.next().id(),2)
|
||||
eq_(fs.next().id(),3)
|
||||
eq_(fs.next().id(),4)
|
||||
eq_(fs.next(),None)
|
||||
|
||||
atexit.register(postgis_takedown)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Reference in a new issue