Comments (8)
I've done a more thorough look at this, and have come up with 3 options:
- Do case-insensitive comparisons. This would break skins that depend on case to distinguish between SQL columns. Don't know how many of them are out there.
- Store the actual (case-sensitive) names as metadata, in a new table.
- Do nothing. We just don't support cross-platform MySQL (which is the only reason to choose to set
lower_case_table_names=1
)
Presently, I'm favoring 3. Otherwise, option 2.
from weewx.
which approach adheres to the sql standard? note that the sql standard and what mysql does are not always the same thing. i as because at some point it would be nice to have built-in support for postgresql.
from weewx.
Beats me. Everything I'm seeing on the web says, "It depends."
As I understand it, postgresql is case-insensitive unless you quote the table/column names. Generally, in weewx, nothing is quoted. One exception: column names are back quoted (to get around interval
being treated as a key word by MySQL).
Are you aware of anyone depending on case-sensitive names?
from weewx.
i do not know of any case-sensitive dependencies in existing weewx extensions.
here is a pretty good summary of the situation across different sql implementations:
http://www.alberton.info/dbms_identifiers_and_case_sensitivity.html
the conclusion: The safest choice if you care about portability and peace of mind is not to quote the identifiers when you create your tables/fields and when you run your queries.
here are additional references:
Some systems (like PostgreSQL) are case sensitive in table and column names, but attempt to hide it through lowercasing or uppercasing all names before looking them up. On these systems you will have to enclose the table name in "double quotes" to make sure the exact name you entered is looked up.
http://stackoverflow.com/questions/153944/is-sql-syntax-case-sensitive
MySQL represents databases and tables using directories and files in the underlying filesystem on the server host. As a result, the default case sensitivity of database and table names depends on how the operating system on that host treats filenames. Windows filenames are not case sensitive, so a MySQL server running on Windows does not treat database and table names as case sensitive. Servers running on Unix usually treat database and table names as case sensitive because Unix filenames are case sensitive. An exception is that names in Mac OS X Extended filesystems can be case insensitive.
http://www.informit.com/articles/article.aspx?p=2036581&seqNum=3
from weewx.
the conclusion: The safest choice if you care about portability and peace of mind is not to quote the
identifiers when you create your tables/fields and when you run your queries.
Which is exactly what we do, except for backquoting the column names when creating a table. (Backquoting is necessary because the column name interval
is a reserved keyword in MySQL. Backquoting doesn't change the case, it just "escapes" the recognition as a keyword.)
The problem is when it comes time to recognize those columns. If lower_case_table_names=1
has been set, a select statement such as
SELECT mintime FROM ArChiVe_Day_OutTemp;
works just fine, but if you try
SHOW TABLES;
you'll get back archive_day_outtemp
. The manager uses this name to figure out what observation types are in the database, so it gets outtemp
and thinks it is different from the outTemp
being offered in the archive record. An exception occurs.
The problem is not so much on the database end, as in the interaction of a now case-insensitive database with the still very case-sensitive Python language.
Anyway, if I'm reading the article you linked to correctly, we should be assuming that all identifiers are case-insensitive. This means we should be converting outTemp
to outtemp
, etc., before comparing. As for the keyword interval
, it would not be hard to backquote only its use, and no other identifiers.
from weewx.
we might have problems if we lowercase everything. DB2/Oracle does an uppercase of everything, PostgreSQL does a lowercase of everything, and MySQL depends on the platform's file system.
perhaps a small test suite would answer this definitively. could we create the 3/10/whatever examples of sql that are representative of what happens in weewx, then use that in a unit test to see exactly what we must do to make weewx work across databases and database configurations, or at least definitively say which will be compatible and which will not?
from weewx.
Sorry, I didn't make myself clear. Both the observation type and what's coming from the database would be lower-cased. So, it doesn't matter what the database does with it.
I'm pretty sure most of weewx will not be touched by this. Only the logic that determines whether a daily summary is available for a type.
In any case, it's too late for V3.2. Let's wait until 3.3. We've got to stabilize this thing.
from weewx.
This issue has been kicking around for nearly a year and a half and, in that time, no new users have reported having this problem. So, I guess, there are not that many people doing cross-platform MySQL (that is, who have set lower_case_table_names=1
in their MySQL configuration).
So, I say we punt and choose my option number 3: do nothing. The additional complexity is not worth it.
from weewx.
Related Issues (20)
- wee_extension fails if there are no line "restful_services" HOT 1
- weewx v5 restart fails on Ethernet connection - Too quick? HOT 22
- changing case of example Basic skin causes problems on weectl create station HOT 1
- v5.x - weewx.cheetahgenerator SeasonsReport runs almost 10x longer than in v4.x HOT 8
- Special characters in de.conf HOT 5
- Upgrade Google Analytics handling to use GA4 rather than deprecated UA tags HOT 4
- Reliable import project from wunderground in real time HOT 2
- [[Corrections]] doesn't work with partial packets and software record generation HOT 1
- include my patch to support time_offset within diagrams HOT 4
- `wee_database --calc-missing` needs configurable transaction size [was: stuck always on same record] HOT 18
- Separate extraction of records from accumulator from StdArchive
- rpm --import https://weewx.com/keys.html fails on RHEL9(ish) HOT 19
- weectl extension list returns 'No extensions installed' under some circumstances HOT 1
- Error when crt is installed togheter weewx-weatherlink-live in WeeWX HOT 2
- Download package not found HOT 2
- Correct Chinese language code
- Missing values in exported Cumulus realtime.txt file when retrieving data from WeatherLink Live using weatherlink-live v1.1.2 driver HOT 1
- 5.0.0rc3 upgrade issues HOT 2
- values for derived variables when there should be none HOT 5
- Is this the extension or the code? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from weewx.