dapgx

package module
Version: v0.0.0-...-40d0db8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2021 License: BSD-2-Clause Imports: 18 Imported by: 0

README

dapgx

dapgx provides a PostgreSQL backends for the daql project.

License

Copyright (c) Martin Schnabel. All rights reserved. Use of the source code is governed by a BSD-style license that can found in the LICENSE file.

Documentation

Index

Constants

View Source
const (
	PrecOr
	PrecAnd
	PrecNot
	PrecIs  // , is null, is not null, …
	PrecCmp // <, >, =, <=, >=, <>, !=
	PrecIn  // , between, like, ilike, similar
	PrecDef
	PrecAdd // +, -
	PrecMul // *, /, %
)

Variables

View Source
var External = fmt.Errorf("external symbol")

Functions

func Open

func Open(dsn string, logger pgx.Logger) (*pgxpool.Pool, error)

func Quote

func Quote(text string) string

func TypString

func TypString(t typ.Type) (string, error)

func Unreserved

func Unreserved(name string) (string, bool)

Unreserved returns the lowercase key and whether it is an unreserved identifier. If unreserved returns false the key must be escaped with double quotes.

func WithTx

func WithTx(db DB, f func(C) error) error

func WrapArg

func WrapArg(arg interface{}) interface{}

func WrapPtr

func WrapPtr(reg *lit.Reg, ptr interface{}) interface{}

func WriteCall

func WriteCall(w *Writer, env exp.Env, e *exp.Call) error

WriteCall writes the expression e to w using env or returns an error. Most xelf expressions with resolvers from the core or lib built-ins have a corresponding expression in postgresql. Custom resolvers can be rendered to sql by detecting and handling them before calling this function.

func WriteExp

func WriteExp(w *Writer, env exp.Env, e exp.Exp) error

WriteExp writes the element e to w or returns an error. This is used for explicit selectors for example.

func WriteLit

func WriteLit(b *Writer, l *exp.Lit) error

WriteLit renders the literal l to b or returns an error.

func WriteQuote

func WriteQuote(w *Writer, text string) error

WriteQuote quotes a string as a postgres string, all single quotes are use sql escaping.

func WriteVal

func WriteVal(b *Writer, t typ.Type, l lit.Val) error

Types

type C

type C interface {
	Query(Ctx, string, ...interface{}) (pgx.Rows, error)
	QueryRow(Ctx, string, ...interface{}) pgx.Row
	Exec(Ctx, string, ...interface{}) (pgconn.CommandTag, error)
	CopyFrom(Ctx, pgx.Identifier, []string, pgx.CopyFromSource) (int64, error)
}

type Ctx

type Ctx = context.Context

type DB

type DB interface {
	Begin(Ctx) (pgx.Tx, error)
}

type ExpEnv

type ExpEnv struct{}

func (ExpEnv) Translate

func (ee ExpEnv) Translate(p *exp.Prog, env exp.Env, s *exp.Sym) (string, lit.Val, error)

type MutWrap

type MutWrap struct {
	Mut UnmarshalMut
}

func (*MutWrap) DecodeText

func (m *MutWrap) DecodeText(c *pgtype.ConnInfo, b []byte) error

func (*MutWrap) EncodeText

func (m *MutWrap) EncodeText(c *pgtype.ConnInfo, b []byte) ([]byte, error)

type Param

type Param struct {
	Name  string
	Type  typ.Type
	Value lit.Val
}

type Translator

type Translator interface {
	Translate(*exp.Prog, exp.Env, *exp.Sym) (string, lit.Val, error)
}

type UnmarshalMut

type UnmarshalMut interface {
	lit.Mut
	json.Unmarshaler
}

type Writer

type Writer struct {
	gen.Gen
	Prog *exp.Prog
	Translator
	Params []Param
}

func NewWriter

func NewWriter(b bfr.Writer, pr *dom.Project, p *exp.Prog, t Translator) *Writer

func (*Writer) Translate

func (w *Writer) Translate(p *exp.Prog, env exp.Env, s *exp.Sym) (string, lit.Val, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL