-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bugfix][postgres] Browser panel D&D a layer onto a postgresql connection tree … #5694
[bugfix][postgres] Browser panel D&D a layer onto a postgresql connection tree … #5694
Conversation
…node icon fails without notice Fixes qgis#17518 by defaulting to "public" if no schema is given
@jef-n does it make sense to you? Or is there a better logic to get the "default" schema? |
Doesn't say what the problem with the missing schema name is. Knowing which schema to refresh? Otherwise creating the table without the schema will do the right thing anyway. |
@jef-n have a look to the test that I've added: it fails (badly, because it creates part of the table but not the geometry or attributes) on 2.x and master because the schema is not specified when creating the empty layer. The problem with the empty |
@jef-n I guess that instead of setting the default to "public" we could also change the logic that build the |
the empty schema case needs to be handled everywhere (at least when checking whether the table exists and when calling |
@@ -3791,6 +3792,20 @@ QgsVectorLayerExporter::ExportError QgsPostgresProvider::createEmptyLayer( const | |||
{ | |||
conn->PQexecNR( QStringLiteral( "BEGIN" ) ); | |||
|
|||
// We want a valid schema name ... | |||
if ( schemaName.isEmpty() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, what I meant was schemaName = schemaName.isEmpty() ? "current_schema" : quotedValue(schemaName);
here and schemaName
instead of quotedValue(schemaName)
below. Just one query less ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked on psql and you cannot use current_schema to prefix a table. That's why I added an extra query to retrieve its value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to. a not prefixed table lands in the current schema
…node icon fails without notice and leaving the destination table half-constructed ...
Fixes #17518 by defaulting to "public" if no schema is given
With test.