Commit 5fb0d1c3 authored by kmontrose's avatar kmontrose

Making it so SqlBuilder templates resolve properly even if no clauses have been added.

parent adf35ffc
......@@ -103,7 +103,7 @@ public void InsertGetUpdate()
}
}
public void SelectClause()
public void BuilderSelectClause()
{
using (var connection = GetOpenConnection())
{
......@@ -132,5 +132,22 @@ public void SelectClause()
}
}
}
public void BuilderTemplateWOComposition()
{
var builder = new SqlBuilder();
var template = builder.AddTemplate("SELECT COUNT(*) FROM Users WHERE Age = @age", new {age = 5});
if (template.RawSql == null) throw new Exception("RawSql null");
if (template.Parameters == null) throw new Exception("Parameters null");
using (var connection = GetOpenConnection())
{
connection.Insert(new User { Age = 5, Name = "Testy McTestington" });
if (connection.Query<int>(template.RawSql, template.Parameters).Single() != 1)
throw new Exception("Query failed");
}
}
}
}
......@@ -476,7 +476,7 @@ public class Template
readonly string sql;
readonly SqlBuilder builder;
readonly object initParams;
int dataSeq;
int dataSeq = -1; // Unresolved
public Template(SqlBuilder builder, string sql, dynamic parameters)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment