Documentation
¶
Overview ¶
Package mssql provides a Microsoft SQL Server database adapter.
Index ¶
- func New(dsn string, noLock bool, normalizeTurkish bool) (core.Source, error)
- type MSSQLAdapter
- func (m *MSSQLAdapter) Close(ctx context.Context) error
- func (m *MSSQLAdapter) Connect(ctx context.Context) error
- func (m *MSSQLAdapter) ExecuteProcedure(ctx context.Context, name string, params map[string]string) (*core.QueryResult, error)
- func (m *MSSQLAdapter) ExecuteQuery(ctx context.Context, query string, args ...any) (*core.QueryResult, error)
- func (m *MSSQLAdapter) GetProcedures(ctx context.Context) ([]core.StoredProcedure, error)
- func (m *MSSQLAdapter) GetSchema(ctx context.Context) ([]core.TableSchema, error)
- func (m *MSSQLAdapter) GetViews(ctx context.Context) ([]core.ViewSchema, error)
- func (m *MSSQLAdapter) Name() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates a new MSSQL adapter with the given DSN. DSN format: sqlserver://username:password@host:port?database=dbname
When noLock is true, all SELECT queries are executed under READ UNCOMMITTED transaction isolation level, which is equivalent to applying WITH (NOLOCK) to every table in the query. This prevents read locks and improves throughput on busy OLTP databases at the cost of potentially reading uncommitted data.
When normalizeTurkish is true, the adapter activates the Turkish normalization middleware:
- Outgoing: Turkish characters inside SQL string literals are converted to their ASCII uppercase equivalents before the query is sent to the database. This enables AI-generated queries to match data in legacy Turkish ERP systems that store text as uppercase ASCII (e.g. "HUSEYIN" instead of "Hüseyin").
- Incoming: Common Windows-1254 → Windows-1252 mojibake patterns in result strings are corrected automatically.
Types ¶
type MSSQLAdapter ¶
type MSSQLAdapter struct {
// contains filtered or unexported fields
}
MSSQLAdapter implements the core.Source interface for Microsoft SQL Server.
func (*MSSQLAdapter) ExecuteProcedure ¶ added in v0.4.0
func (m *MSSQLAdapter) ExecuteProcedure(ctx context.Context, name string, params map[string]string) (*core.QueryResult, error)
ExecuteProcedure executes a stored procedure by name with the given named parameters. The procedure name is validated against a safe-identifier regex before execution. Parameters are passed as named SQL parameters to prevent SQL injection. Example: ExecuteProcedure(ctx, "sp_CiroHesapla", map[string]string{"StartDate": "2024-01-01", "EndDate": "2024-12-31"})
func (*MSSQLAdapter) ExecuteQuery ¶
func (m *MSSQLAdapter) ExecuteQuery(ctx context.Context, query string, args ...any) (*core.QueryResult, error)
func (*MSSQLAdapter) GetProcedures ¶ added in v0.4.0
func (m *MSSQLAdapter) GetProcedures(ctx context.Context) ([]core.StoredProcedure, error)
GetProcedures retrieves all stored procedures and their parameters from the database.
func (*MSSQLAdapter) GetSchema ¶
func (m *MSSQLAdapter) GetSchema(ctx context.Context) ([]core.TableSchema, error)
func (*MSSQLAdapter) GetViews ¶ added in v0.4.0
func (m *MSSQLAdapter) GetViews(ctx context.Context) ([]core.ViewSchema, error)
GetViews retrieves all views from the database along with their column information.
func (*MSSQLAdapter) Name ¶
func (m *MSSQLAdapter) Name() string