MCPcopy Create free account
hub / github.com/Effect-TS/effect / exec

Method exec

packages/sql-sqlite-do/test/Client.test.ts:33–55  ·  view source on GitHub ↗
(sql: string)

Source from the content-addressed store, hash-verified

31 }
32
33 exec(sql: string) {
34 this.statements.push(sql)
35 const statement = sql.replace(/\s+/g, " ").trim()
36 if (transactionSql.test(statement)) {
37 throw new Error(`Unsupported transaction SQL: ${statement}`)
38 }
39 const create = /^CREATE TABLE (\w+)/i.exec(statement)
40 if (create !== null) {
41 this.tables.set(create[1], [])
42 return new FakeCursor([])
43 }
44 const insert = /^INSERT INTO (\w+) \(name\) VALUES \('([^']*)'\)$/i.exec(statement)
45 if (insert !== null) {
46 const rows = this.tables.get(insert[1])!
47 rows.push({ id: rows.length + 1, name: insert[2] })
48 return new FakeCursor([])
49 }
50 const select = /^SELECT \* FROM (\w+)$/i.exec(statement)
51 if (select !== null) {
52 return new FakeCursor(this.tables.get(select[1]) ?? [], ["id", "name"])
53 }
54 return new FakeCursor([])
55 }
56}
57
58class FakeDurableObjectStorage {

Callers 13

runIteratorFunction · 0.80
runValuesFunction · 0.80
runCommandFunction · 0.80
processArgsFunction · 0.80
parseCommandLineFunction · 0.80
makeDatePartsFunction · 0.80
parseDotEnvFunction · 0.80
makeFunction · 0.80
decodeFunction · 0.80
fromIsoFunction · 0.80
dateTime.tsFile · 0.80

Calls 2

setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected