mirror of
https://github.com/xiaoxinpro/nginx-proxy-manager-zh.git
synced 2025-03-13 17:28:12 -04:00
Fix quotes
This commit is contained in:
parent
e78dd069f1
commit
c4db4a2647
@ -18,11 +18,12 @@ const (
|
||||
// is for special cases where we run raw sql
|
||||
func QuoteTableName(tbl string) string {
|
||||
switch strings.ToLower(config.Configuration.DB.Driver) {
|
||||
case config.DatabasePostgres:
|
||||
return fmt.Sprintf(`"%s"`, tbl)
|
||||
default:
|
||||
// This is the same for Mysql and Sqlite
|
||||
case config.DatabaseMysql:
|
||||
// backticks for mysql
|
||||
return fmt.Sprintf("`%s`", tbl)
|
||||
default:
|
||||
// double quotes for everything else
|
||||
return fmt.Sprintf(`"%s"`, tbl)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,12 +122,12 @@ func (s *testsuite) TestList() {
|
||||
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||
|
||||
s.mock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT count(*) FROM \"certificate_authority\" WHERE `certificate_authority`.`name` LIKE $1 AND \"certificate_authority\".\"is_deleted\" = $2")).
|
||||
ExpectQuery(regexp.QuoteMeta(`SELECT count(*) FROM "certificate_authority" WHERE "certificate_authority"."name" LIKE $1 AND "certificate_authority"."is_deleted" = $2`)).
|
||||
WithArgs("%test%", 0).
|
||||
WillReturnRows(s.listCountRows)
|
||||
|
||||
s.mock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT * FROM \"certificate_authority\" WHERE `certificate_authority`.`name` LIKE $1 AND \"certificate_authority\".\"is_deleted\" = $2 ORDER BY name asc LIMIT $3")).
|
||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "certificate_authority" WHERE "certificate_authority"."name" LIKE $1 AND "certificate_authority"."is_deleted" = $2 ORDER BY name asc LIMIT $3`)).
|
||||
WithArgs("%test%", 0, 8).
|
||||
WillReturnRows(s.listRows)
|
||||
|
||||
|
@ -204,12 +204,12 @@ func (s *testsuite) TestList() {
|
||||
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||
|
||||
s.mock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT count(*) FROM \"dns_provider\" WHERE `dns_provider`.`acmesh_name` LIKE $1 AND \"dns_provider\".\"is_deleted\" = $2")).
|
||||
ExpectQuery(regexp.QuoteMeta(`SELECT count(*) FROM "dns_provider" WHERE "dns_provider"."acmesh_name" LIKE $1 AND "dns_provider"."is_deleted" = $2`)).
|
||||
WithArgs("dns%", 0).
|
||||
WillReturnRows(s.listCountRows)
|
||||
|
||||
s.mock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT * FROM \"dns_provider\" WHERE `dns_provider`.`acmesh_name` LIKE $1 AND \"dns_provider\".\"is_deleted\" = $2 ORDER BY name asc LIMIT $3")).
|
||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "dns_provider" WHERE "dns_provider"."acmesh_name" LIKE $1 AND "dns_provider"."is_deleted" = $2 ORDER BY name asc LIMIT $3`)).
|
||||
WithArgs("dns%", 0, 8).
|
||||
WillReturnRows(s.listRows)
|
||||
|
||||
|
@ -258,7 +258,7 @@ func (s *testsuite) TestDeleteAll() {
|
||||
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||
|
||||
s.mock.
|
||||
ExpectExec(regexp.QuoteMeta("DELETE FROM `user` WHERE is_system = $1")).
|
||||
ExpectExec(regexp.QuoteMeta(`DELETE FROM "user" WHERE is_system = $1`)).
|
||||
WithArgs(false).
|
||||
WillReturnResult(sqlmock.NewResult(0, 1))
|
||||
|
||||
@ -307,12 +307,12 @@ func (s *testsuite) TestList() {
|
||||
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||
|
||||
s.mock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT count(*) FROM \"user\" WHERE `user`.`name` LIKE $1 AND \"user\".\"is_deleted\" = $2")).
|
||||
ExpectQuery(regexp.QuoteMeta(`SELECT count(*) FROM "user" WHERE "user"."name" LIKE $1 AND "user"."is_deleted" = $2`)).
|
||||
WithArgs("%jon%", 0).
|
||||
WillReturnRows(s.listCountRows)
|
||||
|
||||
s.mock.
|
||||
ExpectQuery(regexp.QuoteMeta("SELECT * FROM \"user\" WHERE `user`.`name` LIKE $1 AND \"user\".\"is_deleted\" = $2 ORDER BY name asc LIMIT $3")).
|
||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "user" WHERE "user"."name" LIKE $1 AND "user"."is_deleted" = $2 ORDER BY name asc LIMIT $3`)).
|
||||
WithArgs("%jon%", 0, 8).
|
||||
WillReturnRows(s.listRows)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user