/
githubmirror
/
xorm
Обзор
Документация
Войти
/
githubmirror
/
xorm
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
internal/statements/table_name.go
56 строк
1 KB
Lunny Xiao
Refactor orderby and support arguments (#2150)
31 май 2022, 06:00
31 май 2022, 06:00
f9a6990
Код
Авторство
О чём код?
// Copyright 2022 The Xorm Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package statements import ( "fmt" "strings" "xorm.io/builder" "xorm.io/xorm/schemas" ) // TableName return current tableName func (statement *Statement) TableName() string { if statement.AltTableName != "" { return statement.AltTableName } return statement.tableName } // Alias set the table alias func (statement *Statement) Alias(alias string) *Statement { statement.TableAlias = alias return statement } func (statement *Statement) writeAlias(w builder.Writer) error { if statement.TableAlias != "" { if statement.dialect.URI().DBType == schemas.ORACLE { if _, err := fmt.Fprint(w, " ", statement.quote(statement.TableAlias)); err != nil { return err } } else { if _, err := fmt.Fprint(w, " AS ", statement.quote(statement.TableAlias)); err != nil { return err } } } return nil } func (statement *Statement) writeTableName(w builder.Writer) error { if statement.dialect.URI().DBType == schemas.MSSQL && strings.Contains(statement.TableName(), "..") { if _, err := fmt.Fprint(w, statement.TableName()); err != nil { return err } } else { if _, err := fmt.Fprint(w, statement.quote(statement.TableName())); err != nil { return err } } return nil }