utils

package
v1.17.3 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const AllowMapSQLScript = "set allow_experimental_map_type = 1"

Variables

This section is empty.

Functions

func FormatCount

func FormatCount(count int64) string

func IsInsert

func IsInsert(query string) bool

func MakeColumnValues

func MakeColumnValues(nColumns int, blockSize int) [][]interface{}

func NewMatcher

func NewMatcher(needle string) *wordMatcher

NewMatcher returns matcher for word needle

func NumArgs

func NumArgs(query string) int

NumArgs returns the number of arguments in a sql query Arguments are denoted by '?'

func ParamParser

func ParamParser(reader *bytes.Reader) string

func SkipIntegrationTestIfShort

func SkipIntegrationTestIfShort(t *testing.T)

func TransposeMatrix

func TransposeMatrix(table [][]interface{}) [][]interface{}

todo: this might be slow, think of another way to "tranpose" TransposeMatrix row values to column values

Types

type InsertQuery

type InsertQuery struct {
	DataFmt string
	Query   string
	Values  string
}

InsertQuery is a insert Query disected e.g. INSERT INTO table VALUES (1); becomes

{
  DataFmt: "VALUES",
  Query: "INSERT INTO table VALUES",
  Values: "(1)"
}

func ParseInsertQuery

func ParseInsertQuery(query string) (*InsertQuery, error)

In this method, we Parse the Insert query into dataFmt (which can be CSV, VALUES, JSON or CSVWITHNAMES), Query (excluding the values but including the format) and the values. This is done by first matching the first part of the insert query with our InsertInto regex: INSERT INTO [db.]table [(c1, c2, c3)]

Then we get the format from the remaining string using the insertFormat regex. This is necessary to ensure that a table, database or column name containing the format key words isn't treated as the format.

Jump to

Keyboard shortcuts

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