From 658c6e90810c2a5256d83d570f7091ff888af7bc Mon Sep 17 00:00:00 2001 From: Simone Palacino Date: Mon, 22 Jun 2020 23:01:00 +0200 Subject: [PATCH] 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. --- src/include/sqlset.cpp | 71 +++++++++++++++++++++--------------------- src/include/strings.h | 2 +- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/include/sqlset.cpp b/src/include/sqlset.cpp index 2d4056f70..82d20e79b 100755 --- a/src/include/sqlset.cpp +++ b/src/include/sqlset.cpp @@ -93,7 +93,7 @@ sqlite3* TSQLite::open(const char* fname) const char* errmsg = sqlite3_errmsg(_handle); // Stringa di sitema: inutile sqlite3_free(errmsg) error_box(errmsg); _handle = NULL; - } + } return _handle; } @@ -386,7 +386,7 @@ bool TSQLite::parse_select_from(const char* szSql) { 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) { 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++) { TRecordset_column_info* info = new TRecordset_column_info; - info->_name = columns[i]; - info->_width = 1; - info->_type = _alfafld; + info->_name = columns[i]; + info->_width = 1; + info->_type = _alfafld; - const char* fldtype = columns[argc+i]; + /*const char* fldtype = columns[argc+i]; if (fldtype != NULL) { 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->_width = 50; } - } + }*/ _column.add(info); } } - if (_items < _pagesize) - { - // Aggiusta le lunghezze dei campi testo e numerici - for (int i = 0; i < argc; i++) if (values[i] && *values[i]) - { - TRecordset_column_info& info = (TRecordset_column_info&)_column[i]; - if (info._type == _alfafld || info._type == _realfld) - { - const int len = strlen(values[i]); - if (len > info._width) - { - info._width = len; - if (info._type == _alfafld) - { - if (len == 8 && atol(values[i]) > 19000000) - { - info._type = _datefld; - info._width = 10; - } else - if (real::is_real(values[i])) - info._type = _realfld; - } - } - } - } - } + //if (_items < _pagesize) + //{ + // // Aggiusta le lunghezze dei campi testo e numerici + // for (int i = 0; i < argc; i++) if (values[i] && *values[i]) + // { + // TRecordset_column_info& info = (TRecordset_column_info&)_column[i]; + // if (info._type == _alfafld || info._type == _realfld) + // { + // const int len = strlen(values[i]); + // if (len > info._width) + // { + // info._width = len; + // if (info._type == _alfafld) + // { + // if (len == 8 && atol(values[i]) > 19000000) + // { + // info._type = _datefld; + // info._width = 10; + // } else + // if (real::is_real(values[i])) + // info._type = _realfld; + // } + // } + // } + // } + //} _items++; return SQLITE_OK; @@ -502,9 +502,9 @@ TRecnotype TSQL_recordset::items() const { TString sql; parsed_text(sql); 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("PRAGMA show_datatypes=OFF;", NULL, NULL); + //_TheDataBase.exec("PRAGMA show_datatypes=OFF;", NULL, NULL); } return _items; } @@ -634,4 +634,3 @@ TSQL_recordset::TSQL_recordset(const char* sql) { set(sql); } - diff --git a/src/include/strings.h b/src/include/strings.h index 8c242d598..ad9953e08 100755 --- a/src/include/strings.h +++ b/src/include/strings.h @@ -671,7 +671,7 @@ public: void add(int n, int pos = -1); // @cmember Aggiunge un reale void add(const real r, int pos = -1); - // @cmember Aggiunge un reale + // @cmember Aggiunge una data void add(const TDate d, int pos = -1); // @cmember Aggiunge un booleano void add(bool on, int pos = -1) { add(on ? "X" : ""); }