internal C4Query *CompileSelect(string queryString)
 {
     WriteLine($"Query = {queryString}");
     Native.c4query_free(_query);
     _query = (C4Query *)LiteCoreBridge.Check(err => Native.c4query_new(Db, queryString, err));
     return(_query);
 }
 internal C4Query *CompileSelect(string queryString)
 {
     WriteLine($"Query = {queryString}");
     Native.c4query_release(_query);
     _query = (C4Query *)LiteCoreBridge.Check(err => Native.c4query_new2(Db, C4QueryLanguage.JSONQuery, queryString, null, err));
     return(_query);
 }
Пример #3
0
        private unsafe Dictionary <string, int> CreateColumnNames(C4Query *query)
        {
            var fromImpl = FromImpl;

            Debug.Assert(fromImpl != null, "CreateColumnNames reached without a FROM clause received");

            var map = new Dictionary <string, int>();

            var columnCnt = Native.c4query_columnCount(query);

            for (int i = 0; i < columnCnt; i++)
            {
                var titleStr = Native.c4query_columnTitle(query, (uint)i).CreateString();

                if (titleStr.StartsWith("*"))
                {
                    titleStr = fromImpl.ColumnName;
                }

                if (map.ContainsKey(titleStr))
                {
                    throw new CouchbaseLiteException(C4ErrorCode.InvalidQuery,
                                                     String.Format(CouchbaseLiteErrorMessage.DuplicateSelectResultName, titleStr));
                }

                map.Add(titleStr, i);
            }

            return(map);
        }
 public static string c4query_fullTextMatched(C4Query *query, string docID, ulong seq, C4Error *outError)
 {
     using (var docID_ = new C4String(docID)) {
         using (var retVal = NativeRaw.c4query_fullTextMatched(query, docID_.AsC4Slice(), seq, outError)) {
             return(((C4Slice)retVal).CreateString());
         }
     }
 }
 private unsafe void CreateQuery(string queryStr)
 {
     _query     = (C4Query *)LiteCoreBridge.Check(err => Native.c4query_new(_db.c4db, queryStr, err));
     _queryEnum = (C4QueryEnumerator *)LiteCoreBridge.Check(err =>
     {
         var opts = C4QueryOptions.Default;
         return(Native.c4query_run(_query, &opts, null, err));
     });
 }
Пример #6
0
        public static C4QueryEnumerator *c4query_run(C4Query *query,
                                                     C4QueryOptions *options,
                                                     byte[] encodedParams,
                                                     C4Error *outError)
        {
            fixed(byte *b = encodedParams)
            {
                var length = encodedParams == null ? 0UL : (ulong)encodedParams.Length;

                return(NativeRaw.c4query_run(query, options, new C4Slice(b, length), outError));
            }
        }
Пример #7
0
        internal C4Query *Compile(string whereExpr, string sortExpr = null)
        {
            string queryString = whereExpr;

            if (sortExpr != null)
            {
                queryString = $"[\"SELECT\", {{\"WHERE\": {whereExpr}, \"ORDER_BY\": {sortExpr}}}]";
            }

            Native.c4query_free(_query);
            _query = (C4Query *)LiteCoreBridge.Check(err => Native.c4query_new(Db, queryString, err));
            return(_query);
        }
Пример #8
0
 private void QueryObserverCalled(C4QueryObserver *obs, C4Query *query)
 {
     WriteLine("---- Query observer called!");
     if ((long)obs == (long)_queryObserver)
     {
         _queryCallbackCalls++;
     }
     else if ((long)obs == (long)_queryObserver2)
     {
         _queryCallbackCalls2++;
     }
     else if ((long)obs == (long)_queryObserver3)
     {
         _queryCallbackCalls3++;
     }
 }
Пример #9
0
        private unsafe Dictionary <string, int> CreateColumnNames(C4Query *query)
        {
            var map       = new Dictionary <string, int>();
            var columnCnt = Native.c4query_columnCount(query);

            for (int i = 0; i < columnCnt; i++)
            {
                var titleStr = Native.c4query_columnTitle(query, (uint)i).CreateString();
                if (map.ContainsKey(titleStr))
                {
                    throw new CouchbaseLiteException(C4ErrorCode.InvalidQuery,
                                                     String.Format(CouchbaseLiteErrorMessage.DuplicateSelectResultName, titleStr));
                }

                map.Add(titleStr, i);
            }

            return(map);
        }
Пример #10
0
 public static extern C4QueryObserver *c4queryobs_create(C4Query *query, C4QueryObserverCallback callback, void *context);
Пример #11
0
        private static void QueryObserverCallback(C4QueryObserver *obs, C4Query *query, void *context)
        {
            var obj = GCHandle.FromIntPtr((IntPtr)context).Target as QueryTest;

            obj.QueryObserverCalled(obs, query);
        }
Пример #12
0
 public static C4QueryEnumerator *c4query_run(C4Query *query, C4QueryOptions *options, string encodedParameters, C4Error *outError)
 {
     using (var encodedParameters_ = new C4String(encodedParameters)) {
         return(NativeRaw.c4query_run(query, options, encodedParameters_.AsFLSlice(), outError));
     }
 }
Пример #13
0
 public static void c4query_release(C4Query *query) => c4base_release(query);
Пример #14
0
 public static extern uint c4query_columnCount(C4Query *query);
Пример #15
0
 public static extern FLSlice c4query_columnTitle(C4Query *query, uint column);
 public uint c4query_columnCount(C4Query *query) => Native.c4query_columnCount(query);
Пример #17
0
 public static string c4query_explain(C4Query *query)
 {
     using (var retVal = NativeRaw.c4query_explain(query)) {
         return(((FLSlice)retVal).CreateString());
     }
 }
 public void c4query_free(C4Query *x) => Native.c4query_free(x);
 public string c4query_fullTextMatched(C4Query *query, C4FullTextMatch *term, C4Error *outError) => Native.c4query_fullTextMatched(query, term, outError);
 protected override void TeardownVariant(int option)
 {
     Native.c4query_free(_query);
     _query = null;
     base.TeardownVariant(option);
 }
 public static extern C4SliceResult c4query_fullTextMatched(C4Query *query, C4Slice docID, ulong seq, C4Error *outError);
 public C4SliceResult c4query_fullTextMatched(C4Query *query, C4FullTextMatch *term, C4Error *outError) => NativeRaw.c4query_fullTextMatched(query, term, outError);
 public C4QueryEnumerator *c4query_run(C4Query *query, C4QueryOptions *options, C4Slice encodedParameters, C4Error *outError) => NativeRaw.c4query_run(query, options, encodedParameters, outError);
 public C4SliceResult c4query_explain(C4Query *query) => NativeRaw.c4query_explain(query);
Пример #25
0
 public static extern FLSliceResult c4query_explain(C4Query *query);
 public string c4query_explain(C4Query *query) => Native.c4query_explain(query);
Пример #27
0
 public static extern void c4query_free(C4Query *query);
 public static extern C4SliceResult c4query_fullTextMatched(C4Query *query, C4FullTextMatch *term, C4Error *outError);
Пример #29
0
 public static extern C4QueryEnumerator *c4query_run(C4Query *query,
                                                     C4QueryOptions *options,
                                                     C4Slice encodedParams,
                                                     C4Error *outError);
 public static string c4query_fullTextMatched(C4Query *query, C4FullTextMatch *term, C4Error *outError)
 {
     using (var retVal = NativeRaw.c4query_fullTextMatched(query, term, outError)) {
         return(((C4Slice)retVal).CreateString());
     }
 }