@@ -48,10 +48,11 @@
Loading
48 48
private struct CTStatement(SQL_CMD...)
49 49
{
50 50
    QueryParams qp;
51 +
    alias qp this;
51 52
52 -
    this(SQL_CMD sqlCmd, Connection conn)
53 +
    this(Connection conn, SQL_CMD sqlCmd)
53 54
    {
54 -
        qp = parseSqlCmd!SQL_CMD(sqlCmd, conn);
55 +
        qp = parseSqlCmd!SQL_CMD(conn, sqlCmd);
55 56
    }
56 57
}
57 58
@@ -89,8 +90,10 @@
Loading
89 90
{
90 91
91 92
    if(
92 -
        val.length && val[0].symbolNeedsDelimit &&
93 -
        appender.data.length && appender.data[$-1].symbolNeedsDelimit
93 +
        val.length &&
94 +
        appender.data.length &&
95 +
        val[0].symbolNeedsDelimit &&
96 +
        appender.data[$-1].symbolNeedsDelimit
94 97
    )
95 98
        appender ~= ' ';
96 99
@@ -105,7 +108,7 @@
Loading
105 108
        return '"'~s~'"';
106 109
}
107 110
108 -
private QueryParams parseSqlCmd(SQL_CMD...)(SQL_CMD sqlCmd, Connection conn)
111 +
private QueryParams parseSqlCmd(SQL_CMD...)(Connection conn, SQL_CMD sqlCmd)
109 112
{
110 113
    QueryParams qp;
111 114
    auto resultSql = appender!string;
@@ -116,14 +119,14 @@
Loading
116 119
        static if(isStatementArg!(typeof(V)))
117 120
        {
118 121
            // previous argument already was processed?
119 -
            static if(isStatementArg!(typeof(sqlCmd[i-1])))
122 +
            static if(i > 0 && isStatementArg!(typeof(sqlCmd[i-1])))
120 123
            {
121 124
                resultSql ~= `,`;
122 125
            }
123 126
124 127
            static if(isInstanceOf!(DollarArg, typeof(V)))
125 128
            {
126 -
                resultSql ~= `$`;
129 +
                resultSql.concatWithDelimiter(`$`);
127 130
                resultSql ~= (qp.args.length + 1).to!string;
128 131
            }
129 132
            else static if(V.argLikeIn == ArgLikeIn.UPDATE)
@@ -163,8 +166,17 @@
Loading
163 166
164 167
struct Dollars {}
165 168
166 -
auto wrapStatement(T...)(T statement, Connection conn = null) {
167 -
    return CTStatement!T(statement, conn);
169 +
///
170 +
auto wrapStatement(T...)(Connection conn, T statement)
171 +
{
172 +
    return CTStatement!T(conn, statement);
173 +
}
174 +
175 +
///
176 +
auto wrapStatement(T...)(T statement)
177 +
if(!is(T[0] == Connection))
178 +
{
179 +
    return CTStatement!T(null, statement);
168 180
}
169 181
170 182
unittest
@@ -224,3 +236,14 @@
Loading
224 236
    assert(stmnt.qp.args[1] == `abc`.toValue);
225 237
    assert(stmnt.qp.args[2] == 456.toValue);
226 238
}
239 +
240 +
version(integration_tests)
241 +
void _integration_test(string connParam)
242 +
{
243 +
    auto conn = new Connection(connParam);
244 +
    auto stmnt = wrapStatement(conn, i!"Some Integer"(123));
245 +
246 +
    assert(stmnt.qp.sqlCommand == `"Some Integer"`);
247 +
    assert(stmnt.qp.args.length == 1);
248 +
    assert(stmnt.qp.args[0] == 123.toValue);
249 +
}

@@ -5,6 +5,7 @@
Loading
5 5
import dpq2;
6 6
import conn = dpq2.connection: _integration_test;
7 7
import query = dpq2.query: _integration_test;
8 +
import query_gen = dpq2.query_gen: _integration_test;
8 9
import result = dpq2.result: _integration_test;
9 10
import native = dpq2.conv.native_tests: _integration_test;
10 11
import bson = dpq2.conv.to_bson: _integration_test;
@@ -16,6 +17,7 @@
Loading
16 17
17 18
    conn._integration_test( conninfo );
18 19
    query._integration_test( conninfo );
20 +
    query_gen._integration_test( conninfo );
19 21
    result._integration_test( conninfo );
20 22
    native._integration_test( conninfo );
21 23
    bson._integration_test( conninfo );
Files Coverage
src/dpq2 56.09%
integration_tests/integration_tests.d 0.00%
Project Totals (20 files) 55.81%
1201.17
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading