testsql

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ExtendedDefinitions        = false
	ExtendedDefinitionsUser    = false
	ExtendedDefinitionsTodo    = false
	ExtendedDefinitionsProfile = false
)

Functions

func NewAuthAppConfig

func NewAuthAppConfig() django.AppConfig

func NewBlogAppConfig

func NewBlogAppConfig() django.AppConfig

func NewTodoAppConfig

func NewTodoAppConfig() django.AppConfig

Types

type Action

type Action struct {
	Type  migrator.ActionType
	Table migrator.Table
	Field migrator.Column
	Index migrator.Index
}

type BlogComment

type BlogComment struct {
	ID        int64     `attrs:"primary"`
	Body      string    `attrs:"max_length=255"`
	Author    *User     `attrs:"fk=test_sql.User;column=author_id"`
	Post      *BlogPost `attrs:"fk=test_sql.BlogPost;column=post_id"`
	CreatedAt time.Time `attrs:"-"`
	UpdatedAt time.Time `attrs:"-"`
}

func (*BlogComment) FieldDefs

func (m *BlogComment) FieldDefs() attrs.Definitions

type BlogPost

type BlogPost struct {
	ID        int64     `attrs:"primary"`
	Title     string    `attrs:"max_length=255"`
	Body      string    `attrs:"max_length=255"`
	Author    *User     `attrs:"fk=test_sql.User;column=author_id"`
	Published bool      `attrs:"-"`
	CreatedAt time.Time `attrs:"-"`
	UpdatedAt time.Time `attrs:"-"`
}

func (*BlogPost) FieldDefs

func (m *BlogPost) FieldDefs() attrs.Definitions

type Profile

type Profile struct {
	ID        int64  `attrs:"primary"`
	User      *User  `attrs:"o2o=test_sql.User;column=user_id"`
	Image     string `attrs:"-"`
	Biography string `attrs:"-"`
	Website   string `attrs:"-"`
}

func (*Profile) FieldDefs

func (m *Profile) FieldDefs() attrs.Definitions

type SQL

type SQL struct {
	SQL    string
	Params []any
}

type TestMigrationEngine

type TestMigrationEngine struct {
	SetupCalled      bool
	StoredMigrations map[string]map[string]map[string]struct{}
	RawSQL           []SQL
	Actions          []Action
	// contains filtered or unexported fields
}

func NewTestMigrationEngine

func NewTestMigrationEngine(t *testing.T) *TestMigrationEngine

func (*TestMigrationEngine) AddField

func (t *TestMigrationEngine) AddField(table migrator.Table, col migrator.Column) error
func (t *TestMigrationEngine) AlterUniqueTogether(table migrator.Table, unique bool) error {
	t.Actions = append(t.Actions, Action{Type: migrator.ActionAlterUniqueTogether, Table: table})
	return nil
}
func (t *TestMigrationEngine) AlterIndexTogether(table migrator.Table, unique bool) error {
	t.Actions = append(t.Actions, Action{Type: migrator.ActionAlterIndexTogether, Table: table})
	return nil
}

func (*TestMigrationEngine) AddIndex

func (t *TestMigrationEngine) AddIndex(table migrator.Table, index migrator.Index) error

func (*TestMigrationEngine) AlterField

func (t *TestMigrationEngine) AlterField(table migrator.Table, old migrator.Column, newCol migrator.Column) error

func (*TestMigrationEngine) CreateTable

func (t *TestMigrationEngine) CreateTable(table migrator.Table) error

func (*TestMigrationEngine) DropIndex

func (t *TestMigrationEngine) DropIndex(table migrator.Table, index migrator.Index) error

func (*TestMigrationEngine) DropTable

func (t *TestMigrationEngine) DropTable(table migrator.Table) error

func (*TestMigrationEngine) Execute

func (t *TestMigrationEngine) Execute(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*TestMigrationEngine) HasMigration

func (t *TestMigrationEngine) HasMigration(appName string, modelName string, migrationName string) (bool, error)

func (*TestMigrationEngine) RemoveField

func (t *TestMigrationEngine) RemoveField(table migrator.Table, col migrator.Column) error

func (*TestMigrationEngine) RemoveMigration

func (t *TestMigrationEngine) RemoveMigration(appName string, modelName string, migrationName string) error

func (*TestMigrationEngine) RenameIndex

func (t *TestMigrationEngine) RenameIndex(table migrator.Table, oldName string, newName string) error

func (*TestMigrationEngine) RenameTable

func (t *TestMigrationEngine) RenameTable(table migrator.Table, newName string) error

func (*TestMigrationEngine) Setup

func (t *TestMigrationEngine) Setup() error

func (*TestMigrationEngine) StoreMigration

func (t *TestMigrationEngine) StoreMigration(appName string, modelName string, migrationName string) error

type Todo

type Todo struct {
	ID          int64     `attrs:"primary"`
	Title       string    `attrs:"max_length=255"`
	Completed   bool      `attrs:"default=false"`
	User        *User     `attrs:"fk=test_sql.User;column=user_id"`
	Description string    `attrs:"-"`
	CreatedAt   time.Time `attrs:"-"`
	UpdatedAt   time.Time `attrs:"-"`
}

func (*Todo) FieldDefs

func (m *Todo) FieldDefs() attrs.Definitions

type User

type User struct {
	ID        int64  `attrs:"primary"`
	Name      string `attrs:"max_length=255"`
	Email     string `attrs:"max_length=255"`
	Age       int32  `attrs:"min_value=0;max_value=120"`
	IsActive  bool   `attrs:"-"`
	FirstName string `attrs:"-"`
	LastName  string `attrs:"-"`
}

func (*User) FieldDefs

func (m *User) FieldDefs() attrs.Definitions

Jump to

Keyboard shortcuts

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