fix: update schema and table names for mssql metadata extraction
This commit is contained in:
@@ -27,8 +27,8 @@ func main() {
|
||||
log.Fatal("Couldn't ping mssql db", err)
|
||||
}
|
||||
|
||||
schema := "test"
|
||||
table := "migration_test"
|
||||
schema := "Cartografia"
|
||||
table := "MANZANA"
|
||||
|
||||
columns, err := getTableMetadata(db, schema, table)
|
||||
if err != nil {
|
||||
@@ -58,15 +58,15 @@ func getTableMetadata(db *sql.DB, schema, table string) ([]ColumnInfo, error) {
|
||||
SELECT
|
||||
c.name AS column_name,
|
||||
t.name AS user_type_name,
|
||||
bt.name AS system_type_name,
|
||||
c.max_length,
|
||||
c.precision,
|
||||
c.scale,
|
||||
c.is_nullable,
|
||||
c.is_identity
|
||||
CASE WHEN t.is_user_defined = 0 THEN t.name ELSE bt.name END AS system_type_name,
|
||||
c.max_length AS max_length,
|
||||
c.precision AS precision,
|
||||
c.scale AS scale,
|
||||
c.is_nullable AS is_nullable,
|
||||
c.is_identity AS is_identity
|
||||
FROM sys.columns c
|
||||
JOIN sys.types t ON c.user_type_id = t.user_type_id
|
||||
JOIN sys.types bt ON c.system_type_id = bt.system_type_id AND bt.user_type_id = bt.system_type_id
|
||||
LEFT JOIN sys.types bt ON t.is_user_defined = 1 AND bt.user_type_id = t.system_type_id
|
||||
JOIN sys.tables st ON c.object_id = st.object_id
|
||||
JOIN sys.schemas s ON st.schema_id = s.schema_id
|
||||
WHERE s.name = @schema AND st.name = @table
|
||||
|
||||
Reference in New Issue
Block a user