Skip to content

Commit 8db0797

Browse files
authored
Merge pull request #66 from noborus/tablenames
Rename listTable to TableNames
2 parents fa12786 + e9f0371 commit 8db0797

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

importer.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const DefaultDBType = "text"
4848
// Return the rewritten SQL and error.
4949
// No error is returned if there is no table to import.
5050
func (i *ReadFormat) Import(db *DB, query string) (string, error) {
51-
tables := listTable(query)
51+
tables := TableNames(query)
5252
if len(tables) == 0 {
5353
// without FROM clause. ex. SELECT 1+1;
5454
debug.Printf("table not found\n")
@@ -74,7 +74,10 @@ func (i *ReadFormat) Import(db *DB, query string) (string, error) {
7474
return query, nil
7575
}
7676

77-
func listTable(query string) []string {
77+
// TableNames returns slices of table names
78+
// that may be tables by a simple SQL parser
79+
// from the query string of the argument.
80+
func TableNames(query string) []string {
7881
var tables []string
7982
var tableFlag, frontFlag bool
8083
word := sqlFields(query)

importer_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ func Test_listTable(t *testing.T) {
111111
}
112112
for _, tt := range tests {
113113
t.Run(tt.name, func(t *testing.T) {
114-
if got := listTable(tt.query); !reflect.DeepEqual(got, tt.want) {
115-
t.Errorf("listTable() = %v, want %v", got, tt.want)
114+
if got := TableNames(tt.query); !reflect.DeepEqual(got, tt.want) {
115+
t.Errorf("TableNames() = %v, want %v", got, tt.want)
116116
}
117117
})
118118
}

0 commit comments

Comments
 (0)