@514labs/moose-lib 0.6.435 → 0.6.436

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,11 +62,18 @@ var init_sqlHelpers = __esm({
62
62
  isView = (value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "View";
63
63
  isColumn = (value) => typeof value === "object" && value !== null && !("kind" in value) && "name" in value && "annotations" in value;
64
64
  sql = sqlImpl;
65
+ sql.statement = function(strings, ...values) {
66
+ return new Sql(strings, values, false);
67
+ };
68
+ sql.fragment = function(strings, ...values) {
69
+ return new Sql(strings, values, true);
70
+ };
65
71
  instanceofSql = (value) => typeof value === "object" && "values" in value && "strings" in value;
66
72
  Sql = class _Sql {
67
73
  values;
68
74
  strings;
69
- constructor(rawStrings, rawValues) {
75
+ isFragment;
76
+ constructor(rawStrings, rawValues, isFragment) {
70
77
  if (rawStrings.length - 1 !== rawValues.length) {
71
78
  if (rawStrings.length === 0) {
72
79
  throw new TypeError("Expected at least 1 string");
@@ -81,6 +88,7 @@ var init_sqlHelpers = __esm({
81
88
  );
82
89
  this.values = new Array(valuesLength);
83
90
  this.strings = new Array(valuesLength + 1);
91
+ this.isFragment = isFragment;
84
92
  this.strings[0] = rawStrings[0];
85
93
  let i = 0, pos = 0;
86
94
  while (i < rawValues.length) {
@@ -127,19 +135,26 @@ var init_sqlHelpers = __esm({
127
135
  * Append another Sql fragment, returning a new Sql instance.
128
136
  */
129
137
  append(other) {
130
- return new _Sql([...this.strings, ""], [...this.values, other]);
138
+ return new _Sql(
139
+ [...this.strings, ""],
140
+ [...this.values, other],
141
+ this.isFragment
142
+ );
131
143
  }
132
144
  };
133
145
  sql.join = function(fragments, separator) {
134
- if (fragments.length === 0) return new Sql([""], []);
135
- if (fragments.length === 1) return fragments[0];
146
+ if (fragments.length === 0) return new Sql([""], [], true);
147
+ if (fragments.length === 1) {
148
+ const frag = fragments[0];
149
+ return new Sql(frag.strings, frag.values, true);
150
+ }
136
151
  const sep = separator ?? ", ";
137
152
  const normalized = sep.includes(" ") ? sep : ` ${sep} `;
138
153
  const strings = ["", ...Array(fragments.length - 1).fill(normalized), ""];
139
- return new Sql(strings, fragments);
154
+ return new Sql(strings, fragments, true);
140
155
  };
141
156
  sql.raw = function(text) {
142
- return new Sql([text], []);
157
+ return new Sql([text], [], true);
143
158
  };
144
159
  toQuery = (sql3) => {
145
160
  const parameterizedStubs = sql3.values.map(