@ignisia/sql 0.4.0 → 0.4.2

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 (93) hide show
  1. package/dist/cjs/database/alter.d.cts +2 -2
  2. package/dist/cjs/database/column.d.cts +2 -2
  3. package/dist/cjs/database/contract.d.cts +2 -2
  4. package/dist/cjs/database/index.d.cts +2 -2
  5. package/dist/cjs/database/table.d.cts +2 -2
  6. package/dist/cjs/database/types.d.cts +1 -1
  7. package/dist/cjs/database/wrapper.d.cts +1 -1
  8. package/dist/cjs/{index-CHxuUiO4.d.cts → index-CY-nPZED.d.cts} +102 -74
  9. package/dist/cjs/{index-CZhrzE5r.d.cts → index-DQRamRz3.d.cts} +1 -1
  10. package/dist/cjs/index.d.cts +2 -2
  11. package/dist/cjs/migration/index.d.cts +2 -2
  12. package/dist/cjs/migration/type.d.cts +2 -2
  13. package/dist/cjs/query/ast.d.cts +8 -0
  14. package/dist/cjs/query/ast.js +2 -0
  15. package/dist/cjs/query/builder.d.cts +3 -3
  16. package/dist/cjs/query/builder.js +8 -10
  17. package/dist/cjs/query/compiler.d.cts +13 -0
  18. package/dist/cjs/query/compiler.js +114 -0
  19. package/dist/cjs/query/condition/common.d.cts +16 -11
  20. package/dist/cjs/query/condition/common.js +0 -12
  21. package/dist/cjs/query/condition/core.d.cts +1 -1
  22. package/dist/cjs/query/condition/core.js +67 -33
  23. package/dist/cjs/query/condition/index.d.cts +2 -2
  24. package/dist/cjs/query/condition/index.js +0 -7
  25. package/dist/cjs/query/condition/not.d.cts +15 -3
  26. package/dist/cjs/query/constants.d.cts +8 -9
  27. package/dist/cjs/query/constants.js +9 -10
  28. package/dist/cjs/query/contract.d.cts +1 -1
  29. package/dist/cjs/query/explain.d.cts +1 -1
  30. package/dist/cjs/query/explain.js +1 -1
  31. package/dist/cjs/query/helper.d.cts +1 -1
  32. package/dist/cjs/query/helper.js +0 -4
  33. package/dist/cjs/query/index.d.cts +3 -3
  34. package/dist/cjs/query/index.js +1 -11
  35. package/dist/cjs/query/join.d.cts +5 -5
  36. package/dist/cjs/query/join.js +19 -11
  37. package/dist/cjs/query/sql.d.cts +2 -2
  38. package/dist/cjs/query/sql.js +39 -22
  39. package/dist/cjs/query/types.d.cts +1 -1
  40. package/dist/cjs/query/utilities.d.cts +4 -6
  41. package/dist/cjs/query/utilities.js +0 -116
  42. package/dist/cjs/table/index.d.cts +1 -1
  43. package/dist/cjs/table/types.d.cts +1 -1
  44. package/dist/cjs/table/utilities.d.cts +1 -1
  45. package/dist/esm/database/alter.d.ts +2 -2
  46. package/dist/esm/database/column.d.ts +2 -2
  47. package/dist/esm/database/contract.d.ts +2 -2
  48. package/dist/esm/database/index.d.ts +2 -2
  49. package/dist/esm/database/table.d.ts +2 -2
  50. package/dist/esm/database/types.d.ts +1 -1
  51. package/dist/esm/database/wrapper.d.ts +1 -1
  52. package/dist/esm/{index-DgOs61lH.d.ts → index-BWg1JZRt.d.ts} +1 -1
  53. package/dist/esm/{index-CjurLJdK.d.ts → index-CsVPGz2o.d.ts} +102 -74
  54. package/dist/esm/index.d.ts +2 -2
  55. package/dist/esm/migration/index.d.ts +2 -2
  56. package/dist/esm/migration/type.d.ts +2 -2
  57. package/dist/esm/query/ast.d.ts +8 -0
  58. package/dist/esm/query/ast.js +1 -0
  59. package/dist/esm/query/builder.d.ts +3 -3
  60. package/dist/esm/query/builder.js +8 -10
  61. package/dist/esm/query/compiler.d.ts +13 -0
  62. package/dist/esm/query/compiler.js +112 -0
  63. package/dist/esm/query/condition/common.d.ts +16 -11
  64. package/dist/esm/query/condition/common.js +1 -12
  65. package/dist/esm/query/condition/core.d.ts +1 -1
  66. package/dist/esm/query/condition/core.js +68 -34
  67. package/dist/esm/query/condition/index.d.ts +2 -2
  68. package/dist/esm/query/condition/index.js +0 -1
  69. package/dist/esm/query/condition/not.d.ts +15 -3
  70. package/dist/esm/query/constants.d.ts +8 -9
  71. package/dist/esm/query/constants.js +9 -11
  72. package/dist/esm/query/contract.d.ts +1 -1
  73. package/dist/esm/query/explain.d.ts +1 -1
  74. package/dist/esm/query/explain.js +1 -1
  75. package/dist/esm/query/helper.d.ts +1 -1
  76. package/dist/esm/query/helper.js +1 -4
  77. package/dist/esm/query/index.d.ts +3 -3
  78. package/dist/esm/query/index.js +2 -12
  79. package/dist/esm/query/join.d.ts +5 -5
  80. package/dist/esm/query/join.js +19 -11
  81. package/dist/esm/query/sql.d.ts +2 -2
  82. package/dist/esm/query/sql.js +40 -23
  83. package/dist/esm/query/types.d.ts +1 -1
  84. package/dist/esm/query/utilities.d.ts +4 -6
  85. package/dist/esm/query/utilities.js +2 -116
  86. package/dist/esm/table/index.d.ts +1 -1
  87. package/dist/esm/table/types.d.ts +1 -1
  88. package/dist/esm/table/utilities.d.ts +1 -1
  89. package/package.json +4 -4
  90. package/dist/cjs/query/condition/raw.d.cts +0 -8
  91. package/dist/cjs/query/condition/raw.js +0 -54
  92. package/dist/esm/query/condition/raw.d.ts +0 -8
  93. package/dist/esm/query/condition/raw.js +0 -50
@@ -1,8 +1,9 @@
1
1
  import { Dialect } from '../table/constants.js';
2
2
  import { buildDeleteQuery, buildUpdateQuery, buildInsertQuery, buildSelectQuery } from './builder.js';
3
+ import { compileJoin, compileAst } from './compiler.js';
3
4
  import { QueryType, QueryHooksType } from './constants.js';
4
5
  import { buildExplainQuery } from './explain.js';
5
- import { getWhereConditions, getGroupByConditions, sanitizeParams, parseAliasedRow } from './utilities.js';
6
+ import { getGroupByConditions, sanitizeParams, parseAliasedRow } from './utilities.js';
6
7
 
7
8
  // src/query/sql.ts
8
9
  function buildQuery(query) {
@@ -12,17 +13,18 @@ function buildQuery(query) {
12
13
  return `$${index}`;
13
14
  });
14
15
  }
15
- function toQuery(dialect) {
16
+ function toQuery(dialect = this.table.dialect) {
17
+ const params = [];
16
18
  const parts = [];
17
19
  switch (this.definition.queryType) {
18
20
  case QueryType.SELECT:
19
21
  parts.push(buildSelectQuery(this));
20
22
  break;
21
23
  case QueryType.INSERT:
22
- parts.push(buildInsertQuery(this));
24
+ parts.push(buildInsertQuery(this, params));
23
25
  break;
24
26
  case QueryType.UPDATE:
25
- parts.push(buildUpdateQuery(this));
27
+ parts.push(buildUpdateQuery(this, params));
26
28
  break;
27
29
  case QueryType.DELETE:
28
30
  parts.push(buildDeleteQuery(this));
@@ -31,33 +33,39 @@ function toQuery(dialect) {
31
33
  throw new Error("No query type defined");
32
34
  }
33
35
  if (this.definition?.joins?.length) {
34
- parts.push(this.definition.joins.join(" "));
36
+ const joinParts = this.definition.joins.map(
37
+ (join) => compileJoin(dialect, join, params)
38
+ );
39
+ parts.push(...joinParts);
35
40
  }
36
- const whereConditions = getWhereConditions(this);
37
- if (whereConditions.length) {
38
- parts.push(`WHERE ${whereConditions.join(" ")}`);
41
+ if (this.definition.where) {
42
+ const whereConditions = compileAst(dialect, this.definition.where, params);
43
+ parts.push(`WHERE ${whereConditions}`);
39
44
  }
40
45
  const groupByConditions = getGroupByConditions(this);
41
46
  if (groupByConditions.length) {
42
47
  parts.push(`GROUP BY ${groupByConditions.join(", ")}`);
43
48
  }
44
- if (this.definition?.having?.length) {
45
- parts.push(`HAVING ${this.definition.having.join(" ")}`);
49
+ if (this.definition?.having) {
50
+ const havingConditions = compileAst(
51
+ dialect,
52
+ this.definition.having,
53
+ params
54
+ );
55
+ parts.push(`HAVING ${havingConditions}`);
46
56
  }
47
57
  if (this.definition?.orderBy?.length) {
48
58
  parts.push(
49
59
  `ORDER BY ${this.definition.orderBy.map((order) => `${order.column} ${order.direction}`).join(", ")}`
50
60
  );
51
61
  }
52
- if (this.definition?.limit !== null) {
62
+ if (this.definition?.limit != null) {
53
63
  parts.push("LIMIT ?");
54
- if (!this.definition.params) this.definition.params = [];
55
- this.definition.params.push(this.definition.limit);
64
+ params.push(this.definition.limit);
56
65
  }
57
- if (this.definition?.offset !== null) {
66
+ if (this.definition?.offset != null) {
58
67
  parts.push("OFFSET ?");
59
- if (!this.definition.params) this.definition.params = [];
60
- this.definition.params.push(this.definition.offset);
68
+ params.push(this.definition.offset);
61
69
  }
62
70
  if (this.definition.queryType === QueryType.UPDATE || this.definition.queryType === QueryType.DELETE) {
63
71
  if (dialect !== Dialect.MYSQL) {
@@ -65,7 +73,7 @@ function toQuery(dialect) {
65
73
  }
66
74
  }
67
75
  const sql = buildQuery(parts.join(" "));
68
- return { query: `${sql};`, params: this.definition.params };
76
+ return { query: `${sql};`, params };
69
77
  }
70
78
  function toString() {
71
79
  return this.toQuery().query;
@@ -121,15 +129,24 @@ async function exec(tx) {
121
129
  });
122
130
  }
123
131
  }
124
- let result = await client.exec({
132
+ let result = [];
133
+ let mySqlResult = [];
134
+ if (isMySQL && isDelete) {
135
+ const query2 = this.clone().select(`${this.table.name}.*`);
136
+ mySqlResult = await client.exec({
137
+ sql: query2.toQuery().query,
138
+ params,
139
+ tx
140
+ });
141
+ }
142
+ result = await client.exec({
125
143
  sql: query,
126
144
  params,
127
145
  tx
128
146
  });
129
- if (isMySQL && isReturning) {
130
- const query2 = this.clone();
131
- query2.definition.queryType = QueryType.SELECT;
132
- result = await client.exec({
147
+ if (isMySQL && isUpdate) {
148
+ const query2 = this.clone().select(`${this.table.name}.*`);
149
+ mySqlResult = await client.exec({
133
150
  sql: query2.toQuery().query,
134
151
  params,
135
152
  tx
@@ -145,7 +162,7 @@ async function exec(tx) {
145
162
  });
146
163
  }
147
164
  }
148
- return result.map(
165
+ return (isMySQL && isReturning ? mySqlResult : result).map(
149
166
  (r) => parseAliasedRow({
150
167
  row: r,
151
168
  selects: this.definition.select ?? [],
@@ -1,7 +1,7 @@
1
1
  import 'bun';
2
2
  import '../column/index.js';
3
3
  import '../column/constants.js';
4
- export { u as AcceptedInsertValues, t as AcceptedOrderBy, v as AcceptedUpdateValues, w as AggregateColumn, A as AliasedColumn, C as ColumnSelector, E as ExplainOptions, Q as QueryDefinition, p as QueryHooks, y as QueryOutput, s as QueryRunHooks, z as QueryRunHooksOptions, R as RawColumn, x as SelectQueryOutput, m as SelectableColumn, k as StrictColumnSelector, W as WhereValue } from '../index-CjurLJdK.js';
4
+ export { r as AcceptedInsertValues, q as AcceptedOrderBy, s as AcceptedUpdateValues, t as AggregateColumn, A as AliasedColumn, C as ColumnSelector, E as ExplainOptions, Q as QueryDefinition, n as QueryHooks, v as QueryOutput, p as QueryRunHooks, w as QueryRunHooksOptions, R as RawColumn, u as SelectQueryOutput, d as SelectableColumn, S as StrictColumnSelector, W as WhereValue } from '../index-CsVPGz2o.js';
5
5
  import '../types.js';
6
6
  import './constants.js';
7
7
  import '../table/constants.js';
@@ -1,17 +1,16 @@
1
- import { T as Table, W as WhereValue, Q as QueryDefinition, C as ColumnSelector, k as StrictColumnSelector, l as QueryBuilder, A as AliasedColumn, m as SelectableColumn } from '../index-CjurLJdK.js';
1
+ import { T as Table, Q as QueryDefinition, C as ColumnSelector, S as StrictColumnSelector, c as QueryBuilder, A as AliasedColumn, d as SelectableColumn } from '../index-CsVPGz2o.js';
2
2
  import { Column } from '../column/index.js';
3
- import { Dialect } from '../table/constants.js';
4
- import { AcceptedOperator } from './constants.js';
5
3
  import 'bun';
6
4
  import '../types.js';
5
+ import './constants.js';
7
6
  import '../column/constants.js';
7
+ import '../table/constants.js';
8
8
  import '../column/types.js';
9
9
 
10
10
  declare function getTableColumnNames<ColName extends string, BaseAlias extends string, BaseTable extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>>(column: ColName, baseAlias: BaseAlias, baseTable: BaseTable, joinedTables: JoinedTables): {
11
11
  from: string;
12
12
  columns: string[];
13
13
  };
14
- declare function getCondition<DbDialect extends Dialect, ColName extends string, Operator extends AcceptedOperator, Value extends WhereValue<Column>[Operator]>(dialect: DbDialect, column: ColName, operator: Operator, value: Value): string;
15
14
  declare function getTimestamp<TableRef extends Table<string, Record<string, Column>>>(table: TableRef): {
16
15
  isWithTimestamp: boolean;
17
16
  timestamp: Date;
@@ -25,7 +24,6 @@ declare function getParanoid<TableRef extends Table<string, Record<string, Colum
25
24
  timestamp: Date;
26
25
  deletedAt: string;
27
26
  };
28
- declare function getWhereConditions<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>, Query extends QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>>(q: Query): string[];
29
27
  declare function getGroupByConditions<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>, Query extends QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>>(q: Query): (string | AliasedColumn<ColumnSelector<Alias, TableRef, JoinedTables>, string>)[];
30
28
  declare function getTableSelectName<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>, Query extends QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>>(q: Query): string;
31
29
  declare function parseAliasedRow({ row, selects, root, }: {
@@ -35,4 +33,4 @@ declare function parseAliasedRow({ row, selects, root, }: {
35
33
  }): Record<string, any>;
36
34
  declare function sanitizeParams(params: unknown[]): (string | number | bigint | boolean | null)[];
37
35
 
38
- export { getCondition, getGroupByConditions, getParanoid, getTableColumnNames, getTableSelectName, getTimestamp, getWhereConditions, parseAliasedRow, sanitizeParams };
36
+ export { getGroupByConditions, getParanoid, getTableColumnNames, getTableSelectName, getTimestamp, parseAliasedRow, sanitizeParams };
@@ -1,7 +1,6 @@
1
1
  import './index.js';
2
- import { Dialect } from '../table/constants.js';
3
2
  import { quoteIdentifier } from '../utilities.js';
4
- import { AcceptedOperator, QueryType } from './constants.js';
3
+ import { QueryType } from './constants.js';
5
4
 
6
5
  // src/query/utilities.ts
7
6
  function getTableColumnNames(column, baseAlias, baseTable, joinedTables) {
@@ -14,102 +13,6 @@ function getTableColumnNames(column, baseAlias, baseTable, joinedTables) {
14
13
  columns
15
14
  };
16
15
  }
17
- function getCondition(dialect, column, operator, value) {
18
- switch (operator) {
19
- case AcceptedOperator.EQ:
20
- return `${column} = ?`;
21
- case AcceptedOperator.NE:
22
- return `${column} != ?`;
23
- case AcceptedOperator.GT:
24
- return `${column} > ?`;
25
- case AcceptedOperator.LT:
26
- return `${column} < ?`;
27
- case AcceptedOperator.GTE:
28
- return `${column} >= ?`;
29
- case AcceptedOperator.LTE:
30
- return `${column} <= ?`;
31
- case AcceptedOperator.IN:
32
- return `${column} IN (${value.map(() => "?").join(", ")})`;
33
- case AcceptedOperator.NOT_IN:
34
- return `${column} NOT IN (${value.map(() => "?").join(", ")})`;
35
- case AcceptedOperator.LIKE:
36
- return `${column} LIKE ?`;
37
- case AcceptedOperator.NOT_LIKE:
38
- return `${column} NOT LIKE ?`;
39
- case AcceptedOperator.ILIKE:
40
- if (dialect === Dialect.POSTGRES) {
41
- return `${column} ILIKE ?`;
42
- }
43
- return `LOWER(${column}) LIKE LOWER(?)`;
44
- case AcceptedOperator.NOT_ILIKE:
45
- if (dialect === Dialect.POSTGRES) {
46
- return `${column} NOT ILIKE ?`;
47
- }
48
- return `LOWER(${column}) NOT LIKE LOWER(?)`;
49
- case AcceptedOperator.IS_NULL:
50
- return `${column} IS NULL`;
51
- case AcceptedOperator.IS_NOT_NULL:
52
- return `${column} IS NOT NULL`;
53
- case AcceptedOperator.BETWEEN:
54
- return `${column} BETWEEN ? AND ?`;
55
- case AcceptedOperator.NOT_BETWEEN:
56
- return `${column} NOT BETWEEN ? AND ?`;
57
- case AcceptedOperator.STARTS_WITH:
58
- return `${column} LIKE ?`;
59
- case AcceptedOperator.ENDS_WITH:
60
- return `${column} LIKE ?`;
61
- case AcceptedOperator.REG_EXP: {
62
- switch (dialect) {
63
- case Dialect.POSTGRES:
64
- return `${column} ~ ?`;
65
- case Dialect.MYSQL:
66
- return `${column} REGEXP ?`;
67
- case Dialect.SQLITE:
68
- return `${column} GLOB ?`;
69
- default:
70
- throw new Error("Operator not supported");
71
- }
72
- }
73
- case AcceptedOperator.NOT_REG_EXP: {
74
- switch (dialect) {
75
- case Dialect.POSTGRES:
76
- return `${column} !~ ?`;
77
- case Dialect.MYSQL:
78
- return `${column} NOT REGEXP ?`;
79
- case Dialect.SQLITE:
80
- return `${column} NOT GLOB ?`;
81
- default:
82
- throw new Error("Operator not supported");
83
- }
84
- }
85
- case AcceptedOperator.RLIKE: {
86
- switch (dialect) {
87
- case Dialect.POSTGRES:
88
- return `${column} ~* ?`;
89
- case Dialect.MYSQL:
90
- return `${column} RLIKE ?`;
91
- case Dialect.SQLITE:
92
- return `${column} GLOB ?`;
93
- default:
94
- throw new Error("Operator not supported");
95
- }
96
- }
97
- case AcceptedOperator.NOT_RLIKE: {
98
- switch (dialect) {
99
- case Dialect.POSTGRES:
100
- return `${column} !~* ?`;
101
- case Dialect.MYSQL:
102
- return `${column} NOT RLIKE ?`;
103
- case Dialect.SQLITE:
104
- return `${column} NOT GLOB ?`;
105
- default:
106
- throw new Error("Operator not supported");
107
- }
108
- }
109
- default:
110
- throw new Error("Invalid operator");
111
- }
112
- }
113
16
  function getTimestamp(table) {
114
17
  const isWithTimestamp = !!table.timestamp;
115
18
  const timestamp = /* @__PURE__ */ new Date();
@@ -156,23 +59,6 @@ function getParanoid(table) {
156
59
  deletedAt
157
60
  };
158
61
  }
159
- function getWhereConditions(q) {
160
- if (q.definition.queryType === QueryType.INSERT) return [];
161
- const conditions = [];
162
- const base = q.definition.baseAlias ?? q.table.name;
163
- const { isWithParanoid, deletedAt } = getParanoid(q.table);
164
- const withDeleted = !!q.definition.withDeleted;
165
- const isHasConditions = !!q.definition.where?.length;
166
- if (!withDeleted && isWithParanoid) {
167
- const suffix = isHasConditions ? " AND" : "";
168
- const column = `${base}.${quoteIdentifier(deletedAt)}`;
169
- conditions.unshift(`${column} IS NULL${suffix}`);
170
- }
171
- if (q.definition.where?.length) {
172
- conditions.push(...q.definition.where);
173
- }
174
- return conditions;
175
- }
176
62
  function getGroupByConditions(q) {
177
63
  if (q.definition.queryType !== QueryType.SELECT) return [];
178
64
  if (q.definition.groupBy?.length) return q.definition.groupBy;
@@ -253,4 +139,4 @@ function sanitizeParams(params) {
253
139
  });
254
140
  }
255
141
 
256
- export { getCondition, getGroupByConditions, getParanoid, getTableColumnNames, getTableSelectName, getTimestamp, getWhereConditions, parseAliasedRow, sanitizeParams };
142
+ export { getGroupByConditions, getParanoid, getTableColumnNames, getTableSelectName, getTimestamp, parseAliasedRow, sanitizeParams };
@@ -1,4 +1,4 @@
1
- export { T as Table } from '../index-CjurLJdK.js';
1
+ export { T as Table } from '../index-CsVPGz2o.js';
2
2
  import '../column/index.js';
3
3
  import './constants.js';
4
4
  import 'bun';
@@ -1,5 +1,5 @@
1
1
  import 'bun';
2
- export { X as ExecOptions, M as MergeTimestampParanoid, U as TableOptions, V as TableOutput, f as TimestampOptions } from '../index-CjurLJdK.js';
2
+ export { K as ExecOptions, M as MergeTimestampParanoid, H as TableOptions, I as TableOutput, h as TimestampOptions } from '../index-CsVPGz2o.js';
3
3
  import '../column/index.js';
4
4
  import './constants.js';
5
5
  import '../types.js';
@@ -1,7 +1,7 @@
1
1
  import '../column/constants.js';
2
2
  import '../column/index.js';
3
3
  import './constants.js';
4
- export { K as createdAt, O as defineColumns, N as deletedAt, L as updatedAt } from '../index-CjurLJdK.js';
4
+ export { y as createdAt, F as defineColumns, B as deletedAt, z as updatedAt } from '../index-CsVPGz2o.js';
5
5
  import '../column/types.js';
6
6
  import 'bun';
7
7
  import '../types.js';
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "dist/cjs/index.js",
4
4
  "module": "dist/esm/index.js",
5
5
  "types": "./dist/esm/index.d.ts",
6
- "version": "0.4.0",
6
+ "version": "0.4.2",
7
7
  "type": "module",
8
8
  "exports": {
9
9
  ".": {
@@ -68,10 +68,10 @@
68
68
  ],
69
69
  "repository": {
70
70
  "type": "git",
71
- "url": "git+https://github.com/krsbx/aio-web.git"
71
+ "url": "git+https://github.com/krsbx/ignisia.git"
72
72
  },
73
73
  "bugs": {
74
- "url": "https://github.com/krsbx/aio-web/issues"
74
+ "url": "https://github.com/krsbx/ignisia/issues"
75
75
  },
76
76
  "keywords": [
77
77
  "bun",
@@ -81,4 +81,4 @@
81
81
  "postgres",
82
82
  "mysql"
83
83
  ]
84
- }
84
+ }
@@ -1,8 +0,0 @@
1
- export { c as addRawCondition, e as rawHaving, d as rawOr, r as rawWhere } from '../../index-CHxuUiO4.cjs';
2
- import '../../column/index.cjs';
3
- import '../constants.cjs';
4
- import 'bun';
5
- import '../../types.cjs';
6
- import '../../column/constants.cjs';
7
- import '../../table/constants.cjs';
8
- import '../../column/types.cjs';
@@ -1,54 +0,0 @@
1
- 'use strict';
2
-
3
- var constants = require('../constants');
4
- var helper = require('../helper');
5
-
6
- function addRawCondition(query, clause, column, logical, params) {
7
- const validClause = clause.toLowerCase();
8
- if (!query.definition[validClause]) query.definition[validClause] = [];
9
- const condition = column(helper.rawCol);
10
- const logicalPrefix = query.definition[validClause].length > 0 ? logical : "";
11
- query.definition[validClause].push(`${logicalPrefix} ${condition}`.trim());
12
- if (!query.definition.params) query.definition.params = [];
13
- if (typeof params === "undefined") {
14
- return query;
15
- }
16
- if (Array.isArray(params)) {
17
- query.definition.params.push(...params);
18
- } else {
19
- query.definition.params.push(params);
20
- }
21
- return query;
22
- }
23
- function rawWhere(column, params) {
24
- return addRawCondition(
25
- this,
26
- constants.ConditionClause.WHERE,
27
- column,
28
- constants.LogicalOperator.AND,
29
- params
30
- );
31
- }
32
- function rawOr(column, params) {
33
- return addRawCondition(
34
- this,
35
- constants.ConditionClause.WHERE,
36
- column,
37
- constants.LogicalOperator.OR,
38
- params
39
- );
40
- }
41
- function rawHaving(column, params) {
42
- return addRawCondition(
43
- this,
44
- constants.ConditionClause.HAVING,
45
- column,
46
- constants.LogicalOperator.AND,
47
- params
48
- );
49
- }
50
-
51
- exports.addRawCondition = addRawCondition;
52
- exports.rawHaving = rawHaving;
53
- exports.rawOr = rawOr;
54
- exports.rawWhere = rawWhere;
@@ -1,8 +0,0 @@
1
- export { c as addRawCondition, e as rawHaving, d as rawOr, r as rawWhere } from '../../index-CjurLJdK.js';
2
- import '../../column/index.js';
3
- import '../constants.js';
4
- import 'bun';
5
- import '../../types.js';
6
- import '../../column/constants.js';
7
- import '../../table/constants.js';
8
- import '../../column/types.js';
@@ -1,50 +0,0 @@
1
- import { LogicalOperator, ConditionClause } from '../constants.js';
2
- import { rawCol } from '../helper.js';
3
-
4
- // src/query/condition/raw.ts
5
- function addRawCondition(query, clause, column, logical, params) {
6
- const validClause = clause.toLowerCase();
7
- if (!query.definition[validClause]) query.definition[validClause] = [];
8
- const condition = column(rawCol);
9
- const logicalPrefix = query.definition[validClause].length > 0 ? logical : "";
10
- query.definition[validClause].push(`${logicalPrefix} ${condition}`.trim());
11
- if (!query.definition.params) query.definition.params = [];
12
- if (typeof params === "undefined") {
13
- return query;
14
- }
15
- if (Array.isArray(params)) {
16
- query.definition.params.push(...params);
17
- } else {
18
- query.definition.params.push(params);
19
- }
20
- return query;
21
- }
22
- function rawWhere(column, params) {
23
- return addRawCondition(
24
- this,
25
- ConditionClause.WHERE,
26
- column,
27
- LogicalOperator.AND,
28
- params
29
- );
30
- }
31
- function rawOr(column, params) {
32
- return addRawCondition(
33
- this,
34
- ConditionClause.WHERE,
35
- column,
36
- LogicalOperator.OR,
37
- params
38
- );
39
- }
40
- function rawHaving(column, params) {
41
- return addRawCondition(
42
- this,
43
- ConditionClause.HAVING,
44
- column,
45
- LogicalOperator.AND,
46
- params
47
- );
48
- }
49
-
50
- export { addRawCondition, rawHaving, rawOr, rawWhere };