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

PocoDoc: search support #4494

Merged
merged 19 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
2 changes: 1 addition & 1 deletion Data/SQLite/SQLite.progen
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ vc.project.platforms = Win32
vc.project.configurations = debug_shared, release_shared, debug_static_mt, release_static_mt, debug_static_md, release_static_md
vc.project.prototype = ${vc.project.name}_vs90.vcproj
vc.project.compiler.include = ..\\..\\Foundation\\include;..\\..\\Data\\include
vc.project.compiler.defines = SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_FTS3_PARENTHESIS;SQLITE_OMIT_UTF16;SQLITE_OMIT_PROGRESS_CALLBACK;SQLITE_OMIT_COMPLETE;SQLITE_OMIT_TCL_VARIABLE;SQLITE_OMIT_DEPRECATED
vc.project.compiler.defines = SQLITE_THREADSAFE=1;SQLITE_ENABLE_FTS5;SQLITE_OMIT_UTF16;SQLITE_OMIT_PROGRESS_CALLBACK;SQLITE_OMIT_COMPLETE;SQLITE_OMIT_TCL_VARIABLE;SQLITE_OMIT_DEPRECATED
vc.project.compiler.defines.shared = ${vc.project.name}_EXPORTS
vc.project.compiler.defines.debug_shared = ${vc.project.compiler.defines.shared}
vc.project.compiler.defines.release_shared = ${vc.project.compiler.defines.shared}
Expand Down
148 changes: 74 additions & 74 deletions Data/SQLite/SQLite_vs160.vcxproj

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Data/SQLite/SQLite_vs160.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="SQLite">
<UniqueIdentifier>{08f657c8-6a2c-4a05-9cb8-0a24df22511f}</UniqueIdentifier>
<UniqueIdentifier>{100e33ce-9d1d-4aa8-a695-8a142faf8823}</UniqueIdentifier>
</Filter>
<Filter Include="SQLite\Header Files">
<UniqueIdentifier>{137e5445-13e9-4d0e-88ca-b51c2a78b87f}</UniqueIdentifier>
<UniqueIdentifier>{77206dbd-501e-4814-8778-66aec54307c6}</UniqueIdentifier>
</Filter>
<Filter Include="SQLite\Source Files">
<UniqueIdentifier>{5ca955a1-b2cf-4690-aab9-5e8d1ab6b763}</UniqueIdentifier>
<UniqueIdentifier>{5fcf0bdd-b676-4729-900c-bc7f1383a543}</UniqueIdentifier>
</Filter>
<Filter Include="3rdparty">
<UniqueIdentifier>{5c4ae9d1-7bd9-4987-8827-56c88c89d82d}</UniqueIdentifier>
<UniqueIdentifier>{85efd7ee-ee09-40d2-acd1-3a29ed7439f6}</UniqueIdentifier>
</Filter>
<Filter Include="3rdparty\Header Files">
<UniqueIdentifier>{62d12f40-dd7c-4f3d-b128-b1a896b55544}</UniqueIdentifier>
<UniqueIdentifier>{b862c44f-e276-42f3-b078-837cf482a0c1}</UniqueIdentifier>
</Filter>
<Filter Include="3rdparty\Source Files">
<UniqueIdentifier>{34619493-0c10-4820-a64c-1a7b24284750}</UniqueIdentifier>
<UniqueIdentifier>{9d999f10-40c8-408d-bc98-354804d153eb}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
Expand Down
166 changes: 83 additions & 83 deletions Data/SQLite/SQLite_vs170.vcxproj

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Data/SQLite/SQLite_vs170.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="SQLite">
<UniqueIdentifier>{c43e4fe6-e999-4710-abf9-c3ac71054bdf}</UniqueIdentifier>
<UniqueIdentifier>{ae0dae38-b1e2-4c25-8986-ffb7a71d63d2}</UniqueIdentifier>
</Filter>
<Filter Include="SQLite\Header Files">
<UniqueIdentifier>{256a7282-f781-469b-82ef-898c04defe77}</UniqueIdentifier>
<UniqueIdentifier>{967a7f18-16d5-4138-963c-14f5581c1d06}</UniqueIdentifier>
</Filter>
<Filter Include="SQLite\Source Files">
<UniqueIdentifier>{1dec9834-f18c-4dfe-8e14-d35b73b83636}</UniqueIdentifier>
<UniqueIdentifier>{750e3590-154f-43ef-922f-fb208184f6cb}</UniqueIdentifier>
</Filter>
<Filter Include="3rdparty">
<UniqueIdentifier>{3a52346c-b114-4989-9c9d-55627fabbe24}</UniqueIdentifier>
<UniqueIdentifier>{b491a2c6-9895-4ba1-b059-50b156e55b0e}</UniqueIdentifier>
</Filter>
<Filter Include="3rdparty\Header Files">
<UniqueIdentifier>{faae9992-6c0f-4ac6-9af2-2e3a2bb39def}</UniqueIdentifier>
<UniqueIdentifier>{518b3aba-5a41-47bc-b125-23bc694773a9}</UniqueIdentifier>
</Filter>
<Filter Include="3rdparty\Source Files">
<UniqueIdentifier>{e9f5da58-ed7a-4e9d-8731-751b30b0f2a8}</UniqueIdentifier>
<UniqueIdentifier>{930ce918-f656-4d48-ab21-addd59889448}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
Expand Down
68 changes: 38 additions & 30 deletions Data/SQLite/testsuite/src/SQLiteTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3588,48 +3588,56 @@ void SQLiteTest::testTransactor()
}


void SQLiteTest::testFTS3()
void SQLiteTest::testFTS()
{
#ifdef SQLITE_ENABLE_FTS3
#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS5)
Session session(Poco::Data::SQLite::Connector::KEY, "dummy.db");
assertTrue (session.isConnected());
assertTrue(session.isConnected());

session << "DROP TABLE IF EXISTS docs", now;

#if defined(SQLITE_ENABLE_FTS5)
session << "CREATE VIRTUAL TABLE docs USING fts5(content)", now;
const std::string idColumn = "rowid";
#elif defined(SQLITE_ENABLE_FTS3)
session << "CREATE VIRTUAL TABLE docs USING fts3()", now;
const std::string idColumn = "docid";
#endif

session << "INSERT INTO docs(docid, content) VALUES(1, 'a database is a software system')", now;
session << "INSERT INTO docs(docid, content) VALUES(2, 'sqlite is a software system')", now;
session << "INSERT INTO docs(docid, content) VALUES(3, 'sqlite is a database')", now;
session << "INSERT INTO docs(" << idColumn << ", content) VALUES(1, 'a database is a software system')", now;
session << "INSERT INTO docs(" << idColumn << ", content) VALUES(2, 'sqlite is a software system')", now;
session << "INSERT INTO docs(" << idColumn << ", content) VALUES(3, 'sqlite is a database')", now;

int docid = 0;
session << "SELECT docid FROM docs WHERE docs MATCH 'sqlite AND database'", into(docid), now;
assertTrue (docid == 3);
int id = 0;
session << "SELECT " << idColumn << " FROM docs WHERE docs MATCH 'sqlite AND database'", into(id), now;
assertTrue(id == 3);

docid = 0;
session << "SELECT docid FROM docs WHERE docs MATCH 'database sqlite'", into(docid), now;
assertTrue (docid == 3);
id = 0;
session << "SELECT " << idColumn << " FROM docs WHERE docs MATCH 'database sqlite'", into(id), now;
assertTrue(id == 3);

std::vector<int> docids;
session << "SELECT docid FROM docs WHERE docs MATCH 'sqlite OR database' ORDER BY docid",
into(docids), now;
assertTrue (docids.size() == 3);
assertTrue (docids[0] == 1);
assertTrue (docids[1] == 2);
assertTrue (docids[2] == 3);
std::vector<int> ids;
session << "SELECT " << idColumn << " FROM docs WHERE docs MATCH 'sqlite OR database' ORDER BY " << idColumn,
into(ids), now;
assertTrue(ids.size() == 3);
assertTrue(ids[0] == 1);
assertTrue(ids[1] == 2);
assertTrue(ids[2] == 3);

std::string content;
docid = 0;
session << "SELECT docid, content FROM docs WHERE docs MATCH 'database NOT sqlite'",
into(docid), into(content), now;
assertTrue (docid == 1);
assertTrue (content == "a database is a software system");

docid = 0;
session << "SELECT count(*) FROM docs WHERE docs MATCH 'database and sqlite'", into(docid), now;
assertTrue (docid == 0);
id = 0;
session << "SELECT " << idColumn << ", content FROM docs WHERE docs MATCH 'database NOT sqlite'",
into(id), into(content), now;
assertTrue(id == 1);
assertTrue(content == "a database is a software system");

id = 0;
session << "SELECT count(*) FROM docs WHERE docs MATCH 'database and sqlite'", into(id), now;
assertTrue(id == 0);

#else
std::cout << "SQLite FTS not enabled, test not executed." << std::endl;
#endif // SQLITE_ENABLE_FTS3
#endif
}


Expand Down Expand Up @@ -3856,7 +3864,7 @@ CppUnit::Test* SQLiteTest::suite()
CppUnit_addTest(pSuite, SQLiteTest, testSessionTransactionRepeatableRead);
CppUnit_addTest(pSuite, SQLiteTest, testTransaction);
CppUnit_addTest(pSuite, SQLiteTest, testTransactor);
CppUnit_addTest(pSuite, SQLiteTest, testFTS3);
CppUnit_addTest(pSuite, SQLiteTest, testFTS);
CppUnit_addTest(pSuite, SQLiteTest, testIllegalFilePath);
CppUnit_addTest(pSuite, SQLiteTest, testTransactionTypeProperty);
CppUnit_addTest(pSuite, SQLiteTest, testRecordsetCopyMove);
Expand Down
2 changes: 1 addition & 1 deletion Data/SQLite/testsuite/src/SQLiteTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class SQLiteTest: public CppUnit::TestCase
void testTransaction();
void testTransactor();

void testFTS3();
void testFTS();

void testIllegalFilePath();
void testTransactionTypeProperty();
Expand Down
6 changes: 5 additions & 1 deletion PocoDoc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ objects = DocWriter PocoDoc

target = PocoDoc
target_version = 1
target_libs = PocoCppParser PocoFoundation PocoXML PocoUtil
target_libs = PocoCppParser PocoDataSQLite PocoData PocoFoundation PocoXML PocoUtil
matejk marked this conversation as resolved.
Show resolved Hide resolved

ifdef POCO_ENABLE_SQLITE_FTS5
matejk marked this conversation as resolved.
Show resolved Hide resolved
CXXFLAGS += -DPOCO_ENABLE_SQLITE_FTS5
matejk marked this conversation as resolved.
Show resolved Hide resolved
endif

include $(POCO_BASE)/build/rules/exec
2 changes: 1 addition & 1 deletion PocoDoc/PocoDoc_vs160.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<_ProjectFileVersion>17.0.34714.143</_ProjectFileVersion>
<_ProjectFileVersion>17.0.35327.3</_ProjectFileVersion>
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_shared|Win32'">PocoDocd</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_md|Win32'">PocoDocd</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='debug_static_mt|Win32'">PocoDocd</TargetName>
Expand Down
12 changes: 6 additions & 6 deletions PocoDoc/PocoDoc_vs160.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="App">
<UniqueIdentifier>{60784c21-9594-42df-b825-d0f44b70df1c}</UniqueIdentifier>
<UniqueIdentifier>{3279ef27-6e23-4360-a636-18ee2a52791b}</UniqueIdentifier>
</Filter>
<Filter Include="App\Header Files">
<UniqueIdentifier>{2a417507-cb80-467d-b536-9153294bfc14}</UniqueIdentifier>
<UniqueIdentifier>{606a0745-3e35-4ed1-9af9-095f83d95076}</UniqueIdentifier>
</Filter>
<Filter Include="App\Source Files">
<UniqueIdentifier>{b343204e-6b48-4460-bada-38c9cfe379c0}</UniqueIdentifier>
<UniqueIdentifier>{cc2cef1e-d6dc-4a9f-8fc6-13b24be514bc}</UniqueIdentifier>
</Filter>
<Filter Include="DocWriter">
<UniqueIdentifier>{572c4d2f-4b19-47ab-9865-e808cb6873e7}</UniqueIdentifier>
<UniqueIdentifier>{f5123ebf-f5e1-4feb-98f4-268edcfebb0e}</UniqueIdentifier>
</Filter>
<Filter Include="DocWriter\Header Files">
<UniqueIdentifier>{07846630-d09f-4420-a819-1485dc758039}</UniqueIdentifier>
<UniqueIdentifier>{bd60ed4a-d71e-4427-9ab5-f79e4aabb4e0}</UniqueIdentifier>
</Filter>
<Filter Include="DocWriter\Source Files">
<UniqueIdentifier>{0979336d-8413-4b57-876f-3093be25d25e}</UniqueIdentifier>
<UniqueIdentifier>{1a6d4661-f349-4799-8bd7-578ab30e3c74}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
Expand Down
Loading
Loading