Closes #16, although maybe not in the cleanest possible way. I feel like this should not be a thing, and the problem will show up again when and if we want nullable fields.

Olivier Tremblay 4 years ago
parent
commit
b1354db6a7
2 changed files with 5 additions and 5 deletions
  1. 1 1
      lib/httpcodegenerator.go
  2. 4 4
      lib/tablecolumn.go

+ 1 - 1
lib/httpcodegenerator.go

@@ -46,7 +46,7 @@ func List(res http.ResponseWriter, req *http.Request){
46 46
     if len(req.Form) > 0 {
47 47
         {{range .Table.ColOrder}}
48 48
         if _, ok := req.Form["{{.LowercaseColumnName}}"]; ok {
49
-            {{.LowercaseColumnName}} := req.FormValue("{{.LowercaseColumnName}}")
49
+            form_{{.LowercaseColumnName}} := req.FormValue("{{.LowercaseColumnName}}")
50 50
             shouldFilter = true
51 51
             {{.TextRightHandConvert}}
52 52
             filterObject.{{.CapitalizedColumnName}} = parsedField 

+ 4 - 4
lib/tablecolumn.go

@@ -24,13 +24,13 @@ func (t tableColumn) CapitalizedColumnName() string {
24 24
 func (t tableColumn) TextRightHandConvert() string {
25 25
 	switch t.MappedColumnType() {
26 26
 	case "int", "uint8", "int8", "uint16", "int16", "uint32", "int32", "uint64", "int64":
27
-		return "i, _ := strconv.Atoi(" + t.LowercaseColumnName() + "); parsedField := " + t.MappedColumnType() + "(i)"
27
+		return "i, _ := strconv.Atoi(form_" + t.LowercaseColumnName() + "); parsedField := " + t.MappedColumnType() + "(i)"
28 28
 	case "[]byte":
29
-		return "parsedField:= []byte(" + t.LowercaseColumnName() + ")"
29
+		return "parsedField:= []byte(form_" + t.LowercaseColumnName() + ")"
30 30
 	case "bool":
31
-		return "parsedField, _ := strconv.ParseBool(" + t.LowercaseColumnName() + ")"
31
+		return "parsedField, _ := strconv.ParseBool(form_" + t.LowercaseColumnName() + ")"
32 32
 	default:
33
-		return "parsedField:= " + t.LowercaseColumnName()
33
+		return "parsedField:= form_" + t.LowercaseColumnName()
34 34
 	}
35 35
 }
36 36