v0.0.350
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m2s

This commit is contained in:
Mike Schwörer 2023-12-29 18:06:45 +01:00
parent 05580c384a
commit 6e90239fef
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 33 additions and 3 deletions

View File

@ -1,5 +1,5 @@
package goext
const GoextVersion = "0.0.349"
const GoextVersion = "0.0.350"
const GoextVersionTimestamp = "2023-12-28T01:36:21+0100"
const GoextVersionTimestamp = "2023-12-29T18:06:45+0100"

View File

@ -13,7 +13,9 @@ import (
"strings"
)
func HashSqliteSchema(ctx context.Context, schemaStr string) (string, error) {
// HashMattnSqliteSchema
// use if github.com/glebarez/go-sqlite
func HashMattnSqliteSchema(ctx context.Context, schemaStr string) (string, error) {
dbdir := os.TempDir()
dbfile1 := filepath.Join(dbdir, langext.MustHexUUID()+".sqlite3")
@ -39,6 +41,34 @@ func HashSqliteSchema(ctx context.Context, schemaStr string) (string, error) {
return HashSqliteDatabase(ctx, db)
}
// HashGoSqliteSchema
// use if mattn/go-sqlite3
func HashGoSqliteSchema(ctx context.Context, schemaStr string) (string, error) {
dbdir := os.TempDir()
dbfile1 := filepath.Join(dbdir, langext.MustHexUUID()+".sqlite3")
err := os.MkdirAll(dbdir, os.ModePerm)
if err != nil {
return "", err
}
url := fmt.Sprintf("file:%s?_pragma=journal_mode(%s)&_pragma=timeout(%d)&_pragma=foreign_keys(%s)&_pragma=busy_timeout(%d)", dbfile1, "DELETE", 1000, "true", 1000)
xdb, err := sqlx.Open("sqlite", url)
if err != nil {
return "", err
}
db := NewDB(xdb)
_, err = db.Exec(ctx, schemaStr, PP{})
if err != nil {
return "", err
}
return HashSqliteDatabase(ctx, db)
}
func HashSqliteDatabase(ctx context.Context, db Queryable) (string, error) {
ss, err := CreateSqliteDatabaseSchemaString(ctx, db)
if err != nil {