I want to define a route to retrieve my table columns names.
This code (embedded in app.get("table-columns") ):
let tableName = Vocabulario.schema
let query = SQLQueryString("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = `\(unsafeRaw: tableName)` ")
let rows = try await sql.raw(query).all()
let columns: [String] = rows.compactMap { row in
return try? row.decode(column: "COLUMN_NAME", as: String.self)
}
return columns
generates a MySQL error: Server error: Unknown column 'Vocabulario' in 'WHERE'.
I know there are no columns having the same name of the table . So any idea on whats wrong?