-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
306 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package sqldb | ||
|
||
// Compile time check to ensure CockroachDB satisfies the Engine interface. | ||
var _ Engine = (*CockroachDB)(nil) | ||
|
||
// CockroachDBOptions holds options for the CockroachDB database engine. | ||
type CockroachDBOptions struct { | ||
DriverName string | ||
} | ||
|
||
// CockroachDB represents the CockroachDB database engine. | ||
type CockroachDB struct { | ||
*Postgres | ||
} | ||
|
||
// NewCockroachDB creates a new instance of the CockroachDB database engine. | ||
func NewCockroachDB(dataSourceName string, optFns ...func(o *CockroachDBOptions)) (*CockroachDB, error) { | ||
opts := CockroachDBOptions{ | ||
DriverName: "pgx", | ||
} | ||
|
||
for _, fn := range optFns { | ||
fn(&opts) | ||
} | ||
|
||
postgres, err := NewPostgres(dataSourceName, func(o *PostgresOptions) { | ||
o.DriverName = opts.DriverName | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &CockroachDB{ | ||
Postgres: postgres, | ||
}, nil | ||
} | ||
|
||
// Dialect returns the dialect of the CockroachDB database engine. | ||
func (e *CockroachDB) Dialect() string { | ||
return "CockroachDB" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package sqldb | ||
|
||
// Compile time check to ensure MariaDB satisfies the Engine interface. | ||
var _ Engine = (*MariaDB)(nil) | ||
|
||
// MariaDBOptions holds options for the MariaDB database engine. | ||
type MariaDBOptions struct { | ||
DriverName string | ||
} | ||
|
||
// MariaDB represents the MariaDB database engine. | ||
type MariaDB struct { | ||
*MySQL | ||
} | ||
|
||
// NewMariaDB creates a new instance of the MariaDB database engine. | ||
func NewMariaDB(dataSourceName string, optFns ...func(o *MariaDBOptions)) (*MariaDB, error) { | ||
opts := MariaDBOptions{ | ||
DriverName: "mysql", | ||
} | ||
|
||
for _, fn := range optFns { | ||
fn(&opts) | ||
} | ||
|
||
mysql, err := NewMySQL(dataSourceName, func(o *MySQLOptions) { | ||
o.DriverName = opts.DriverName | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &MariaDB{ | ||
MySQL: mysql, | ||
}, nil | ||
} | ||
|
||
// Dialect returns the dialect of the MariaDB database engine. | ||
func (e *MariaDB) Dialect() string { | ||
return "MariaDB" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.