Skip to content

v.db.connect: accept layer number/name without parser warning#6997

Open
Abhi-d-gr8 wants to merge 1 commit intoOSGeo:mainfrom
Abhi-d-gr8:fix-6100-v-db-connect-layer-syntax
Open

v.db.connect: accept layer number/name without parser warning#6997
Abhi-d-gr8 wants to merge 1 commit intoOSGeo:mainfrom
Abhi-d-gr8:fix-6100-v-db-connect-layer-syntax

Conversation

@Abhi-d-gr8
Copy link
Contributor

Fixes #6100

v.db.connect advertises and prints the layer number[/layer name] syntax, but using layer=1/name triggered a parser warning:
Illegal filename <1/name>. Character </> not allowed. This was caused by filename validation being enabled for the layer option via field_opt->gisprompt. This PR removes that override so the documented number/name syntax works without warnings, and adds a regression test to ensure no warning is emitted.

@wenzeslaus

@github-actions github-actions bot added vector Related to vector data processing Python Related code is in Python C Related code is in C module tests Related to Test Suite labels Jan 30, 2026
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

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

I need to see more background discussion here to be confident enough to merge this. Tests for different use cases may help to facilitate that.

Comment on lines -86 to +89
field_opt->description = _("Format: layer number[/layer name]");
field_opt->gisprompt = "new,layer,layer";
field_opt->description =
_("Layer number or name (format: layer number[/layer name])");
/* no gisprompt override: allow layer_number/layer_name without filename
* validation */
Copy link
Member

Choose a reason for hiding this comment

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

I don't know why new is here in the first place.

Comment on lines +121 to +122
self.assertNotIn("Illegal filename", m.outputs.stderr)
self.assertNotIn("Character </> not allowed", m.outputs.stderr)
Copy link
Member

Choose a reason for hiding this comment

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

Good, but not robust when case or wording changes (likely to happen if also the parameter handling changes).

@@ -113,6 +114,13 @@ def test_columns_csv(self):
).splitlines()
self.assertEqual(actual, expected)

def test_layer_number_name_syntax_no_warning(self):
"""layer=number/name should not trigger filename validation warnings"""
m = SimpleModule("v.db.connect", map="bridges", layer="1/bridges", flags="c")
Copy link
Member

Choose a reason for hiding this comment

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

The doc and general expectation is layer or number, so all these need test. Number only should be easy to test. I'm not clear about how name is actually supported here, while at same time, there is a lot of ways this tool can be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Related code is in C module Python Related code is in Python tests Related to Test Suite vector Related to vector data processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] v.db.connect advertises layer_number/layer_name syntax but gives warning

2 participants