From 4bfef308a48cdce20c240998ac38ff9c8c21b823 Mon Sep 17 00:00:00 2001 From: ketmar Date: Mon, 18 Oct 2021 05:09:53 +0000 Subject: [PATCH] sq3: added `blob_()` to row FossilOrigin-Name: 7a6bf06d6e35d2ea63964db60ee5c59af160d3cb2160e32f63cff6481296578e --- sq3.d | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sq3.d b/sq3.d index fcc544e..6442b06 100644 --- a/sq3.d +++ b/sq3.d @@ -713,6 +713,14 @@ private: } T to(T) (const(char)[] name) { return this.to!T(fieldIndex____(name)); } + const(ubyte)[] blob_ (const(char)[] name) { + immutable int idx = fieldIndex____(name); + auto len = sqlite3_column_bytes(data____.st, idx); + if (len < 0) throw new SQLiteException("invalid result"); + const(ubyte)* res = cast(const(ubyte)*)sqlite3_column_blob(data____.st, idx); + return res[0..len]; + } + template opIndex() { T opIndexImpl(T) (uint idx) if ((isNarrowString!T && is(ElementEncodingType!T : char)) || isIntegral!T || is(T : DBFieldIndex) || is(T : DBFieldType)) { return this.to!T(idx); } T opIndexImpl(T) (const(char)[] name) if ((isNarrowString!T && is(ElementEncodingType!T : char)) || isIntegral!T || is(T : DBFieldIndex) || is(T : DBFieldType)) { return this.to!T(name); } -- 2.11.4.GIT