diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index ed66147cb..65bdd0d28 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -89,10 +89,16 @@ sqlite_datasource::sqlite_datasource(parameters const& params, bool bind) boost::optional key_field_name = params_.get("key_field"); if (key_field_name) { - if (key_field_name->empty()) + std::string const& key_field_string = *key_field_name; + if (key_field_string.empty()) { key_field_ = "rowid"; - else - key_field_ = *key_field_name; + } else { + key_field_ = key_field_string; + } + } + else + { + key_field_ = "rowid"; } boost::optional wkb = params_.get("wkb_format"); @@ -571,7 +577,12 @@ featureset_ptr sqlite_datasource::features(query const& q) const s << " FROM "; - std::string query (table_); + std::string query (table_); + + /* todo + throw if select * and key_field == rowid? + or add schema support so sqlite throws + */ if (has_spatial_index_) {