docs: Add CLAUDE.md with codebase guidance
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>
This commit is contained in:
@@ -3,11 +3,11 @@ package sqlserver
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.fsdpf.net/go/db/v2"
|
||||
"git.fsdpf.net/go/db/v2/dialect/sqlserver"
|
||||
"git.fsdpf.net/go/db/v2/internal/sb"
|
||||
"git.fsdpf.net/go/db/v2/schema"
|
||||
"git.fsdpf.net/go/db/v2/sqlgen"
|
||||
"git.fsdpf.net/go/db"
|
||||
"git.fsdpf.net/go/db/dialect/sqlserver"
|
||||
"git.fsdpf.net/go/db/internal/sb"
|
||||
"git.fsdpf.net/go/db/schema"
|
||||
"git.fsdpf.net/go/db/sqlgen"
|
||||
)
|
||||
|
||||
type SQLServer struct {
|
||||
@@ -39,7 +39,7 @@ func (this SQLServer) TableExists(table string) (bool, error) {
|
||||
|
||||
func (this SQLServer) CompileCreate(bp *schema.Blueprint) []string {
|
||||
temporary := db.L("CREATE")
|
||||
if bp.IsTemporary() {
|
||||
if bp.Temporary {
|
||||
temporary = db.L("CREATE")
|
||||
}
|
||||
columns := strings.Join(this.getAddedColumns(bp), ",\n")
|
||||
@@ -94,6 +94,35 @@ func (this SQLServer) CompileRename(bp *schema.Blueprint) []string {
|
||||
return []string{this.GenerateSQL("EXEC sp_rename ?, ?", db.T(bp.GetTable()), db.T(toName))}
|
||||
}
|
||||
|
||||
// 修改表备注
|
||||
func (this SQLServer) CompileModifyComment(bp *schema.Blueprint) []string {
|
||||
return []string{
|
||||
this.GenerateSQL(`
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM sys.extended_properties
|
||||
WHERE major_id = OBJECT_ID(?)
|
||||
AND name = 'MS_Description'
|
||||
AND minor_id = 0
|
||||
)
|
||||
BEGIN
|
||||
EXEC sp_updateextendedproperty
|
||||
@name = N'MS_Description',
|
||||
@value = ?,
|
||||
@level0type = N'SCHEMA', @level0name = 'dbo',
|
||||
@level1type = N'TABLE', @level1name = ?
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
EXEC sp_addextendedproperty
|
||||
@name = N'MS_Description',
|
||||
@value = ?,
|
||||
@level0type = N'SCHEMA', @level0name = 'dbo',
|
||||
@level1type = N'TABLE', @level1name = ?
|
||||
END
|
||||
`, db.T(bp.GetTable()), db.V(bp.Comment), db.T(bp.GetTable()), db.V(bp.Comment), db.T(bp.GetTable())),
|
||||
}
|
||||
}
|
||||
|
||||
func (this SQLServer) addModifiers(sql string, bp *schema.Blueprint, column *schema.ColumnDefinition) string {
|
||||
for _, modifier := range sqlServerDefaultModifiers {
|
||||
sql += this.GetColumnModifier(modifier, bp, column)
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"git.fsdpf.net/go/db/v2/engine"
|
||||
"git.fsdpf.net/go/db/v2/schema"
|
||||
"git.fsdpf.net/go/db/engine"
|
||||
"git.fsdpf.net/go/db/schema"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
_ "github.com/denisenkom/go-mssqldb"
|
||||
|
||||
Reference in New Issue
Block a user