-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefines.go
More file actions
50 lines (41 loc) · 1.74 KB
/
defines.go
File metadata and controls
50 lines (41 loc) · 1.74 KB
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
// Package builder provides a fluent SQL query builder with support for multiple SQL dialects.
package builder
// SQLType represents the type of SQL query being constructed.
// It is used to track and validate the query type during construction.
type SQLType int
// SQL query types supported by the builder.
const (
// RawSQL represents a raw SQL query that will be used as-is.
RawSQL SQLType = iota + 1
// SelectSQL represents a SELECT query for retrieving data.
SelectSQL
// InsertSQL represents an INSERT query for adding new records.
InsertSQL
// ReplaceSQL represents a REPLACE query (MySQL-specific) for replacing records.
ReplaceSQL
// InsertOrUpdateSQL represents an INSERT ... ON DUPLICATE KEY UPDATE query (MySQL-specific).
InsertOrUpdateSQL
// UpdateSQL represents an UPDATE query for modifying existing records.
UpdateSQL
// DeleteSQL represents a DELETE query for removing records.
DeleteSQL
)
// operMap defines the mapping between SQL operators and their expected number of values.
// A value of 1 indicates a single-value operator (e.g., =, >).
// A value of 2 indicates a two-value operator (e.g., BETWEEN).
// A value of 3 indicates a multi-value operator (e.g., IN).
var operMap = map[string]int{
"=": 1, // Equal
"!=": 1, // Not equal
"<>": 1, // Not equal (alternative syntax)
">": 1, // Greater than
">=": 1, // Greater than or equal
"<": 1, // Less than
"<=": 1, // Less than or equal
"IN": 3, // IN clause (multiple values)
"NOT IN": 3, // NOT IN clause (multiple values)
"LIKE": 1, // Pattern matching
"NOT LIKE": 1, // Negative pattern matching
"BETWEEN": 2, // Range comparison
"NOT BETWEEN": 2, // Negative range comparison
}