@polyglot-sql/sdk 0.5.3 → 0.5.5

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/README.md CHANGED
@@ -347,9 +347,9 @@ Walk, search, and transform parsed AST nodes.
347
347
 
348
348
  ```typescript
349
349
  import {
350
- parse, Dialect, walk, transform, findAll, findFirst, findByType,
350
+ parse, Dialect, col, walk, transform, findAll, findFirst, findByType,
351
351
  getColumns, getColumnNames, getTableNames, renameColumns, renameTables,
352
- addWhere, removeWhere, setLimit, setDistinct, qualifyColumns,
352
+ addWhere, removeWhere, setLimit, setOffset, setOrderBy, setDistinct, qualifyColumns,
353
353
  getAggregateFunctions, hasSubqueries, nodeCount,
354
354
  } from '@polyglot-sql/sdk';
355
355
 
@@ -382,6 +382,8 @@ const qualified = qualifyColumns(ast, 'users');
382
382
 
383
383
  // Modify query structure
384
384
  const withLimit = setLimit(ast, 100);
385
+ const withOffset = setOffset(withLimit, 10);
386
+ const ordered = setOrderBy(withOffset, col('a').toJSON());
385
387
  const distinct = setDistinct(ast, true);
386
388
  const noWhere = removeWhere(ast);
387
389
  ```
@@ -612,6 +614,8 @@ projection `typeHint` values. `cteFacts` reports top-level CTE definitions,
612
614
  `starProjections` records original star projections and schema-expanded
613
615
  columns, and each projection includes conservative `nullability`: `'non_null'`,
614
616
  `'nullable'`, or `'unknown'`.
617
+ For physical relation facts, `name` remains the qualified display name while
618
+ `catalog`, `schema`, and `table` expose parsed identifier parts.
615
619
 
616
620
  ```typescript
617
621
  import { analyzeQuery, Dialect } from '@polyglot-sql/sdk';
@@ -639,6 +643,7 @@ if (result.success) {
639
643
  console.log(result.analysis.starProjections[0].expandedColumns); // ['id', 'amount']
640
644
  console.log(result.analysis.projections[0].nullability); // 'non_null'
641
645
  console.log(result.analysis.baseTables[0].name); // 'orders'
646
+ console.log(result.analysis.baseTables[0].table); // 'orders'
642
647
  }
643
648
 
644
649
  const duckdbSummary = analyzeQuery('SELECT 1', Dialect.DuckDB);
@@ -880,6 +885,7 @@ const formattedSafe = pg.formatWithOptions('SELECT a,b FROM t', Dialect.Generic,
880
885
  | `removeSelectColumns(node, predicate)` | Remove columns from SELECT |
881
886
  | `setLimit(node, limit)` | Set LIMIT clause |
882
887
  | `setOffset(node, offset)` | Set OFFSET clause |
888
+ | `setOrderBy(node, orderBy)` | Set ORDER BY clause |
883
889
  | `removeLimitOffset(node)` | Remove LIMIT and OFFSET |
884
890
  | `setDistinct(node, distinct?)` | Set SELECT DISTINCT |
885
891
  | `clone(node)` | Deep clone AST |