[GRASS-user] Why v.extract produces columns of type "CHARACTER"?

Moritz Lennert mlennert at club.worldonline.be
Wed Jan 14 04:46:59 EST 2009


On 14/01/09 10:19, maning sambale wrote:
> On Wed, Jan 14, 2009 at 5:02 PM, Glynn Clements
> <glynn at gclements.plus.com> wrote:
>> Nikos Alexandris wrote:
>>
>>>> The columns produces by v.extract are of type "CHARACTER" and v.dissolve
>>>> does not like this. It's an "old" issue. Can someone explain why it
>>>> becomes CHARACTER since grass' type for strings is "varchar"?
>>>>
>>>> Regards, Nikos
>>> Sorry, wrong question - false alarm.
>>>
>>> Actually, the *real* question I have asked in the past but never really
>>> got a reply is: why "sqlitebrowser" reports the columns as "varchar"
>>> while db.describe reports (in grass-shell) the same columns to be of
>>> type "CHARACTER"?
>> GRASS' DBMI doesn't distinguish CHARACTER from CHARACTER VARYING (aka
>> VARCHAR); the constant DB_SQL_TYPE_CHARACTER is used for both
>> (although there is also DB_SQL_TYPE_TEXT for TEXT).
>>
>> Also, SQLite doesn't really have column types; it assigns types to
>> individual values rather than to columns. Columns may have a type of
>> SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB or SQLITE_NULL,

AFAIK, columns can have any "type", even ones invented by you. I.e.

create table test (key int, chartest ThisIsMyTextType);

works in sqlite, where "works" means that sqlite just ignores the column 
"type" and automatically affects a type amongst the ones listed by Glynn 
to each value.

>> but it doesn't actually require that the values' types conform to the
>> type.
> A bit off-topic.  Does this mean I can actually edit vector data
> attributes as text even if the column is an INTEGER?
> I'm using Sqlite database browser for editing.  A bit dangerous for
> me.

Yes. I find SQLite a bit dangerous because of that, especially since 
GRASS enforces types.

 > Any other way to add checks/controls for editing mistakes?

IMHO, the best way to deal with attributes in GRASS + SQLite is to do it 
via the built-in tools in GRASS, and not via the SQLiteBrowser or other 
tools as this can lead to incompatibilities and confusion. The new wxgui 
has a very nice interface for attribute and table management.

Moritz


More information about the grass-user mailing list