Skip to content

Commit

Permalink
Fixed string case comparision
Browse files Browse the repository at this point in the history
  • Loading branch information
woanware committed Oct 31, 2016
1 parent 71240b1 commit d4e2fbd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion source/src/woanware/lookuper/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func (j *Job) OutputTeStrings(outputDir string) {
var temp TeString
for _, d := range data {

err = dbMap.SelectOne(&temp, "SELECT * FROM te_string WHERE LOWER(string) = $1", strings.ToLower(d))
err = dbMap.SelectOne(&temp, "SELECT * FROM te_string WHERE string = $1", strings.ToLower(d))
if err != nil {
if strings.Contains(strings.ToLower(err.Error()), "no rows in result set") == false {
log.Printf("Error retrieving data for TE string output: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion source/src/woanware/lookuper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
// ##### Constants ############################################################

const APP_NAME string = "lookuper"
const APP_VERSION string = "0.0.2"
const APP_VERSION string = "0.0.5"
const DB_FILE_NAME string = "./lookuper.db"
const CONFIG_FILE_NAME string = "./lookuper.config"

Expand Down
8 changes: 5 additions & 3 deletions source/src/woanware/lookuper/te_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (s *TeString) Process(data string) int8 {
func (s *TeString) DoesDataExist(data string, staleTimestamp time.Time) (error, bool) {

var temp TeString
err := dbMap.SelectOne(&temp, "SELECT * FROM te_string WHERE string = $1", data)
err := dbMap.SelectOne(&temp, "SELECT * FROM te_string WHERE string = $1", strings.ToLower(data))
err, exists := validateDbData(temp.UpdateDate, staleTimestamp.Unix(), err)

return err, exists
Expand All @@ -77,6 +77,7 @@ func (s *TeString) DoesDataExist(data string, staleTimestamp time.Time) (error,

// Processes the TE response for a string
func (s *TeString) processResponse(data string, body string) int8 {

regexMatch := regexTeStringMatch.FindAllStringSubmatch(string(body), -1)
if regexMatch == nil {
log.Printf("No regex match in TE string report")
Expand All @@ -88,6 +89,7 @@ func (s *TeString) processResponse(data string, body string) int8 {

// Inserts a new TE string record, if that fails due to it already existing, then retrieve details and update
func (s *TeString) setRecord(data string, count int) int8 {

stringTe := new(TeString)
s.updateObject(stringTe, data, count)

Expand All @@ -98,7 +100,7 @@ func (s *TeString) setRecord(data string, count int) int8 {
return WORK_RESPONSE_ERROR
}

err := dbMap.SelectOne(stringTe, "SELECT * FROM te_string WHERE string = $1", strings.ToLower(stringTe.String))
err := dbMap.SelectOne(stringTe, "SELECT * FROM te_string WHERE string = $1", stringTe.String)
if err != nil {
log.Printf("Error retrieving TE string record: %v", err)
return WORK_RESPONSE_ERROR
Expand All @@ -121,7 +123,7 @@ func (s *TeString) updateObject(
data string,
count int) {

stringTe.String = data
stringTe.String = strings.ToLower(data)
stringTe.Count = count
stringTe.UpdateDate = time.Now().UTC().Unix()
}

0 comments on commit d4e2fbd

Please sign in to comment.