aboutsummaryrefslogtreecommitdiff
path: root/utils/constants.go
blob: 6ec594cad0280f727c40d4f4f039f8d96f9e7643 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package utils

import "nectar/types"

// Form field indices using iota for better readability
const (
	FieldConnectionType = iota
	FieldHost
	FieldPort
	FieldSSL
	FieldUser
	FieldPassword
	FieldConnectionName
	FieldColor
)

// SQLite-specific field indices (redefine to match the layout)
const (
	SQLiteFieldConnectionType = iota // 0: Connection Type
	SQLiteFieldDatabaseFile          // 1: Database File
	SQLiteFieldConnectionName        // 2: Connection Name
	SQLiteFieldColor                 // 3: Color
)

// Input field indices using iota
const (
	InputHost = iota
	InputPort
	InputUser
	InputPassword
	InputConnectionName
)

// Database connection defaults
var (
	DefaultPorts = map[types.ConnectionType]string{
		types.PostgreSQL: "5432",
		types.MySQL:      "3306",
		types.SQLite:     "",
	}

	ConnectionTypes = []types.ConnectionType{
		types.PostgreSQL,
		types.MySQL,
		types.SQLite,
	}

	// Total field counts for each database type
	FieldCounts = map[types.ConnectionType]int{
		types.SQLite:     4, // Connection Type, Database File, Connection Name, Color
		types.PostgreSQL: 8, // Connection Type, Host, Port, SSL, User, Password, Connection Name, Color
		types.MySQL:      8, // Same as PostgreSQL
	}
)

// Field mapping for SQLite (simplified structure)
var SQLiteFieldMapping = map[int]int{
	SQLiteFieldConnectionName: InputConnectionName,
}

// Field mapping for PostgreSQL and MySQL (full structure)
var NonSQLiteFieldMapping = map[int]int{
	FieldHost:           InputHost,
	FieldPort:           InputPort,
	FieldUser:           InputUser,
	FieldPassword:       InputPassword,
	FieldConnectionName: InputConnectionName,
}

// Complete field mappings for all database types
var FieldMappings = map[types.ConnectionType]map[int]int{
	types.SQLite:     SQLiteFieldMapping,
	types.PostgreSQL: NonSQLiteFieldMapping,
	types.MySQL:      NonSQLiteFieldMapping,
}