Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sqlite sql err #252

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/collection_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool
CollectionData::DropCollection(SQLite::Database* db) {
// DROP TABLE {collection_name_}
std::string drop_sql =
string_util::SFormat("DROP TABLE \"{}\"", collection_name_);
string_util::SFormat("DROP TABLE '{}'", collection_name_);

if (db->tryExec(drop_sql) != 0) {
const char* err = db->getErrorMsg();
Expand Down Expand Up @@ -93,7 +93,7 @@ CollectionData::Load(SQLite::Database* db,
std::vector<std::string>* output_rows) {
// SELECT {col_data_} from {collection_name_} LIMIT {limit} OFFSET {start}
std::string select_sql =
string_util::SFormat("SELECT {} from \"{}\" LIMIT {} OFFSET {}",
string_util::SFormat("SELECT {} from '{}' LIMIT {} OFFSET {}",
col_data_,
collection_name_,
limit,
Expand All @@ -115,13 +115,13 @@ CollectionData::Delete(SQLite::Database* db,
// DELETE FROM {collection_name_} WHERE {col_milvus_id} in ({})
std::stringstream ss;
for (size_t i = 0; i < milvus_ids.size(); i++) {
ss << "\"" << milvus_ids[i] << "\"";
ss << "'" << milvus_ids[i] << "'";
if (i < milvus_ids.size() - 1)
ss << ",";
}

std::string delete_sql =
string_util::SFormat("DELETE FROM \"{}\" WHERE {} IN ({})",
string_util::SFormat("DELETE FROM '{}' WHERE {} IN ({})",
collection_name_,
col_milvus_id_,
ss.str());
Expand All @@ -139,7 +139,7 @@ int64_t
CollectionData::Count(SQLite::Database* db) {
// SELECT count(*) FROM {};
std::string count_sql =
string_util::SFormat("SELECT count(*) FROM \"{}\"", collection_name_);
string_util::SFormat("SELECT count(*) FROM '{}'", collection_name_);
try {
SQLite::Statement query(*db, count_sql);
query.executeStep();
Expand Down
2 changes: 1 addition & 1 deletion src/collection_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ CollectionMeta::CreateIndex(SQLite::Database* db,
// INSERT INTO {table_name} VALUES (NULL, {collection_name}, "schema", {data}, NULL)
collections_[collection_name]->AddIndex(index_name, index_proto.c_str());
std::string insert_cmd = string_util::SFormat(
"INSERT INTO {} VALUES (NULL, \"{}\", \"index\", \"{}\", \"{}\")",
"INSERT INTO {} VALUES (NULL, '{}', 'index', '{}', '{}')",
table_meta_name_,
collection_name,
index_proto,
Expand Down