parse

package
v0.0.0-...-ef1f557 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package parse parses SQL statements for the SimpleDB driver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsID

func IsID(name string) bool

IsID returns true if name corresponds to the special name of the item name column ("id").

Types

type Column

type Column struct {
	ColumnName string  // name of associated column
	Ordinal    int     // zero-based placeholder ordinal
	Value      *string // if non-nil, then a literal value
}

Column represents a column in the query and the placeholder or value it is associated with.

func (*Column) GetValue

func (col *Column) GetValue(values []driver.Value) (driver.Value, error)

GetValue gets the value for a column, either from the placeholder value or the literal value.

type CreateTableQuery

type CreateTableQuery struct {
	TableName string
}

CreateTableQuery is the representation of a create table query.

type DeleteQuery

type DeleteQuery struct {
	TableName string
	Key       Key
}

DeleteQuery is the representation of a delete query.

type DropTableQuery

type DropTableQuery struct {
	TableName string
}

DropTableQuery is the representation of a drop table query.

type InsertQuery

type InsertQuery struct {
	TableName string
	Columns   []Column
	Key       Key
}

InsertQuery is the representation of an insert query.

type Key

type Key struct {
	Ordinal int     // zero-based placeholder ordinal
	Value   *string // if non-nil, then a literal value
}

Key represents the primary key of the record being inserted/updated/deleted.

func (*Key) String

func (key *Key) String(values []driver.Value) (string, error)

String returns the string for the primary key, either from the placeholder values or the literal value.

type Query

type Query struct {
	Select      *SelectQuery
	Insert      *InsertQuery
	Update      *UpdateQuery
	Delete      *DeleteQuery
	CreateTable *CreateTableQuery
	DropTable   *DropTableQuery
}

Query is the representation of a single parsed query.

func Parse

func Parse(query string) (*Query, error)

Parse a query.

type SelectQuery

type SelectQuery struct {
	ConsistentRead bool
	ColumnNames    []string
	TableName      string
	WhereClause    []string // lexemes starting with "WHERE"
	Key            *Key     // if non-nil, indicates a "where id = ?" query
}

SelectQuery is the representation of a select query.

type UpdateQuery

type UpdateQuery struct {
	TableName string
	Upsert    bool
	Columns   []Column
	Key       Key
}

UpdateQuery is the representation of an update query.

Jump to

Keyboard shortcuts

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