Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/mssql: added mssql support #144

Merged
merged 10 commits into from
Jan 2, 2025
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"
SysIntruder marked this conversation as resolved.
Show resolved Hide resolved
)
Loading