@514labs/moose-lib 0.6.435 → 0.6.437

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.
@@ -77,11 +77,18 @@ var init_sqlHelpers = __esm({
77
77
  isView = (value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "View";
78
78
  isColumn = (value) => typeof value === "object" && value !== null && !("kind" in value) && "name" in value && "annotations" in value;
79
79
  sql = sqlImpl;
80
+ sql.statement = function(strings, ...values) {
81
+ return new Sql(strings, values, false);
82
+ };
83
+ sql.fragment = function(strings, ...values) {
84
+ return new Sql(strings, values, true);
85
+ };
80
86
  instanceofSql = (value) => typeof value === "object" && "values" in value && "strings" in value;
81
87
  Sql = class _Sql {
82
88
  values;
83
89
  strings;
84
- constructor(rawStrings, rawValues) {
90
+ isFragment;
91
+ constructor(rawStrings, rawValues, isFragment) {
85
92
  if (rawStrings.length - 1 !== rawValues.length) {
86
93
  if (rawStrings.length === 0) {
87
94
  throw new TypeError("Expected at least 1 string");
@@ -96,6 +103,7 @@ var init_sqlHelpers = __esm({
96
103
  );
97
104
  this.values = new Array(valuesLength);
98
105
  this.strings = new Array(valuesLength + 1);
106
+ this.isFragment = isFragment;
99
107
  this.strings[0] = rawStrings[0];
100
108
  let i = 0, pos = 0;
101
109
  while (i < rawValues.length) {
@@ -142,19 +150,26 @@ var init_sqlHelpers = __esm({
142
150
  * Append another Sql fragment, returning a new Sql instance.
143
151
  */
144
152
  append(other) {
145
- return new _Sql([...this.strings, ""], [...this.values, other]);
153
+ return new _Sql(
154
+ [...this.strings, ""],
155
+ [...this.values, other],
156
+ this.isFragment
157
+ );
146
158
  }
147
159
  };
148
160
  sql.join = function(fragments, separator) {
149
- if (fragments.length === 0) return new Sql([""], []);
150
- if (fragments.length === 1) return fragments[0];
161
+ if (fragments.length === 0) return new Sql([""], [], true);
162
+ if (fragments.length === 1) {
163
+ const frag = fragments[0];
164
+ return new Sql(frag.strings, frag.values, true);
165
+ }
151
166
  const sep = separator ?? ", ";
152
167
  const normalized = sep.includes(" ") ? sep : ` ${sep} `;
153
168
  const strings = ["", ...Array(fragments.length - 1).fill(normalized), ""];
154
- return new Sql(strings, fragments);
169
+ return new Sql(strings, fragments, true);
155
170
  };
156
171
  sql.raw = function(text) {
157
- return new Sql([text], []);
172
+ return new Sql([text], [], true);
158
173
  };
159
174
  toQuery = (sql3) => {
160
175
  const parameterizedStubs = sql3.values.map(