Giter Club home page Giter Club logo

mssql's Introduction

mssql

GoDoc Integration Go Report Card codecov Gitter chat

Microsoft SQL Server adapter for REL.

Example

package main

import (
	"context"

	_ "github.com/microsoft/go-mssqldb"
	"github.com/go-rel/mssql"
	"github.com/go-rel/rel"
)

func main() {
	// open mssql connection.
	adapter, err := mssql.Open("sqlserver://sa:REL2021-mssql@localhost:1433?database=rel")
	if err != nil {
		panic(err)
	}
	defer adapter.Close()

	// initialize REL's repo.
	repo := rel.New(adapter)
	repo.Ping(context.TODO())
}

Supported Driver

  • github.com/microsoft/go-mssqldb
  • github.com/denisenkom/go-mssqldb

Supported Database

  • Microsoft SQL Server 2017
  • Microsoft SQL Server 2019

Testing

Start Microsoft SQL server in Docker

docker run -it --rm -p 1434:1433 -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=REL2021-mssql" -e "MSSQL_PID=Developer"  mcr.microsoft.com/mssql/server:2019-latest

Run tests

MSSQL_DATABASE="sqlserver://sa:REL2021-mssql@localhost:1434" go test ./...

mssql's People

Contributors

deepsource-autofix[bot] avatar dependabot[bot] avatar fs02 avatar lafriks avatar youpy avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

mssql's Issues

Support upsert and insert ignore

  • Other adapter have this support since DB support on conflict/on duplicate key syntax. but this syntax seems not supported in MSSQL
  • Alternatively, MSSQL maybe can utilize other query like MERGE.

rel.String should be NVARCHAR

Disclaimer: I'm just reviewing the code while deciding whether to use or not. I haven't used this for real yet.

I believe a GO string (Unicode) best matches to NVARCHAR instead of VARCHAR. That will support the full Unicode set. At least that's what I've done in my code and it's worked well.

mssql/mssql.go

Lines 137 to 142 in e7d7d12

case rel.String:
typ = "VARCHAR"
m = column.Limit
if m == 0 {
m = 255
}

Consider rel.BigID

Disclaimer: Just reviewing code at this point.

rel.ID is interesting. It mixes in a few different things. It would be interesting to have a rel.BigID that maps to BIGINT NOT NULL IDENTITY(1,1) PRIMARY KEY

I'm using BIGINT instead of INT in more and more tables these days -- especially for anything transactional.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.