Пример #1
0
        private static async Task Given_a_logTtable_and_an_ftsTable(IDbConnection connection)
        {
            var tableSql = SQLiteSQLGenerator.Table <FTSContext.Log>();
            await connection.ExecuteAsync(tableSql);

            var ftsTableSql = SQLiteSQLGenerator.FTSTable <FTSContext.Log>(FTSTableType.ExternalContent);
            await connection.ExecuteAsync(ftsTableSql);
        }
Пример #2
0
        public void When_generating_full_text_search_content_less_table_sql()
        {
            Should.Throw <KeyNotFoundException>(() => SQLiteSQLGenerator.FTSTable <SampleModel>(FTSTableType.ContentLess, m => m.Composite))
            .Message.ShouldBe("Could not find a mapping for property: Composite. Ensure it is not marked with an IgnoreAttribute.");

            var ftsTableSql = SQLiteSQLGenerator.FTSTable <SampleModel>(FTSTableType.ContentLess, m => m.Flag, m => m.Text, m => m.Guid);

            ftsTableSql.ShouldNotBeNullOrWhiteSpace();
            ftsTableSql.ShouldBe("CREATE VIRTUAL TABLE IF NOT EXISTS SampleModel_fts USING FTS4 (content=\"\", [Flag], [Text], [Key]);");
        }
Пример #3
0
        public void When_generating_full_text_search_external_content_table_sql()
        {
            Should.Throw <KeyNotFoundException>(() => SQLiteSQLGenerator.FTSTable <SampleModel>(FTSTableType.ExternalContent, m => m.Composite))
            .Message.ShouldBe("Could not find a mapping for property: Composite. Ensure it is not marked with an IgnoreAttribute.");

            var ftsTableSql = SQLiteSQLGenerator.FTSTable <SampleModel>(FTSTableType.ExternalContent, m => m.Flag, m => m.Text, m => m.Guid);

            ftsTableSql.ShouldNotBeNullOrWhiteSpace();
            ftsTableSql.ShouldBe("CREATE VIRTUAL TABLE IF NOT EXISTS SampleModel_fts USING FTS4 (content=\"SampleModel\", [Flag], [Text], [Key]);\r\n\r\n"
                                 + "CREATE TRIGGER IF NOT EXISTS SampleModel_bu BEFORE UPDATE ON SampleModel BEGIN\r\n"
                                 + "    DELETE FROM SampleModel_fts WHERE docId = old.rowId;\r\n"
                                 + "END;\r\n\r\n"
                                 + "CREATE TRIGGER IF NOT EXISTS SampleModel_bd BEFORE DELETE ON SampleModel BEGIN\r\n"
                                 + "    DELETE FROM SampleModel_fts WHERE docId = old.rowId;\r\n"
                                 + "END;\r\n\r\n"
                                 + "CREATE TRIGGER IF NOT EXISTS SampleModel_au AFTER UPDATE ON SampleModel BEGIN\r\n"
                                 + "    INSERT INTO SampleModel_fts (docId, [Flag], [Text], [Key]) VALUES (new.rowId, new.[Flag], new.[Text], new.[Key]);\r\n"
                                 + "END;\r\n\r\n"
                                 + "CREATE TRIGGER IF NOT EXISTS SampleModel_ai AFTER INSERT ON SampleModel BEGIN\r\n"
                                 + "    INSERT INTO SampleModel_fts (docId, [Flag], [Text], [Key]) VALUES (new.rowId, new.[Flag], new.[Text], new.[Key]);\r\n"
                                 + "END;");
        }