Skip to content
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

Fix Vector info bug #359 #364

Merged
merged 4 commits into from
Jan 16, 2023
Merged

Fix Vector info bug #359 #364

merged 4 commits into from
Jan 16, 2023

Conversation

linakrisztian
Copy link
Member

@linakrisztian linakrisztian commented Jul 28, 2022

#359: By changing v.info -c to v.db.connect -c, GRASS does not return an error for vector maps with missing table. Instead this message is printed: "Map <test_random_vect> is not connected to a database". Thus the endpoint does not return an error anymore.

Copy link
Contributor

@griembauer griembauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good and tested successfully locally!

@@ -65,7 +65,7 @@ def _execute(self):
"flags": "h"}

pc["3"] = {
"module": "v.info",
"module": "v.db.connect",
"inputs": {"map": vector_name + "@" + self.mapset_name},
"flags": "c"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really want to print types/names of table columns for the specified layer (default is layer 1) or rather print all map connection parameters for all layers, would be empty if there are no connections?

Suggested change
"flags": "c"}
"flags": "g"}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anikaweinmann or @mmacata : The old case (v.info -c) also printed only type/names of the specified layer (default layer 1). Should we change it as @metzm suggested?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think v.db.connect -c is the one which is like it is now. So I would prefer this. The style of g is anonther one than we have a breaking change, or not?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check with v.db.connect -g if there are more than 1 layer/tables or no layers (count number of rows). If there is only one layer the output should be v.info -c as before, by multiple layer/tables v.db.connect -g should be inside the results. By no layer/table nothing has to be added to the results.

Open question: how to write this in the api docs.

@metzm
Copy link
Contributor

metzm commented Jul 29, 2022

A GRASS vector can have no database connection at all or one or several database connections, one possible connection for each layer. The common case is that a vector has one database connection, the corresponding layer is layer 1. For other cases v.info -c or v.db.connect -c does not make sense because no columns would be reported or only columns for layer 1, ignoring attribute columns for other layers.
The class EphemeralVectorInfo()reports general information about a vector. Therefore I would argue that this is the wrong place for column names and types of a specific layer. Instead, any database connections as reported by v.db.connect -g() would be useful information in this place. After that, a user might want to know column names and types of a specific vector layer, see also https://github.com/OSGeo/grass/blob/main/python/grass/script/vector.py#L101.

Maybe introduce a new endpoint where the layer of a vector can be specified?

@metzm
Copy link
Contributor

metzm commented Jul 29, 2022

Instead of a new endpoint for a vector layer, the syntax also recognized by TGIS could be used: <name>:<layer>@<mapset>. If a layer is given, v.db.connect -c layer=<layer> map=<name> could be used, otherwise v.db.connect -g map=<name>.

@linakrisztian linakrisztian changed the title changed v.info -c to v.db.connect -c Fix Vector info bug #359 Jan 16, 2023
@linakrisztian linakrisztian merged commit 652982f into main Jan 16, 2023
@linakrisztian linakrisztian deleted the vector_info_bug branch January 16, 2023 15:03
linakrisztian added a commit that referenced this pull request Jan 16, 2023
linakrisztian added a commit that referenced this pull request Jan 16, 2023
Revert "Fix Vector info bug #359 (#364)"

This reverts commit 652982f.
@linakrisztian linakrisztian restored the vector_info_bug branch January 16, 2023 15:57
@linakrisztian linakrisztian mentioned this pull request Jan 16, 2023
@mmacata mmacata added this to the not_released milestone Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants