deno.land / x / pg_mem@2.8.1 / execution / exec-utils.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { QName, Statement, NodeLocation, toSql } from 'https://deno.land/x/pgsql_ast_parser@12.0.1/mod.ts';import { _ISchema, QueryError, _Transaction, _IDb } from '../interfaces-private.ts';
export function checkExistence(schema: _ISchema, name: QName, ifNotExists: boolean | undefined, act: () => void): boolean { // check if object exists const exists = schema.getObject(name, { skipSearch: true, nullIfNotFound: true }); if (exists) { if (ifNotExists) { return false; } throw new QueryError(`relation "${name.name}" already exists`); }
// else, perform operation act(); return true;}


export function locOf(p: Statement): NodeLocation { return p._location ?? { start: 0, end: 0 };}
export abstract class ExecHelper { constructor(private statement: Statement) { }
protected noData(t: _Transaction, name?: string) { return { result: { command: name ?? this.statement.type.toUpperCase(), fields: [], rowCount: 0, rows: [], location: locOf(this.statement), }, state: t, }; }}
pg_mem

Version Info

Tagged at
4 months ago