Column naming curiosity
Tried the add, and rename columns feature of the wee_database utility. Both seemed to work fine, however I noticed a peculiarity in the column names that were renamed, or created .
Normally a sqlite3 query of .schema archive shows ALL column names surrounded by what seems to be the U+0060 GRAVE ACCENT Character.
However a sqlite3 query after --rename-column shows the added column surrounded by double quotes.
Also a sqlite3 query after --add-column shows a naked column name not surrounded at all?
Please note that what I perceive as a column naming peculiarity, seems to have no noticeable effect on the database, it functions normally.
My wild speculation is that there's an inconsistency between handing of string to unicode in the table create and new add column rename column function.
Spied this in /weedb/sqlite.py
# Extract the table name. Sqlite returns unicode, so always
# convert to a regular string:
I am sure this is hard to follow, so here is an outline of my test methodology hopefully it helps,and doesn't make it more confusing!
Let WeeWx create new database with a few fields using wview_small.py reduced to these fields:
table = [('dateTime', 'INTEGER NOT NULL UNIQUE PRIMARY KEY'),
('usUnits', 'INTEGER NOT NULL'),
('interval', 'INTEGER NOT NULL'),
('altimeter', 'REAL'),
('barometer', 'REAL'),
('dewpoint', 'REAL'),
('ET', 'REAL'),
('heatindex', 'REAL'),
]
sqlite3 query of .schema archive after database creation
sqlite> .schema archive
CREATE TABLE archive (`dateTime` INTEGER NOT NULL UNIQUE PRIMARY KEY, `usUnits` INTEGER NOT NULL, `interval` INTEGER NOT NULL, `altimeter` REAL, `barometer` REAL, `dewpoint` REAL, `ET` REAL, `heatindex` REAL);
*** Note what seems to be the U+0060 GRAVE ACCENT Character surrounding the column names.
Rename heatindex to renamedheatindex
wee_database --rename-column=heatindex --to-name=renamedheatindex
Added addedcolumn
wee_database --add-column=addedcolumn
sqlite3 query of .schema archive after the Rename and add column operation
sqlite> .schema archive
CREATE TABLE archive (`dateTime` INTEGER NOT NULL UNIQUE PRIMARY KEY, `usUnits` INTEGER NOT NULL, `interval` INTEGER NOT NULL, `altimeter` REAL, `barometer` REAL, `dewpoint` REAL, `ET` REAL, "renamedheatindex" REAL, addedcolumn REAL);
*** Note the name of the renamedheatindex column is surrounded by double quotes, and the added column addedcolumn isn't surrounded by anything.
Thanks!
Paul