fix: readers and linting issues
Some checks failed
CI / Test (1.24) (push) Failing after -24m50s
CI / Test (1.25) (push) Failing after -24m42s
CI / Build (push) Successful in -25m49s
CI / Lint (push) Successful in -25m36s

This commit is contained in:
2025-12-19 22:28:24 +02:00
parent d9225a7310
commit aad5db5175
16 changed files with 1237 additions and 80 deletions

View File

@@ -67,15 +67,6 @@ func (r *Reader) ReadTable() (*models.Table, error) {
return schema.Tables[0], nil
}
// stripQuotes removes surrounding quotes from an identifier
func stripQuotes(s string) string {
s = strings.TrimSpace(s)
if len(s) >= 2 && ((s[0] == '"' && s[len(s)-1] == '"') || (s[0] == '\'' && s[len(s)-1] == '\'')) {
return s[1 : len(s)-1]
}
return s
}
// parsePrisma parses Prisma schema content and returns a Database model
func (r *Reader) parsePrisma(content string) (*models.Database, error) {
db := models.InitDatabase("database")
@@ -239,8 +230,8 @@ func (r *Reader) parseModelFields(lines []string, table *models.Table) {
if matches := fieldRegex.FindStringSubmatch(trimmed); matches != nil {
fieldName := matches[1]
fieldType := matches[2]
modifier := matches[3] // ? or []
attributes := matches[4] // @... part
modifier := matches[3] // ? or []
attributes := matches[4] // @... part
column := r.parseField(fieldName, fieldType, modifier, attributes, table)
if column != nil {
@@ -370,9 +361,10 @@ func (r *Reader) extractDefaultValue(attributes string) string {
i := start
for i < len(attributes) && depth > 0 {
if attributes[i] == '(' {
switch attributes[i] {
case '(':
depth++
} else if attributes[i] == ')' {
case ')':
depth--
}
i++
@@ -479,11 +471,11 @@ func (r *Reader) parseBlockAttribute(attrName, content string, table *models.Tab
// relationField stores information about a relation field for second-pass processing
type relationField struct {
tableName string
fieldName string
relatedModel string
isArray bool
relationAttr string
tableName string
fieldName string
relatedModel string
isArray bool
relationAttr string
}
// resolveRelationships performs a second pass to resolve @relation attributes