xormadapter

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package xormadapter. xormadapter.go - Adapts a *xorm.Engine to the dbtestkit.Engine interface. Users of xorm (casdoor, etc.) can pass an instance of this adapter to their WithEngineInitializer callback.

Example:

import (
    "github.com/seyallius/gopherbox/dbtestkit"
    "github.com/seyallius/gopherbox/dbtestkit/xormadapter"
    "github.com/xorm-io/xorm"

)

dbtestkit.Run(m,
    dbtestkit.WithDriver(mysql.New()),
    dbtestkit.WithEngineInitializer(func(env *dbtestkit.Environment) (dbtestkit.Engine, error) {
        eng, err := xorm.NewEngine("mysql", env.DSN())
        if err != nil {
            return nil, err
        }
        return xormadapter.New(eng), nil
    }),
    ...
)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter wraps a *xorm.Engine to satisfy dbtestkit.Engine.

func New

func New(eng *xorm.Engine) *Adapter

New returns an Adapter wrapping the given *xorm.Engine.

The Adapter does NOT take ownership of the engine — the caller is responsible for closing it (which dbtestkit does via Engine.Close()).

func (*Adapter) ClearCache

func (a *Adapter) ClearCache() error

ClearCache implements dbtestkit.Engine. Forwards to xorm.Engine.ClearCache, which flushes the ORM-level Ristretto store. Safe to call even if caching is disabled (ClearCache is a no-op in that case).

func (*Adapter) Close

func (a *Adapter) Close() error

Close implements dbtestkit.Engine.

func (*Adapter) Engine

func (a *Adapter) Engine() *xorm.Engine

Engine returns the underlying *xorm.Engine, should the caller need to pass it to ORM-specific helpers (e.g. Sync2).

func (*Adapter) Exec

func (a *Adapter) Exec(query string, args ...any) (sql.Result, error)

Exec implements dbtestkit.Engine.

func (*Adapter) Ping

func (a *Adapter) Ping() error

Ping implements dbtestkit.Engine.

func (*Adapter) QueryString

func (a *Adapter) QueryString(query string, args ...any) ([]map[string]string, error)

QueryString implements dbtestkit.Engine.

Jump to

Keyboard shortcuts

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