@sqg/sqg 0.17.2 → 0.17.3

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.
package/dist/sqg.mjs CHANGED
@@ -3418,7 +3418,7 @@ async function processProject(projectPath, ui) {
3418
3418
  //#region src/mcp-server.ts
3419
3419
  const server = new Server({
3420
3420
  name: "sqg-mcp",
3421
- version: process.env.npm_package_version ?? "0.17.2"
3421
+ version: process.env.npm_package_version ?? "0.17.3"
3422
3422
  }, { capabilities: {
3423
3423
  tools: {},
3424
3424
  resources: {}
@@ -3883,7 +3883,7 @@ function formatMs(ms) {
3883
3883
  }
3884
3884
  //#endregion
3885
3885
  //#region src/sqg.ts
3886
- const version = process.env.npm_package_version ?? "0.17.2";
3886
+ const version = process.env.npm_package_version ?? "0.17.3";
3887
3887
  updateNotifier({ pkg: {
3888
3888
  name: "@sqg/sqg",
3889
3889
  version
@@ -46,6 +46,12 @@ public class {{className}} {
46
46
  this.connection = connection;
47
47
  }
48
48
 
49
+ /** Options for streaming queries. fetchSize hints at the JDBC driver's batch size; 0 means driver default. */
50
+ public record StreamOptions(int fetchSize) {
51
+ public static final StreamOptions DEFAULT = new StreamOptions({{#if (isPostgres)}}1000{{else}}0{{/if}});
52
+ public StreamOptions withFetchSize(int fetchSize) { return new StreamOptions(fetchSize); }
53
+ }
54
+
49
55
  private static Object[] getObjectArray(Array array) {
50
56
  if (array == null) {
51
57
  return null;
@@ -258,7 +264,16 @@ public class {{className}} {
258
264
  {{/if}}
259
265
  {{#if isQuery}}{{#unless isOne}}
260
266
  public Stream<{{rowType}}> {{functionName}}Stream({{#each variables}}{{{type}}} {{name}}{{#unless @last}}, {{/unless}}{{/each}}) throws SQLException {
267
+ return {{functionName}}Stream({{#each variables}}{{name}}, {{/each}}StreamOptions.DEFAULT);
268
+ }
269
+
270
+ public Stream<{{rowType}}> {{functionName}}Stream({{#each variables}}{{{type}}} {{name}}, {{/each}}StreamOptions options) throws SQLException {
271
+ {{#if (isPostgres)}}
272
+ boolean wasAutoCommit = connection.getAutoCommit();
273
+ if (wasAutoCommit) connection.setAutoCommit(false);
274
+ {{/if}}
261
275
  var stmt = connection.prepareStatement({{{partsToString sqlQueryParts}}});
276
+ if (options.fetchSize() > 0) stmt.setFetchSize(options.fetchSize());
262
277
  {{#each parameters}}{{#if isArray}}stmt.setArray({{plusOne @index}}, connection.createArrayOf("{{arrayBaseType}}", {{name}}.toArray()));
263
278
  {{else if isEnum}}stmt.setObject({{plusOne @index}}, {{name}}.getValue());
264
279
  {{else}}{{{jdbcSet type (plusOne @index) name}}}
@@ -283,7 +298,13 @@ public class {{className}} {
283
298
  return StreamSupport.stream(
284
299
  Spliterators.spliteratorUnknownSize(iter, Spliterator.ORDERED), false
285
300
  ).onClose(() -> {
286
- try { rs.close(); stmt.close(); }
301
+ try {
302
+ rs.close();
303
+ stmt.close();
304
+ {{#if (isPostgres)}}
305
+ if (wasAutoCommit) connection.setAutoCommit(true);
306
+ {{/if}}
307
+ }
287
308
  catch (SQLException e) { throw new RuntimeException(e); }
288
309
  });
289
310
  }
@@ -13228,31 +13228,28 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13228
13228
  parse: wsParse,
13229
13229
  serialize: wsSerialize
13230
13230
  };
13231
- const wss = {
13232
- scheme: "wss",
13233
- domainHost: ws.domainHost,
13234
- parse: ws.parse,
13235
- serialize: ws.serialize
13236
- };
13237
- const urn = {
13238
- scheme: "urn",
13239
- parse: urnParse,
13240
- serialize: urnSerialize,
13241
- skipNormalize: true
13242
- };
13243
- const urnuuid = {
13244
- scheme: "urn:uuid",
13245
- parse: urnuuidParse,
13246
- serialize: urnuuidSerialize,
13247
- skipNormalize: true
13248
- };
13249
13231
  const SCHEMES = {
13250
13232
  http,
13251
13233
  https,
13252
13234
  ws,
13253
- wss,
13254
- urn,
13255
- "urn:uuid": urnuuid
13235
+ wss: {
13236
+ scheme: "wss",
13237
+ domainHost: ws.domainHost,
13238
+ parse: ws.parse,
13239
+ serialize: ws.serialize
13240
+ },
13241
+ urn: {
13242
+ scheme: "urn",
13243
+ parse: urnParse,
13244
+ serialize: urnSerialize,
13245
+ skipNormalize: true
13246
+ },
13247
+ "urn:uuid": {
13248
+ scheme: "urn:uuid",
13249
+ parse: urnuuidParse,
13250
+ serialize: urnuuidSerialize,
13251
+ skipNormalize: true
13252
+ }
13256
13253
  };
13257
13254
  Object.setPrototypeOf(SCHEMES, null);
13258
13255
  /**
@@ -22274,6 +22271,7 @@ var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
22274
22271
  break;
22275
22272
  case "<":
22276
22273
  case "<=": break;
22274
+ /* istanbul ignore next */
22277
22275
  default: throw new Error(`Unexpected operation: ${comparator.operator}`);
22278
22276
  }
22279
22277
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqg/sqg",
3
- "version": "0.17.2",
3
+ "version": "0.17.3",
4
4
  "description": "SQG - SQL Query Generator - Type-safe code generation from SQL (https://sqg.dev)",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",