Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle https://xorm.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
757B

  1. // Copyright 2017 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestEraseAny(t *testing.T) {
  10. raw := "SELECT * FROM `table`.[table_name]"
  11. assert.EqualValues(t, raw, eraseAny(raw))
  12. assert.EqualValues(t, "SELECT * FROM table.[table_name]", eraseAny(raw, "`"))
  13. assert.EqualValues(t, "SELECT * FROM table.table_name", eraseAny(raw, "`", "[", "]"))
  14. }
  15. func TestQuoteColumns(t *testing.T) {
  16. cols := []string{"f1", "f2", "f3"}
  17. quoteFunc := func(value string) string {
  18. return "[" + value + "]"
  19. }
  20. assert.EqualValues(t, "[f1], [f2], [f3]", quoteColumns(cols, quoteFunc, ","))
  21. }