diff --git a/app/templates/queries.html b/app/templates/queries.html
index ad56e8f..3f9770f 100644
--- a/app/templates/queries.html
+++ b/app/templates/queries.html
@@ -247,27 +247,43 @@ function renderSchemaTree(tablas) {
const key = t.tabla.replace(/\W/g, '_');
const wrap = document.createElement('div');
wrap.className = 'mb-0.5';
- wrap.innerHTML = `
-
-
-
- ${t.tabla}
- ${t.columnas.length}
-
-
-
- ${t.columnas.map(c => `
-
-
- ${c.nombre}
- ${c.tipo}
-
`).join('')}
-
`;
+
+ // fila de la tabla
+ const row = document.createElement('div');
+ row.className = 'schema-table-row flex items-center gap-1 px-2 py-1 rounded cursor-pointer group select-none';
+ row.innerHTML = `
+
+
+ ${t.tabla}
+ ${t.columnas.length}`;
+ row.addEventListener('click', () => toggleCols(key));
+
+ // botón SELECT * — sin JSON en atributo
+ const btnSelect = document.createElement('button');
+ btnSelect.title = 'SELECT *';
+ btnSelect.className = 'hidden group-hover:inline text-blue-400 hover:text-blue-600 text-xs ml-0.5';
+ btnSelect.innerHTML = '';
+ btnSelect.addEventListener('click', e => { e.stopPropagation(); selectAll(t.tabla); });
+ row.appendChild(btnSelect);
+
+ // columnas
+ const colsDiv = document.createElement('div');
+ colsDiv.id = 'cols-' + key;
+ colsDiv.className = 'hidden ml-4 border-l border-gray-200 pl-2';
+ t.columnas.forEach(c => {
+ const colRow = document.createElement('div');
+ colRow.className = 'schema-col flex items-center gap-1 px-1 py-0.5 rounded cursor-pointer text-xs';
+ colRow.title = `Insertar ${c.nombre}`;
+ colRow.innerHTML = `
+
+ ${c.nombre}
+ ${c.tipo}`;
+ colRow.addEventListener('click', () => insertarTexto(c.nombre));
+ colsDiv.appendChild(colRow);
+ });
+
+ wrap.appendChild(row);
+ wrap.appendChild(colsDiv);
tree.appendChild(wrap);
});
}
@@ -286,8 +302,10 @@ function insertarTexto(texto) {
editor.focus();
}
-function selectAll(tabla, columnas) {
- const cols = columnas.map(c => ` ${c}`).join(',\n');
+function selectAll(tabla) {
+ const t = esquema.find(e => e.tabla === tabla);
+ if (!t) return;
+ const cols = t.columnas.map(c => ` ${c.nombre}`).join(',\n');
const sql = `SELECT\n${cols}\nFROM ${tabla}\nROWS 50`;
editor.setValue(sql);
editor.focus();