Skip to content

Commit

Permalink
Fix bug when collection name is sql key worlds (#160)
Browse files Browse the repository at this point in the history
Signed-off-by: junjie.jiang <junjie.jiang@zilliz.com>
  • Loading branch information
junjiejiangjjj authored Jun 6, 2024
1 parent 66e13d3 commit c08feae
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
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 All @@ -75,7 +75,7 @@ CollectionData::Insert(SQLite::Database* db,
const std::string& milvus_id,
const std::string& data) {
std::string insert_sql = string_util::SFormat(
"INSERT INTO {} VALUES (NULL, ?, ?)", collection_name_);
"INSERT INTO \"{}\" VALUES (NULL, ?, ?)", collection_name_);
try {
SQLite::Statement query(*db, insert_sql);
SQLite::bind(query, milvus_id, data);
Expand All @@ -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 Down Expand Up @@ -121,7 +121,7 @@ CollectionData::Delete(SQLite::Database* db,
}

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/unittest/run_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

def run_all(py_path):
for f in py_path.glob('*.py'):
if str(f).endswith('bfloat16_example.py') or str(f).endswith('dynamic_field.py'):
if str(f).endswith('bfloat16_example.py') or str(f).endswith('dynamic_field.py') or str(f).endswith('conftest.py'):
continue
print(str(f))
p = subprocess.Popen(args=[sys.executable, str(f)])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class TestDefaultSearch(unittest.TestCase):
def test_delete_by_ids(self):
dim = 2
collection_name = 'hello_milvus'
collection_name = 'default'
milvus_client = MilvusClient('./local_test.db')
has_collection = milvus_client.has_collection(collection_name, timeout=5)
if has_collection:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class TestQuery(unittest.TestCase):
def setUp(self):
self.dim = 2
self.collection_name = 'hello_milvus'
self.collection_name = 'default'
self.milvus_client = MilvusClient('./local_test.db')
has_collection = self.milvus_client.has_collection(self.collection_name, timeout=5)
if has_collection:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class TestDefaultSearch(unittest.TestCase):
def setUp(self):
self.dim = 2
self.collection_name = 'hello_milvus'
self.collection_name = 'default'
self.milvus_client = MilvusClient('./local_test.db')
has_collection = self.milvus_client.has_collection(self.collection_name, timeout=5)
if has_collection:
Expand Down

0 comments on commit c08feae

Please sign in to comment.