@nshiab/simple-data-analysis-core 2.0.5 → 2.0.6

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.
Files changed (238) hide show
  1. package/README.md +118 -12
  2. package/esm/class/Simple.d.ts +8 -2
  3. package/esm/class/Simple.d.ts.map +1 -1
  4. package/esm/class/Simple.js +9 -3
  5. package/esm/class/SimpleDB.d.ts +72 -1
  6. package/esm/class/SimpleDB.d.ts.map +1 -1
  7. package/esm/class/SimpleDB.js +81 -1
  8. package/esm/class/SimpleTable.d.ts +251 -274
  9. package/esm/class/SimpleTable.d.ts.map +1 -1
  10. package/esm/class/SimpleTable.js +248 -325
  11. package/esm/helpers/LogValue.d.ts +8 -0
  12. package/esm/helpers/LogValue.d.ts.map +1 -0
  13. package/esm/helpers/LogValue.js +23 -0
  14. package/esm/helpers/cacheTableDependencies.d.ts +9 -0
  15. package/esm/helpers/cacheTableDependencies.d.ts.map +1 -1
  16. package/esm/helpers/cacheTableDependencies.js +131 -21
  17. package/esm/helpers/cleanSQL.d.ts +1 -1
  18. package/esm/helpers/cleanSQL.d.ts.map +1 -1
  19. package/esm/helpers/cleanSQL.js +268 -23
  20. package/esm/helpers/flushAllTables.d.ts.map +1 -1
  21. package/esm/helpers/flushAllTables.js +23 -28
  22. package/esm/helpers/foldIdentifier.d.ts +3 -0
  23. package/esm/helpers/foldIdentifier.d.ts.map +1 -0
  24. package/esm/helpers/foldIdentifier.js +4 -0
  25. package/esm/helpers/geometryFromJSON.d.ts +3 -0
  26. package/esm/helpers/geometryFromJSON.d.ts.map +1 -0
  27. package/esm/helpers/geometryFromJSON.js +4 -0
  28. package/esm/helpers/index.d.ts +1 -0
  29. package/esm/helpers/index.d.ts.map +1 -1
  30. package/esm/helpers/index.js +1 -0
  31. package/esm/helpers/logData.d.ts.map +1 -1
  32. package/esm/helpers/logData.js +45 -44
  33. package/esm/helpers/makeLogConverter.d.ts +5 -0
  34. package/esm/helpers/makeLogConverter.d.ts.map +1 -0
  35. package/esm/helpers/makeLogConverter.js +64 -0
  36. package/esm/helpers/osmFiles.d.ts.map +1 -1
  37. package/esm/helpers/parseTypes.d.ts +1 -1
  38. package/esm/helpers/parseTypes.d.ts.map +1 -1
  39. package/esm/helpers/parseTypes.js +4 -0
  40. package/esm/helpers/pendingOps.d.ts +4 -2
  41. package/esm/helpers/pendingOps.d.ts.map +1 -1
  42. package/esm/helpers/prepareGeometry.d.ts +3 -0
  43. package/esm/helpers/prepareGeometry.d.ts.map +1 -0
  44. package/esm/helpers/prepareGeometry.js +99 -0
  45. package/esm/helpers/prepareJSON.d.ts +3 -0
  46. package/esm/helpers/prepareJSON.d.ts.map +1 -0
  47. package/esm/helpers/prepareJSON.js +50 -0
  48. package/esm/helpers/printTable.d.ts +5 -4
  49. package/esm/helpers/printTable.d.ts.map +1 -1
  50. package/esm/helpers/printTable.js +32 -36
  51. package/esm/helpers/queryDB.js +1 -1
  52. package/esm/helpers/queueAsyncBarrier.d.ts +4 -0
  53. package/esm/helpers/queueAsyncBarrier.d.ts.map +1 -1
  54. package/esm/helpers/queueAsyncBarrier.js +4 -0
  55. package/esm/helpers/queueOp.d.ts.map +1 -1
  56. package/esm/helpers/queueOp.js +5 -3
  57. package/esm/helpers/readMutationRows.d.ts +9 -0
  58. package/esm/helpers/readMutationRows.d.ts.map +1 -0
  59. package/esm/helpers/readMutationRows.js +94 -0
  60. package/esm/helpers/referencedTables.d.ts +9 -0
  61. package/esm/helpers/referencedTables.d.ts.map +1 -0
  62. package/esm/helpers/referencedTables.js +22 -0
  63. package/esm/helpers/runQuery.d.ts.map +1 -1
  64. package/esm/helpers/runQuery.js +11 -13
  65. package/esm/helpers/scanSQL.d.ts +7 -0
  66. package/esm/helpers/scanSQL.d.ts.map +1 -0
  67. package/esm/helpers/scanSQL.js +71 -0
  68. package/esm/helpers/tableRegistry.d.ts +2 -0
  69. package/esm/helpers/tableRegistry.d.ts.map +1 -1
  70. package/esm/helpers/tableRegistry.js +12 -4
  71. package/esm/helpers/updateColumnsWithJS.d.ts +52 -0
  72. package/esm/helpers/updateColumnsWithJS.d.ts.map +1 -0
  73. package/esm/helpers/updateColumnsWithJS.js +139 -0
  74. package/esm/methods/addColumn.d.ts +1 -1
  75. package/esm/methods/addColumn.d.ts.map +1 -1
  76. package/esm/methods/bm25.d.ts.map +1 -1
  77. package/esm/methods/bm25.js +1 -2
  78. package/esm/methods/cache.d.ts.map +1 -1
  79. package/esm/methods/cache.js +4 -6
  80. package/esm/methods/convert.d.ts +2 -2
  81. package/esm/methods/convert.d.ts.map +1 -1
  82. package/esm/methods/convert.js +5 -0
  83. package/esm/methods/getBottom.d.ts +1 -1
  84. package/esm/methods/getBottom.d.ts.map +1 -1
  85. package/esm/methods/getBottom.js +2 -2
  86. package/esm/methods/getData.d.ts +1 -1
  87. package/esm/methods/getData.d.ts.map +1 -1
  88. package/esm/methods/getData.js +2 -2
  89. package/esm/methods/join.d.ts.map +1 -1
  90. package/esm/methods/join.js +8 -16
  91. package/esm/methods/joinGeo.d.ts.map +1 -1
  92. package/esm/methods/joinGeo.js +10 -19
  93. package/esm/methods/loadArray.d.ts +1 -1
  94. package/esm/methods/loadArray.d.ts.map +1 -1
  95. package/esm/methods/loadArray.js +74 -19
  96. package/esm/methods/loadData.js +3 -0
  97. package/esm/methods/log.d.ts +7 -0
  98. package/esm/methods/log.d.ts.map +1 -0
  99. package/esm/methods/log.js +58 -0
  100. package/esm/methods/logBottom.d.ts +5 -0
  101. package/esm/methods/logBottom.d.ts.map +1 -0
  102. package/esm/methods/logBottom.js +9 -0
  103. package/esm/methods/removeTable.d.ts.map +1 -1
  104. package/esm/methods/removeTable.js +2 -0
  105. package/esm/methods/removeTables.d.ts.map +1 -1
  106. package/esm/methods/removeTables.js +7 -0
  107. package/esm/methods/renameTable.d.ts.map +1 -1
  108. package/esm/methods/renameTable.js +4 -0
  109. package/esm/methods/rowToText.js +2 -2
  110. package/esm/methods/selectTables.d.ts.map +1 -1
  111. package/esm/methods/selectTables.js +6 -0
  112. package/esm/methods/setTypes.d.ts +1 -1
  113. package/esm/methods/setTypes.d.ts.map +1 -1
  114. package/esm/methods/stream.d.ts.map +1 -1
  115. package/esm/methods/stream.js +2 -1
  116. package/esm/methods/updateWithJS.d.ts +1 -3
  117. package/esm/methods/updateWithJS.d.ts.map +1 -1
  118. package/esm/methods/updateWithJS.js +123 -37
  119. package/llm.md +337 -444
  120. package/llms.txt +1 -1
  121. package/package.json +1 -1
  122. package/script/class/Simple.d.ts +8 -2
  123. package/script/class/Simple.d.ts.map +1 -1
  124. package/script/class/Simple.js +9 -3
  125. package/script/class/SimpleDB.d.ts +72 -1
  126. package/script/class/SimpleDB.d.ts.map +1 -1
  127. package/script/class/SimpleDB.js +81 -1
  128. package/script/class/SimpleTable.d.ts +251 -274
  129. package/script/class/SimpleTable.d.ts.map +1 -1
  130. package/script/class/SimpleTable.js +248 -325
  131. package/script/helpers/LogValue.d.ts +8 -0
  132. package/script/helpers/LogValue.d.ts.map +1 -0
  133. package/script/helpers/LogValue.js +26 -0
  134. package/script/helpers/cacheTableDependencies.d.ts +9 -0
  135. package/script/helpers/cacheTableDependencies.d.ts.map +1 -1
  136. package/script/helpers/cacheTableDependencies.js +170 -20
  137. package/script/helpers/cleanSQL.d.ts +1 -1
  138. package/script/helpers/cleanSQL.d.ts.map +1 -1
  139. package/script/helpers/cleanSQL.js +271 -23
  140. package/script/helpers/flushAllTables.d.ts.map +1 -1
  141. package/script/helpers/flushAllTables.js +24 -29
  142. package/script/helpers/foldIdentifier.d.ts +3 -0
  143. package/script/helpers/foldIdentifier.d.ts.map +1 -0
  144. package/script/helpers/foldIdentifier.js +7 -0
  145. package/script/helpers/geometryFromJSON.d.ts +3 -0
  146. package/script/helpers/geometryFromJSON.d.ts.map +1 -0
  147. package/script/helpers/geometryFromJSON.js +7 -0
  148. package/script/helpers/index.d.ts +1 -0
  149. package/script/helpers/index.d.ts.map +1 -1
  150. package/script/helpers/index.js +3 -1
  151. package/script/helpers/logData.d.ts.map +1 -1
  152. package/script/helpers/logData.js +45 -44
  153. package/script/helpers/makeLogConverter.d.ts +5 -0
  154. package/script/helpers/makeLogConverter.d.ts.map +1 -0
  155. package/script/helpers/makeLogConverter.js +70 -0
  156. package/script/helpers/osmFiles.d.ts.map +1 -1
  157. package/script/helpers/parseTypes.d.ts +1 -1
  158. package/script/helpers/parseTypes.d.ts.map +1 -1
  159. package/script/helpers/parseTypes.js +4 -0
  160. package/script/helpers/pendingOps.d.ts +4 -2
  161. package/script/helpers/pendingOps.d.ts.map +1 -1
  162. package/script/helpers/prepareGeometry.d.ts +3 -0
  163. package/script/helpers/prepareGeometry.d.ts.map +1 -0
  164. package/script/helpers/prepareGeometry.js +102 -0
  165. package/script/helpers/prepareJSON.d.ts +3 -0
  166. package/script/helpers/prepareJSON.d.ts.map +1 -0
  167. package/script/helpers/prepareJSON.js +53 -0
  168. package/script/helpers/printTable.d.ts +5 -4
  169. package/script/helpers/printTable.d.ts.map +1 -1
  170. package/script/helpers/printTable.js +32 -36
  171. package/script/helpers/queryDB.js +1 -1
  172. package/script/helpers/queueAsyncBarrier.d.ts +4 -0
  173. package/script/helpers/queueAsyncBarrier.d.ts.map +1 -1
  174. package/script/helpers/queueAsyncBarrier.js +4 -0
  175. package/script/helpers/queueOp.d.ts.map +1 -1
  176. package/script/helpers/queueOp.js +4 -2
  177. package/script/helpers/readMutationRows.d.ts +9 -0
  178. package/script/helpers/readMutationRows.d.ts.map +1 -0
  179. package/script/helpers/readMutationRows.js +97 -0
  180. package/script/helpers/referencedTables.d.ts +9 -0
  181. package/script/helpers/referencedTables.d.ts.map +1 -0
  182. package/script/helpers/referencedTables.js +28 -0
  183. package/script/helpers/runQuery.d.ts.map +1 -1
  184. package/script/helpers/runQuery.js +11 -13
  185. package/script/helpers/scanSQL.d.ts +7 -0
  186. package/script/helpers/scanSQL.d.ts.map +1 -0
  187. package/script/helpers/scanSQL.js +74 -0
  188. package/script/helpers/tableRegistry.d.ts +2 -0
  189. package/script/helpers/tableRegistry.d.ts.map +1 -1
  190. package/script/helpers/tableRegistry.js +16 -4
  191. package/script/helpers/updateColumnsWithJS.d.ts +52 -0
  192. package/script/helpers/updateColumnsWithJS.d.ts.map +1 -0
  193. package/script/helpers/updateColumnsWithJS.js +145 -0
  194. package/script/methods/addColumn.d.ts +1 -1
  195. package/script/methods/addColumn.d.ts.map +1 -1
  196. package/script/methods/bm25.d.ts.map +1 -1
  197. package/script/methods/bm25.js +1 -2
  198. package/script/methods/cache.d.ts.map +1 -1
  199. package/script/methods/cache.js +3 -5
  200. package/script/methods/convert.d.ts +2 -2
  201. package/script/methods/convert.d.ts.map +1 -1
  202. package/script/methods/convert.js +5 -0
  203. package/script/methods/getBottom.d.ts +1 -1
  204. package/script/methods/getBottom.d.ts.map +1 -1
  205. package/script/methods/getBottom.js +2 -2
  206. package/script/methods/getData.d.ts +1 -1
  207. package/script/methods/getData.d.ts.map +1 -1
  208. package/script/methods/getData.js +2 -2
  209. package/script/methods/join.d.ts.map +1 -1
  210. package/script/methods/join.js +8 -16
  211. package/script/methods/joinGeo.d.ts.map +1 -1
  212. package/script/methods/joinGeo.js +10 -19
  213. package/script/methods/loadArray.d.ts +1 -1
  214. package/script/methods/loadArray.d.ts.map +1 -1
  215. package/script/methods/loadArray.js +74 -19
  216. package/script/methods/loadData.js +3 -0
  217. package/script/methods/log.d.ts +7 -0
  218. package/script/methods/log.d.ts.map +1 -0
  219. package/script/methods/log.js +64 -0
  220. package/script/methods/logBottom.d.ts +5 -0
  221. package/script/methods/logBottom.d.ts.map +1 -0
  222. package/script/methods/logBottom.js +15 -0
  223. package/script/methods/removeTable.d.ts.map +1 -1
  224. package/script/methods/removeTable.js +2 -0
  225. package/script/methods/removeTables.d.ts.map +1 -1
  226. package/script/methods/removeTables.js +7 -0
  227. package/script/methods/renameTable.d.ts.map +1 -1
  228. package/script/methods/renameTable.js +4 -0
  229. package/script/methods/rowToText.js +2 -2
  230. package/script/methods/selectTables.d.ts.map +1 -1
  231. package/script/methods/selectTables.js +6 -0
  232. package/script/methods/setTypes.d.ts +1 -1
  233. package/script/methods/setTypes.d.ts.map +1 -1
  234. package/script/methods/stream.d.ts.map +1 -1
  235. package/script/methods/stream.js +2 -1
  236. package/script/methods/updateWithJS.d.ts +1 -3
  237. package/script/methods/updateWithJS.d.ts.map +1 -1
  238. package/script/methods/updateWithJS.js +122 -36
package/llms.txt CHANGED
@@ -3,7 +3,7 @@
3
3
  > Lightweight DuckDB-powered TypeScript library for tabular, SQL, CSV, Parquet, and geospatial data analysis on Deno, Node.js, and Bun.
4
4
 
5
5
  - Package: `@nshiab/simple-data-analysis-core`
6
- - Version: `2.0.5`
6
+ - Version: `2.0.6`
7
7
 
8
8
  Install with Deno: `deno add jsr:@nshiab/simple-data-analysis-core`
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nshiab/simple-data-analysis-core",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "Lightweight DuckDB-powered TypeScript library for tabular, SQL, CSV, Parquet, and geospatial data analysis on Deno, Node.js, and Bun.",
5
5
  "keywords": [
6
6
  "data-analysis",
@@ -18,9 +18,15 @@ export default class Simple {
18
18
  */
19
19
  typesToLog: boolean;
20
20
  /**
21
- * The maximum number of characters to display for text-based cells. If undefined, the entire text is shown.
21
+ * The maximum number of characters to display for text and stringified nested cells, including the truncation marker. This does not control column width. Set to Infinity to show the entire text.
22
22
  *
23
- * @defaultValue `undefined`
23
+ * @example
24
+ * ```ts
25
+ * const sdb = new SimpleDB({ charsToLog: 150 });
26
+ * await sdb.newTable().loadArray([{ text: "x".repeat(200) }]).log();
27
+ * ```
28
+ *
29
+ * @defaultValue `75`
24
30
  */
25
31
  charsToLog: number | undefined;
26
32
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Simple.d.ts","sourceRoot":"","sources":["../../src/class/Simple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,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AAM,CAAC,OAAO,OAAO,MAAM;IACzB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;;;;;;;;;OAUG;IACH,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B;;OAEG;IACH,EAAE,EAAG,cAAc,CAAC;IACpB;;OAEG;IACH,UAAU,EAAG,gBAAgB,CAAC;IAC9B;;;;OAIG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QAAQ,EAAG,CACT,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,gBAAgB,EAC5B,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,UAAU,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,GAAG,IAAI,CAAC;QAC9C,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;QACvB,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC;KACrB,KACE,OAAO,CACR;QACA,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,EAAE,GACD,IAAI,CACP,CAAC;gBAGA,OAAO,GAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,OAAO,CAAC;KACjB;CAOT"}
@@ -30,9 +30,15 @@ class Simple {
30
30
  value: void 0
31
31
  });
32
32
  /**
33
- * The maximum number of characters to display for text-based cells. If undefined, the entire text is shown.
33
+ * The maximum number of characters to display for text and stringified nested cells, including the truncation marker. This does not control column width. Set to Infinity to show the entire text.
34
34
  *
35
- * @defaultValue `undefined`
35
+ * @example
36
+ * ```ts
37
+ * const sdb = new SimpleDB({ charsToLog: 150 });
38
+ * await sdb.newTable().loadArray([{ text: "x".repeat(200) }]).log();
39
+ * ```
40
+ *
41
+ * @defaultValue `75`
36
42
  */
37
43
  Object.defineProperty(this, "charsToLog", {
38
44
  enumerable: true,
@@ -102,7 +108,7 @@ class Simple {
102
108
  value: void 0
103
109
  });
104
110
  this.rowsToLog = options.rowsToLog ?? 10;
105
- this.charsToLog = options.charsToLog;
111
+ this.charsToLog = options.charsToLog ?? 75;
106
112
  this.typesToLog = options.typesToLog ?? false;
107
113
  this.defaultTableName = false;
108
114
  }
@@ -36,6 +36,73 @@ import Simple from "./Simple.js";
36
36
  */
37
37
  export default class SimpleDB<Table extends SimpleTable = SimpleTable> extends Simple {
38
38
  #private;
39
+ /**
40
+ * The operator syntax used by expressions and custom queries in this database.
41
+ * `"js"` translates JavaScript-style operators (`&&`, `||`, `==`, `===`,
42
+ * `!==`) and null comparisons within SQL expressions. It does not evaluate
43
+ * arbitrary JavaScript. `||` remains concatenation when string literals, list
44
+ * literals, explicit text casts, or `concat()` results make that intent clear.
45
+ * Otherwise `||` becomes OR; column types are not inferred. Use `concat()`
46
+ * when concatenation would otherwise be ambiguous, such as `first || last`.
47
+ * `"sql"` passes SQL through unchanged, including `||` and null comparisons.
48
+ * Choose the syntax when constructing the database; it applies to all tables.
49
+ *
50
+ * @defaultValue `"js"`
51
+ * @category Properties
52
+ * @example
53
+ * ```ts
54
+ * const sdb = new SimpleDB({ expressionSyntax: "js" }); // The default mode
55
+ * // || becomes SQL OR: keep rows where at least one condition is true.
56
+ * await sdb.newTable().loadArray([{ active: true, admin: false }])
57
+ * .filter("active || admin").log();
58
+ * ```
59
+ * @example
60
+ * ```ts
61
+ * const sdb = new SimpleDB({ expressionSyntax: "js" });
62
+ * // && becomes SQL AND: both conditions must be true.
63
+ * // === becomes SQL =: compare the age with 18.
64
+ * await sdb.newTable().loadArray([{ active: true, age: 18 }])
65
+ * .filter("active && age === 18").log();
66
+ * ```
67
+ * @example
68
+ * ```ts
69
+ * const sdb = new SimpleDB({ expressionSyntax: "js" });
70
+ * // SQL AND and OR also work in JS mode; they pass through unchanged.
71
+ * // Keep active adults, or anyone who is an admin.
72
+ * await sdb.newTable().loadArray([{ active: true, age: 18, admin: false }])
73
+ * .filter("(active AND age >= 18) OR admin").log();
74
+ * ```
75
+ * @example
76
+ * ```ts
77
+ * const sdb = new SimpleDB({ expressionSyntax: "js" });
78
+ * // Bare column names do not establish concatenation. Use concat() explicitly.
79
+ * await sdb.newTable().loadArray([{ first: "Jane", last: "Doe" }])
80
+ * .addColumn("name", "string", "concat(first, ' ', last)").log();
81
+ * ```
82
+ * @example
83
+ * ```ts
84
+ * const sdb = new SimpleDB(); // JS mode is the default
85
+ * // The string literal ' ' makes concatenation clear, so both || stay unchanged.
86
+ * await sdb.newTable().loadArray([{ first: "Jane", last: "Doe" }])
87
+ * .addColumn("name", "string", "first || ' ' || last").log();
88
+ * ```
89
+ * @example
90
+ * ```ts
91
+ * const sdb = new SimpleDB({ expressionSyntax: "sql" });
92
+ * // SQL mode preserves || as concatenation: the name becomes "Jane Doe".
93
+ * await sdb.newTable().loadArray([{ first: "Jane", last: "Doe" }])
94
+ * .addColumn("name", "string", "first || ' ' || last").log();
95
+ * ```
96
+ * @example
97
+ * ```ts
98
+ * const sdb = new SimpleDB({ expressionSyntax: "sql" });
99
+ * // Use SQL AND and OR for logical conditions; && and || are not translated.
100
+ * // Both active and adult must be true, unless admin is true.
101
+ * await sdb.newTable().loadArray([{ active: true, age: 18, admin: false }])
102
+ * .filter("(active AND age >= 18) OR admin").log();
103
+ * ```
104
+ */
105
+ readonly expressionSyntax: "js" | "sql";
39
106
  /**
40
107
  * Whether to log each SQL statement immediately before execution.
41
108
  *
@@ -255,9 +322,10 @@ export default class SimpleDB<Table extends SimpleTable = SimpleTable> extends S
255
322
  * @param options.readOnly - Opens an existing DuckDB file read-only. Defaults to false. Requires a file and cannot be combined with overwrite.
256
323
  * @param options.logDuration - A flag indicating whether to log the total execution duration.
257
324
  * @param options.rowsToLog - The number of rows to display when logging a table.
258
- * @param options.charsToLog - The maximum number of characters to display for text-based cells.
325
+ * @param options.charsToLog - The maximum characters to display for text and stringified nested cells, including truncation markers (default: 75). Independent of column width. Use Infinity for unlimited text.
259
326
  * @param options.typesToLog - A flag indicating whether to include data types when logging a table.
260
327
  * @param options.cacheVerbose - Whether to log cache hits and misses, code and input changes, TTL status, and cache read/write timing.
328
+ * @param options.expressionSyntax - Operator syntax for expressions and custom queries: `"js"` (default) translates JavaScript-style operators in SQL expressions; `"sql"` preserves SQL unchanged.
261
329
  * @param options.logSQL - A flag indicating whether to log SQL immediately before execution.
262
330
  * @param options.explainSQL - A flag indicating whether to log DuckDB query plans for supported statements.
263
331
  * @param options.duckDbCache - A flag indicating whether to use DuckDB's external file cache.
@@ -283,6 +351,7 @@ export default class SimpleDB<Table extends SimpleTable = SimpleTable> extends S
283
351
  charsToLog?: number;
284
352
  typesToLog?: boolean;
285
353
  cacheVerbose?: boolean;
354
+ expressionSyntax?: "js" | "sql";
286
355
  logSQL?: boolean;
287
356
  explainSQL?: boolean;
288
357
  duckDbCache?: boolean | null;
@@ -300,6 +369,7 @@ export default class SimpleDB<Table extends SimpleTable = SimpleTable> extends S
300
369
  start(): Promise<SimpleDB>;
301
370
  /**
302
371
  * Creates a new SimpleTable instance within the database.
372
+ * The name must be unique among registered tables, ignoring ASCII letter case.
303
373
  *
304
374
  * @param name - The name of the new table. If not provided, a default name is generated (e.g., "table1").
305
375
  * @returns A new table instance.
@@ -486,6 +556,7 @@ export default class SimpleDB<Table extends SimpleTable = SimpleTable> extends S
486
556
  }[]>;
487
557
  /**
488
558
  * Executes a custom SQL query directly against the DuckDB instance.
559
+ * With the default `SimpleDB.expressionSyntax: "js"`, queries support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
489
560
  * Queries run in UTC. When data is returned, temporal values use the same
490
561
  * JavaScript representations as `SimpleTable.getData()`.
491
562
  *
@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C,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMvD;;;;;;;;;;;;OAYG;IACG,aAAa,IAAI,OAAO,CAC5B;QACE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,EAAE,CACJ;IAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACG,WAAW,CACf,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QACP,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;KACX,GACL,OAAO,CACN;QACA,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,EAAE,GACD,IAAI,CACP;IAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACG,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAO,GACxD,OAAO,CAAC,IAAI,CAAC;IAKhB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;IAU9B;;;;;;;;;;;;;;;OAeG;IACG,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC;CAkGjC"}
@@ -127,9 +127,10 @@ class SimpleDB extends Simple_js_1.default {
127
127
  * @param options.readOnly - Opens an existing DuckDB file read-only. Defaults to false. Requires a file and cannot be combined with overwrite.
128
128
  * @param options.logDuration - A flag indicating whether to log the total execution duration.
129
129
  * @param options.rowsToLog - The number of rows to display when logging a table.
130
- * @param options.charsToLog - The maximum number of characters to display for text-based cells.
130
+ * @param options.charsToLog - The maximum characters to display for text and stringified nested cells, including truncation markers (default: 75). Independent of column width. Use Infinity for unlimited text.
131
131
  * @param options.typesToLog - A flag indicating whether to include data types when logging a table.
132
132
  * @param options.cacheVerbose - Whether to log cache hits and misses, code and input changes, TTL status, and cache read/write timing.
133
+ * @param options.expressionSyntax - Operator syntax for expressions and custom queries: `"js"` (default) translates JavaScript-style operators in SQL expressions; `"sql"` preserves SQL unchanged.
133
134
  * @param options.logSQL - A flag indicating whether to log SQL immediately before execution.
134
135
  * @param options.explainSQL - A flag indicating whether to log DuckDB query plans for supported statements.
135
136
  * @param options.duckDbCache - A flag indicating whether to use DuckDB's external file cache.
@@ -149,6 +150,78 @@ class SimpleDB extends Simple_js_1.default {
149
150
  constructor(options = {}) {
150
151
  super(options);
151
152
  _SimpleDB_instances.add(this);
153
+ /**
154
+ * The operator syntax used by expressions and custom queries in this database.
155
+ * `"js"` translates JavaScript-style operators (`&&`, `||`, `==`, `===`,
156
+ * `!==`) and null comparisons within SQL expressions. It does not evaluate
157
+ * arbitrary JavaScript. `||` remains concatenation when string literals, list
158
+ * literals, explicit text casts, or `concat()` results make that intent clear.
159
+ * Otherwise `||` becomes OR; column types are not inferred. Use `concat()`
160
+ * when concatenation would otherwise be ambiguous, such as `first || last`.
161
+ * `"sql"` passes SQL through unchanged, including `||` and null comparisons.
162
+ * Choose the syntax when constructing the database; it applies to all tables.
163
+ *
164
+ * @defaultValue `"js"`
165
+ * @category Properties
166
+ * @example
167
+ * ```ts
168
+ * const sdb = new SimpleDB({ expressionSyntax: "js" }); // The default mode
169
+ * // || becomes SQL OR: keep rows where at least one condition is true.
170
+ * await sdb.newTable().loadArray([{ active: true, admin: false }])
171
+ * .filter("active || admin").log();
172
+ * ```
173
+ * @example
174
+ * ```ts
175
+ * const sdb = new SimpleDB({ expressionSyntax: "js" });
176
+ * // && becomes SQL AND: both conditions must be true.
177
+ * // === becomes SQL =: compare the age with 18.
178
+ * await sdb.newTable().loadArray([{ active: true, age: 18 }])
179
+ * .filter("active && age === 18").log();
180
+ * ```
181
+ * @example
182
+ * ```ts
183
+ * const sdb = new SimpleDB({ expressionSyntax: "js" });
184
+ * // SQL AND and OR also work in JS mode; they pass through unchanged.
185
+ * // Keep active adults, or anyone who is an admin.
186
+ * await sdb.newTable().loadArray([{ active: true, age: 18, admin: false }])
187
+ * .filter("(active AND age >= 18) OR admin").log();
188
+ * ```
189
+ * @example
190
+ * ```ts
191
+ * const sdb = new SimpleDB({ expressionSyntax: "js" });
192
+ * // Bare column names do not establish concatenation. Use concat() explicitly.
193
+ * await sdb.newTable().loadArray([{ first: "Jane", last: "Doe" }])
194
+ * .addColumn("name", "string", "concat(first, ' ', last)").log();
195
+ * ```
196
+ * @example
197
+ * ```ts
198
+ * const sdb = new SimpleDB(); // JS mode is the default
199
+ * // The string literal ' ' makes concatenation clear, so both || stay unchanged.
200
+ * await sdb.newTable().loadArray([{ first: "Jane", last: "Doe" }])
201
+ * .addColumn("name", "string", "first || ' ' || last").log();
202
+ * ```
203
+ * @example
204
+ * ```ts
205
+ * const sdb = new SimpleDB({ expressionSyntax: "sql" });
206
+ * // SQL mode preserves || as concatenation: the name becomes "Jane Doe".
207
+ * await sdb.newTable().loadArray([{ first: "Jane", last: "Doe" }])
208
+ * .addColumn("name", "string", "first || ' ' || last").log();
209
+ * ```
210
+ * @example
211
+ * ```ts
212
+ * const sdb = new SimpleDB({ expressionSyntax: "sql" });
213
+ * // Use SQL AND and OR for logical conditions; && and || are not translated.
214
+ * // Both active and adult must be true, unless admin is true.
215
+ * await sdb.newTable().loadArray([{ active: true, age: 18, admin: false }])
216
+ * .filter("(active AND age >= 18) OR admin").log();
217
+ * ```
218
+ */
219
+ Object.defineProperty(this, "expressionSyntax", {
220
+ enumerable: true,
221
+ configurable: true,
222
+ writable: true,
223
+ value: void 0
224
+ });
152
225
  /**
153
226
  * Whether to log each SQL statement immediately before execution.
154
227
  *
@@ -461,6 +534,11 @@ class SimpleDB extends Simple_js_1.default {
461
534
  writable: true,
462
535
  value: SimpleTable_js_1.default
463
536
  });
537
+ if (options.expressionSyntax !== undefined &&
538
+ !["js", "sql"].includes(options.expressionSyntax)) {
539
+ throw new Error('expressionSyntax must be "js" or "sql".');
540
+ }
541
+ this.expressionSyntax = options.expressionSyntax ?? "js";
464
542
  this.file = options.file ?? ":memory:";
465
543
  this.logSQL = options.logSQL ?? false;
466
544
  this.explainSQL = options.explainSQL ?? false;
@@ -513,6 +591,7 @@ class SimpleDB extends Simple_js_1.default {
513
591
  }
514
592
  /**
515
593
  * Creates a new SimpleTable instance within the database.
594
+ * The name must be unique among registered tables, ignoring ASCII letter case.
516
595
  *
517
596
  * @param name - The name of the new table. If not provided, a default name is generated (e.g., "table1").
518
597
  * @returns A new table instance.
@@ -766,6 +845,7 @@ class SimpleDB extends Simple_js_1.default {
766
845
  }
767
846
  /**
768
847
  * Executes a custom SQL query directly against the DuckDB instance.
848
+ * With the default `SimpleDB.expressionSyntax: "js"`, queries support JavaScript-style operators (`&&`, `||`, `===`, `!==`). Set `expressionSyntax: "sql"` for unchanged SQL.
769
849
  * Queries run in UTC. When data is returned, temporal values use the same
770
850
  * JavaScript representations as `SimpleTable.getData()`.
771
851
  *