From aaf9d960d793ce28d4cfe04fc17862f060f511b3 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 16 Aug 2011 23:05:19 +0000 Subject: [PATCH] sqlite: properly initialize rowid default --- plugins/input/sqlite/sqlite_datasource.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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_) {