Skip to content

Commit 4711ba3

Browse files
cigraingerclaude
andcommitted
test: comprehensive macro tests matching AGENTS.md quality bar
Expand from 20 to 47 tests (44 unit + 3 property-based) covering all required categories: Happy path: scalar, multi-param, string ops, boolean, CASE, table macros, table macro in joins, redefine Sad path: invalid SQL, mismatched params, wrong arity, zero args, invalid table SQL, failed define doesn't leave partial registry Adversarial: no params, 10 params, NULL handling, NULL propagation, macro composition, SQL reserved words as params, single quotes, Unicode, empty strings, 50 simultaneous macros Wicked: 2000-row pipeline with filter+sort, group_by+summarise on 1000 rows, chained macros (double→shift→clamp), table macro feeding into scalar macro pipeline, define/undefine/redefine cycle Property-based: macro arithmetic matches inline SQL, define then list always shows macro, undefine then list never shows macro Distributed: worker replay on single worker, macro_setup_sqls replayable on fresh connection, single-worker distributed matches local result Also fixes: quote macro params with qi() to support SQL reserved words as parameter names. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 71d7efc commit 4711ba3

2 files changed

Lines changed: 400 additions & 37 deletions

File tree

lib/dux.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ defmodule Dux do
856856
"""
857857
def define(name, params, sql_body)
858858
when is_atom(name) and is_list(params) and is_binary(sql_body) do
859-
param_list = Enum.map_join(params, ", ", &to_string/1)
859+
param_list = Enum.map_join(params, ", ", fn p -> qi(to_string(p)) end)
860860
macro_name = to_string(name)
861861

862862
create_sql =
@@ -890,7 +890,7 @@ defmodule Dux do
890890
"""
891891
def define_table(name, params, sql_body)
892892
when is_atom(name) and is_list(params) and is_binary(sql_body) do
893-
param_list = Enum.map_join(params, ", ", &to_string/1)
893+
param_list = Enum.map_join(params, ", ", fn p -> qi(to_string(p)) end)
894894
macro_name = to_string(name)
895895

896896
create_sql =

0 commit comments

Comments
 (0)