Create comprehensive documentation for future Claude Code instances working in this repository, including: - Development commands for testing, building, and code quality - Core architecture overview of the SQL query builder system - Directory structure and component explanations - Testing patterns and conventions - Key dependencies and their purposes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
100 lines
2.8 KiB
Go
100 lines
2.8 KiB
Go
package sqlserver
|
|
|
|
import (
|
|
"git.fsdpf.net/go/db"
|
|
"git.fsdpf.net/go/db/exp"
|
|
"git.fsdpf.net/go/db/sqlgen"
|
|
)
|
|
|
|
func DialectOptions() *db.SQLDialectOptions {
|
|
opts := db.DefaultDialectOptions()
|
|
|
|
opts.BooleanDataTypeSupported = false
|
|
opts.UseLiteralIsBools = false
|
|
|
|
opts.SupportsReturn = false
|
|
opts.SupportsOrderByOnUpdate = false
|
|
opts.SupportsLimitOnUpdate = false
|
|
opts.SupportsLimitOnDelete = false
|
|
opts.SupportsOrderByOnDelete = true
|
|
opts.SupportsConflictUpdateWhere = false
|
|
opts.SupportsInsertIgnoreSyntax = false
|
|
opts.SupportsConflictTarget = false
|
|
opts.SupportsWithCTE = false
|
|
opts.SupportsWithCTERecursive = false
|
|
opts.SupportsDistinctOn = false
|
|
opts.SupportsWindowFunction = false
|
|
opts.SurroundLimitWithParentheses = true
|
|
|
|
opts.PlaceHolderFragment = []byte("@p")
|
|
opts.LimitFragment = []byte(" TOP ")
|
|
opts.IncludePlaceholderNum = true
|
|
opts.DefaultValuesFragment = []byte("")
|
|
opts.True = []byte("1")
|
|
opts.False = []byte("0")
|
|
opts.TimeFormat = "2006-01-02 15:04:05"
|
|
opts.BooleanOperatorLookup = map[exp.BooleanOperation][]byte{
|
|
exp.EqOp: []byte("="),
|
|
exp.NeqOp: []byte("!="),
|
|
exp.GtOp: []byte(">"),
|
|
exp.GteOp: []byte(">="),
|
|
exp.LtOp: []byte("<"),
|
|
exp.LteOp: []byte("<="),
|
|
exp.InOp: []byte("IN"),
|
|
exp.NotInOp: []byte("NOT IN"),
|
|
exp.IsOp: []byte("IS"),
|
|
exp.IsNotOp: []byte("IS NOT"),
|
|
exp.LikeOp: []byte("LIKE"),
|
|
exp.NotLikeOp: []byte("NOT LIKE"),
|
|
exp.ILikeOp: []byte("LIKE"),
|
|
exp.NotILikeOp: []byte("NOT LIKE"),
|
|
exp.RegexpLikeOp: []byte("REGEXP BINARY"),
|
|
exp.RegexpNotLikeOp: []byte("NOT REGEXP BINARY"),
|
|
exp.RegexpILikeOp: []byte("REGEXP"),
|
|
exp.RegexpNotILikeOp: []byte("NOT REGEXP"),
|
|
}
|
|
opts.BitwiseOperatorLookup = map[exp.BitwiseOperation][]byte{
|
|
exp.BitwiseInversionOp: []byte("~"),
|
|
exp.BitwiseOrOp: []byte("|"),
|
|
exp.BitwiseAndOp: []byte("&"),
|
|
exp.BitwiseXorOp: []byte("^"),
|
|
}
|
|
|
|
opts.FetchFragment = []byte(" FETCH FIRST ")
|
|
|
|
opts.SelectSQLOrder = []sqlgen.SQLFragmentType{
|
|
sqlgen.CommonTableSQLFragment,
|
|
sqlgen.SelectWithLimitSQLFragment,
|
|
sqlgen.FromSQLFragment,
|
|
sqlgen.JoinSQLFragment,
|
|
sqlgen.WhereSQLFragment,
|
|
sqlgen.GroupBySQLFragment,
|
|
sqlgen.HavingSQLFragment,
|
|
sqlgen.WindowSQLFragment,
|
|
sqlgen.CompoundsSQLFragment,
|
|
sqlgen.OrderWithOffsetFetchSQLFragment,
|
|
sqlgen.ForSQLFragment,
|
|
}
|
|
|
|
opts.EscapedRunes = map[rune][]byte{
|
|
'\'': []byte("\\'"),
|
|
'"': []byte("\\\""),
|
|
'\\': []byte("\\\\"),
|
|
'\n': []byte("\\n"),
|
|
'\r': []byte("\\r"),
|
|
0: []byte("\\x00"),
|
|
0x1a: []byte("\\x1a"),
|
|
}
|
|
|
|
opts.OfFragment = []byte("")
|
|
opts.ConflictFragment = []byte("")
|
|
opts.ConflictDoUpdateFragment = []byte("")
|
|
opts.ConflictDoNothingFragment = []byte("")
|
|
|
|
return opts
|
|
}
|
|
|
|
func init() {
|
|
db.RegisterDialect("sqlserver", DialectOptions())
|
|
}
|