File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,9 +72,20 @@ func (e *Entry) BuildSQLForTables() string {
7272}
7373
7474// BuildSQLForColumns returns the SQL statement used to retrieve the list of columns
75- // for the given table name. The placeholder "{table_name }" in the template will be replaced.
75+ // for the given table name. The placeholder "{table }" in the template will be replaced.
7676func (e * Entry ) BuildSQLForColumns (table string ) string {
77- return strings .ReplaceAll (e .SQLForColumns , "{table_name}" , table )
77+ var schema string
78+ var schemaDot string
79+ if dotPos := strings .IndexByte (table , '.' ); dotPos >= 0 {
80+ schema = table [:dotPos ]
81+ schemaDot = table [:dotPos + 1 ]
82+ table = table [dotPos + 1 :]
83+ }
84+ sql := e .SQLForColumns
85+ sql = strings .ReplaceAll (sql , "{table}" , table )
86+ sql = strings .ReplaceAll (sql , "{schema}" , schema )
87+ sql = strings .ReplaceAll (sql , "{schema.}" , schemaDot )
88+ return sql
7889}
7990
8091// Tables executes the SQL to list all table names defined by the dialect.
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ var Entry = &dialect.Entry{
2222 where type = 'table'` ,
2323 TypeConverterFor : typeNameToConv ,
2424 PlaceHolder : & placeHolder {},
25- SQLForColumns : `PRAGMA table_info({table_name })` ,
25+ SQLForColumns : `PRAGMA {schema.} table_info({table })` ,
2626 TableNameField : "name" ,
2727 ColumnNameField : "name" ,
2828 IsTransactionSafe : canUseInTransaction ,
You can’t perform that action at this time.
0 commit comments