MCPcopy Index your code
hub / github.com/simstudioai/sim / executeOrderContaining

Function executeOrderContaining

apps/sim/lib/table/__tests__/lock-order.test.ts:54–71  ·  view source on GitHub ↗

* invocationCallOrder of the first `tx.execute(...)` whose SQL contains * `substring` — checks the template strings, the interpolated values (the * advisory key is passed as a value), and `sql.raw` output.

(substring: string)

Source from the content-addressed store, hash-verified

52 * advisory key is passed as a value), and `sql.raw` output.
53 */
54function executeOrderContaining(substring: string): number {
55 const { calls, invocationCallOrder } = dbChainMockFns.execute.mock
56 for (let i = 0; i < calls.length; i++) {
57 const arg = calls[i][0] as { strings?: unknown; values?: unknown; rawSql?: unknown } | undefined
58 const haystacks: string[] = []
59 if (Array.isArray(arg?.strings)) {
60 haystacks.push(
61 ...(arg.strings as unknown[]).filter((s): s is string => typeof s === 'string')
62 )
63 }
64 if (Array.isArray(arg?.values)) {
65 haystacks.push(...(arg.values as unknown[]).filter((v): v is string => typeof v === 'string'))
66 }
67 if (typeof arg?.rawSql === 'string') haystacks.push(arg.rawSql)
68 if (haystacks.some((s) => s.includes(substring))) return invocationCallOrder[i]
69 }
70 return -1
71}
72
73/** invocationCallOrder of the first `tx.update(table)` call. */
74function updateOrderForTable(table: unknown): number {

Callers 1

lock-order.test.tsFile · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected