gouin

package module
v0.0.0-...-1cce59f Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

gouin

Name

Named after Gouin Boulevard in Montreal, Quebec, Canada. Close to where I grew up on the West Island.

Pronunciation

IPA transcription: [ɡwɛ̃]

Want to hear the name? Try it at the phoneme synthesis

Documentation

Index

Constants

View Source
const SEPARATOR = "|"

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialect

type Dialect interface {
	InsertPreparedStatementSql(table string, fields []*Field) (string, error)
	DeleteByPKPreparedStatementSql(table string, pk string, needsQuotes bool) (string, error)
	SelectOneRecordByPKPreparedStatementSql(table string, fields []*Field, pk string, needsQuotes bool) (string, error)
	CreateTableSql(table string, fields []*Field, pk string) (string, error)
	SetEnforceForeignKeys(bool)
	GetEnforceForeignKeys() bool

	SetPragmas([]string)
	GetPragmas() []string

	OpenDB(dataSourceName string) (*sql.DB, error)
}

borrowed from otira https://github.com/gnewton/otira/blob/master/dialect.go

func NewDialectSqlite3

func NewDialectSqlite3() (Dialect, error)

type DialectSqlite3

type DialectSqlite3 struct {
	// contains filtered or unexported fields
}

func (*DialectSqlite3) CreateTableSql

func (d *DialectSqlite3) CreateTableSql(table string, fields []*Field, pk string) (string, error)

func (*DialectSqlite3) DeleteByPKPreparedStatementSql

func (d *DialectSqlite3) DeleteByPKPreparedStatementSql(table string, pk string, needsQuotes bool) (string, error)

func (*DialectSqlite3) GetEnforceForeignKeys

func (t *DialectSqlite3) GetEnforceForeignKeys() bool

func (*DialectSqlite3) GetPragmas

func (t *DialectSqlite3) GetPragmas() []string

func (*DialectSqlite3) InsertPreparedStatementSql

func (d *DialectSqlite3) InsertPreparedStatementSql(table string, fields []*Field) (string, error)

func (*DialectSqlite3) OpenDB

func (d *DialectSqlite3) OpenDB(dataSourceName string) (*sql.DB, error)

func (*DialectSqlite3) SelectOneRecordByPKPreparedStatementSql

func (d *DialectSqlite3) SelectOneRecordByPKPreparedStatementSql(table string, fields []*Field, pk string, needsQuotes bool) (string, error)

func (*DialectSqlite3) SetEnforceForeignKeys

func (t *DialectSqlite3) SetEnforceForeignKeys(enforceForeignKeys bool)

func (*DialectSqlite3) SetPragmas

func (t *DialectSqlite3) SetPragmas(pragmas []string)

type Field

type Field struct {
	// contains filtered or unexported fields
}

func (*Field) CheckValueType

func (f *Field) CheckValueType(v any) error

func (*Field) NeedsQuotes

func (f *Field) NeedsQuotes() bool

type JoinTableInfo

type JoinTableInfo struct {
	// contains filtered or unexported fields
}

type PTable

type PTable interface {
	Name() string
	Fields() []*Field
	PK() *Field
}

type Persister

type Persister struct {
	// contains filtered or unexported fields
}

func NewPersister

func NewPersister(dialect Dialect, db *sql.DB, txSize uint32) (*Persister, error)

func (*Persister) CreateTables

func (p *Persister) CreateTables(tables ...*Table) error

func (*Persister) DeleteByPK

func (p *Persister) DeleteByPK(tab *Table, v any) error

func (*Persister) ExistsByPK

func (p *Persister) ExistsByPK(tab *Table, v any) (bool, error)

func (*Persister) Insert

func (p *Persister) Insert(rec *Record) error

func (*Persister) InsertJoin

func (p *Persister) InsertJoin(jt *Table, leftRec, rightRec *Record) error

Responsible to: 1 - If Right table id is not in cache (not previously saved; key is )

  • Increment right table id counter, add it to cache; assign to right table rec,
  • Assign right table rec PK = right table id counter
  • Save right table rec

2 - Assign jt rt id = right table id counter 3 - Save jt

func (*Persister) JoinTableInsert

func (p *Persister) JoinTableInsert(joinTable *Table, leftRec, rightRec *Record) error

func (*Persister) SelectOneRecordByPK

func (p *Persister) SelectOneRecordByPK(tab *Table, v any, rec *Record) error

func (*Persister) TxBegin

func (p *Persister) TxBegin(tables ...*Table) error

Start a DB transactions

All tables involved in a transaction must be included here, as prepared statements for each table are created here and cached

func (*Persister) TxCommit

func (p *Persister) TxCommit(tables ...*Table) error

type Record

type Record struct {
	// contains filtered or unexported fields
}

func (*Record) GetValue

func (r *Record) GetValue(f *Field) (any, error)

func (*Record) Reset

func (r *Record) Reset() error

func (*Record) Set

func (r *Record) Set(f *Field, v any) error

func (*Record) SetAt

func (r *Record) SetAt(i int, v any) error

func (r *Record) SetAt(i int, v any) error {

type SqlType

type SqlType int
const (
	UNKNOWN SqlType = iota
	Text
	Uint8  //TODO
	Int8   //TODO
	Uint16 //TODO
	Int16  //TODO
	Uint32
	Int32 //TODO
	Uint64
	Int64   //TODO
	Float32 //TODO
	Float64 //TODO
	Boolean
	Time //TODO
)

func (SqlType) String

func (t SqlType) String() string

func (SqlType) ValueToString

func (t SqlType) ValueToString(field *Field, v any) (string, error)

type Table

type Table struct {
	// contains filtered or unexported fields
}

func NewJoinTable

func NewJoinTable(leftTable, rightTable *Table, additionalFields []*Field, rightTableIDCacheKeyFields ...*Field) (*Table, error)

func NewJoinTable(leftTable, rightTable *Table, additionalFields []*Field, rightTableIDCacheKeyFields ...*Field) (*Table, error) {

func (*Table) AddField

func (t *Table) AddField(f *Field) error

func (*Table) JoinRecords

func (t *Table) JoinRecords(leftR, rightR *Record, joinTable *Table, additionalJTfields *Field) ([]*Record, error)

Returns the newly create join record and (if does not already exist) the right record (which is also passed in) Whatever records are return are to be saved

func (*Table) Record

func (t *Table) Record() (*Record, error)

func (*Table) SetPrimaryKey

func (t *Table) SetPrimaryKey(pk *Field) error

func (*Table) String

func (t *Table) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL