<commit_before>package gorm

import (
	"database/sql"
	"errors"
	"fmt"
	"reflect"
)

type DB struct {
	Value         interface{}
	Error         error
	RowsAffected  int64
	callback      *callback
	db            sqlCommon
	parent        *DB
	search        *search
	logMode       int
	logger        logger
	dialect       Dialect
	tagIdentifier string
	singularTable bool
	source        string
}

func Open(driver, source string) (DB, error) {
	var err error
	db := DB{dialect: NewDialect(driver), tagIdentifier: "sql", logger: defaultLogger, callback: DefaultCallback, source: source}
	db.db, err = sql.Open(driver, source)
	db.parent = &db
	return db, err
}

func (s *DB) Close() error {
	return s.parent.db.(*sql.DB).Close()
}

func (s *DB) DB() *sql.DB {
	return s.db.(*sql.DB)
}

// Return the underlying sql.DB or sql.Tx instance.
// Use of this method is discouraged. It's mainly intended to allow
// coexistence with legacy non-GORM code.
func (s *DB) CommonDB() sqlCommon {
	return s.db
}

func (s *DB) Callback() *callback {
	s.parent.callback = s.parent.callback.clone()
	return s.parent.callback
}
<commit_msg>Specify database dialect when open database, fixes #169<commit_after>package gorm

import (
	"database/sql"
	"errors"
	"fmt"
	"reflect"
)

type DB struct {
	Value         interface{}
	Error         error
	RowsAffected  int64
	callback      *callback
	db            sqlCommon
	parent        *DB
	search        *search
	logMode       int
	logger        logger
	dialect       Dialect
	tagIdentifier string
	singularTable bool
	source        string
}

func Open(dialect string, drivesources ...string) (DB, error) {
	var db DB
	var err error
	var driver = dialect
	var source string

	if len(drivesources) == 0 {
		err = errors.New("invalid database source")
	} else {
		if len(drivesources) == 1 {
			source = drivesources[0]
		} else if len(drivesources) >= 2 {
			driver = drivesources[0]
			source = drivesources[1]
		}

		db = DB{dialect: NewDialect(dialect), tagIdentifier: "sql", logger: defaultLogger, callback: DefaultCallback, source: source}
		db.db, err = sql.Open(driver, source)
		db.parent = &db
	}
	return db, err
}

func (s *DB) Close() error {
	return s.parent.db.(*sql.DB).Close()
}

func (s *DB) DB() *sql.DB {
	return s.db.(*sql.DB)
}

// Return the underlying sql.DB or sql.Tx instance.
// Use of this method is discouraged. It's mainly intended to allow
// coexistence with legacy non-GORM code.
func (s *DB) CommonDB() sqlCommon {
	return s.db
}

func (s *DB) Callback() *callback {
	s.parent.callback = s.parent.callback.clone()
	return s.parent.callback
}

{'fraction_non_alphanumeric': 0.11397766653831344, 'fraction_numerical': 0.0050057758952637655, 'mean_word_length': 3.027906976744186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7157542', 'n_tokens_mistral': 914, 'n_tokens_neox': 871, 'n_words': 274}