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

Method exist

Source/Basic/Database.cpp:90–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90bool DB::exist(String tableName, String schema) const {
91 bool existed = false;
92 _thread->runInMainSync([&]() {
93 if (!schema.empty() && !existDBUnsafe(_database.get(), schema)) {
94 return;
95 }
96 try {
97 SQLite::Statement statement(*_database, schema.empty() ? "SELECT EXISTS(SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?)"s : fmt::format("SELECT EXISTS(SELECT 1 FROM {}.sqlite_master WHERE type='table' AND name = ?)", schema.toString()));
98 statement.bind(1, tableName.toString());
99 int result = 0;
100 if (statement.executeStep()) {
101 result = statement.getColumn(0);
102 }
103 existed = result == 0 ? false : true;
104 } catch (std::exception& e) {
105 Warn("failed to execute DB query: {}", e.what());
106 }
107 });
108 return existed;
109}
110
111int DB::exec(String sql) {
112 int rowChanged = -1;

Callers

nothing calls this directly

Calls 10

runInMainSyncMethod · 0.80
getColumnMethod · 0.80
getMethod · 0.65
toStringMethod · 0.65
bindMethod · 0.65
formatFunction · 0.50
WarnFunction · 0.50
emptyMethod · 0.45
executeStepMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected