Skip to content

Commit 6508969

Browse files
committed
fixed null db bug
1 parent 0854375 commit 6508969

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

sqlite_modern_cpp.h

+12-6
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,29 @@ namespace sqlite {
138138
}
139139
void get_col_from_db(int inx, string& s){
140140
if (sqlite3_column_type(_stmt, inx) == SQLITE_NULL) s = string();
141-
sqlite3_column_bytes(_stmt, inx);
142-
s = string((char*)sqlite3_column_text(_stmt, inx));
141+
else {
142+
sqlite3_column_bytes(_stmt, inx);
143+
s = string((char*)sqlite3_column_text(_stmt, inx));
144+
}
143145
}
144146
void get_col_from_db(int inx, wstring& w){
145147
if (sqlite3_column_type(_stmt, inx) == SQLITE_NULL) w = wstring();
146-
sqlite3_column_bytes16(_stmt, inx);
147-
w = wstring((wchar_t *)sqlite3_column_text16(_stmt, inx));
148+
else {
149+
sqlite3_column_bytes16(_stmt, inx);
150+
w = wstring((wchar_t *)sqlite3_column_text16(_stmt, inx));
151+
}
148152
}
149153
void get_col_from_db(int inx, double& d){
150154
if (sqlite3_column_type(_stmt, inx) == SQLITE_NULL)
151155
d = 0;
152-
d = sqlite3_column_double(_stmt, inx);
156+
else
157+
d = sqlite3_column_double(_stmt, inx);
153158
}
154159
void get_col_from_db(int inx, float& f){
155160
if (sqlite3_column_type(_stmt, inx) == SQLITE_NULL)
156161
f = 0;
157-
f = float(sqlite3_column_double(_stmt, inx));
162+
else
163+
f = float(sqlite3_column_double(_stmt, inx));
158164
}
159165
#pragma endregion
160166

0 commit comments

Comments
 (0)