Help us shape the future of Go! Take the 2026 Go Developer Survey

cuckle

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

README

cuckle

Go Reference

A structured way to assemble CQL syntax.

Documentation

Overview

Package cuckle builds Cassandra CQL query strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryAggregateCreate

func QueryAggregateCreate(keyspace, aggregate, stateFunc Identifier, parameters []Type, stateType Type, o ...Option) string

func QueryAggregateDrop

func QueryAggregateDrop(keyspace, aggregate Identifier, parameters []Type, o ...Option) string

func QueryBatch

func QueryBatch(counter bool, timestamp int64, queries []string) string

func QueryFunctionCreate

func QueryFunctionCreate(keyspace, function Identifier, parameters []Type, null bool, returns Type, language string, body string, o ...Option) string

func QueryFunctionDrop

func QueryFunctionDrop(keyspace, function Identifier, parameters []Type, o ...Option) string

func QueryIndexCreate

func QueryIndexCreate(keyspace, table, column Identifier, o ...Option) string

func QueryIndexDrop

func QueryIndexDrop(keyspace, index Identifier, o ...Option) string

func QueryKeyspaceAlter

func QueryKeyspaceAlter(keyspace Identifier, properties map[Identifier]Term) string

func QueryKeyspaceCreate

func QueryKeyspaceCreate(keyspace Identifier, properties map[Identifier]Term, o ...Option) string

func QueryKeyspaceDrop

func QueryKeyspaceDrop(keyspace Identifier, o ...Option) string

func QueryRowDelete

func QueryRowDelete(keyspace, table Identifier, where []Relation, o ...Option) string

func QueryRowInsert

func QueryRowInsert(keyspace, table Identifier, columns []Identifier, values []Term, json string, o ...Option) string

func QueryRowSelect

func QueryRowSelect(keyspace, table Identifier, s []Selector, o ...Option) string

func QueryRowUpdate

func QueryRowUpdate(keyspace, table Identifier, assign, where []Relation, o ...Option) string

func QueryTableAlter

func QueryTableAlter(keyspace, table Identifier, properties map[Identifier]Term, o ...Option) string

func QueryTableColumnAdd

func QueryTableColumnAdd(keyspace, table, column Identifier, data Type) string

func QueryTableColumnAlter

func QueryTableColumnAlter(keyspace, table, column Identifier, data Type) string

func QueryTableColumnDrop

func QueryTableColumnDrop(keyspace, table, column Identifier) string

func QueryTableCreate

func QueryTableCreate(keyspace, table Identifier, columns map[Identifier]Type, static map[Identifier]struct{}, partition, cluster []Identifier, o ...Option) string

func QueryTableDrop

func QueryTableDrop(keyspace, table Identifier, o ...Option) string

func QueryTableTruncate

func QueryTableTruncate(keyspace, table Identifier) string

func QueryTriggerCreate

func QueryTriggerCreate(keyspace, table, trigger Identifier, class string, o ...Option) string

func QueryTriggerDrop

func QueryTriggerDrop(keyspace, table Identifier, o ...Option) string

func QueryTypeCreate

func QueryTypeCreate(keyspace, type_ Identifier, fields map[Identifier]Type, o ...Option) string

func QueryTypeDrop

func QueryTypeDrop(keyspace, type_ Identifier, o ...Option) string

func QueryTypeFieldAdd

func QueryTypeFieldAdd(keyspace, type_, field Identifier, data Type) string

func QueryTypeFieldAlter

func QueryTypeFieldAlter(keyspace, type_, field Identifier, data Type) string

func QueryTypeFieldRename

func QueryTypeFieldRename(keyspace, type_, renames map[Identifier]Identifier) string

func QueryViewAlter

func QueryViewAlter(keyspace, view Identifier, o ...Option) string

func QueryViewCreate

func QueryViewCreate(keyspace, table, view Identifier, s []Selector, partition, cluster []Identifier, o ...Option) string

func QueryViewDrop

func QueryViewDrop(keyspace, table Identifier, o ...Option) string

Types

type Constant

type Constant string

Constant is a scalar literal.

func ConstantBoolean

func ConstantBoolean(b bool) Constant

ConstantBoolean returns a Constant for b.

func ConstantFloat

func ConstantFloat(f float64) Constant

ConstantFloat returns a Constant for f.

func ConstantHex

func ConstantHex(b []byte) Constant

ConstantHex returns a Constant for b prefixed by 0x. Two characters represent each byte.

func ConstantInteger

func ConstantInteger(i int64) Constant

ConstantInteger returns a Constant for i.

func ConstantString

func ConstantString(s string) Constant

ConstantString returns a Constant for s.

func ConstantStringEscaped

func ConstantStringEscaped(s string) Constant

ConstantStringEscaped returns a Constant for s.

func ConstantUUID

func ConstantUUID(uuid string) Constant

ConstantUUID returns a Constant for uuid.

type Identifier

type Identifier string

Identifier is a double-quoted identifier.

const (
	FuncAvg             Identifier = "avg"
	FuncDateOf          Identifier = "dateof"
	FuncFromJSON        Identifier = "fromjson"
	FuncMax             Identifier = "max"
	FuncMaxTimeuuid     Identifier = "maxtimeuuid"
	FuncMin             Identifier = "min"
	FuncMinTimeuuid     Identifier = "mintimeuuid"
	FuncNow             Identifier = "now"
	FuncSum             Identifier = "sum"
	FuncToDate          Identifier = "todate"
	FuncToJSON          Identifier = "tojson"
	FuncToken           Identifier = "token"
	FuncToTimestamp     Identifier = "totimestamp"
	FuncToUnixTimestamp Identifier = "tounixtimestamp"
	FuncUnixTimestampOf Identifier = "unixtimestampof"
	FuncUUID            Identifier = "uuid"
)

General functions.

const (
	FuncBlobToASCII     Identifier = "blobtoascii"
	FuncBlobToBigInt    Identifier = "blobtobigint"
	FuncBlobToBoolean   Identifier = "blobtoboolean"
	FuncBlobToCounter   Identifier = "blobtocounter"
	FuncBlobToDate      Identifier = "blobtodate"
	FuncBlobToDecimal   Identifier = "blobtodecimal"
	FuncBlobToDouble    Identifier = "blobtodouble"
	FuncBlobToFloat     Identifier = "blobtofloat"
	FuncBlobToInet      Identifier = "blobtoinet"
	FuncBlobToInt       Identifier = "blobtoint"
	FuncBlobToSmallInt  Identifier = "blobtosmallint"
	FuncBlobToText      Identifier = "blobtotext"
	FuncBlobToTime      Identifier = "blobtotime"
	FuncBlobToTimeUUID  Identifier = "blobtotimeuuid"
	FuncBlobToTimestamp Identifier = "blobtotimestamp"
	FuncBlobToTinyInt   Identifier = "blobtotinyint"
	FuncBlobToUUID      Identifier = "blobtouuid"
	FuncBlobToVarChar   Identifier = "blobtovarchar"
	FuncBlobToVarInt    Identifier = "blobtovarint"
)

Functions that convert from blob to other types.

const (
	FuncASCIIToBlob     Identifier = "asciitoblob"
	FuncBigIntToBlob    Identifier = "biginttoblob"
	FuncBooleanToBlob   Identifier = "booleantoblob"
	FuncCounterToBlob   Identifier = "countertoblob"
	FuncDateToBlob      Identifier = "datetoblob"
	FuncDecimalToBlob   Identifier = "decimaltoblob"
	FuncDoubleToBlob    Identifier = "doubletoblob"
	FuncFloatToBlob     Identifier = "floattoblob"
	FuncInetToBlob      Identifier = "inettoblob"
	FuncIntToBlob       Identifier = "inttoblob"
	FuncSmallIntToBlob  Identifier = "smallinttoblob"
	FuncTextToBlob      Identifier = "texttoblob"
	FuncTimeToBlob      Identifier = "timetoblob"
	FuncTimeUUIDToBlob  Identifier = "timeuuidtoblob"
	FuncTimestampToBlob Identifier = "timestamptoblob"
	FuncTinyIntToBlob   Identifier = "tinyinttoblob"
	FuncUUIDToBlob      Identifier = "uuidtoblob"
	FuncVarCharToBlob   Identifier = "varchartoblob"
	FuncVarIntToBlob    Identifier = "varinttoblob"
)

Functions that convert from other types to blob.

const (
	KeyspaceDurableWrites Identifier = "durable_writes"
	KeyspaceReplication   Identifier = "replication"
)

Keyspace properties.

const (
	TableBaseTimeSeconds              Identifier = "base_time_seconds"
	TableBloomFilterFPChance          Identifier = "bloom_filter_fp_chance"
	TableBucketHigh                   Identifier = "bucket_high"
	TableBucketLow                    Identifier = "bucket_low"
	TableCRCCheckChance               Identifier = "crc_check_chance"
	TableCaching                      Identifier = "caching"
	TableChunkLengthInKB              Identifier = "chunk_length_in_kb"
	TableClass                        Identifier = "class"
	TableComment                      Identifier = "comment"
	TableCompaction                   Identifier = "compaction"
	TableCompression                  Identifier = "compression"
	TableDCLocalReadRepairChance      Identifier = "dclocal_read_repair_chance"
	TableDefaultTimeToLive            Identifier = "default_time_to_live"
	TableEnabled                      Identifier = "enabled"
	TableGCGraceSeconds               Identifier = "gc_grace_seconds"
	TableKeys                         Identifier = "keys"
	TableMaxSSTableAgeDays            Identifier = "max_sstable_age_days"
	TableMaxThreshold                 Identifier = "max_threshold"
	TableMinSSTableSize               Identifier = "min_sstable_size"
	TableMinThreshold                 Identifier = "min_threshold"
	TableReadRepairChance             Identifier = "read_repair_chance"
	TableRowsPerPartition             Identifier = "rows_per_partition"
	TableSSTableSizeInMB              Identifier = "sstable_size_in_mb"
	TableTimestampResolution          Identifier = "timestamp_resolution"
	TableTombstoneCompactionInternal  Identifier = "tombstone_compaction_interval"
	TableTombstoneThreshold           Identifier = "tombstone_threshold"
	TableUncheckedTombstoneCompaction Identifier = "unchecked_tombstone_compaction"
)

Table properties.

func (Identifier) String

func (i Identifier) String() string

type Operator

type Operator string
const (
	OperatorAdd          Operator = "+"
	OperatorContains     Operator = "contains"
	OperatorContainsKey  Operator = "contains key"
	OperatorEqual        Operator = "="
	OperatorGreater      Operator = ">"
	OperatorGreaterEqual Operator = ">="
	OperatorIn           Operator = "in"
	OperatorLess         Operator = "<"
	OperatorLessEqual    Operator = "<="
	OperatorNotEqual     Operator = "!="
	OperatorSubtract     Operator = "-"
)

type Option

type Option map[option]interface{}

Option stores optional query parameters.

var (
	// OptionAllowFiltering allows filtering result rows.
	OptionAllowFiltering Option = Option{/* contains filtered or unexported fields */}

	// OptionClusteringOrder is the ordering of rows on disk.
	OptionClusteringOrder Option = Option{/* contains filtered or unexported fields */}

	// OptionCompactStorage uses a more compact but less flexible layout for tables.
	OptionCompactStorage Option = Option{/* contains filtered or unexported fields */}

	// OptionDistinct removes rows with duplicate partition keys from result rows.
	OptionDistinct Option = Option{/* contains filtered or unexported fields */}

	// OptionIfExists does not execute create queries for existing primary keys.
	OptionIfExists Option = Option{/* contains filtered or unexported fields */}

	// OptionIfNotExists does not execute drop queries for invalid primary keys.
	OptionIfNotExists Option = Option{/* contains filtered or unexported fields */}

	// OptionIndexKeys creates an index on map keys.
	OptionIndexKeys Option = Option{/* contains filtered or unexported fields */}

	// OptionJSON uses JSON for insert and select queries.
	OptionJSON Option = Option{/* contains filtered or unexported fields */}

	// OptionReplace replaces any existing aggregates and functions.
	OptionReplace Option = Option{/* contains filtered or unexported fields */}
)

Options with no parameters.

func OptionAliases

func OptionAliases(aliases map[Identifier]Identifier) Option

OptionAliases returns an Option for column aliases.

func OptionClass

func OptionClass(class string) Option

OptionClass returns an Option for a custom index class.

func OptionClassOptions

func OptionClassOptions(options map[Term]Term) Option

OptionClassOptions returns an Option for custom index class options.

func OptionFinalFunc

func OptionFinalFunc(finalFunc Identifier) Option

OptionFinalFunc returns an Option for an aggregate final function.

func OptionIf

func OptionIf(r ...Relation) Option

OptionIf returns an Option for lightweight transaction conditions.

func OptionInitCond

func OptionInitCond(initCond Term) Option

OptionInitCond returns an Option for an aggregate initial condition.

func OptionLimit

func OptionLimit(limit int) Option

OptionLimit returns an Option for a result row limit.

func OptionName

func OptionName(name Identifier) Option

OptionName returns an Option for a name.

func OptionOrder

func OptionOrder(i []Identifier, o []Order) Option

OptionOrder returns an Option for ordering result rows by columns and directions. There must be the same number of columns and directions.

func OptionProperties

func OptionProperties(options map[Identifier]Term) Option

OptionProperties returns an Option for mapping property keys to values.

func OptionSelectors

func OptionSelectors(s ...Selector) Option

OptionSelectors returns an Option for selecting column values.

func OptionTTL

func OptionTTL(ttl int64) Option

OptionTTL returns an Option for insert and update time-to-lives.

func OptionTimestamp

func OptionTimestamp(timestamp int64) Option

OptionTimestamp returns an Option for insert and update timestamps.

func OptionWhere

func OptionWhere(r ...Relation) Option

OptionWhere returns an Option for conditions.

type Order

type Order string

Order is an ordering direction, either ascending or descending.

const (
	// OrderAscending is ascending order.
	OrderAscending Order = "asc"

	// OrderDescending is descending order.
	OrderDescending Order = "desc"
)

The two orderings.

type Relation

type Relation string

Relation is an infix operation with an operator and two operands.

func NewRelation

func NewRelation(o Operator, left, right Term) Relation

NewRelation returns a new Relation for left, o, and right.

type Selector

type Selector string

Selector selects the result row values.

const (
	// SelectorAll selects all columns.
	SelectorAll Selector = "*"

	// SelectorCount selects the count of all result rows.
	SelectorCount Selector = "count(*)"
)

Simple selectors.

func SelectorAlias

func SelectorAlias(s Selector, alias Identifier) Selector

SelectorAlias returns a Selector for aliasing a Selector.

func SelectorFunc

func SelectorFunc(function Identifier, arguments ...Selector) Selector

SelectorFunc returns a Selector for calling a function with argumnets.

func SelectorIdentifier

func SelectorIdentifier(column Identifier) Selector

SelectorIdentifier returns a Selector for a column.

func SelectorIndex

func SelectorIndex(column Identifier, index Term) Selector

SelectorIndex returns a Selector for indexing a column.

func SelectorTTL

func SelectorTTL(i Identifier) Selector

SelectorTTL returns a Selector for the time-to-live of a column.

func SelectorWriteTime

func SelectorWriteTime(i Identifier) Selector

SelectorWriteTime returns a Selector for the write time of a column.

type Term

type Term string

Term is a value.

func TermConstant

func TermConstant(c Constant) Term

TermConstant returns a Term for a Constant.

func TermFunc

func TermFunc(function Identifier, arguments ...Term) Term

TermFunc returns a Term for calling a function with arguments.

func TermIdentifier

func TermIdentifier(i Identifier) Term

TermIdentifier returns a Term for an Identifier.

func TermIndex

func TermIndex(i Identifier, t Term) Term

TermIndex returns a Term for indexing a column.

func TermList

func TermList(t ...Term) Term

TermList returns a Term for a list.

func TermMap

func TermMap(m map[Term]Term) Term

TermMap returns a Term for a map.

func TermRelation

func TermRelation(r Relation) Term

TermRelation returns a Term for a Relation.

func TermSet

func TermSet(t ...Term) Term

TermSet returns a Term for a set.

func TermTuple

func TermTuple(t ...Term) Term

TermTuple returns a Term for a tuple.

type Type

type Type string

Type is a type.

const (
	TypeAscii     Type = "ascii"
	TypeBigint    Type = "bigint"
	TypeBlob      Type = "blob"
	TypeBoolean   Type = "boolean"
	TypeCounter   Type = "counter"
	TypeDate      Type = "date"
	TypeDecimal   Type = "decimal"
	TypeDouble    Type = "double"
	TypeFloat     Type = "float"
	TypeInet      Type = "inet"
	TypeInt       Type = "int"
	TypeSmallint  Type = "smallint"
	TypeText      Type = "text"
	TypeTime      Type = "time"
	TypeTimestamp Type = "timestamp"
	TypeTimeuuid  Type = "timeuuid"
	TypeTinyint   Type = "tinyint"
	TypeUuid      Type = "uuid"
	TypeVarchar   Type = "varchar"
	TypeVarint    Type = "varint"
)

Built-in types.

func TypeList

func TypeList(element Type) Type

TypeList returns a Type for a list of element.

func TypeMap

func TypeMap(key, value Type) Type

TypeMap returns a Type for a map from key to value.

func TypeSet

func TypeSet(element Type) Type

TypeSet returns a Type for a set of element.

func TypeTuple

func TypeTuple(elements ...Type) Type

TypleTuple returns a Type for a tuple of elements.

type Variable

type Variable string

Variable is a CQL variable.

const VariableAnonymous Variable = "?"

VariableAnonymous is anonymous.

func NewVariable

func NewVariable(name string) Variable

NewVariable returns a Variable for a name.

Jump to

Keyboard shortcuts

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