fix: update schema and table names for mssql metadata extraction

This commit is contained in:
2026-04-03 00:08:26 -05:00
parent 50169bee9e
commit 7eaa3478e1

View File

@@ -27,8 +27,8 @@ func main() {
log.Fatal("Couldn't ping mssql db", err) log.Fatal("Couldn't ping mssql db", err)
} }
schema := "test" schema := "Cartografia"
table := "migration_test" table := "MANZANA"
columns, err := getTableMetadata(db, schema, table) columns, err := getTableMetadata(db, schema, table)
if err != nil { if err != nil {
@@ -58,15 +58,15 @@ func getTableMetadata(db *sql.DB, schema, table string) ([]ColumnInfo, error) {
SELECT SELECT
c.name AS column_name, c.name AS column_name,
t.name AS user_type_name, t.name AS user_type_name,
bt.name AS system_type_name, CASE WHEN t.is_user_defined = 0 THEN t.name ELSE bt.name END AS system_type_name,
c.max_length, c.max_length AS max_length,
c.precision, c.precision AS precision,
c.scale, c.scale AS scale,
c.is_nullable, c.is_nullable AS is_nullable,
c.is_identity c.is_identity AS is_identity
FROM sys.columns c FROM sys.columns c
JOIN sys.types t ON c.user_type_id = t.user_type_id 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.tables st ON c.object_id = st.object_id
JOIN sys.schemas s ON st.schema_id = s.schema_id JOIN sys.schemas s ON st.schema_id = s.schema_id
WHERE s.name = @schema AND st.name = @table WHERE s.name = @schema AND st.name = @table