drizzle-sybase 2.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -6
- package/dist/columns/index.d.ts +186 -36
- package/dist/columns/index.d.ts.map +1 -1
- package/dist/columns/index.js +113 -23
- package/dist/columns/index.js.map +1 -1
- package/dist/connection.d.ts +77 -157
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +244 -506
- package/dist/connection.js.map +1 -1
- package/dist/datetime.d.ts +15 -0
- package/dist/datetime.d.ts.map +1 -1
- package/dist/datetime.js +25 -0
- package/dist/datetime.js.map +1 -1
- package/dist/db.d.ts +36 -10
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +15 -25
- package/dist/db.js.map +1 -1
- package/dist/dialect.d.ts +24 -0
- package/dist/dialect.d.ts.map +1 -1
- package/dist/dialect.js +63 -9
- package/dist/dialect.js.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/introspect/codegen.d.ts +8 -1
- package/dist/introspect/codegen.d.ts.map +1 -1
- package/dist/introspect/codegen.js +117 -29
- package/dist/introspect/codegen.js.map +1 -1
- package/dist/introspect/fetch.d.ts +9 -2
- package/dist/introspect/fetch.d.ts.map +1 -1
- package/dist/introspect/fetch.js +37 -8
- package/dist/introspect/fetch.js.map +1 -1
- package/dist/introspect/index.d.ts +1 -0
- package/dist/introspect/index.d.ts.map +1 -1
- package/dist/introspect/index.js +8 -5
- package/dist/introspect/index.js.map +1 -1
- package/dist/introspect/type-map.d.ts +17 -8
- package/dist/introspect/type-map.d.ts.map +1 -1
- package/dist/introspect/type-map.js +28 -9
- package/dist/introspect/type-map.js.map +1 -1
- package/dist/native/index.d.ts +4 -1
- package/dist/native/index.d.ts.map +1 -1
- package/dist/native/index.js.map +1 -1
- package/dist/native/sybase_native.darwin-arm64.node +0 -0
- package/dist/native/sybase_native.darwin-x64.node +0 -0
- package/dist/native/sybase_native.linux-arm64.node +0 -0
- package/dist/native/sybase_native.linux-x64.node +0 -0
- package/dist/native/sybase_native.win32-x64.node +0 -0
- package/dist/pool.d.ts +197 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +638 -0
- package/dist/pool.js.map +1 -0
- package/dist/query-builders/delete.d.ts +6 -4
- package/dist/query-builders/delete.d.ts.map +1 -1
- package/dist/query-builders/delete.js +4 -4
- package/dist/query-builders/delete.js.map +1 -1
- package/dist/query-builders/index.d.ts +1 -1
- package/dist/query-builders/index.d.ts.map +1 -1
- package/dist/query-builders/index.js.map +1 -1
- package/dist/query-builders/insert.d.ts +28 -4
- package/dist/query-builders/insert.d.ts.map +1 -1
- package/dist/query-builders/insert.js +8 -5
- package/dist/query-builders/insert.js.map +1 -1
- package/dist/query-builders/select-types.d.ts +132 -0
- package/dist/query-builders/select-types.d.ts.map +1 -0
- package/dist/query-builders/select-types.js +2 -0
- package/dist/query-builders/select-types.js.map +1 -0
- package/dist/query-builders/select.d.ts +54 -34
- package/dist/query-builders/select.d.ts.map +1 -1
- package/dist/query-builders/select.js +99 -92
- package/dist/query-builders/select.js.map +1 -1
- package/dist/query-builders/update.d.ts +7 -5
- package/dist/query-builders/update.d.ts.map +1 -1
- package/dist/query-builders/update.js +4 -4
- package/dist/query-builders/update.js.map +1 -1
- package/dist/session.d.ts +141 -14
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +456 -40
- package/dist/session.js.map +1 -1
- package/dist/sql-classify.d.ts +70 -0
- package/dist/sql-classify.d.ts.map +1 -0
- package/dist/sql-classify.js +189 -0
- package/dist/sql-classify.js.map +1 -0
- package/dist/table.d.ts +85 -3
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +8 -2
- package/dist/table.js.map +1 -1
- package/package.json +9 -8
- package/scripts/clean.ts +4 -3
- package/src/native/binding.c +463 -62
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a raw SQL batch may do, read from its text alone.
|
|
3
|
+
*
|
|
4
|
+
* Used to decide whether a statement can be retried, whether the session needs
|
|
5
|
+
* resetting before a pooled connection is reused, and what may run inside a
|
|
6
|
+
* managed transaction. Every classifier errs on the safe side: literals,
|
|
7
|
+
* quoted identifiers and comments are removed first so their content cannot
|
|
8
|
+
* match, and text that cannot be tokenized is treated as the risky case.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Whether `sql` is safe to re-run after a connection died mid-statement.
|
|
12
|
+
*
|
|
13
|
+
* Conservative by design — a false "no" only skips a retry, a false "yes" could
|
|
14
|
+
* repeat a write. Accepts `select` batches, optionally
|
|
15
|
+
* wrapped in `SET ROWCOUNT` (a common raw-SQL way to cap rows). Literals,
|
|
16
|
+
* quoted identifiers and comments are removed first (see {@link codeOnly}) so
|
|
17
|
+
* their content cannot match; any write keyword or other `SET` option anywhere
|
|
18
|
+
* rejects the batch, as does anything that cannot be tokenized.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare const isReadOnlySql: (sql: string) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether a batch that succeeded may have left the session in a state that
|
|
25
|
+
* must not reach the next user of a pooled connection — an open transaction,
|
|
26
|
+
* chained mode, a ROWCOUNT, another isolation level.
|
|
27
|
+
*
|
|
28
|
+
* Conservative like {@link isReadOnlySql}: a false "yes" costs one round-trip
|
|
29
|
+
* to reset the session, a false "no" could hand someone else an open
|
|
30
|
+
* transaction. Anything that cannot be tokenized counts as "yes".
|
|
31
|
+
*
|
|
32
|
+
* Text cannot prove a reset will run — `SET ROWCOUNT 0` at the end of a batch
|
|
33
|
+
* is skipped by an earlier `RETURN` or error — so no batch is exempt. (The
|
|
34
|
+
* select builder paginates with `TOP`, so its SQL never sets any of this.)
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export declare const mayLeaveSessionState: (sql: string) => boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether a batch may have created a `#temp` table, which outlives the batch
|
|
41
|
+
* and would reach the next user of a pooled connection. Every such name
|
|
42
|
+
* contains `#` and cannot be quoted, so a batch without one creates none
|
|
43
|
+
* (tables created inside a procedure or `exec()` are dropped when it returns).
|
|
44
|
+
* A `#` inside a literal only costs a needless check.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare const mayCreateTempTable: (sql: string) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Whether a batch explicitly ends a transaction: a `COMMIT`, or a `ROLLBACK`
|
|
51
|
+
* that names no savepoint. Inside a managed transaction such a batch is
|
|
52
|
+
* refused before it is sent — checking afterwards is too late, because the
|
|
53
|
+
* statements following it in the same batch have already run in autocommit.
|
|
54
|
+
* `ROLLBACK TRAN <name>` (to a savepoint) is allowed; the transaction is still
|
|
55
|
+
* checked after every statement that could end it, which also catches a
|
|
56
|
+
* procedure that commits internally.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export declare const endsTransaction: (sql: string) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Whether a batch may switch the session's identity (`setuser`). Unlike the
|
|
63
|
+
* rest of the session state there is no restoring it to a known baseline —
|
|
64
|
+
* the original identity may lack the permission to switch back — so a
|
|
65
|
+
* connection that ran one is discarded rather than reused.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
export declare const mayChangeIdentity: (sql: string) => boolean;
|
|
70
|
+
//# sourceMappingURL=sql-classify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-classify.d.ts","sourceRoot":"","sources":["../src/sql-classify.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmFH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,OAa3C,CAAC;AAiBF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,QAAS,MAAM,KAAG,OAGlD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,QAAS,MAAM,KAAG,OAA4B,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,QAAS,MAAM,KAAG,OAY7C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,QAAS,MAAM,KAAG,OAG/C,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a raw SQL batch may do, read from its text alone.
|
|
3
|
+
*
|
|
4
|
+
* Used to decide whether a statement can be retried, whether the session needs
|
|
5
|
+
* resetting before a pooled connection is reused, and what may run inside a
|
|
6
|
+
* managed transaction. Every classifier errs on the safe side: literals,
|
|
7
|
+
* quoted identifiers and comments are removed first so their content cannot
|
|
8
|
+
* match, and text that cannot be tokenized is treated as the risky case.
|
|
9
|
+
*/
|
|
10
|
+
/** Keywords that can change data, schema, or session/transaction state. */
|
|
11
|
+
const WRITE_KEYWORDS = /\b(insert|update|delete|merge|into|exec|execute|create|alter|drop|truncate|grant|revoke|begin|commit|rollback|save|declare|writetext|dump|load|dbcc|kill|shutdown|reconfigure|use|setuser)\b/;
|
|
12
|
+
/**
|
|
13
|
+
* The code of a batch with literals, quoted identifiers and comments blanked
|
|
14
|
+
* out, or `null` when the batch cannot be tokenized reliably.
|
|
15
|
+
*
|
|
16
|
+
* A scanner rather than a regex because ASE block comments nest: in
|
|
17
|
+
* `/* a /* b *\/ ' *\/ delete from t`, the server sees one comment ending
|
|
18
|
+
* at the second `*\/` and then runs the DELETE. A regex closing the comment at
|
|
19
|
+
* the first `*\/` would read `' *\/ ... '` as a string literal and hide it.
|
|
20
|
+
* Anything left unterminated returns `null`, which callers must treat as
|
|
21
|
+
* "unknown".
|
|
22
|
+
*/
|
|
23
|
+
const QUOTE = 39; // '
|
|
24
|
+
const DOUBLE_QUOTE = 34; // "
|
|
25
|
+
const BRACKET = 91; // [
|
|
26
|
+
const DASH = 45; // -
|
|
27
|
+
const SLASH = 47; // /
|
|
28
|
+
const STAR = 42; // *
|
|
29
|
+
const codeOnly = (sql) => {
|
|
30
|
+
// Scans char codes and copies the code between literals and comments in
|
|
31
|
+
// slices; literals and comments themselves are skipped with indexOf.
|
|
32
|
+
const parts = [];
|
|
33
|
+
let segment = 0;
|
|
34
|
+
let i = 0;
|
|
35
|
+
while (i < sql.length) {
|
|
36
|
+
const c = sql.charCodeAt(i);
|
|
37
|
+
let end;
|
|
38
|
+
if (c === QUOTE || c === DOUBLE_QUOTE || c === BRACKET) {
|
|
39
|
+
const close = c === BRACKET ? "]" : sql[i];
|
|
40
|
+
end = i + 1;
|
|
41
|
+
for (;;) {
|
|
42
|
+
end = sql.indexOf(close, end);
|
|
43
|
+
if (end === -1) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
// A doubled closing character is an escaped one, not the end.
|
|
47
|
+
if (sql[end + 1] === close) {
|
|
48
|
+
end += 2;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
end++;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (c === DASH && sql.charCodeAt(i + 1) === DASH) {
|
|
56
|
+
end = sql.indexOf("\n", i);
|
|
57
|
+
if (end === -1) {
|
|
58
|
+
end = sql.length;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (c === SLASH && sql.charCodeAt(i + 1) === STAR) {
|
|
62
|
+
let depth = 1;
|
|
63
|
+
end = i + 2;
|
|
64
|
+
while (depth > 0) {
|
|
65
|
+
const closeAt = sql.indexOf("*/", end);
|
|
66
|
+
if (closeAt === -1) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const open = sql.indexOf("/*", end);
|
|
70
|
+
if (open !== -1 && open < closeAt) {
|
|
71
|
+
depth++;
|
|
72
|
+
end = open + 2;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
depth--;
|
|
76
|
+
end = closeAt + 2;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
i++;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
parts.push(sql.slice(segment, i), " ");
|
|
85
|
+
i = end;
|
|
86
|
+
segment = end;
|
|
87
|
+
}
|
|
88
|
+
parts.push(sql.slice(segment));
|
|
89
|
+
return parts.join("").toLowerCase();
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Whether `sql` is safe to re-run after a connection died mid-statement.
|
|
93
|
+
*
|
|
94
|
+
* Conservative by design — a false "no" only skips a retry, a false "yes" could
|
|
95
|
+
* repeat a write. Accepts `select` batches, optionally
|
|
96
|
+
* wrapped in `SET ROWCOUNT` (a common raw-SQL way to cap rows). Literals,
|
|
97
|
+
* quoted identifiers and comments are removed first (see {@link codeOnly}) so
|
|
98
|
+
* their content cannot match; any write keyword or other `SET` option anywhere
|
|
99
|
+
* rejects the batch, as does anything that cannot be tokenized.
|
|
100
|
+
*
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
export const isReadOnlySql = (sql) => {
|
|
104
|
+
const code = codeOnly(sql);
|
|
105
|
+
if (code === null) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if (!/^\s*(select|set\s+rowcount)\b/.test(code)) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (WRITE_KEYWORDS.test(code)) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
// `SET ROWCOUNT` is the only session option allowed.
|
|
115
|
+
return !/\bset\s+(?!rowcount\b)/.test(code);
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Statements that can leave a transaction open or change the session state
|
|
119
|
+
* the pool resets: transaction control, procedures (which may do either), and
|
|
120
|
+
* the `SET` options {@link SybaseConnection.resetSessionState} covers.
|
|
121
|
+
*/
|
|
122
|
+
const STATE_CHANGING = /\b(begin\s+tran(saction)?|save\s+tran(saction)?|commit|rollback|exec|execute|use|setuser)\b|\bset\s+(rowcount|chained|transaction)\b/;
|
|
123
|
+
/**
|
|
124
|
+
* Words a batch can start with that are not a procedure name. ASE runs a
|
|
125
|
+
* batch whose first word is anything else as `exec <word>`.
|
|
126
|
+
*/
|
|
127
|
+
const KEYWORD_START = /^\s*(select|insert|update|delete|truncate|create|drop|alter|declare|if|while|begin|set|print|raiserror|waitfor|grant|revoke|dbcc|checkpoint|dump|load|readtext|writetext|commit|rollback|save|exec|execute|use|setuser|return|kill|reconfigure|open|fetch|close|deallocate|lock)\b/;
|
|
128
|
+
/**
|
|
129
|
+
* Whether a batch that succeeded may have left the session in a state that
|
|
130
|
+
* must not reach the next user of a pooled connection — an open transaction,
|
|
131
|
+
* chained mode, a ROWCOUNT, another isolation level.
|
|
132
|
+
*
|
|
133
|
+
* Conservative like {@link isReadOnlySql}: a false "yes" costs one round-trip
|
|
134
|
+
* to reset the session, a false "no" could hand someone else an open
|
|
135
|
+
* transaction. Anything that cannot be tokenized counts as "yes".
|
|
136
|
+
*
|
|
137
|
+
* Text cannot prove a reset will run — `SET ROWCOUNT 0` at the end of a batch
|
|
138
|
+
* is skipped by an earlier `RETURN` or error — so no batch is exempt. (The
|
|
139
|
+
* select builder paginates with `TOP`, so its SQL never sets any of this.)
|
|
140
|
+
*
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
143
|
+
export const mayLeaveSessionState = (sql) => {
|
|
144
|
+
const code = codeOnly(sql);
|
|
145
|
+
return code === null || !KEYWORD_START.test(code) || STATE_CHANGING.test(code);
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Whether a batch may have created a `#temp` table, which outlives the batch
|
|
149
|
+
* and would reach the next user of a pooled connection. Every such name
|
|
150
|
+
* contains `#` and cannot be quoted, so a batch without one creates none
|
|
151
|
+
* (tables created inside a procedure or `exec()` are dropped when it returns).
|
|
152
|
+
* A `#` inside a literal only costs a needless check.
|
|
153
|
+
*
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
export const mayCreateTempTable = (sql) => sql.includes("#");
|
|
157
|
+
/**
|
|
158
|
+
* Whether a batch explicitly ends a transaction: a `COMMIT`, or a `ROLLBACK`
|
|
159
|
+
* that names no savepoint. Inside a managed transaction such a batch is
|
|
160
|
+
* refused before it is sent — checking afterwards is too late, because the
|
|
161
|
+
* statements following it in the same batch have already run in autocommit.
|
|
162
|
+
* `ROLLBACK TRAN <name>` (to a savepoint) is allowed; the transaction is still
|
|
163
|
+
* checked after every statement that could end it, which also catches a
|
|
164
|
+
* procedure that commits internally.
|
|
165
|
+
*
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
export const endsTransaction = (sql) => {
|
|
169
|
+
const code = codeOnly(sql);
|
|
170
|
+
if (code === null) {
|
|
171
|
+
// Cannot be tokenized: the server will reject it anyway.
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
return (/\bcommit\b/.test(code) ||
|
|
175
|
+
/\brollback\b(?!\s+tran(saction)?\s+(?!(work|select|insert|update|delete|exec|execute|commit|rollback|begin|end|if|else|while|set|declare|print|return|create|drop|alter|truncate|save|waitfor|raiserror|use|dump|load)\b)[a-z_@#$][\w@#$]*)/.test(code));
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Whether a batch may switch the session's identity (`setuser`). Unlike the
|
|
179
|
+
* rest of the session state there is no restoring it to a known baseline —
|
|
180
|
+
* the original identity may lack the permission to switch back — so a
|
|
181
|
+
* connection that ran one is discarded rather than reused.
|
|
182
|
+
*
|
|
183
|
+
* @internal
|
|
184
|
+
*/
|
|
185
|
+
export const mayChangeIdentity = (sql) => {
|
|
186
|
+
const code = codeOnly(sql);
|
|
187
|
+
return code === null || /\bsetuser\b/.test(code);
|
|
188
|
+
};
|
|
189
|
+
//# sourceMappingURL=sql-classify.js.map
|
|
@@ -0,0 +1 @@
|
|
|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C,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjF,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAW,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAW,EAAW,EAAE;IACtD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,yDAAyD;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CACL,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;QACvB,6OAA6O,CAAC,IAAI,CAChP,IAAI,CACL,CACF,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAW,EAAE;IACxD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,IAAI,KAAK,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnD,CAAC,CAAC"}
|
package/dist/table.d.ts
CHANGED
|
@@ -7,10 +7,84 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Does NOT depend on drizzle-orm/mssql-core.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import type { Column, SQLWrapper } from "drizzle-orm";
|
|
11
|
+
import { SybaseColumnBuilder, type SybaseColumn, type SybaseColumnRead, type SybaseColumnWrite } from "./columns/index.js";
|
|
11
12
|
declare const entityKind: unique symbol;
|
|
12
|
-
|
|
13
|
+
type AnyColumnBuilder = SybaseColumnBuilder<any>;
|
|
14
|
+
/** Flatten an intersection into one object type, for readable hovers. */
|
|
15
|
+
type Simplify<T> = {
|
|
16
|
+
[K in keyof T]: T[K];
|
|
17
|
+
} & {};
|
|
18
|
+
/**
|
|
19
|
+
* How the select builder tells tables apart in types: `owner.name` when an
|
|
20
|
+
* owner was given, the bare name otherwise — the same distinction the SQL
|
|
21
|
+
* makes (`[owner].[name]` vs `[name]`).
|
|
22
|
+
*/
|
|
23
|
+
export type SybaseTableKey<TName extends string, TOwner extends string | undefined> = TOwner extends string ? `${TOwner}.${TName}` : TName;
|
|
24
|
+
/** Built columns of a table, keyed by property name. */
|
|
25
|
+
export type SybaseTableColumns<TKey extends string, TColumns extends Record<string, AnyColumnBuilder>> = {
|
|
26
|
+
[K in keyof TColumns]: SybaseColumn<TColumns[K]["_"], TKey>;
|
|
27
|
+
};
|
|
28
|
+
/** Row a select returns: `null` for every nullable column. */
|
|
29
|
+
type SelectModel<TColumns extends Record<string, AnyColumnBuilder>> = Simplify<{
|
|
30
|
+
[K in keyof TColumns]: SybaseColumnRead<TColumns[K]>;
|
|
31
|
+
}>;
|
|
32
|
+
/** Columns an insert must supply: not null, and nothing else would fill them. */
|
|
33
|
+
type RequiredInsertKey<C extends AnyColumnBuilder> = C["_"]["notNull"] extends true ? C["_"]["hasDefault"] extends true ? false : true : false;
|
|
34
|
+
/**
|
|
35
|
+
* Values an insert accepts. Identity columns are absent — the server assigns
|
|
36
|
+
* them and the insert builder never writes them. A column may be omitted when
|
|
37
|
+
* it is nullable or something supplies a default.
|
|
38
|
+
*/
|
|
39
|
+
type InsertModel<TColumns extends Record<string, AnyColumnBuilder>> = Simplify<{
|
|
40
|
+
[K in keyof TColumns as TColumns[K]["_"]["identity"] extends true ? never : RequiredInsertKey<TColumns[K]> extends true ? K : never]: SybaseColumnWrite<TColumns[K]>;
|
|
41
|
+
} & {
|
|
42
|
+
[K in keyof TColumns as TColumns[K]["_"]["identity"] extends true ? never : RequiredInsertKey<TColumns[K]> extends true ? never : K]?: SybaseColumnWrite<TColumns[K]>;
|
|
43
|
+
}>;
|
|
44
|
+
/** A table defined with {@link sybaseTable}, with its columns as properties. */
|
|
45
|
+
export type SybaseTableWithColumns<TName extends string, TColumns extends Record<string, AnyColumnBuilder>, TOwner extends string | undefined = undefined> = SybaseTable<TName, TOwner> & SybaseTableColumns<SybaseTableKey<TName, TOwner>, TColumns> & {
|
|
46
|
+
/** Row type a select returns (type only). */
|
|
47
|
+
readonly $inferSelect: SelectModel<TColumns>;
|
|
48
|
+
/** Values an insert accepts (type only). */
|
|
49
|
+
readonly $inferInsert: InsertModel<TColumns>;
|
|
50
|
+
};
|
|
51
|
+
/** Any table defined with {@link sybaseTable}. */
|
|
52
|
+
export type AnySybaseTable = SybaseTable<string> & {
|
|
53
|
+
readonly $inferSelect: Record<string, unknown>;
|
|
54
|
+
readonly $inferInsert: Record<string, unknown>;
|
|
55
|
+
};
|
|
56
|
+
/** Row type a select on `T` returns. */
|
|
57
|
+
export type InferSelectModel<T extends AnySybaseTable> = T["$inferSelect"];
|
|
58
|
+
/** Values an insert into `T` accepts. */
|
|
59
|
+
export type InferInsertModel<T extends AnySybaseTable> = T["$inferInsert"];
|
|
60
|
+
/** One row for `insert(T).values(...)`: each value may also be a SQL expression. */
|
|
61
|
+
export type SybaseInsertValues<T extends AnySybaseTable> = {
|
|
62
|
+
[K in keyof T["$inferInsert"]]: T["$inferInsert"][K] | SQLWrapper;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Values for `update(T).set(...)`: any subset of the writable columns, each
|
|
66
|
+
* value possibly a SQL expression. Identity columns cannot be updated.
|
|
67
|
+
*/
|
|
68
|
+
export type SybaseUpdateValues<T extends AnySybaseTable> = {
|
|
69
|
+
[K in keyof T["$inferInsert"]]?: Exclude<T["$inferInsert"][K], undefined> | SQLWrapper;
|
|
70
|
+
};
|
|
71
|
+
export declare class SybaseTable<TName extends string = string, TOwner extends string | undefined = string | undefined> {
|
|
13
72
|
static [entityKind]: string;
|
|
73
|
+
/**
|
|
74
|
+
* Type-level description (phantom: absent at runtime), shaped like
|
|
75
|
+
* drizzle's `TableTypeConfig` so a Sybase table is a drizzle `Table` to the
|
|
76
|
+
* type checker too — as it already is at runtime (`is(table, Table)`). That
|
|
77
|
+
* is what lets drizzle's own helpers (`getTableName`, `getColumns`, ...) take
|
|
78
|
+
* one. `columns` is drizzle's general column type, which is how drizzle
|
|
79
|
+
* treats these columns; the precise types live on the table's properties.
|
|
80
|
+
*/
|
|
81
|
+
readonly _: {
|
|
82
|
+
readonly brand: "Table";
|
|
83
|
+
readonly name: TName;
|
|
84
|
+
readonly schema: TOwner;
|
|
85
|
+
readonly columns: Record<string, Column>;
|
|
86
|
+
readonly dialect: "sybase";
|
|
87
|
+
};
|
|
14
88
|
static Symbol: {
|
|
15
89
|
Name: symbol;
|
|
16
90
|
Schema: symbol;
|
|
@@ -26,6 +100,10 @@ export declare class SybaseTable {
|
|
|
26
100
|
/**
|
|
27
101
|
* Define a Sybase table schema.
|
|
28
102
|
*
|
|
103
|
+
* `owner` qualifies the table as `[owner].[name]` everywhere it is referenced.
|
|
104
|
+
* Leave it unset for tables that should resolve the usual way (the current
|
|
105
|
+
* user's object, then dbo's).
|
|
106
|
+
*
|
|
29
107
|
* @example
|
|
30
108
|
* ```ts
|
|
31
109
|
* const users = sybaseTable("users", {
|
|
@@ -33,8 +111,12 @@ export declare class SybaseTable {
|
|
|
33
111
|
* name: varchar("name", { length: 100 }).notNull(),
|
|
34
112
|
* email: varchar("email", { length: 200 })
|
|
35
113
|
* });
|
|
114
|
+
*
|
|
115
|
+
* const audit = sybaseTable("audit", { id: int("id") }, { owner: "ops" });
|
|
36
116
|
* ```
|
|
37
117
|
*/
|
|
38
|
-
export declare const sybaseTable:
|
|
118
|
+
export declare const sybaseTable: <const TName extends string, TColumns extends Record<string, AnyColumnBuilder>, const TOwner extends string | undefined = undefined>(name: TName, columns: TColumns, options?: {
|
|
119
|
+
owner?: TOwner;
|
|
120
|
+
}) => SybaseTableWithColumns<TName, TColumns, TOwner>;
|
|
39
121
|
export {};
|
|
40
122
|
//# sourceMappingURL=table.d.ts.map
|
package/dist/table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EACL,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAE5B,QAAA,MAAM,UAAU,eAAmC,CAAC;AAiBpD,KAAK,gBAAgB,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;AAEjD,yEAAyE;AACzE,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAC;AAEjD;;;;GAIG;AACH,MAAM,MAAM,cAAc,CACxB,KAAK,SAAS,MAAM,EACpB,MAAM,SAAS,MAAM,GAAG,SAAS,IAC/B,MAAM,SAAS,MAAM,GAAG,GAAG,MAAM,IAAI,KAAK,EAAE,GAAG,KAAK,CAAC;AAEzD,wDAAwD;AACxD,MAAM,MAAM,kBAAkB,CAC5B,IAAI,SAAS,MAAM,EACnB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAC/C;KACD,CAAC,IAAI,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;CAC5D,CAAC;AAEF,8DAA8D;AAC9D,KAAK,WAAW,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,QAAQ,CAAC;KAC5E,CAAC,IAAI,MAAM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iB;IAEpC;;;;;;;OAOG;IACH,SAAiB,CAAC,EAAE;QAClB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;QACxB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;QACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;KAC5B,CAAC;IAGF,MAAM,CAAC,MAAM;;;;;;;;;MASX;IAEF,YAAY,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EASxC;CACF;AAiBD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,WAAW,GACtB,KAAK,CAAC,KAAK,SAAS,MAAM,EAC1B,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACjD,KAAK,CAAC,MAAM,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,QAE7C,KAAK,WACF,QAAQ,YACP;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3B,sBAAsB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAiBhD,CAAC"}
|
package/dist/table.js
CHANGED
|
@@ -62,6 +62,10 @@ Object.setPrototypeOf(SybaseTable, _TableMarker);
|
|
|
62
62
|
/**
|
|
63
63
|
* Define a Sybase table schema.
|
|
64
64
|
*
|
|
65
|
+
* `owner` qualifies the table as `[owner].[name]` everywhere it is referenced.
|
|
66
|
+
* Leave it unset for tables that should resolve the usual way (the current
|
|
67
|
+
* user's object, then dbo's).
|
|
68
|
+
*
|
|
65
69
|
* @example
|
|
66
70
|
* ```ts
|
|
67
71
|
* const users = sybaseTable("users", {
|
|
@@ -69,10 +73,12 @@ Object.setPrototypeOf(SybaseTable, _TableMarker);
|
|
|
69
73
|
* name: varchar("name", { length: 100 }).notNull(),
|
|
70
74
|
* email: varchar("email", { length: 200 })
|
|
71
75
|
* });
|
|
76
|
+
*
|
|
77
|
+
* const audit = sybaseTable("audit", { id: int("id") }, { owner: "ops" });
|
|
72
78
|
* ```
|
|
73
79
|
*/
|
|
74
|
-
export const sybaseTable = (name, columns) => {
|
|
75
|
-
const table = new SybaseTable(name);
|
|
80
|
+
export const sybaseTable = (name, columns, options) => {
|
|
81
|
+
const table = new SybaseTable(name, options?.owner);
|
|
76
82
|
const builtColumns = {};
|
|
77
83
|
for (const [key, builder] of Object.entries(columns)) {
|
|
78
84
|
if (builder instanceof SybaseColumnBuilder) {
|
package/dist/table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACL,mBAAmB,EAIpB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAEpD,iDAAiD;AACjD,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AAC7C,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACjD,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AACxD,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AACnD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;AAChD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAC9C,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;AAC5D,MAAM,kBAAkB,GAAG,MAAM,CA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AC,cAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAEjD,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAKzB,IAAW,EACX,OAAiB,EACjB,OAA4B,EACqB,EAAE;IACnD,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACpD,MAAM,YAAY,GAAiC,EAAE,CAAC;IAEtD,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACrD,IAAI,OAAO,YAAY,mBAAmB,EAAE,CAAC;YAC3C,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACjC,YAAY,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;YACxB,kEAAkE;YACjE,KAAa,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,oDAAoD;IACnD,KAAa,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAE5C,OAAO,KAAwD,CAAC;AAClE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-sybase",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Drizzle ORM driver for Sybase ASE with built-in FreeTDS native bindings",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ase",
|
|
@@ -45,18 +45,19 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/node": "^26.6.
|
|
49
|
-
"concurrently": "^10.0.
|
|
48
|
+
"@types/node": "^26.6.5",
|
|
49
|
+
"concurrently": "^10.0.6",
|
|
50
50
|
"husky": "^9.1.7",
|
|
51
|
-
"node-gyp": "^13.0
|
|
52
|
-
"oxfmt": "^0.
|
|
53
|
-
"oxlint": "^1.
|
|
51
|
+
"node-gyp": "^13.1.0",
|
|
52
|
+
"oxfmt": "^0.74.0",
|
|
53
|
+
"oxlint": "^1.89.0",
|
|
54
54
|
"oxlint-tsgolint": "latest",
|
|
55
55
|
"typescript": "^7.0.2",
|
|
56
|
-
"vitest": "^5.0.
|
|
56
|
+
"vitest": "^5.0.5",
|
|
57
|
+
"zod": "^4.6.7"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
59
|
-
"drizzle-orm": "^1.0.0-rc.
|
|
60
|
+
"drizzle-orm": "^1.0.0-rc.5"
|
|
60
61
|
},
|
|
61
62
|
"engines": {
|
|
62
63
|
"node": ">=24"
|
package/scripts/clean.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import { globSync } from "fs";
|
|
19
19
|
import { rm } from "fs/promises";
|
|
20
|
-
import { relative, resolve, sep } from "path";
|
|
20
|
+
import { isAbsolute, relative, resolve, sep } from "path";
|
|
21
21
|
import { parseArgs } from "util";
|
|
22
22
|
|
|
23
23
|
const { values, positionals: patterns } = parseArgs({
|
|
@@ -47,8 +47,9 @@ const matches = globSync(patterns, {
|
|
|
47
47
|
exclude: path => /(?:^|[\\/])\.git(?:[\\/]|$)/.test(path)
|
|
48
48
|
})
|
|
49
49
|
.map(match => relative(root, resolve(root, match)))
|
|
50
|
-
// Never delete the working directory itself, nor anything outside it.
|
|
51
|
-
|
|
50
|
+
// Never delete the working directory itself, nor anything outside it. On Windows
|
|
51
|
+
// `relative` returns an absolute path for a target on another drive.
|
|
52
|
+
.filter(match => match && match !== ".." && !match.startsWith(".." + sep) && !isAbsolute(match))
|
|
52
53
|
.sort();
|
|
53
54
|
|
|
54
55
|
// Drop matches nested inside another match — deleting the parent removes them
|