MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / queryUnsafe

Method queryUnsafe

Source/Basic/Database.cpp:223–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223DB::Rows DB::queryUnsafe(SQLite::Database* db, String sql, const std::vector<Own<Value>>& args, bool withColumns) {
224 Rows result;
225 SQLite::Statement statement(*db, sql.toString());
226 bindValues(statement, args);
227 bool columnCollected = false;
228 while (statement.executeStep()) {
229 int colCount = statement.getColumnCount();
230 if (!columnCollected && withColumns) {
231 columnCollected = true;
232 auto& values = result.emplace_back(colCount);
233 for (int i = 0; i < colCount; i++) {
234 values[i] = std::string(statement.getColumn(i).getName());
235 }
236 }
237 auto& values = result.emplace_back(colCount);
238 for (int i = 0; i < colCount; i++) {
239 auto col = statement.getColumn(i);
240 if (col.isInteger()) {
241 values[i] = col.getInt64();
242 } else if (col.isFloat()) {
243 values[i] = col.getDouble();
244 } else if (col.isText() || col.isBlob()) {
245 values[i] = std::string(col.getText());
246 } else if (col.isNull()) {
247 values[i] = false;
248 }
249 }
250 }
251 return result;
252}
253
254void DB::insertUnsafe(SQLite::Database* db, String tableName, const std::deque<std::vector<Own<Value>>>& rows) {
255 if (rows.empty() || rows.front().empty()) return;

Callers 1

queryAsyncMethod · 0.80

Calls 11

bindValuesFunction · 0.85
stringFunction · 0.85
getColumnMethod · 0.80
getInt64Method · 0.80
getDoubleMethod · 0.80
toStringMethod · 0.65
getNameMethod · 0.65
isIntegerMethod · 0.65
executeStepMethod · 0.45
emplace_backMethod · 0.45
getTextMethod · 0.45

Tested by

no test coverage detected