Skip to content

Commit 833988f

Browse files
committed
MSSQL: Show message if geometry_columns not found
Funded by TechnologyOne, Australia - Backported to 2.8.3 - Cherry-picked from 9f0ea0c
1 parent e9181d9 commit 833988f

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/providers/mssql/qgsmssqlsourceselect.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,30 @@ void QgsMssqlSourceSelect::on_btnConnect_clicked()
519519

520520
QString connectionName = db.connectionName();
521521

522+
// Test for geometry columns table first. Don't use it if not found.
523+
QSqlQuery q = QSqlQuery( db );
524+
q.setForwardOnly( true );
525+
526+
if ( useGeometryColumns )
527+
{
528+
QString testquery( "SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'geometry_columns'" );
529+
q.exec( testquery );
530+
int count = q.value( 0 ).toInt();
531+
bool geometryColumnsFound = count != 0;
532+
if ( !geometryColumnsFound )
533+
{
534+
QMessageBox::StandardButtons reply;
535+
reply = QMessageBox::question( this, "Scan full database?",
536+
"No geometry_columns table found. \nWould you like to search full database (might be slower)? ",
537+
QMessageBox::Yes | QMessageBox::No
538+
);
539+
if ( reply == QMessageBox::Yes )
540+
useGeometryColumns = false;
541+
else
542+
return;
543+
}
544+
}
545+
522546
// Read supported layers from database
523547
QApplication::setOverrideCursor( Qt::WaitCursor );
524548

@@ -539,7 +563,7 @@ void QgsMssqlSourceSelect::on_btnConnect_clicked()
539563
}
540564

541565
// issue the sql query
542-
QSqlQuery q = QSqlQuery( db );
566+
q = QSqlQuery( db );
543567
q.setForwardOnly( true );
544568
( void )q.exec( query );
545569

0 commit comments

Comments
 (0)