@lightcone-ai/daemon 0.15.57 → 0.15.58
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.
|
@@ -4,6 +4,7 @@ export const DEFAULT_LIMIT = 200;
|
|
|
4
4
|
export const MAX_LIMIT = 1000;
|
|
5
5
|
|
|
6
6
|
const READ_QUERY_PREFIX = /^(SELECT|SHOW|DESCRIBE|DESC|EXPLAIN|WITH)\b/i;
|
|
7
|
+
const AUTO_LIMIT_PREFIX = /^(SELECT|WITH)\b/i;
|
|
7
8
|
const REQUIRED_DB_KEYS = ['DB_HOST', 'DB_PORT', 'DB_USER', 'DB_PASSWORD', 'DB_NAME'];
|
|
8
9
|
|
|
9
10
|
function trimTrailingSemicolons(sql) {
|
|
@@ -27,6 +28,10 @@ export function isReadQuery(sql) {
|
|
|
27
28
|
return READ_QUERY_PREFIX.test(sql);
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
export function supportsAutoLimit(sql) {
|
|
32
|
+
return AUTO_LIMIT_PREFIX.test(sql);
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
export function hasLimitClause(sql) {
|
|
31
36
|
return /\bLIMIT\b/i.test(sql);
|
|
32
37
|
}
|
|
@@ -36,7 +41,7 @@ export function prepareSql(sql, limit) {
|
|
|
36
41
|
if (!normalizedSql) throw new Error('sql must be a non-empty string');
|
|
37
42
|
|
|
38
43
|
const effectiveLimit = normalizeLimit(limit);
|
|
39
|
-
if (!
|
|
44
|
+
if (!supportsAutoLimit(normalizedSql) || hasLimitClause(normalizedSql)) {
|
|
40
45
|
return {
|
|
41
46
|
sql: normalizedSql,
|
|
42
47
|
limit: effectiveLimit,
|