orm icon indicating copy to clipboard operation
orm copied to clipboard

DatabaseValidations: true gives not informative error

Open AlexanderMatveev opened this issue 2 years ago • 1 comments

if err := orm.SetupConnections(orm.ConnectionConfig{
	DB:      db,
	Dialect: orm.Dialects.PostgreSQL,
	Entities: []orm.Entity{
		//...
	},
	DatabaseValidations: true,
}); err != nil {
	log.Fatalf("orm.SetupConnections: %v", err)
}
2023/10/04 14:52:44 orm.SetupConnections: pq: syntax error at or near "\"

AlexanderMatveev avatar Oct 04 '23 11:10 AlexanderMatveev

Looks like this happens because of "\dt" is failing with database/sql

db, err := sql.Open("postgres", conf.DatabaseUrl)
if err != nil {
	log.Fatal(err)
}

if _, err := db.Exec("\\dt"); err != nil {
	log.Fatalf("db.Exec: %v", err)
}

// 2023/10/04 14:57:35 db.Exec: pq: syntax error at or near "\"


AlexanderMatveev avatar Oct 04 '23 11:10 AlexanderMatveev