Patch level : 12.0 972
Files correlati : ba8.exe f90.exe Commento : Corretta classe record sqlite: i datatype erano sempre sbagliati perche' presi dalla prima riga del set e quasi sempre i campi erano considerati real per i TVariant solitamente dovuto a un guessing di campi vuoti.
This commit is contained in:
parent
4d7d204fee
commit
658c6e9081
@ -93,7 +93,7 @@ sqlite3* TSQLite::open(const char* fname)
|
|||||||
const char* errmsg = sqlite3_errmsg(_handle); // Stringa di sitema: inutile sqlite3_free(errmsg)
|
const char* errmsg = sqlite3_errmsg(_handle); // Stringa di sitema: inutile sqlite3_free(errmsg)
|
||||||
error_box(errmsg);
|
error_box(errmsg);
|
||||||
_handle = NULL;
|
_handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _handle;
|
return _handle;
|
||||||
}
|
}
|
||||||
@ -386,7 +386,7 @@ bool TSQLite::parse_select_from(const char* szSql)
|
|||||||
{ table.cut(i); break; }
|
{ table.cut(i); break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
const int logicnum = (table == "MAG") ? LF_MAG : table2logic(table);
|
const int logicnum = (table == "MAG") ? LF_MAG : table2logic(table);
|
||||||
if (logicnum >= LF_USER)
|
if (logicnum >= LF_USER)
|
||||||
{
|
{
|
||||||
pi.set_text(table);
|
pi.set_text(table);
|
||||||
@ -428,11 +428,11 @@ int TSQL_recordset::on_get_items(int argc, char** values, char** columns)
|
|||||||
for (int i = 0; i < argc; i++)
|
for (int i = 0; i < argc; i++)
|
||||||
{
|
{
|
||||||
TRecordset_column_info* info = new TRecordset_column_info;
|
TRecordset_column_info* info = new TRecordset_column_info;
|
||||||
info->_name = columns[i];
|
info->_name = columns[i];
|
||||||
info->_width = 1;
|
info->_width = 1;
|
||||||
info->_type = _alfafld;
|
info->_type = _alfafld;
|
||||||
|
|
||||||
const char* fldtype = columns[argc+i];
|
/*const char* fldtype = columns[argc+i];
|
||||||
if (fldtype != NULL)
|
if (fldtype != NULL)
|
||||||
{
|
{
|
||||||
if (xvt_str_same(fldtype, "DATE"))
|
if (xvt_str_same(fldtype, "DATE"))
|
||||||
@ -449,36 +449,36 @@ int TSQL_recordset::on_get_items(int argc, char** values, char** columns)
|
|||||||
info->_type = _memofld;
|
info->_type = _memofld;
|
||||||
info->_width = 50;
|
info->_width = 50;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
_column.add(info);
|
_column.add(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_items < _pagesize)
|
//if (_items < _pagesize)
|
||||||
{
|
//{
|
||||||
// Aggiusta le lunghezze dei campi testo e numerici
|
// // Aggiusta le lunghezze dei campi testo e numerici
|
||||||
for (int i = 0; i < argc; i++) if (values[i] && *values[i])
|
// for (int i = 0; i < argc; i++) if (values[i] && *values[i])
|
||||||
{
|
// {
|
||||||
TRecordset_column_info& info = (TRecordset_column_info&)_column[i];
|
// TRecordset_column_info& info = (TRecordset_column_info&)_column[i];
|
||||||
if (info._type == _alfafld || info._type == _realfld)
|
// if (info._type == _alfafld || info._type == _realfld)
|
||||||
{
|
// {
|
||||||
const int len = strlen(values[i]);
|
// const int len = strlen(values[i]);
|
||||||
if (len > info._width)
|
// if (len > info._width)
|
||||||
{
|
// {
|
||||||
info._width = len;
|
// info._width = len;
|
||||||
if (info._type == _alfafld)
|
// if (info._type == _alfafld)
|
||||||
{
|
// {
|
||||||
if (len == 8 && atol(values[i]) > 19000000)
|
// if (len == 8 && atol(values[i]) > 19000000)
|
||||||
{
|
// {
|
||||||
info._type = _datefld;
|
// info._type = _datefld;
|
||||||
info._width = 10;
|
// info._width = 10;
|
||||||
} else
|
// } else
|
||||||
if (real::is_real(values[i]))
|
// if (real::is_real(values[i]))
|
||||||
info._type = _realfld;
|
// info._type = _realfld;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
_items++;
|
_items++;
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
@ -502,9 +502,9 @@ TRecnotype TSQL_recordset::items() const
|
|||||||
{
|
{
|
||||||
TString sql; parsed_text(sql);
|
TString sql; parsed_text(sql);
|
||||||
TPerformance_profiler prof("SQL query");
|
TPerformance_profiler prof("SQL query");
|
||||||
_TheDataBase.exec("PRAGMA show_datatypes=ON;", NULL, NULL);
|
//_TheDataBase.exec("PRAGMA show_datatypes=ON;", NULL, NULL);
|
||||||
_TheDataBase.exec(sql, query_get_items, (TSQL_recordset*)this);
|
_TheDataBase.exec(sql, query_get_items, (TSQL_recordset*)this);
|
||||||
_TheDataBase.exec("PRAGMA show_datatypes=OFF;", NULL, NULL);
|
//_TheDataBase.exec("PRAGMA show_datatypes=OFF;", NULL, NULL);
|
||||||
}
|
}
|
||||||
return _items;
|
return _items;
|
||||||
}
|
}
|
||||||
@ -634,4 +634,3 @@ TSQL_recordset::TSQL_recordset(const char* sql)
|
|||||||
{
|
{
|
||||||
set(sql);
|
set(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,7 +671,7 @@ public:
|
|||||||
void add(int n, int pos = -1);
|
void add(int n, int pos = -1);
|
||||||
// @cmember Aggiunge un reale
|
// @cmember Aggiunge un reale
|
||||||
void add(const real r, int pos = -1);
|
void add(const real r, int pos = -1);
|
||||||
// @cmember Aggiunge un reale
|
// @cmember Aggiunge una data
|
||||||
void add(const TDate d, int pos = -1);
|
void add(const TDate d, int pos = -1);
|
||||||
// @cmember Aggiunge un booleano
|
// @cmember Aggiunge un booleano
|
||||||
void add(bool on, int pos = -1) { add(on ? "X" : ""); }
|
void add(bool on, int pos = -1) { add(on ? "X" : ""); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user