diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index c8d2fdef9..679a21861 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -502,15 +502,18 @@ featureset_ptr postgis_datasource::features(const query& q) const std::ostringstream s; s << "SELECT ST_AsBinary(\"" << geometryColumn_ << "\") AS geom"; + mapnik::context_ptr ctx = boost::make_shared(); + if (!key_field_.empty()) + { mapnik::sql_utils::quote_attr(s,key_field_); + ctx->push(key_field_); + } std::set const& props=q.property_names(); std::set::const_iterator pos=props.begin(); std::set::const_iterator end=props.end(); - mapnik::context_ptr ctx = boost::make_shared(); - for ( ;pos != end;++pos) { mapnik::sql_utils::quote_attr(s,*pos); @@ -526,9 +529,6 @@ featureset_ptr postgis_datasource::features(const query& q) const } boost::shared_ptr rs = get_resultset(conn, s.str()); - unsigned num_attr = props.size(); - if (!key_field_.empty()) - ++num_attr; return boost::make_shared(rs, ctx, desc_.get_encoding(), !key_field_.empty()); } else @@ -574,11 +574,14 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt) const std::ostringstream s; s << "SELECT ST_AsBinary(\"" << geometryColumn_ << "\") AS geom"; - if (!key_field_.empty()) - mapnik::sql_utils::quote_attr(s,key_field_); - mapnik::context_ptr ctx = boost::make_shared(); + if (!key_field_.empty()) + { + mapnik::sql_utils::quote_attr(s,key_field_); + ctx->push(key_field_); + } + std::vector::const_iterator itr = desc_.get_descriptors().begin(); std::vector::const_iterator end = desc_.get_descriptors().end();