sqlfmt

package
v0.40.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlterTableAddColStmt

func AlterTableAddColStmt(tableName string, newColDef string) string

func AlterTableAddForeignKeyStmt

func AlterTableAddForeignKeyStmt(fk doltdb.ForeignKey, sch, parentSch schema.Schema) string

func AlterTableAddIndexStmt

func AlterTableAddIndexStmt(tableName string, idx schema.Index) string

func AlterTableAddPrimaryKeys

func AlterTableAddPrimaryKeys(tableName string, pks *schema.ColCollection) string

func AlterTableDropColStmt

func AlterTableDropColStmt(tableName string, oldColName string) string

func AlterTableDropForeignKeyStmt

func AlterTableDropForeignKeyStmt(fk doltdb.ForeignKey) string

func AlterTableDropIndexStmt

func AlterTableDropIndexStmt(tableName string, idx schema.Index) string

func AlterTableDropPks

func AlterTableDropPks(tableName string) string

func AlterTableModifyColStmt

func AlterTableModifyColStmt(tableName string, newColDef string) string

func AlterTableRenameColStmt

func AlterTableRenameColStmt(tableName string, oldColName string, newColName string) string

func DropTableIfExistsStmt

func DropTableIfExistsStmt(tableName string) string

func DropTableStmt

func DropTableStmt(tableName string) string

func FmtCol

func FmtCol(indent, nameWidth, typeWidth int, col schema.Column) string
FmtCol converts a column to a string with a given indent space count, name width, and type width.  If nameWidth or

typeWidth are 0 or less than the length of the name or type, then the length of the name or type will be used

func FmtColPrimaryKey

func FmtColPrimaryKey(indent int, colStr string, newline bool) string

FmtColPrimaryKey creates a string representing a primary key constraint within a sql create table statement with a given indent.

func FmtColWithNameAndType

func FmtColWithNameAndType(indent, nameWidth, typeWidth int, colName, typeStr string, col schema.Column) string

FmtColWithNameAndType creates a string representing a column within a sql create table statement with a given indent space count, name width, and type width. If nameWidth or typeWidth are 0 or less than the length of the name or type, then the length of the name or type will be used.

func FmtForeignKey

func FmtForeignKey(fk doltdb.ForeignKey, sch, parentSch schema.Schema) string

func FmtIndex

func FmtIndex(index schema.Index) string

func InsertStatementPrefix

func InsertStatementPrefix(tableName string, tableSch schema.Schema) (string, error)

InsertStatementPrefix returns the first part of an SQL insert query for a given table

func QuoteComment

func QuoteComment(s string) string

QuoteComment quotes the given string with apostrophes, and escapes any contained within the string.

func QuoteIdentifier

func QuoteIdentifier(s string) string

Quotes the identifier given with backticks.

func RenameTableStmt

func RenameTableStmt(fromName string, toName string) string

func RowAsDeleteStmt

func RowAsDeleteStmt(r row.Row, tableName string, tableSch schema.Schema) (string, error)

func RowAsInsertStmt

func RowAsInsertStmt(r row.Row, tableName string, tableSch schema.Schema) (string, error)

func RowAsTupleString

func RowAsTupleString(ctx context.Context, r row.Row, tableSch schema.Schema) (string, error)

RowAsTupleString converts a row into it's tuple string representation for SQL insert statements.

func RowAsUpdateStmt

func RowAsUpdateStmt(r row.Row, tableName string, tableSch schema.Schema, colDiffs *set.StrSet) (string, error)

func SqlRowAsCreateFragStmt

func SqlRowAsCreateFragStmt(r sql.Row) (string, error)

SqlRowAsCreateFragStmt Converts a Row into either a CREATE TRIGGER or CREATE VIEW statement This function expects a row from the dolt_schemas table

func SqlRowAsCreateProcStmt

func SqlRowAsCreateProcStmt(r sql.Row) (string, error)

SqlRowAsCreateProcStmt Converts a Row into either a CREATE PROCEDURE statement This function expects a row from the dolt_procedures table.

func SqlRowAsInsertStmt

func SqlRowAsInsertStmt(ctx context.Context, r sql.Row, tableName string, tableSch schema.Schema) (string, error)

func SqlRowAsTupleString

func SqlRowAsTupleString(ctx context.Context, r sql.Row, tableSch schema.Schema) (string, error)

SqlRowAsTupleString converts a sql row into it's tuple string representation for SQL insert statements.

Types

This section is empty.

Jump to

Keyboard shortcuts

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