Skip to content

Commit

Permalink
Merge pull request #144 from SysIntruder/feat/mssql
Browse files Browse the repository at this point in the history
feat/mssql: added mssql support
  • Loading branch information
jorgerojas26 authored Jan 2, 2025
2 parents b087ec7 + 682d8e7 commit 34430fb
Show file tree
Hide file tree
Showing 9 changed files with 838 additions and 12 deletions.
2 changes: 2 additions & 0 deletions components/connection_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ func (form *ConnectionForm) testConnection(connectionString string) {
db = &drivers.Postgres{}
case drivers.DriverSqlite:
db = &drivers.SQLite{}
case drivers.DriverMSSQL:
db = &drivers.MSSQL{}
}

err = db.TestConnection(connectionString)
Expand Down
2 changes: 2 additions & 0 deletions components/connection_selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ func (cs *ConnectionSelection) Connect(connection models.Connection) *tview.Appl
newDBDriver = &drivers.Postgres{}
case drivers.DriverSqlite:
newDBDriver = &drivers.SQLite{}
case drivers.DriverMSSQL:
newDBDriver = &drivers.MSSQL{}
}

err := newDBDriver.Connect(connection.URL)
Expand Down
29 changes: 24 additions & 5 deletions components/results_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,11 +917,30 @@ func (table *ResultsTable) FetchRecords(onError func()) [][]string {
table.SetIsFiltering(false)
}

columns, _ := table.DBDriver.GetTableColumns(databaseName, tableName)
constraints, _ := table.DBDriver.GetConstraints(databaseName, tableName)
foreignKeys, _ := table.DBDriver.GetForeignKeys(databaseName, tableName)
indexes, _ := table.DBDriver.GetIndexes(databaseName, tableName)
primaryKeyColumnNames, _ := table.DBDriver.GetPrimaryKeyColumnNames(databaseName, tableName)
columns, err := table.DBDriver.GetTableColumns(databaseName, tableName)
if err != nil {
table.SetError(err.Error(), nil)
}

constraints, err := table.DBDriver.GetConstraints(databaseName, tableName)
if err != nil {
table.SetError(err.Error(), nil)
}

foreignKeys, err := table.DBDriver.GetForeignKeys(databaseName, tableName)
if err != nil {
table.SetError(err.Error(), nil)
}

indexes, err := table.DBDriver.GetIndexes(databaseName, tableName)
if err != nil {
table.SetError(err.Error(), nil)
}

primaryKeyColumnNames, err := table.DBDriver.GetPrimaryKeyColumnNames(databaseName, tableName)
if err != nil {
table.SetError(err.Error(), nil)
}

logger.Info("FetchRecords", map[string]any{"primaryKeyColumnNames": primaryKeyColumnNames})

Expand Down
1 change: 1 addition & 0 deletions drivers/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ const (
DriverMySQL string = "mysql"
DriverPostgres string = "postgres"
DriverSqlite string = "sqlite3"
DriverMSSQL string = "sqlserver"
)
Loading

0 comments on commit 34430fb

Please sign in to comment.