gorm_oracle

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 18 Imported by: 0

README

GORM Oracle Driver

GORM Oracle driver for connect Oracle DB and Manager Oracle DB, Based on CengSin/oracle and sijms/go-ora(pure go oracle client), not recommended for use in a production environment.

by the way: fix some bugs in CengSin/oracle version, support batch insert / conflict insert.

but not support returning when using batch insert/update/delete.

Required dependency

  • Oracle 12c+
  • Golang 1.18+
  • gorm 1.25+

Quick Start

How to install

go get -d github.com/sineycoder/gorm-oracle

How to Use

package main

import (
	oracle "github.com/sineycoder/gorm-oracle"
	"gorm.io/gorm"
)

func main() {
	// oracle://user:password@127.0.0.1:1521/service
	url := oracle.BuildUrl("127.0.0.1", "1521", "service", "user", "password", nil)
	db, err := gorm.Open(oracle.Open(url), &gorm.Config{})
	if err != nil {
		// panic error or log error info
	}

	// do somethings
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDSN

func BuildDSN(server string, port int, service, user, password string, options map[string]string) string

func ConvertNameToFormat

func ConvertNameToFormat(x string) string

func Create

func Create(db *gorm.DB)

func DualTableName

func DualTableName() string

func New

func New(config Config) gorm.Dialector

func Open

func Open(dsn string) gorm.Dialector

Types

type Config

type Config struct {
	DriverName        string
	DSN               string
	Conn              gorm.ConnPool // *sql.DB
	DefaultStringSize uint          // varchar2 default size if not specify
	DBVersion         string        // save db version
	FormatTimestamp   bool          // using <TIMESTAMP 'yyyy-MM-dd HH:mm:ss.999'> when gorm time.Time to db timestamp
}

type Dialector

type Dialector struct {
	*Config
}

func (Dialector) BindVarTo

func (d Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v interface{})

func (Dialector) ClauseBuilders

func (d Dialector) ClauseBuilders() (ret map[string]clause.ClauseBuilder)

func (Dialector) DataTypeOf

func (d Dialector) DataTypeOf(field *schema.Field) string

DataTypeOf for migrator

func (Dialector) DefaultValueOf

func (d Dialector) DefaultValueOf(field *schema.Field) clause.Expression

func (Dialector) Explain

func (d Dialector) Explain(sql string, vars ...interface{}) string

func (Dialector) Initialize

func (d Dialector) Initialize(db *gorm.DB) (err error)

func (Dialector) Migrator

func (d Dialector) Migrator(db *gorm.DB) gorm.Migrator

func (Dialector) Name

func (d Dialector) Name() string

func (Dialector) QuoteTo

func (d Dialector) QuoteTo(writer clause.Writer, str string)

func (Dialector) RollbackTo

func (d Dialector) RollbackTo(tx *gorm.DB, name string) error

func (Dialector) SavePoint

func (d Dialector) SavePoint(tx *gorm.DB, name string) error

type Namer

type Namer struct {
	schema.Namer
}

func (Namer) CheckerName

func (n Namer) CheckerName(table, column string) (name string)

func (Namer) ColumnName

func (n Namer) ColumnName(table, column string) (name string)

func (Namer) IndexName

func (n Namer) IndexName(table, column string) (name string)

func (Namer) JoinTableName

func (n Namer) JoinTableName(table string) (name string)

func (Namer) RelationshipFKName

func (n Namer) RelationshipFKName(relationship schema.Relationship) (name string)

func (Namer) SchemaName

func (n Namer) SchemaName(table string) string

func (Namer) TableName

func (n Namer) TableName(table string) (name string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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