Skip to content

Commit a5ad6aa

Browse files
authored
feat: support to desc a table struct (#33)
Co-authored-by: rick <[email protected]>
1 parent 594a8a9 commit a5ad6aa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pkg/inner_sql.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type InnerSQL interface {
2525
const (
2626
InnerSelectTable_ = "@selectTable_"
2727
InnerSelectTableLimit_ = "@selectTableLImit100_"
28+
InnerDescribeTable_ = "@describeTable_"
2829
InnerShowDatabases = "@showDatabases"
2930
InnerShowTables = "@showTables"
3031
InnerCurrentDB = "@currentDB"
@@ -39,14 +40,15 @@ func GetInnerSQL(dialect string) InnerSQL {
3940
}
4041
}
4142

42-
type mysqlDialect struct {
43-
}
43+
type mysqlDialect struct{}
4444

4545
func (m *mysqlDialect) ToNativeSQL(query string) (sql string) {
4646
if strings.HasPrefix(query, InnerSelectTable_) {
4747
sql = "SELECT * FROM " + strings.ReplaceAll(query, InnerSelectTable_, "")
4848
} else if strings.HasPrefix(query, InnerSelectTableLimit_) {
4949
sql = "SELECT * FROM " + strings.ReplaceAll(query, InnerSelectTableLimit_, "") + " LIMIT 100"
50+
} else if strings.HasPrefix(query, InnerDescribeTable_) {
51+
sql = "desc " + strings.ReplaceAll(query, InnerDescribeTable_, "")
5052
} else if query == InnerShowDatabases {
5153
sql = "SHOW DATABASES"
5254
} else if query == InnerShowTables {
@@ -59,8 +61,7 @@ func (m *mysqlDialect) ToNativeSQL(query string) (sql string) {
5961
return
6062
}
6163

62-
type postgresDialect struct {
63-
}
64+
type postgresDialect struct{}
6465

6566
func (p *postgresDialect) ToNativeSQL(query string) (sql string) {
6667
if strings.HasPrefix(query, InnerSelectTable_) {

0 commit comments

Comments
 (0)