• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yyle88 / gormcnm / 14283377767

05 Apr 2025 03:37PM UTC coverage: 54.705% (-0.2%) from 54.912%
14283377767

push

github

yangyile
改改参数顺序和文档单词

0 of 8 new or added lines in 2 files covered. (0.0%)

436 of 797 relevant lines covered (54.71%)

8.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/table_column.go
1
package gormcnm
2

3
import "github.com/yyle88/gormcnm/internal/utils"
4

5
func (columnName ColumnName[TYPE]) TB(tab utils.GormTableNameFace) *TableColumn[TYPE] {
×
6
        return columnName.WithTable(tab)
×
7
}
×
8

9
func (columnName ColumnName[TYPE]) TC(tab utils.GormTableNameFace) *TableColumn[TYPE] {
×
10
        return columnName.WithTable(tab)
×
11
}
×
12

13
func (columnName ColumnName[TYPE]) TN(tableName string) *TableColumn[TYPE] {
×
14
        return columnName.WithTable(utils.NewTableNameImp(tableName))
×
15
}
×
16

17
func (columnName ColumnName[TYPE]) WithTable(tab utils.GormTableNameFace) *TableColumn[TYPE] {
×
18
        return &TableColumn[TYPE]{
×
19
                tab: tab,
×
20
                cnm: columnName,
×
21
        }
×
22
}
×
23

24
func (columnName ColumnName[TYPE]) WithTableName(tableName string) *TableColumn[TYPE] {
×
25
        return columnName.WithTable(utils.NewTableNameImp(tableName))
×
26
}
×
27

28
// TableColumn represents a combination of a table and a column.
29
// TableColumn 表示表和列的组合。
30
type TableColumn[TYPE any] struct {
31
        tab utils.GormTableNameFace
32
        cnm ColumnName[TYPE]
33
}
34

35
// Eq generates an equality condition in SQL format, ensuring type consistency between two columns.
36
// Eq 生成 SQL 格式的相等条件,确保两列之间的类型一致。
37
func (tc *TableColumn[TYPE]) Eq(xc *TableColumn[TYPE]) string {
×
38
        return tc.Name() + " = " + xc.Name()
×
39
}
×
40

41
// Ne generates a SQL inequality condition, ensuring type consistency between two columns.
42
// Ne 生成 SQL 格式的不等条件,确保两列之间的类型一致。
NEW
43
func (tc *TableColumn[TYPE]) Ne(xc *TableColumn[TYPE]) string {
×
NEW
44
        return tc.Name() + " != " + xc.Name()
×
NEW
45
}
×
46

47
// Op generates a custom SQL operation between two columns using the specified operator.
48
// Op 使用指定的操作符生成两列之间的自定义 SQL 操作。
49
func (tc *TableColumn[TYPE]) Op(op string, xc *TableColumn[TYPE]) string {
×
50
        return tc.Name() + " " + op + " " + xc.Name()
×
51
}
×
52

53
// Name returns the fully qualified name of the column in the format "table.column".
54
// Name 返回列的完全限定名称,格式为 "table.column"。
55
func (tc *TableColumn[TYPE]) Name() string {
×
56
        return tc.tab.TableName() + "." + tc.cnm.Name()
×
57
}
×
58

59
// ColumnName retrieves the column name in a ColumnName format, representing the combination of the table and column.
60
// ColumnName 获取以 ColumnName 格式表示的列名,代表表和列的组合。
61
func (tc *TableColumn[TYPE]) ColumnName() ColumnName[TYPE] {
×
62
        return ColumnName[TYPE](tc.Name())
×
63
}
×
64

65
// Cnm retrieves the column name in a ColumnName format, representing the combination of the table and column.
66
// Cnm 获取以 ColumnName 格式表示的列名,代表表和列的组合。
67
func (tc *TableColumn[TYPE]) Cnm() ColumnName[TYPE] {
×
68
        return ColumnName[TYPE](tc.Name())
×
69
}
×
70

71
// Ob creates an OrderByBottle object for specifying ordering based on the column name and direction.
72
// Ob 基于列名和方向创建一个 OrderByBottle 对象用于指定排序。
73
func (tc *TableColumn[TYPE]) Ob(direction string) OrderByBottle {
×
74
        return tc.Cnm().Ob(direction)
×
75
}
×
76

77
// AsAlias generates a SQL alias for the column in the format "table.column AS alias".
78
// AsAlias 生成列的 SQL 别名,格式为 "table.column AS alias"。
79
func (tc *TableColumn[TYPE]) AsAlias(alias string) string {
×
80
        return utils.ApplyAliasToColumn(tc.Name(), alias)
×
81
}
×
82

83
// AsName generates a SQL alias for the column using another ColumnName as the alias.
84
// AsName 使用另一个 ColumnName 作为别名生成列的 SQL 别名。
85
func (tc *TableColumn[TYPE]) AsName(alias ColumnName[TYPE]) string {
×
86
        return utils.ApplyAliasToColumn(tc.Name(), alias.Name())
×
87
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc