MCPcopy Create free account
hub / github.com/expo/expo / parseSQLQuery

Function parseSQLQuery

packages/expo-sqlite/src/queryUtils.ts:31–55  ·  view source on GitHub ↗
(query: string)

Source from the content-addressed store, hash-verified

29 * ```
30 */
31export function parseSQLQuery(query: string): SQLParsedInfo {
32 // Remove quoted strings to avoid false positives
33 // SQLite uses doubled quotes for escaping: 'don''t' or "test""quote"
34 const cleaned = query
35 .replace(SINGLE_QUOTED_STRING, "''") // Remove single-quoted strings
36 .replace(DOUBLE_QUOTED_STRING, '""'); // Remove double-quoted strings
37
38 // Priority 1: Check for RETURNING (highest priority - makes any query return rows)
39 if (RETURNING_KEYWORD.test(cleaned)) {
40 return { canReturnRows: true };
41 }
42
43 // Priority 2: Check for mutations (these don't return rows unless they have RETURNING)
44 if (MUTATION_KEYWORDS.test(cleaned)) {
45 return { canReturnRows: false };
46 }
47
48 // Priority 3: Check for queries (these return rows)
49 if (QUERY_KEYWORDS.test(cleaned)) {
50 return { canReturnRows: true };
51 }
52
53 // Default: doesn't return rows
54 return { canReturnRows: false };
55}

Callers 2

constructorMethod · 0.90

Calls 2

replaceMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…