-
-
Notifications
You must be signed in to change notification settings - Fork 362
Description
Describe the bug
The doc for v.db.connect says that layer can be in the formats layer number[/layer name]
, but using that produces a warning about an illegal filename and character </> not being allowed.
Doc:
layer=string
Layer number or name
Format: layer number[/layer name]
Default: 1
Message:
Illegal filename <1/geology>. Character </> not allowed.
To reproduce
$ grass ~/grassdata/nc_spm_08_grass7/PERMANENT/ --exec v.db.connect -c map=geology layer=1/geology
WARNING: Illegal filename <1/geology>. Character </> not allowed.
INTEGER|cat
DOUBLE PRECISION|onemap_pro
DOUBLE PRECISION|PERIMETER
INTEGER|GEOL250_
INTEGER|GEOL250_ID
CHARACTER|GEO_NAME
DOUBLE PRECISION|SHAPE_area
DOUBLE PRECISION|SHAPE_len
Expected behavior
I don't know what I expect to happen. What do you expect?
The tool-specific code clearly counts on the option of having number/name
there as suggested by the documentation.
The tool not only documents number/name
as a possible way, but also prints information in that format:
$ grass ~/grassdata/nc_spm_08_grass7/PERMANENT/ --exec v.db.connect -p map=geology
Vector map <geology> is connected by:
layer <1/geology> table <geology> in database <.../grassdata/nc_spm_08_grass7/PERMANENT/sqlite/sqlite.db> through driver <sqlite> with key <cat>
$ grass ~/grassdata/nc_spm_08_grass7/PERMANENT/ --exec v.db.connect -g map=geology
1/geology|geology|cat|.../grassdata/nc_spm_08_grass7/PERMANENT/sqlite/sqlite.db|sqlite
On the other hand, a warning is produced by the library.
When I use v.info and v.db.select, 1/geology (and also 1 and geology) are accepted without a warning. This may or may not be intentional given that when the conversion from string to a number is performed, atoi in C is likely used, and C atoi ignores whatever comes after the number (cplusplus.com):
The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function.
Additional context
The internal struct field_info has:
int number
Layer number
char * name
Layer name (optional)
I found this when reviewing #6077.