taon-type-sql 18.0.9

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 (325) hide show
  1. package/assets/shared/shared_folder_info.txt +7 -0
  2. package/browser/README.md +24 -0
  3. package/browser/esm2022/lib/builder/column/basic-column.mjs +13 -0
  4. package/browser/esm2022/lib/builder/column/boolean-column.mjs +14 -0
  5. package/browser/esm2022/lib/builder/column/comparable-column.mjs +41 -0
  6. package/browser/esm2022/lib/builder/column/date-column.mjs +14 -0
  7. package/browser/esm2022/lib/builder/column/number-column.mjs +19 -0
  8. package/browser/esm2022/lib/builder/column/query-column.mjs +21 -0
  9. package/browser/esm2022/lib/builder/column/string-column.mjs +36 -0
  10. package/browser/esm2022/lib/builder/column/value-column.mjs +30 -0
  11. package/browser/esm2022/lib/builder/condition/query-column-condition.mjs +19 -0
  12. package/browser/esm2022/lib/builder/condition/query-condition-chain.mjs +28 -0
  13. package/browser/esm2022/lib/builder/condition/query-condition.mjs +6 -0
  14. package/browser/esm2022/lib/builder/condition/query-join-condition.mjs +19 -0
  15. package/browser/esm2022/lib/builder/helpers/generics-helper.mjs +5 -0
  16. package/browser/esm2022/lib/builder/helpers/internal-types.mjs +4 -0
  17. package/browser/esm2022/lib/builder/join/joined-tables-chain.mjs +14 -0
  18. package/browser/esm2022/lib/builder/join/joined-tables.mjs +22 -0
  19. package/browser/esm2022/lib/builder/other/query-ordering.mjs +17 -0
  20. package/browser/esm2022/lib/builder/query/select-query.mjs +48 -0
  21. package/browser/esm2022/lib/builder/query/table-condition-query.mjs +25 -0
  22. package/browser/esm2022/lib/builder/query/table-query.mjs +54 -0
  23. package/browser/esm2022/lib/builder/query-source.mjs +20 -0
  24. package/browser/esm2022/lib/builder/query-table.mjs +24 -0
  25. package/browser/esm2022/lib/client/mysql.mjs +10 -0
  26. package/browser/esm2022/lib/client/query-processor.mjs +45 -0
  27. package/browser/esm2022/lib/converter/param-converter.mjs +27 -0
  28. package/browser/esm2022/lib/converter/parameterized-converter.mjs +17 -0
  29. package/browser/esm2022/lib/converter/query-converter.mjs +282 -0
  30. package/browser/esm2022/lib/converter/result-converter.mjs +88 -0
  31. package/browser/esm2022/lib/converter/sql-converter.mjs +8 -0
  32. package/browser/esm2022/lib/converter/type-converter.mjs +39 -0
  33. package/browser/esm2022/lib/converter/types.mjs +4 -0
  34. package/browser/esm2022/lib/index.mjs +23 -0
  35. package/browser/esm2022/public-api.mjs +2 -0
  36. package/browser/esm2022/taon-type-sql.mjs +5 -0
  37. package/browser/fesm2022/taon-type-sql.mjs +877 -0
  38. package/browser/fesm2022/taon-type-sql.mjs.map +1 -0
  39. package/browser/index.d.ts +6 -0
  40. package/browser/lib/builder/column/basic-column.d.ts +9 -0
  41. package/browser/lib/builder/column/boolean-column.d.ts +10 -0
  42. package/browser/lib/builder/column/comparable-column.d.ts +19 -0
  43. package/browser/lib/builder/column/date-column.d.ts +10 -0
  44. package/browser/lib/builder/column/number-column.d.ts +11 -0
  45. package/browser/lib/builder/column/query-column.d.ts +19 -0
  46. package/browser/lib/builder/column/string-column.d.ts +18 -0
  47. package/browser/lib/builder/column/value-column.d.ts +16 -0
  48. package/browser/lib/builder/condition/query-column-condition.d.ts +14 -0
  49. package/browser/lib/builder/condition/query-condition-chain.d.ts +18 -0
  50. package/browser/lib/builder/condition/query-condition.d.ts +8 -0
  51. package/browser/lib/builder/condition/query-join-condition.d.ts +13 -0
  52. package/browser/lib/builder/helpers/generics-helper.d.ts +3 -0
  53. package/browser/lib/builder/helpers/internal-types.d.ts +16 -0
  54. package/browser/lib/builder/join/joined-tables-chain.d.ts +12 -0
  55. package/browser/lib/builder/join/joined-tables.d.ts +13 -0
  56. package/browser/lib/builder/other/query-ordering.d.ts +11 -0
  57. package/browser/lib/builder/query/select-query.d.ts +30 -0
  58. package/browser/lib/builder/query/table-condition-query.d.ts +17 -0
  59. package/browser/lib/builder/query/table-query.d.ts +24 -0
  60. package/browser/lib/builder/query-source.d.ts +15 -0
  61. package/browser/lib/builder/query-table.d.ts +16 -0
  62. package/browser/lib/client/mysql.d.ts +6 -0
  63. package/browser/lib/client/query-processor.d.ts +11 -0
  64. package/browser/lib/converter/param-converter.d.ts +3 -0
  65. package/browser/lib/converter/parameterized-converter.d.ts +6 -0
  66. package/browser/lib/converter/query-converter.d.ts +3 -0
  67. package/browser/lib/converter/result-converter.d.ts +3 -0
  68. package/browser/lib/converter/sql-converter.d.ts +3 -0
  69. package/browser/lib/converter/type-converter.d.ts +5 -0
  70. package/browser/lib/converter/types.d.ts +6 -0
  71. package/browser/lib/index.d.ts +26 -0
  72. package/browser/package.json +25 -0
  73. package/browser/public-api.d.ts +2 -0
  74. package/client/README.md +24 -0
  75. package/client/esm2022/lib/builder/column/basic-column.mjs +13 -0
  76. package/client/esm2022/lib/builder/column/boolean-column.mjs +14 -0
  77. package/client/esm2022/lib/builder/column/comparable-column.mjs +41 -0
  78. package/client/esm2022/lib/builder/column/date-column.mjs +14 -0
  79. package/client/esm2022/lib/builder/column/number-column.mjs +19 -0
  80. package/client/esm2022/lib/builder/column/query-column.mjs +21 -0
  81. package/client/esm2022/lib/builder/column/string-column.mjs +36 -0
  82. package/client/esm2022/lib/builder/column/value-column.mjs +30 -0
  83. package/client/esm2022/lib/builder/condition/query-column-condition.mjs +19 -0
  84. package/client/esm2022/lib/builder/condition/query-condition-chain.mjs +28 -0
  85. package/client/esm2022/lib/builder/condition/query-condition.mjs +6 -0
  86. package/client/esm2022/lib/builder/condition/query-join-condition.mjs +19 -0
  87. package/client/esm2022/lib/builder/helpers/generics-helper.mjs +5 -0
  88. package/client/esm2022/lib/builder/helpers/internal-types.mjs +4 -0
  89. package/client/esm2022/lib/builder/join/joined-tables-chain.mjs +14 -0
  90. package/client/esm2022/lib/builder/join/joined-tables.mjs +22 -0
  91. package/client/esm2022/lib/builder/other/query-ordering.mjs +17 -0
  92. package/client/esm2022/lib/builder/query/select-query.mjs +48 -0
  93. package/client/esm2022/lib/builder/query/table-condition-query.mjs +25 -0
  94. package/client/esm2022/lib/builder/query/table-query.mjs +54 -0
  95. package/client/esm2022/lib/builder/query-source.mjs +20 -0
  96. package/client/esm2022/lib/builder/query-table.mjs +24 -0
  97. package/client/esm2022/lib/client/mysql.mjs +10 -0
  98. package/client/esm2022/lib/client/query-processor.mjs +45 -0
  99. package/client/esm2022/lib/converter/param-converter.mjs +27 -0
  100. package/client/esm2022/lib/converter/parameterized-converter.mjs +17 -0
  101. package/client/esm2022/lib/converter/query-converter.mjs +282 -0
  102. package/client/esm2022/lib/converter/result-converter.mjs +88 -0
  103. package/client/esm2022/lib/converter/sql-converter.mjs +8 -0
  104. package/client/esm2022/lib/converter/type-converter.mjs +39 -0
  105. package/client/esm2022/lib/converter/types.mjs +4 -0
  106. package/client/esm2022/lib/index.mjs +23 -0
  107. package/client/esm2022/public-api.mjs +2 -0
  108. package/client/esm2022/taon-type-sql.mjs +5 -0
  109. package/client/fesm2022/taon-type-sql.mjs +877 -0
  110. package/client/fesm2022/taon-type-sql.mjs.map +1 -0
  111. package/client/index.d.ts +6 -0
  112. package/client/lib/builder/column/basic-column.d.ts +9 -0
  113. package/client/lib/builder/column/boolean-column.d.ts +10 -0
  114. package/client/lib/builder/column/comparable-column.d.ts +19 -0
  115. package/client/lib/builder/column/date-column.d.ts +10 -0
  116. package/client/lib/builder/column/number-column.d.ts +11 -0
  117. package/client/lib/builder/column/query-column.d.ts +19 -0
  118. package/client/lib/builder/column/string-column.d.ts +18 -0
  119. package/client/lib/builder/column/value-column.d.ts +16 -0
  120. package/client/lib/builder/condition/query-column-condition.d.ts +14 -0
  121. package/client/lib/builder/condition/query-condition-chain.d.ts +18 -0
  122. package/client/lib/builder/condition/query-condition.d.ts +8 -0
  123. package/client/lib/builder/condition/query-join-condition.d.ts +13 -0
  124. package/client/lib/builder/helpers/generics-helper.d.ts +3 -0
  125. package/client/lib/builder/helpers/internal-types.d.ts +16 -0
  126. package/client/lib/builder/join/joined-tables-chain.d.ts +12 -0
  127. package/client/lib/builder/join/joined-tables.d.ts +13 -0
  128. package/client/lib/builder/other/query-ordering.d.ts +11 -0
  129. package/client/lib/builder/query/select-query.d.ts +30 -0
  130. package/client/lib/builder/query/table-condition-query.d.ts +17 -0
  131. package/client/lib/builder/query/table-query.d.ts +24 -0
  132. package/client/lib/builder/query-source.d.ts +15 -0
  133. package/client/lib/builder/query-table.d.ts +16 -0
  134. package/client/lib/client/mysql.d.ts +6 -0
  135. package/client/lib/client/query-processor.d.ts +11 -0
  136. package/client/lib/converter/param-converter.d.ts +3 -0
  137. package/client/lib/converter/parameterized-converter.d.ts +6 -0
  138. package/client/lib/converter/query-converter.d.ts +3 -0
  139. package/client/lib/converter/result-converter.d.ts +3 -0
  140. package/client/lib/converter/sql-converter.d.ts +3 -0
  141. package/client/lib/converter/type-converter.d.ts +5 -0
  142. package/client/lib/converter/types.d.ts +6 -0
  143. package/client/lib/index.d.ts +26 -0
  144. package/client/public-api.d.ts +2 -0
  145. package/index.d.ts +1 -0
  146. package/index.js +7 -0
  147. package/index.js.map +1 -0
  148. package/lib/build-info._auto-generated_.d.ts +1 -0
  149. package/lib/build-info._auto-generated_.js +5 -0
  150. package/lib/build-info._auto-generated_.js.map +1 -0
  151. package/lib/builder/column/basic-column.d.ts +8 -0
  152. package/lib/builder/column/basic-column.js +19 -0
  153. package/lib/builder/column/basic-column.js.map +1 -0
  154. package/lib/builder/column/boolean-column.d.ts +9 -0
  155. package/lib/builder/column/boolean-column.js +20 -0
  156. package/lib/builder/column/boolean-column.js.map +1 -0
  157. package/lib/builder/column/comparable-column.d.ts +18 -0
  158. package/lib/builder/column/comparable-column.js +46 -0
  159. package/lib/builder/column/comparable-column.js.map +1 -0
  160. package/lib/builder/column/date-column.d.ts +9 -0
  161. package/lib/builder/column/date-column.js +20 -0
  162. package/lib/builder/column/date-column.js.map +1 -0
  163. package/lib/builder/column/number-column.d.ts +10 -0
  164. package/lib/builder/column/number-column.js +25 -0
  165. package/lib/builder/column/number-column.js.map +1 -0
  166. package/lib/builder/column/query-column.d.ts +18 -0
  167. package/lib/builder/column/query-column.js +23 -0
  168. package/lib/builder/column/query-column.js.map +1 -0
  169. package/lib/builder/column/string-column.d.ts +17 -0
  170. package/lib/builder/column/string-column.js +42 -0
  171. package/lib/builder/column/string-column.js.map +1 -0
  172. package/lib/builder/column/value-column.d.ts +15 -0
  173. package/lib/builder/column/value-column.js +34 -0
  174. package/lib/builder/column/value-column.js.map +1 -0
  175. package/lib/builder/condition/query-column-condition.d.ts +13 -0
  176. package/lib/builder/condition/query-column-condition.js +28 -0
  177. package/lib/builder/condition/query-column-condition.js.map +1 -0
  178. package/lib/builder/condition/query-condition-chain.d.ts +17 -0
  179. package/lib/builder/condition/query-condition-chain.js +34 -0
  180. package/lib/builder/condition/query-condition-chain.js.map +1 -0
  181. package/lib/builder/condition/query-condition.d.ts +7 -0
  182. package/lib/builder/condition/query-condition.js +10 -0
  183. package/lib/builder/condition/query-condition.js.map +1 -0
  184. package/lib/builder/condition/query-join-condition.d.ts +12 -0
  185. package/lib/builder/condition/query-join-condition.js +24 -0
  186. package/lib/builder/condition/query-join-condition.js.map +1 -0
  187. package/lib/builder/helpers/generics-helper.d.ts +2 -0
  188. package/lib/builder/helpers/generics-helper.js +10 -0
  189. package/lib/builder/helpers/generics-helper.js.map +1 -0
  190. package/lib/builder/helpers/internal-types.d.ts +15 -0
  191. package/lib/builder/helpers/internal-types.js +4 -0
  192. package/lib/builder/helpers/internal-types.js.map +1 -0
  193. package/lib/builder/join/joined-tables-chain.d.ts +11 -0
  194. package/lib/builder/join/joined-tables-chain.js +16 -0
  195. package/lib/builder/join/joined-tables-chain.js.map +1 -0
  196. package/lib/builder/join/joined-tables.d.ts +12 -0
  197. package/lib/builder/join/joined-tables.js +24 -0
  198. package/lib/builder/join/joined-tables.js.map +1 -0
  199. package/lib/builder/other/query-ordering.d.ts +10 -0
  200. package/lib/builder/other/query-ordering.js +19 -0
  201. package/lib/builder/other/query-ordering.js.map +1 -0
  202. package/lib/builder/query/select-query.d.ts +29 -0
  203. package/lib/builder/query/select-query.js +70 -0
  204. package/lib/builder/query/select-query.js.map +1 -0
  205. package/lib/builder/query/table-condition-query.d.ts +16 -0
  206. package/lib/builder/query/table-condition-query.js +27 -0
  207. package/lib/builder/query/table-condition-query.js.map +1 -0
  208. package/lib/builder/query/table-query.d.ts +23 -0
  209. package/lib/builder/query/table-query.js +63 -0
  210. package/lib/builder/query/table-query.js.map +1 -0
  211. package/lib/builder/query-source.d.ts +14 -0
  212. package/lib/builder/query-source.js +22 -0
  213. package/lib/builder/query-source.js.map +1 -0
  214. package/lib/builder/query-table.d.ts +15 -0
  215. package/lib/builder/query-table.js +26 -0
  216. package/lib/builder/query-table.js.map +1 -0
  217. package/lib/client/mysql.d.ts +5 -0
  218. package/lib/client/mysql.js +15 -0
  219. package/lib/client/mysql.js.map +1 -0
  220. package/lib/client/pg.d.ts +5 -0
  221. package/lib/client/pg.js +15 -0
  222. package/lib/client/pg.js.map +1 -0
  223. package/lib/client/query-processor.d.ts +10 -0
  224. package/lib/client/query-processor.js +75 -0
  225. package/lib/client/query-processor.js.map +1 -0
  226. package/lib/converter/param-converter.d.ts +2 -0
  227. package/lib/converter/param-converter.js +31 -0
  228. package/lib/converter/param-converter.js.map +1 -0
  229. package/lib/converter/parameterized-converter.d.ts +5 -0
  230. package/lib/converter/parameterized-converter.js +18 -0
  231. package/lib/converter/parameterized-converter.js.map +1 -0
  232. package/lib/converter/query-converter.d.ts +2 -0
  233. package/lib/converter/query-converter.js +286 -0
  234. package/lib/converter/query-converter.js.map +1 -0
  235. package/lib/converter/result-converter.d.ts +2 -0
  236. package/lib/converter/result-converter.js +89 -0
  237. package/lib/converter/result-converter.js.map +1 -0
  238. package/lib/converter/sql-converter.d.ts +2 -0
  239. package/lib/converter/sql-converter.js +9 -0
  240. package/lib/converter/sql-converter.js.map +1 -0
  241. package/lib/converter/type-converter.d.ts +4 -0
  242. package/lib/converter/type-converter.js +43 -0
  243. package/lib/converter/type-converter.js.map +1 -0
  244. package/lib/converter/types.d.ts +5 -0
  245. package/lib/converter/types.js +3 -0
  246. package/lib/converter/types.js.map +1 -0
  247. package/lib/index.d.ts +25 -0
  248. package/lib/index.js +48 -0
  249. package/lib/index.js.map +1 -0
  250. package/package.json +38 -0
  251. package/src.d.ts +6 -0
  252. package/taon.jsonc +23 -0
  253. package/tmp-environment.json +359 -0
  254. package/websql/README.md +24 -0
  255. package/websql/esm2022/lib/builder/column/basic-column.mjs +13 -0
  256. package/websql/esm2022/lib/builder/column/boolean-column.mjs +14 -0
  257. package/websql/esm2022/lib/builder/column/comparable-column.mjs +41 -0
  258. package/websql/esm2022/lib/builder/column/date-column.mjs +14 -0
  259. package/websql/esm2022/lib/builder/column/number-column.mjs +19 -0
  260. package/websql/esm2022/lib/builder/column/query-column.mjs +21 -0
  261. package/websql/esm2022/lib/builder/column/string-column.mjs +36 -0
  262. package/websql/esm2022/lib/builder/column/value-column.mjs +30 -0
  263. package/websql/esm2022/lib/builder/condition/query-column-condition.mjs +19 -0
  264. package/websql/esm2022/lib/builder/condition/query-condition-chain.mjs +28 -0
  265. package/websql/esm2022/lib/builder/condition/query-condition.mjs +6 -0
  266. package/websql/esm2022/lib/builder/condition/query-join-condition.mjs +19 -0
  267. package/websql/esm2022/lib/builder/helpers/generics-helper.mjs +5 -0
  268. package/websql/esm2022/lib/builder/helpers/internal-types.mjs +4 -0
  269. package/websql/esm2022/lib/builder/join/joined-tables-chain.mjs +14 -0
  270. package/websql/esm2022/lib/builder/join/joined-tables.mjs +22 -0
  271. package/websql/esm2022/lib/builder/other/query-ordering.mjs +17 -0
  272. package/websql/esm2022/lib/builder/query/select-query.mjs +48 -0
  273. package/websql/esm2022/lib/builder/query/table-condition-query.mjs +25 -0
  274. package/websql/esm2022/lib/builder/query/table-query.mjs +54 -0
  275. package/websql/esm2022/lib/builder/query-source.mjs +20 -0
  276. package/websql/esm2022/lib/builder/query-table.mjs +24 -0
  277. package/websql/esm2022/lib/client/mysql.mjs +10 -0
  278. package/websql/esm2022/lib/client/query-processor.mjs +45 -0
  279. package/websql/esm2022/lib/converter/param-converter.mjs +27 -0
  280. package/websql/esm2022/lib/converter/parameterized-converter.mjs +17 -0
  281. package/websql/esm2022/lib/converter/query-converter.mjs +282 -0
  282. package/websql/esm2022/lib/converter/result-converter.mjs +88 -0
  283. package/websql/esm2022/lib/converter/sql-converter.mjs +8 -0
  284. package/websql/esm2022/lib/converter/type-converter.mjs +39 -0
  285. package/websql/esm2022/lib/converter/types.mjs +4 -0
  286. package/websql/esm2022/lib/index.mjs +23 -0
  287. package/websql/esm2022/public-api.mjs +2 -0
  288. package/websql/esm2022/taon-type-sql.mjs +5 -0
  289. package/websql/fesm2022/taon-type-sql.mjs +877 -0
  290. package/websql/fesm2022/taon-type-sql.mjs.map +1 -0
  291. package/websql/index.d.ts +6 -0
  292. package/websql/lib/builder/column/basic-column.d.ts +9 -0
  293. package/websql/lib/builder/column/boolean-column.d.ts +10 -0
  294. package/websql/lib/builder/column/comparable-column.d.ts +19 -0
  295. package/websql/lib/builder/column/date-column.d.ts +10 -0
  296. package/websql/lib/builder/column/number-column.d.ts +11 -0
  297. package/websql/lib/builder/column/query-column.d.ts +19 -0
  298. package/websql/lib/builder/column/string-column.d.ts +18 -0
  299. package/websql/lib/builder/column/value-column.d.ts +16 -0
  300. package/websql/lib/builder/condition/query-column-condition.d.ts +14 -0
  301. package/websql/lib/builder/condition/query-condition-chain.d.ts +18 -0
  302. package/websql/lib/builder/condition/query-condition.d.ts +8 -0
  303. package/websql/lib/builder/condition/query-join-condition.d.ts +13 -0
  304. package/websql/lib/builder/helpers/generics-helper.d.ts +3 -0
  305. package/websql/lib/builder/helpers/internal-types.d.ts +16 -0
  306. package/websql/lib/builder/join/joined-tables-chain.d.ts +12 -0
  307. package/websql/lib/builder/join/joined-tables.d.ts +13 -0
  308. package/websql/lib/builder/other/query-ordering.d.ts +11 -0
  309. package/websql/lib/builder/query/select-query.d.ts +30 -0
  310. package/websql/lib/builder/query/table-condition-query.d.ts +17 -0
  311. package/websql/lib/builder/query/table-query.d.ts +24 -0
  312. package/websql/lib/builder/query-source.d.ts +15 -0
  313. package/websql/lib/builder/query-table.d.ts +16 -0
  314. package/websql/lib/client/mysql.d.ts +6 -0
  315. package/websql/lib/client/query-processor.d.ts +11 -0
  316. package/websql/lib/converter/param-converter.d.ts +3 -0
  317. package/websql/lib/converter/parameterized-converter.d.ts +6 -0
  318. package/websql/lib/converter/query-converter.d.ts +3 -0
  319. package/websql/lib/converter/result-converter.d.ts +3 -0
  320. package/websql/lib/converter/sql-converter.d.ts +3 -0
  321. package/websql/lib/converter/type-converter.d.ts +5 -0
  322. package/websql/lib/converter/types.d.ts +6 -0
  323. package/websql/lib/index.d.ts +26 -0
  324. package/websql/package.json +25 -0
  325. package/websql/public-api.d.ts +2 -0
@@ -0,0 +1,877 @@
1
+ import { Log } from 'ng2-logger/websql';
2
+
3
+ class QueryCondition {
4
+ }
5
+ ;
6
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/condition/query-condition.ts
7
+
8
+ class QueryConditionChain extends QueryCondition {
9
+ constructor(sibling, child, chainType) {
10
+ super();
11
+ this._parenthesis = false;
12
+ this._negation = false;
13
+ this._sibling = sibling;
14
+ this._child = child;
15
+ this._chainType = chainType;
16
+ }
17
+ $() {
18
+ this._parenthesis = true;
19
+ return this;
20
+ }
21
+ not() {
22
+ this._negation = true;
23
+ return this;
24
+ }
25
+ and(condition) {
26
+ return new QueryConditionChain(this, condition, 'and');
27
+ }
28
+ or(condition) {
29
+ return new QueryConditionChain(this, condition, 'or');
30
+ }
31
+ }
32
+ ;
33
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/condition/query-condition-chain.ts
34
+
35
+ class QueryColumnCondition extends QueryCondition {
36
+ constructor(column, type, ...values) {
37
+ super();
38
+ this._column = column;
39
+ this._type = type;
40
+ this._values = values;
41
+ }
42
+ and(condition) {
43
+ return new QueryConditionChain(this, condition, 'and');
44
+ }
45
+ or(condition) {
46
+ return new QueryConditionChain(this, condition, 'or');
47
+ }
48
+ }
49
+ ;
50
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/condition/query-column-condition.ts
51
+
52
+ class QueryColumn {
53
+ constructor(_table, _name, _modifiers = []) {
54
+ this._table = _table;
55
+ this._name = _name;
56
+ this._modifiers = _modifiers;
57
+ }
58
+ as(alias) {
59
+ return new this.constructor(this._table, this._name, this._modifiers.concat({ name: 'as', params: alias }));
60
+ }
61
+ isNull() {
62
+ return new QueryColumnCondition(this, 'is-null');
63
+ }
64
+ isNotNull() {
65
+ return new QueryColumnCondition(this, 'is-not-null');
66
+ }
67
+ }
68
+ ;
69
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/column/query-column.ts
70
+
71
+ class QueryOrdering {
72
+ constructor(column, direction) {
73
+ this._column = column;
74
+ this._direction = direction;
75
+ }
76
+ nullsFirst() {
77
+ this._nullsPosition = 'FIRST';
78
+ return this;
79
+ }
80
+ nullsLast() {
81
+ this._nullsPosition = 'LAST';
82
+ return this;
83
+ }
84
+ }
85
+ ;
86
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/other/query-ordering.ts
87
+
88
+ class QueryJoinCondition extends QueryCondition {
89
+ constructor(column, type, otherColumn) {
90
+ super();
91
+ this._column = column;
92
+ this._type = type;
93
+ this._otherColumn = otherColumn;
94
+ }
95
+ and(condition) {
96
+ return new QueryConditionChain(this, condition, 'and');
97
+ }
98
+ or(condition) {
99
+ return new QueryConditionChain(this, condition, 'or');
100
+ }
101
+ }
102
+ ;
103
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/condition/query-join-condition.ts
104
+
105
+ class ValueColumn extends QueryColumn {
106
+ constructor(table, name, modifiers = []) {
107
+ super(table, name, modifiers);
108
+ }
109
+ asc() {
110
+ return new QueryOrdering(this, 'ASC');
111
+ }
112
+ desc() {
113
+ return new QueryOrdering(this, 'DESC');
114
+ }
115
+ eq(value) {
116
+ if (value instanceof QueryColumn) {
117
+ return new QueryJoinCondition(this, 'eq', value);
118
+ }
119
+ else {
120
+ return new QueryColumnCondition(this, 'eq', value);
121
+ }
122
+ }
123
+ ne(value) {
124
+ return new QueryColumnCondition(this, 'ne', value);
125
+ }
126
+ }
127
+ ;
128
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/column/value-column.ts
129
+
130
+ class ComparableColumn extends ValueColumn {
131
+ constructor(table, name, modifiers = []) {
132
+ super(table, name, modifiers);
133
+ }
134
+ lt(value) {
135
+ return new QueryColumnCondition(this, 'lt', value);
136
+ }
137
+ gt(value) {
138
+ return new QueryColumnCondition(this, 'gt', value);
139
+ }
140
+ lte(value) {
141
+ return new QueryColumnCondition(this, 'lte', value);
142
+ }
143
+ gte(value) {
144
+ return new QueryColumnCondition(this, 'gte', value);
145
+ }
146
+ in(values) {
147
+ return new QueryColumnCondition(this, 'in', ...values);
148
+ }
149
+ notIn(values) {
150
+ return new QueryColumnCondition(this, 'not-in', ...values);
151
+ }
152
+ between(value1, value2) {
153
+ return new QueryColumnCondition(this, 'between', value1, value2);
154
+ }
155
+ notBetween(value1, value2) {
156
+ return new QueryColumnCondition(this, 'not-between', value1, value2);
157
+ }
158
+ min() {
159
+ return new this.constructor(this._table, this._name, this._modifiers.concat({ name: 'min' }));
160
+ }
161
+ max() {
162
+ return new this.constructor(this._table, this._name, this._modifiers.concat({ name: 'max' }));
163
+ }
164
+ }
165
+ ;
166
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/column/comparable-column.ts
167
+
168
+ class NumberColumn extends ComparableColumn {
169
+ constructor(table, name, modifiers = []) {
170
+ super(table, name, modifiers);
171
+ this._type = 'number';
172
+ }
173
+ count() {
174
+ return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
175
+ }
176
+ sum() {
177
+ return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'sum' }));
178
+ }
179
+ avg() {
180
+ return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'avg' }));
181
+ }
182
+ }
183
+ ;
184
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/column/number-column.ts
185
+
186
+ class BasicColumn extends QueryColumn {
187
+ constructor(table, name, modifiers = []) {
188
+ super(table, name, modifiers);
189
+ }
190
+ count() {
191
+ return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
192
+ }
193
+ }
194
+ ;
195
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/column/basic-column.ts
196
+
197
+ class BooleanColumn extends ValueColumn {
198
+ constructor(table, name, modifiers = []) {
199
+ super(table, name, modifiers);
200
+ this._type = 'boolean';
201
+ }
202
+ count() {
203
+ return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
204
+ }
205
+ }
206
+ ;
207
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/column/boolean-column.ts
208
+
209
+ class DateColumn extends ComparableColumn {
210
+ constructor(table, name, modifiers = []) {
211
+ super(table, name, modifiers);
212
+ this._type = 'date';
213
+ }
214
+ count() {
215
+ return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
216
+ }
217
+ }
218
+ ;
219
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/column/date-column.ts
220
+
221
+ class StringColumn extends ComparableColumn {
222
+ constructor(table, name, modifiers = []) {
223
+ super(table, name, modifiers);
224
+ this._type = 'string';
225
+ }
226
+ count() {
227
+ return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
228
+ }
229
+ lower() {
230
+ return new this.constructor(this._table, this._name, this._modifiers.concat({ name: 'lower' }));
231
+ }
232
+ upper() {
233
+ return new this.constructor(this._table, this._name, this._modifiers.concat({ name: 'upper' }));
234
+ }
235
+ contains(value) {
236
+ return this.like('%' + value + '%');
237
+ }
238
+ startsWith(value) {
239
+ return this.like(value + '%');
240
+ }
241
+ endsWith(value) {
242
+ return this.like('%' + value);
243
+ }
244
+ like(value) {
245
+ return new QueryColumnCondition(this, 'like', value);
246
+ }
247
+ notLike(value) {
248
+ return new QueryColumnCondition(this, 'not-like', value);
249
+ }
250
+ }
251
+ ;
252
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/column/string-column.ts
253
+
254
+ class JoinedTablesChain {
255
+ constructor(_table, _modifier, _parent) {
256
+ this._table = _table;
257
+ this._modifier = _modifier;
258
+ this._parent = _parent;
259
+ }
260
+ on(condition) {
261
+ return new JoinedTables(condition, this);
262
+ }
263
+ }
264
+ ;
265
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/join/joined-tables-chain.ts
266
+
267
+ class JoinedTables {
268
+ constructor(_condition, _parent) {
269
+ this._condition = _condition;
270
+ this._parent = _parent;
271
+ }
272
+ innerJoin(table) {
273
+ return new JoinedTablesChain(table, 'inner', this);
274
+ }
275
+ leftJoin(table) {
276
+ return new JoinedTablesChain(table, 'left', this);
277
+ }
278
+ rightJoin(table) {
279
+ return new JoinedTablesChain(table, 'right', this);
280
+ }
281
+ fullJoin(table) {
282
+ return new JoinedTablesChain(table, 'full', this);
283
+ }
284
+ }
285
+ ;
286
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/join/joined-tables.ts
287
+
288
+ class SelectQuery {
289
+ constructor(_queryProcessor, _tables) {
290
+ this._queryProcessor = _queryProcessor;
291
+ this._tables = _tables;
292
+ this._distinct = false;
293
+ this._conditions = [];
294
+ this._groupBy = [];
295
+ this._having = [];
296
+ this._orderings = [];
297
+ this._columns = [];
298
+ }
299
+ offset(offset) {
300
+ this._offset = offset;
301
+ return this;
302
+ }
303
+ limit(limit) {
304
+ this._limit = limit;
305
+ return this;
306
+ }
307
+ distinct() {
308
+ this._distinct = true;
309
+ return this;
310
+ }
311
+ where(...conditions) {
312
+ this._conditions = conditions;
313
+ return this;
314
+ }
315
+ groupBy(...columns) {
316
+ this._groupBy = columns;
317
+ return this;
318
+ }
319
+ having(...conditions) {
320
+ this._having = conditions;
321
+ return this;
322
+ }
323
+ orderBy(...orderings) {
324
+ this._orderings = orderings;
325
+ return this;
326
+ }
327
+ select(...columns) {
328
+ this._columns = columns;
329
+ this._action = 'select';
330
+ return this._queryProcessor(this);
331
+ }
332
+ }
333
+ ;
334
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/query/select-query.ts
335
+
336
+ class TableConditionQuery {
337
+ constructor(_queryProcessor, _table, _conditions) {
338
+ this._queryProcessor = _queryProcessor;
339
+ this._table = _table;
340
+ this._conditions = _conditions;
341
+ this._columns = [];
342
+ }
343
+ update(entity) {
344
+ this._entity = entity;
345
+ this._action = 'update';
346
+ return this._queryProcessor(this);
347
+ }
348
+ delete() {
349
+ this._action = 'delete';
350
+ return this._queryProcessor(this);
351
+ }
352
+ count() {
353
+ this._columns = [this._table.$all.count()];
354
+ this._action = 'select';
355
+ return this._queryProcessor(this).then((rows) => rows[0]);
356
+ }
357
+ }
358
+ ;
359
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/query/table-condition-query.ts
360
+
361
+ class TableQuery {
362
+ constructor(_queryProcessor, _table) {
363
+ this._queryProcessor = _queryProcessor;
364
+ this._table = _table;
365
+ this._columns = [];
366
+ }
367
+ where(...conditions) {
368
+ return new TableConditionQuery(this._queryProcessor, this._table, conditions);
369
+ }
370
+ insert(param) {
371
+ this._entity = param;
372
+ this._action = 'insert';
373
+ return this._queryProcessor(this);
374
+ }
375
+ deleteAll() {
376
+ this._action = 'delete';
377
+ return this._queryProcessor(this);
378
+ }
379
+ updateAll(entity) {
380
+ this._entity = entity;
381
+ this._action = 'update';
382
+ return this._queryProcessor(this);
383
+ }
384
+ countAll() {
385
+ this._columns = [this._table.$all.count()];
386
+ this._action = 'select';
387
+ return this._queryProcessor(this).then((rows) => rows[0]);
388
+ }
389
+ delete(id) {
390
+ return this._whereId(id).delete().then(count => count > 0);
391
+ }
392
+ update(id, entity) {
393
+ return this._whereId(id).update(entity).then(count => count > 0);
394
+ }
395
+ get(id) {
396
+ let query = this._whereId(id);
397
+ return this._queryProcessor({ _action: 'select', ...query })
398
+ .then((rows) => rows[0]);
399
+ }
400
+ _whereId(id) {
401
+ let $id = this._table.$id;
402
+ if ($id instanceof ValueColumn) {
403
+ return this.where($id.eq(id));
404
+ }
405
+ else {
406
+ return this.where(...Object.keys($id).map(key => this._table[key].eq(id[key])));
407
+ }
408
+ }
409
+ }
410
+ ;
411
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/query/table-query.ts
412
+
413
+ class QuerySource {
414
+ constructor(_queryProcessor) {
415
+ this._queryProcessor = _queryProcessor;
416
+ }
417
+ from(table1, table2, table3) {
418
+ if (table3 != null)
419
+ return new SelectQuery(this._queryProcessor, [table1, table2, table3]);
420
+ else if (table2 != null)
421
+ return new SelectQuery(this._queryProcessor, [table1, table2]);
422
+ return new SelectQuery(this._queryProcessor, [table1]);
423
+ }
424
+ table(table) {
425
+ return new TableQuery(this._queryProcessor, table);
426
+ }
427
+ }
428
+ ;
429
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/query-source.ts
430
+
431
+ class QueryTable {
432
+ constructor(_$name) {
433
+ this._$name = _$name;
434
+ this.$all = new BasicColumn(this, '*');
435
+ }
436
+ innerJoin(table) {
437
+ return new JoinedTablesChain(table, 'inner', this);
438
+ }
439
+ leftJoin(table) {
440
+ return new JoinedTablesChain(table, 'left', this);
441
+ }
442
+ rightJoin(table) {
443
+ return new JoinedTablesChain(table, 'right', this);
444
+ }
445
+ fullJoin(table) {
446
+ return new JoinedTablesChain(table, 'full', this);
447
+ }
448
+ }
449
+ ;
450
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/builder/query-table.ts
451
+
452
+ function number(param) {
453
+ let result = Number(param);
454
+ if (Number.isNaN(result))
455
+ throw new Error('Invalid number parameter in SQL query: ' + param);
456
+ return result;
457
+ }
458
+ function boolean(param) {
459
+ if (typeof param === 'boolean')
460
+ return param;
461
+ if (param instanceof Boolean)
462
+ return param.valueOf();
463
+ if (param === 'true')
464
+ return true;
465
+ if (param === 'false')
466
+ return false;
467
+ throw new Error('Invalid boolean parameter in SQL query: ' + param);
468
+ }
469
+ function date(param) {
470
+ if (param instanceof Date)
471
+ return param; // @ts-ignore
472
+ if (typeof param === 'number' || param instanceof Number)
473
+ return new Date(param);
474
+ if (typeof param === 'string' || param instanceof String) {
475
+ if (Number.isNaN(Date.parse(String(param))))
476
+ throw new Error('Invalid date parameter in SQL query: ' + param); // @ts-ignore
477
+ return new Date(param);
478
+ }
479
+ throw new Error('Invalid date parameter in SQL query: ' + param);
480
+ }
481
+ function string(param) {
482
+ if (typeof param === 'string')
483
+ return param;
484
+ if (param instanceof String)
485
+ return param.valueOf();
486
+ throw new Error('Invalid string parameter in SQL query: ' + param);
487
+ }
488
+ ;
489
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/converter/type-converter.ts
490
+
491
+ function createQueryConverter(paramConverter, options, engine) {
492
+ return convertQuery;
493
+ function convertQuery(query) {
494
+ if (query._action === 'select')
495
+ return convertSelectQuery(query);
496
+ if (query._action === 'delete')
497
+ return convertDeleteQuery(query);
498
+ if (query._action === 'update')
499
+ return convertUpdateQuery(query);
500
+ if (query._action === 'insert')
501
+ return convertInsertQuery(query);
502
+ throw new Error('Unknown query type:' + query._action);
503
+ }
504
+ function convertDeleteQuery(query) {
505
+ let s = 'DELETE FROM ' + convertTable(query._table);
506
+ s += convertConditions(query._conditions);
507
+ return s;
508
+ }
509
+ function convertUpdateQuery(query) {
510
+ let s = 'UPDATE ' + convertTable(query._table) + ' SET ';
511
+ s += convertUpdateSetters(query._table, query._entity);
512
+ s += convertConditions(query._conditions);
513
+ return s;
514
+ }
515
+ function convertUpdateSetters(table, entity) {
516
+ return Object.keys(entity).sort().map(key => {
517
+ let value = entity[key];
518
+ let column = table[key];
519
+ return convertColumnName(column) + ' = ' + convertParam(column, value);
520
+ }).join(', ');
521
+ }
522
+ function convertInsertQuery(query) {
523
+ let items = Array.isArray(query._entity) ? query._entity : [query._entity];
524
+ let keySet = items.reduce((set, item) => {
525
+ Object.keys(item).forEach(key => set.add(key));
526
+ return set;
527
+ }, new Set());
528
+ let keys = Array.from(keySet).sort();
529
+ let s = 'INSERT INTO ' + convertTable(query._table) + ' ';
530
+ s += '(' + keys.map(key => convertColumnName(query._table[key])).join(', ') + ')';
531
+ s += options.lineBreak + 'VALUES ';
532
+ s += items.map(item => convertInsertItem(query._table, item, keys))
533
+ .map((row) => '(' + row + ')').join(', ');
534
+ s += getPgInsertReturningIfNeeded(query);
535
+ return s;
536
+ }
537
+ function getPgInsertReturningIfNeeded(query) {
538
+ if (engine === 'pg' && query._action === 'insert' && !Array.isArray(query._entity) &&
539
+ query._table.$id && query._table.$id._table && query._table.$id._name) {
540
+ return ' RETURNING ' + convertColumnName(query._table.$id);
541
+ }
542
+ return '';
543
+ }
544
+ function convertInsertItem(table, entity, keys) {
545
+ return keys.map(key => {
546
+ let value = entity[key];
547
+ let column = table[key];
548
+ return convertParam(column, value);
549
+ }).join(', ');
550
+ }
551
+ function convertSelectQuery(query) {
552
+ let s = 'SELECT ';
553
+ if (query._distinct) {
554
+ s += 'DISTINCT ';
555
+ }
556
+ if (query._columns == null || query._columns.length === 0) {
557
+ s += '*';
558
+ }
559
+ else {
560
+ s += query._columns.map((column) => convertColumn(column)).join(', ');
561
+ }
562
+ s += options.lineBreak + 'FROM ';
563
+ if (query._tables) {
564
+ s += query._tables.map((table) => table._parent ? convertJoin(table) : convertTable(table)).join(', ');
565
+ }
566
+ else {
567
+ s += convertTable(query._table);
568
+ }
569
+ s += convertConditions(query._conditions);
570
+ if (query._groupBy && query._groupBy.length > 0) {
571
+ s += options.lineBreak + 'GROUP BY ';
572
+ s += query._groupBy.map((column) => convertColumn(column)).join(', ');
573
+ }
574
+ s += convertConditions(query._having, 'HAVING');
575
+ if (query._orderings && query._orderings.length > 0) {
576
+ s += options.lineBreak + 'ORDER BY ';
577
+ s += query._orderings.map((ordering) => convertOrdering(ordering)).join(', ');
578
+ }
579
+ if (query._limit != null) {
580
+ s += options.lineBreak + 'LIMIT ' + number(query._limit);
581
+ }
582
+ if (query._offset != null) {
583
+ s += options.lineBreak + 'OFFSET ' + number(query._offset);
584
+ }
585
+ return s;
586
+ }
587
+ function convertConditions(conditions, keyword = 'WHERE') {
588
+ let s = '';
589
+ if (conditions && conditions.length > 0) {
590
+ s += options.lineBreak + keyword + ' ';
591
+ preprocessConditions(conditions);
592
+ s += conditions.map(condition => convertCondition(condition, true)).join(' AND ');
593
+ }
594
+ return s;
595
+ }
596
+ function convertJoin(joinChain) {
597
+ let items = [];
598
+ while (joinChain) {
599
+ items.push(joinChain);
600
+ joinChain = joinChain._parent;
601
+ }
602
+ let root = items[items.length - 1];
603
+ let s = convertTable(root);
604
+ for (let i = items.length - 2; i >= 0; i -= 2) {
605
+ let table = items[i]._table;
606
+ let modifier = items[i]._modifier;
607
+ let condition = items[i - 1]._condition;
608
+ let param = convertColumn(condition._otherColumn);
609
+ s += ' ' + modifier.toUpperCase() + ' JOIN ' + convertTable(table) + ' ON ' +
610
+ convertColumnCondition(condition, param);
611
+ }
612
+ return s;
613
+ }
614
+ function convertOrdering(ordering) {
615
+ if (ordering._column) {
616
+ let s = convertColumn(ordering._column);
617
+ if (ordering._nullsPosition != null) { // "NULLS FIRST" only exists in PG, this is the general solution
618
+ s += ' IS NULL ' + (ordering._nullsPosition === 'FIRST' ? 'DESC' : 'ASC') + ', ' + s;
619
+ }
620
+ if (ordering._direction === 'ASC')
621
+ s += ' ASC';
622
+ if (ordering._direction === 'DESC')
623
+ s += ' DESC';
624
+ return s;
625
+ }
626
+ else {
627
+ return convertColumn(ordering);
628
+ }
629
+ }
630
+ function convertTable(table) {
631
+ return options.nameEscape + table._$name + options.nameEscape;
632
+ }
633
+ function convertColumn(column) {
634
+ let s = '';
635
+ if (!(column._name === '*' && column._modifiers.length > 0 && column._modifiers[0].name === 'count')) {
636
+ s += convertTable(column._table) + '.';
637
+ }
638
+ s += convertColumnName(column);
639
+ return convertColumnModifiers(s, column);
640
+ }
641
+ function convertColumnModifiers(s, column) {
642
+ if (column._modifiers) {
643
+ column._modifiers.forEach((modifier) => {
644
+ let name = modifier.name;
645
+ if (name === 'lower')
646
+ s = 'LOWER(' + s + ')';
647
+ else if (name === 'upper')
648
+ s = 'UPPER(' + s + ')';
649
+ else if (name === 'count')
650
+ s = 'COUNT(' + s + ')';
651
+ else if (name === 'sum')
652
+ s = 'SUM(' + s + ')';
653
+ else if (name === 'avg')
654
+ s = 'AVG(' + s + ')';
655
+ else if (name === 'min')
656
+ s = 'MIN(' + s + ')';
657
+ else if (name === 'max')
658
+ s = 'MAX(' + s + ')';
659
+ else if (name === 'as')
660
+ s = s + ' AS ' + options.nameEscape + modifier.params + options.nameEscape;
661
+ });
662
+ }
663
+ return s + '';
664
+ }
665
+ function convertColumnName(column) {
666
+ if (column._name === '*')
667
+ return column._name;
668
+ let name = typeof column._name === 'string' ? column._name : column._name.name;
669
+ return options.nameEscape + name + options.nameEscape;
670
+ }
671
+ function preprocessConditions(conditions) {
672
+ conditions.forEach(condition => {
673
+ if (conditions.length > 1 && condition._sibling) {
674
+ condition._parenthesis = true;
675
+ }
676
+ preprocessParams(condition);
677
+ });
678
+ }
679
+ function preprocessParams(condition) {
680
+ if (condition._sibling) {
681
+ preprocessParams(condition._sibling);
682
+ }
683
+ if (!condition._sibling && !condition._child) {
684
+ condition.__param = getConditionParam(condition);
685
+ }
686
+ if (condition._child) {
687
+ preprocessParams(condition._child);
688
+ }
689
+ }
690
+ function convertCondition(condition, root = false) {
691
+ if (!condition._sibling && !condition._child) {
692
+ return convertColumnCondition(condition, condition.__param);
693
+ }
694
+ let s = '';
695
+ if (condition._child) {
696
+ s += convertCondition(condition._child);
697
+ }
698
+ if (condition._sibling) {
699
+ s = convertCondition(condition._sibling, root) + ' ' + condition._chainType.toUpperCase() + ' ' + s;
700
+ }
701
+ if (condition._parenthesis || ((!root || condition._negation) && condition._child)) {
702
+ s = '( ' + s + ' )';
703
+ }
704
+ if (condition._negation) {
705
+ s = 'NOT ' + s;
706
+ }
707
+ return s;
708
+ }
709
+ function convertColumnCondition(condition, param) {
710
+ let s = convertColumn(condition._column);
711
+ s += getConditionString(condition, param);
712
+ return s;
713
+ }
714
+ function getConditionString(condition, param) {
715
+ switch (condition._type) {
716
+ case 'eq': return ' = ' + param;
717
+ case 'ne': return ' <> ' + param;
718
+ case 'lt': return ' < ' + param;
719
+ case 'gt': return ' > ' + param;
720
+ case 'lte': return ' <= ' + param;
721
+ case 'gte': return ' >= ' + param;
722
+ case 'is-null': return ' IS NULL';
723
+ case 'is-not-null': return ' IS NOT NULL';
724
+ case 'like': return ' LIKE ' + param;
725
+ case 'not-like': return ' NOT LIKE ' + param;
726
+ case 'in': return ' IN (' + param + ')';
727
+ case 'not-in': return ' NOT IN (' + param + ')';
728
+ case 'between': return ' BETWEEN ' + param;
729
+ case 'not-between': return ' NOT BETWEEN ' + param;
730
+ default: return '';
731
+ }
732
+ }
733
+ function getConditionParam(condition) {
734
+ let param = '';
735
+ if (condition._otherColumn) {
736
+ param = convertColumn(condition._otherColumn);
737
+ }
738
+ else {
739
+ let _convertParam = (param) => convertParam(condition._column, param);
740
+ if (condition._type === 'in' || condition._type === 'not-in') {
741
+ param = condition._values.map((value) => _convertParam(value)).join(', ');
742
+ }
743
+ else if (condition._type === 'between' || condition._type === 'not-between') {
744
+ param = _convertParam(condition._values[0]) + ' AND ' + _convertParam(condition._values[1]);
745
+ }
746
+ else if (condition._type !== 'is-null' && condition._type !== 'is-not-null') {
747
+ param = _convertParam(condition._values[0]);
748
+ }
749
+ }
750
+ return param;
751
+ }
752
+ function convertParam(column, param) {
753
+ if (param == null)
754
+ return 'NULL';
755
+ return paramConverter(getTypedParam(column._type, param));
756
+ }
757
+ function getTypedParam(type, param) {
758
+ if (type === 'number')
759
+ return number(param);
760
+ else if (type === 'boolean')
761
+ return boolean(param);
762
+ else if (type === 'date')
763
+ return date(param);
764
+ else if (type === 'string')
765
+ return string(param);
766
+ return param;
767
+ }
768
+ }
769
+ ;
770
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/converter/query-converter.ts
771
+
772
+ function convertSubstitutionParam(param) {
773
+ if (param == null)
774
+ return 'NULL';
775
+ if (typeof param === 'string' || param instanceof String) {
776
+ return `'${String(param)}'`;
777
+ }
778
+ else if (typeof param === 'boolean' || param instanceof Boolean) {
779
+ return String(param).toUpperCase();
780
+ }
781
+ else if (param instanceof Date) {
782
+ return `'${param.toISOString()}'`;
783
+ }
784
+ else if (typeof param === 'number' || param instanceof Number) {
785
+ return String(param);
786
+ }
787
+ return `'${JSON.stringify(param)}'`;
788
+ }
789
+ function convertEscapedParam(param) {
790
+ if (typeof param === 'object' && !(param == null || param instanceof String || param instanceof Number ||
791
+ param instanceof Boolean || param instanceof Date)) {
792
+ return JSON.stringify(param);
793
+ }
794
+ return param;
795
+ }
796
+ ;
797
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/converter/param-converter.ts
798
+
799
+ let pgParamConverter = (index) => '$' + index;
800
+ let mySqlParamConverter = (index) => '?';
801
+ function convertSingleParam(param, params, paramConverter) {
802
+ params.push(convertEscapedParam(param));
803
+ return paramConverter(params.length);
804
+ }
805
+ function convertQueryToParameterizedSQL(query, options, engine) {
806
+ let params = [];
807
+ let paramConverter = engine === 'mysql' ? mySqlParamConverter : pgParamConverter;
808
+ let sql = createQueryConverter((param) => convertSingleParam(param, params, paramConverter), options, engine)(query);
809
+ return { sql, params };
810
+ }
811
+ ;
812
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/converter/parameterized-converter.ts
813
+
814
+ function convertQueryToSQL(query, options, engine) {
815
+ return createQueryConverter((param) => convertSubstitutionParam(param), options, engine)(query);
816
+ }
817
+ ;
818
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/converter/sql-converter.ts
819
+
820
+ const log = Log.create('query processor');
821
+ const DEFAULT_OPTIONS = {
822
+ lineBreaks: false,
823
+ parameterized: true,
824
+ logging: true,
825
+ identifierQuote: '"'
826
+ };
827
+ function mySqlTypeCast(field, next) {
828
+ if (field.type == 'TINY' && field.length == 1) { // Boolean
829
+ let value = field.string();
830
+ if (value == '1')
831
+ return true;
832
+ if (value == '0')
833
+ return false;
834
+ return null;
835
+ }
836
+ else if (field.type == 'JSON') {
837
+ let value = field.string();
838
+ return value == null ? null : JSON.parse(value);
839
+ }
840
+ return next();
841
+ }
842
+ function createQueryProcessor(client, _options = {}, engine = 'pg') {
843
+ let options = Object.assign({}, DEFAULT_OPTIONS, _options);
844
+ let queryOptions = {
845
+ lineBreak: options.lineBreaks ? '\n' : ' ',
846
+ nameEscape: _options.identifierQuote || (engine === 'mysql' ? '`' : '"')
847
+ };
848
+ return (query) => {
849
+ if (options.parameterized) {
850
+ let { sql, params } = convertQueryToParameterizedSQL(query, queryOptions, engine);
851
+ return client.query(sql, params);
852
+ }
853
+ else {
854
+ let sql = convertQueryToSQL(query, queryOptions, engine);
855
+ return client.query(sql, undefined);
856
+ }
857
+ };
858
+ }
859
+ ;
860
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/client/query-processor.ts
861
+
862
+ class MySqlQuerySource extends QuerySource {
863
+ constructor(client, options = {}) {
864
+ super(createQueryProcessor(client, options, 'mysql'));
865
+ }
866
+ }
867
+ ;
868
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/client/mysql.ts
869
+
870
+ ({}); // @--end-of-file-for-module=taon-type-sql lib/index.ts
871
+
872
+ /**
873
+ * Generated bundle index. Do not edit.
874
+ */
875
+
876
+ export { BasicColumn, BooleanColumn, ComparableColumn, DateColumn, JoinedTables, JoinedTablesChain, MySqlQuerySource, NumberColumn, QueryColumn, QueryColumnCondition, QueryCondition, QueryConditionChain, QueryJoinCondition, QueryOrdering, QuerySource, QueryTable, SelectQuery, StringColumn, TableConditionQuery, TableQuery, ValueColumn };
877
+ //# sourceMappingURL=taon-type-sql.mjs.map