diff --git a/crates/dbx-core/src/schema.rs b/crates/dbx-core/src/schema.rs index 5d5ec40de..72fb0d5f2 100644 --- a/crates/dbx-core/src/schema.rs +++ b/crates/dbx-core/src/schema.rs @@ -297,7 +297,7 @@ pub async fn get_columns_core( let pool = connections.get(&pool_key).ok_or("Pool not found")?; match pool { - PoolKind::Mysql(p, _) => db::mysql::get_columns(p, schema, table).await, + PoolKind::Mysql(p, _) => db::mysql::get_columns(p, database, table).await, PoolKind::Postgres(p) => db::postgres::get_columns(p, schema, table).await, PoolKind::Sqlite(p) => db::sqlite::get_columns(p, schema, table).await, _ => Ok(vec![]), diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vue index bb5ee9d40..831fe975f 100644 --- a/src/components/grid/DataGrid.vue +++ b/src/components/grid/DataGrid.vue @@ -98,7 +98,7 @@ const props = defineProps<{ const emit = defineEmits<{ reload: [sql?: string, whereInput?: string]; paginate: [offset: number, limit: number, whereInput?: string, orderBy?: string]; - sort: [column: string, direction: "asc" | "desc" | null, whereInput?: string]; + sort: [column: string, columnIndex: number, direction: "asc" | "desc" | null, whereInput?: string]; }>(); const hasData = computed(() => props.result.columns.length > 0); @@ -203,6 +203,7 @@ const showCellDetail = ref(false); const transposeRowIndex = ref(null); const showTranspose = ref(false); const sortCol = ref(null); +const sortColIndex = ref(null); const sortDir = ref<"asc" | "desc">("asc"); const searchText = ref(""); const searchSuggestions = ref([]); @@ -599,21 +600,23 @@ const activeCellDetail = computed(() => { }; }); -function toggleSort(colName: string) { +function toggleSort(colName: string, colIdx: number) { if (isResizing) return; - if (sortCol.value === colName) { + if (sortCol.value === colName && sortColIndex.value === colIdx) { if (sortDir.value === "asc") { sortDir.value = "desc"; - emit("sort", colName, "desc", activeWhereInput.value); + emit("sort", colName, colIdx, "desc", activeWhereInput.value); } else { sortCol.value = null; + sortColIndex.value = null; sortDir.value = "asc"; - emit("sort", colName, null, activeWhereInput.value); + emit("sort", colName, colIdx, null, activeWhereInput.value); } } else { sortCol.value = colName; + sortColIndex.value = colIdx; sortDir.value = "asc"; - emit("sort", colName, "asc", activeWhereInput.value); + emit("sort", colName, colIdx, "asc", activeWhereInput.value); } } @@ -1415,17 +1418,23 @@ defineExpose({ > # - +
{{ col }} - - + +
- {{ t("grid.columnType") }} - {{ columnTypeMap.get(col) }} +