[GRASS-user] Rename multiple sqlite columns at once

Moritz Lennert mlennert at club.worldonline.be
Thu Nov 13 04:28:57 EST 2008


On 07/11/08 01:47, Nikos Alexandris wrote:
> On Fri, 2008-11-07 at 01:38 +0100, Moritz Lennert wrote:
>> You still use quotes:
>> tempcolumn="$tempcolumn\_tmp"
>>
>> IIUC, the quotes will let the slash appear literally. So, just leave
>> out 
>> the quotes as follows:
>>
>> tempcolumn=$tempcolumn\_tmp
>>
>> However, as you say your original script (in my modified form)
>> actually 
>> worked, it just spit out a series of warnings. So it might be more 
>> interesting to check upon these warnings. I only saw these with the 
>> sqlite driver, not with dbf or postgresql, so we should try to find
>> out 
>> what happens  with that driver.
>>
>> Moritz
> 
> Oh, sorry Moritz. Now I see. I am at your service :-) Tell me what/how
> to test?

Sorry, for not coming back on this earlier, but I think I found it now. 
The error (which also appears in other drivers, at least dbf), is due to 
the following line in v.db.renamecol:

oldcoltype="`db.describe -c table=$table database=$database\
		driver=$driver | grep $oldcol | cut -d':' -f3`"

If you have two columns with the name of the first a subset of the name 
of the second (e.g. DATA and DATA2, or in the nc_spm_06 dataset's 
comm_colleges map, CC_ and CC_NAME and CCL_ and CCL_ID), the grep in the 
above line will find both lines and result in an invalid oldcoltype:

GRASS 6.4.svn (nc_spm_06):~ > db.describe -c table=test | grep CC_ 
Column 7: CC_:CHARACTER:8
Column 8: CC_NAME:CHARACTER:30

GRASS 6.4.svn (nc_spm_06):~ > db.describe -c table=test | grep CC_ | 
cut -d':' -f3
CHARACTER
CHARACTER

GRASS 6.4.svn (nc_spm_06):~ > oldcoltype="`db.describe -c table=test | 
grep CC_ |  cut -d':' -f3`"
GRASS 6.4.svn (nc_spm_06):~ > echo $oldcoltype
CHARACTER CHARACTER

Which then obviously leads to an error as 'CHARACTER CHARACTER' is not a 
valid column type.

Can you confirm that this is the case for you as well ?

And actually this is not only a warning issue, but the column is lost 
because of this !

I don't have the time right now to try to figure out a solution, but you 
can either give it a try yourself, or file a bug report, and I'll get 
back to it when I have time.

Moritz


More information about the grass-user mailing list