example

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilOptions              = errors.New("options cannot be nil")
	ErrInvalidObjectIdentifier = errors.New("invalid object identifier")
)
View Source
var (
	DatabaseRole = g.NewInterface(
		"DatabaseRoles",
		"DatabaseRole",
		"DatabaseObjectIdentifier",
	).
		CreateOperation(
			"https://docs.snowflake.com/en/sql-reference/sql/create-database-role",
			g.NewQueryStruct("CreateDatabaseRole").
				Create().
				OrReplace().
				SQL("DATABASE ROLE").
				IfNotExists().
				Name().
				OptionalTextAssignment("COMMENT", g.ParameterOptions().SingleQuotes()).
				WithValidation(g.ValidIdentifier, "name").
				WithValidation(g.ConflictingFields, "OrReplace", "IfNotExists"),
		).
		AlterOperation(
			"https://docs.snowflake.com/en/sql-reference/sql/alter-database-role",
			g.NewQueryStruct("AlterDatabaseRole").
				Alter().
				SQL("DATABASE ROLE").
				IfExists().
				Name().
				OptionalQueryStructField("Rename", dbRoleRename, g.ListOptions().NoParentheses().SQL("RENAME TO")).
				OptionalQueryStructField("Set", dbRoleSet, g.ListOptions().NoParentheses().SQL("SET")).
				OptionalQueryStructField("Unset", dbRoleUnset, g.ListOptions().NoParentheses().SQL("UNSET")).
				WithValidation(g.ValidIdentifier, "name").
				WithValidation(g.ExactlyOneValueSet, "Rename", "Set", "Unset"),
		)
)
View Source
var ToOptsOptionalExample = g.NewInterface(
	"ToOptsOptionalExamples",
	"ToOptsOptionalExample",
	g.KindOfT[DatabaseObjectIdentifier](),
).CreateOperation("https://example.com",
	g.NewQueryStruct("Alter").
		Alter().
		IfExists().
		Name(),
).AlterOperation("https://example.com",
	g.NewQueryStruct("Alter").
		Alter().
		IfExists().
		Name().
		OptionalQueryStructField(
			"OptionalField",
			g.NewQueryStruct("OptionalField").
				List("SomeList", "DatabaseObjectIdentifier", g.ListOptions()),
			g.KeywordOptions(),
		).
		QueryStructField(
			"RequiredField",
			g.NewQueryStruct("RequiredField").
				List("SomeRequiredList", "DatabaseObjectIdentifier", g.ListOptions().Required()),
			g.KeywordOptions().Required(),
		),
)

Functions

func ValidObjectIdentifier added in v0.74.0

func ValidObjectIdentifier(objectIdentifier ObjectIdentifier) bool

Types

type AccountObjectIdentifier

type AccountObjectIdentifier struct{}

func RandomAccountObjectIdentifier added in v0.74.0

func RandomAccountObjectIdentifier(t *testing.T) AccountObjectIdentifier

type AlterDatabaseRoleOptions

type AlterDatabaseRoleOptions struct {
	IfExists *bool `ddl:"keyword" sql:"IF EXISTS"`

	Rename *DatabaseRoleRename `ddl:"list,no_parentheses" sql:"RENAME TO"`
	Set    *DatabaseRoleSet    `ddl:"list,no_parentheses" sql:"SET"`
	Unset  *DatabaseRoleUnset  `ddl:"list,no_parentheses" sql:"UNSET"`
	// contains filtered or unexported fields
}

AlterDatabaseRoleOptions is based on https://docs.snowflake.com/en/sql-reference/sql/alter-database-role.

type AlterDatabaseRoleRequest

type AlterDatabaseRoleRequest struct {
	IfExists *bool

	Rename *DatabaseRoleRenameRequest
	Set    *DatabaseRoleSetRequest
	Unset  *DatabaseRoleUnsetRequest
	// contains filtered or unexported fields
}

func NewAlterDatabaseRoleRequest

func NewAlterDatabaseRoleRequest(
	name DatabaseObjectIdentifier,
) *AlterDatabaseRoleRequest

func (*AlterDatabaseRoleRequest) WithIfExists

func (s *AlterDatabaseRoleRequest) WithIfExists(IfExists *bool) *AlterDatabaseRoleRequest

func (*AlterDatabaseRoleRequest) WithRename

func (*AlterDatabaseRoleRequest) WithSet

func (*AlterDatabaseRoleRequest) WithUnset

type AlterToOptsOptionalExampleOptions added in v1.0.0

type AlterToOptsOptionalExampleOptions struct {
	IfExists *bool `ddl:"keyword" sql:"IF EXISTS"`

	OptionalField *OptionalField `ddl:"keyword"`
	RequiredField RequiredField  `ddl:"keyword"`
	// contains filtered or unexported fields
}

AlterToOptsOptionalExampleOptions is based on https://example.com.

type AlterToOptsOptionalExampleRequest added in v1.0.0

type AlterToOptsOptionalExampleRequest struct {
	IfExists *bool

	OptionalField *OptionalFieldRequest
	RequiredField RequiredFieldRequest // required
	// contains filtered or unexported fields
}

type Client

type Client struct{}

type CreateDatabaseRoleOptions

type CreateDatabaseRoleOptions struct {
	OrReplace *bool `ddl:"keyword" sql:"OR REPLACE"`

	IfNotExists *bool `ddl:"keyword" sql:"IF NOT EXISTS"`

	Comment *string `ddl:"parameter,single_quotes" sql:"COMMENT"`
	// contains filtered or unexported fields
}

CreateDatabaseRoleOptions is based on https://docs.snowflake.com/en/sql-reference/sql/create-database-role.

type CreateDatabaseRoleRequest

type CreateDatabaseRoleRequest struct {
	OrReplace   *bool
	IfNotExists *bool

	Comment *string
	// contains filtered or unexported fields
}

func NewCreateDatabaseRoleRequest

func NewCreateDatabaseRoleRequest(
	name DatabaseObjectIdentifier,
) *CreateDatabaseRoleRequest

func (*CreateDatabaseRoleRequest) WithComment

func (*CreateDatabaseRoleRequest) WithIfNotExists

func (s *CreateDatabaseRoleRequest) WithIfNotExists(IfNotExists *bool) *CreateDatabaseRoleRequest

func (*CreateDatabaseRoleRequest) WithOrReplace

func (s *CreateDatabaseRoleRequest) WithOrReplace(OrReplace *bool) *CreateDatabaseRoleRequest

type CreateToOptsOptionalExampleOptions added in v1.0.0

type CreateToOptsOptionalExampleOptions struct {
	IfExists *bool `ddl:"keyword" sql:"IF EXISTS"`
	// contains filtered or unexported fields
}

CreateToOptsOptionalExampleOptions is based on https://example.com.

type CreateToOptsOptionalExampleRequest added in v1.0.0

type CreateToOptsOptionalExampleRequest struct {
	IfExists *bool
	// contains filtered or unexported fields
}

type DatabaseObjectIdentifier

type DatabaseObjectIdentifier struct{}

func RandomDatabaseObjectIdentifier added in v0.74.0

func RandomDatabaseObjectIdentifier(t *testing.T) DatabaseObjectIdentifier

type DatabaseRoleRename

type DatabaseRoleRename struct {
	Name DatabaseObjectIdentifier `ddl:"identifier"`
}

type DatabaseRoleRenameRequest

type DatabaseRoleRenameRequest struct {
	Name DatabaseObjectIdentifier // required
}

func NewDatabaseRoleRenameRequest

func NewDatabaseRoleRenameRequest(
	Name DatabaseObjectIdentifier,
) *DatabaseRoleRenameRequest

type DatabaseRoleSet

type DatabaseRoleSet struct {
	Comment          string            `ddl:"parameter,single_quotes" sql:"COMMENT"`
	NestedThirdLevel *NestedThirdLevel `ddl:"list,no_parentheses" sql:"NESTED"`
}

type DatabaseRoleSetRequest

type DatabaseRoleSetRequest struct {
	Comment          string // required
	NestedThirdLevel *NestedThirdLevelRequest
}

func NewDatabaseRoleSetRequest

func NewDatabaseRoleSetRequest(
	Comment string,
) *DatabaseRoleSetRequest

func (*DatabaseRoleSetRequest) WithNestedThirdLevel

func (s *DatabaseRoleSetRequest) WithNestedThirdLevel(NestedThirdLevel *NestedThirdLevelRequest) *DatabaseRoleSetRequest

type DatabaseRoleUnset

type DatabaseRoleUnset struct {
	Comment *bool `ddl:"keyword" sql:"COMMENT"`
}

type DatabaseRoleUnsetRequest

type DatabaseRoleUnsetRequest struct {
	Comment *bool
}

func NewDatabaseRoleUnsetRequest

func NewDatabaseRoleUnsetRequest() *DatabaseRoleUnsetRequest

func (*DatabaseRoleUnsetRequest) WithComment added in v0.72.0

func (s *DatabaseRoleUnsetRequest) WithComment(Comment *bool) *DatabaseRoleUnsetRequest

type DatabaseRoles

type DatabaseRoles interface {
	Create(ctx context.Context, request *CreateDatabaseRoleRequest) error
	Alter(ctx context.Context, request *AlterDatabaseRoleRequest) error
}

type ExternalObjectIdentifier

type ExternalObjectIdentifier struct{}

type NestedThirdLevel

type NestedThirdLevel struct {
	Field DatabaseObjectIdentifier `ddl:"identifier"`
}

type NestedThirdLevelRequest

type NestedThirdLevelRequest struct {
	Field DatabaseObjectIdentifier // required
}

func NewNestedThirdLevelRequest

func NewNestedThirdLevelRequest(
	Field DatabaseObjectIdentifier,
) *NestedThirdLevelRequest

type ObjectIdentifier

type ObjectIdentifier interface{}

type OptionalField added in v1.0.0

type OptionalField struct {
	SomeList []DatabaseObjectIdentifier `ddl:"list"`
}

type OptionalFieldRequest added in v1.0.0

type OptionalFieldRequest struct {
	SomeList []DatabaseObjectIdentifier
}

type RequiredField added in v1.0.0

type RequiredField struct {
	SomeRequiredList []DatabaseObjectIdentifier `ddl:"list"`
}

type RequiredFieldRequest added in v1.0.0

type RequiredFieldRequest struct {
	SomeRequiredList []DatabaseObjectIdentifier // required
}

type SchemaObjectIdentifier

type SchemaObjectIdentifier struct{}

func RandomSchemaObjectIdentifier added in v0.74.0

func RandomSchemaObjectIdentifier(t *testing.T) SchemaObjectIdentifier

type TableColumnIdentifier

type TableColumnIdentifier struct{}

type ToOptsOptionalExamples added in v1.0.0

type ToOptsOptionalExamples interface {
	Create(ctx context.Context, request *CreateToOptsOptionalExampleRequest) error
	Alter(ctx context.Context, request *AlterToOptsOptionalExampleRequest) error
}

Jump to

Keyboard shortcuts

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