mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-19 21:10:48 +02:00
filer: default the filemeta CREATE TABLE for postgres2/mysql2 when createTable is unset (#10232)
* postgres2: default the filemeta CREATE TABLE when createTable is unset An empty createTable rendered through fmt.Sprintf produced %!(EXTRA string=filemeta), which Postgres rejected with a syntax error at init. Fall back to a working template so a minimal config bootstraps. * mysql2: default the filemeta CREATE TABLE when createTable is unset Same empty-template failure the postgres2 path had: an unset createTable rendered to %!(EXTRA string=filemeta) and MySQL rejected it at init. Fall back to a working template.
This commit is contained in:
@@ -16,6 +16,17 @@ func TestDefaultUpsertQueryIsConflictSafe(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultCreateTableQueryRendersValidSql(t *testing.T) {
|
||||
gen := &SqlGenPostgres{CreateTableSqlTemplate: DefaultCreateTableQuery}
|
||||
got := gen.GetSqlCreateTable("filemeta")
|
||||
if strings.Contains(got, "%!") {
|
||||
t.Fatalf("template rendered to malformed SQL, got: %s", got)
|
||||
}
|
||||
if !strings.Contains(got, `"filemeta"`) {
|
||||
t.Fatalf("expected quoted table name, got: %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyUpsertTemplateFallsBackToPlainInsert(t *testing.T) {
|
||||
gen := &SqlGenPostgres{}
|
||||
got := gen.GetSqlInsert("filemeta")
|
||||
|
||||
Reference in New Issue
Block a user