Home » U++ Library support » U++ SQL » Lowercase field name in table - error
Lowercase field name in table - error [message #36739] |
Sat, 30 June 2012 00:51  |
mezise
Messages: 54 Registered: April 2006
|
Member |
|
|
I try to use Upp with existing database where there are lowercase field names and I get "Assertion failed" error in NEVER() line:
C:\uppSVN5061\uppsrc\Sql\Sql.cpp, line 339
Value Sql::operator[](SqlId id) const {
String s = ~id;
for(int i = 0; i < cn->info.GetCount(); i++)
if(cn->info[i].name == s)
return operator[](i);
NEVER(); // <---- here ----
return Value();
}
To repeat error:
- revision: SVN 5061
- use package: reference/SQL_Sqlite3
- in simple.sch: change ID to id
- in simple.cpp: change all ID to id
- Execute
|
|
|
|
|
|
|
|
|
Re: Lowercase field name in table - error [message #36795 is a reply to message #36781] |
Thu, 05 July 2012 18:32   |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Hello, Mirek.
mirek wrote on Wed, 04 July 2012 15:25 | Should be now fixed. Anyway, the cause is that you are using lower-cased SqlIds, which is somewhat, well, unexpected; DB column names are uppercased.
|
From the source code point of view, there is no problem to create case-sensitive column names, at least for SQLite. The code, which uppercase column names, is on U++ side:
for(int i = 0; i < cn->info.GetCount(); i++)
cn->info[i].name = ToUpper(cn->info[i].name);
Commenting such part of code removes "case-insensitive restriction" of reading column names (but not the other restrictions with the same case-insensitive characters, inside other U++ source code, e.g. id, ID).
In opposite of uppercase, I read about lowercase identifiers on MySQL documentation.
So, in conclusion, I think, it is related to various database support on U++ side, but not a real restrictions of concrete database (e.g. SQLite) or even C++ identifiers, which are case-sensitive. Therefore, "the fix" fixes the effects, but not the cause, which created by some purpose.
[Updated on: Thu, 05 July 2012 19:09] Report message to a moderator
|
|
|
|
|
Re: Lowercase field name in table - error [message #36799 is a reply to message #36798] |
Fri, 06 July 2012 10:25  |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
In case of SQLite, it returns original column name(s), independent from the query case-sensitivity:
sqlite> .header on
sqlite> .mode column
sqlite> create table SIMPLE_TEST1 (id integer primary key, NAME text, LASTNAME text, BDATE integer);
sqlite> insert into SIMPLE_TEST1(id, NAME, LASTNAME, BDATE) values (0, 'Joe', 'Smith', 20000101);
sqlite> insert into SIMPLE_TEST1(id, NAME, LASTNAME, BDATE) values (1, 'Mike', 'Smith', 20000102);
sqlite> insert into SIMPLE_TEST1(id, NAME, LASTNAME, BDATE) values (2, 'Jon', 'Goober', 20000103);
sqlite> select id, NAME, LASTNAME, BDATE from SIMPLE_TEST1;
id NAME LASTNAME BDATE
---------- ---------- ---------- ----------
0 Joe Smith 20000101
1 Mike Smith 20000102
2 Jon Goober 20000103
sqlite> select ID, NAME, LASTNAME, BDATE from SIMPLE_TEST1;
id NAME LASTNAME BDATE
---------- ---------- ---------- ----------
0 Joe Smith 20000101
1 Mike Smith 20000102
2 Jon Goober 20000103
But yes, I'm aware about possible ambiguities/differences between database engines and why uppercase used instead of lowercase (e.g. because of global SqlId(s) and possible lowercase local variables inside developer's source code). While this didn't change the conclusion, in my opinion.
Personally, I thought about access to column names with the case-sensitivity of constructed query. I already did something inside another topic.
Nevertheless, I agree, that in the current constraints, what you did is "the most prudent option".
[Updated on: Fri, 06 July 2012 10:48] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 25 19:06:16 CEST 2025
Total time taken to generate the page: 0.00881 seconds
|