+ allow multi-line SQL queries in table parameter (#173)
This commit is contained in:
parent
868d43408b
commit
60a956f260
1 changed files with 13 additions and 5 deletions
|
@ -214,15 +214,23 @@ layer_descriptor postgis_datasource::get_descriptor() const
|
||||||
|
|
||||||
std::string postgis_datasource::table_from_sql(const std::string& sql)
|
std::string postgis_datasource::table_from_sql(const std::string& sql)
|
||||||
{
|
{
|
||||||
std::string table_name(sql);
|
std::string table_name = boost::algorithm::to_lower_copy(sql);
|
||||||
std::transform(table_name.begin(),table_name.end(),table_name.begin(),tolower);
|
boost::algorithm::replace_all(table_name,"\n"," ");
|
||||||
|
|
||||||
std::string::size_type idx = table_name.rfind("from");
|
std::string::size_type idx = table_name.rfind("from");
|
||||||
if (idx!=std::string::npos)
|
if (idx!=std::string::npos)
|
||||||
{
|
{
|
||||||
|
|
||||||
idx=table_name.find_first_not_of(" ",idx+4);
|
idx=table_name.find_first_not_of(" ",idx+4);
|
||||||
|
if (idx != std::string::npos)
|
||||||
|
{
|
||||||
table_name=table_name.substr(idx);
|
table_name=table_name.substr(idx);
|
||||||
|
}
|
||||||
idx=table_name.find_first_of(" )");
|
idx=table_name.find_first_of(" )");
|
||||||
return table_name.substr(0,idx);
|
if (idx != std::string::npos)
|
||||||
|
{
|
||||||
|
table_name = table_name.substr(0,idx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return table_name;
|
return table_name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue