Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
suhailpatel committed Nov 17, 2020
1 parent f324190 commit 35e7d70
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 66 deletions.
21 changes: 0 additions & 21 deletions relation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package gocassa
import (
"fmt"
"reflect"
"strings"
"time"
)

Expand Down Expand Up @@ -48,26 +47,6 @@ func (r Relation) Terms() []interface{} {
return r.terms
}

func (r Relation) cql() (string, []interface{}) {
ret := ""
field := strings.ToLower(r.Field())
switch r.Comparator() {
case CmpEquality:
ret = field + " = ?"
case CmpIn:
return field + " IN ?", r.Terms()
case CmpGreaterThan:
ret = field + " > ?"
case CmpGreaterThanOrEquals:
ret = field + " >= ?"
case CmpLesserThan:
ret = field + " < ?"
case CmpLesserThanOrEquals:
ret = field + " <= ?"
}
return ret, r.Terms()
}

func anyEquals(value interface{}, terms []interface{}) bool {
primVal := convertToPrimitive(value)
for _, term := range terms {
Expand Down
45 changes: 0 additions & 45 deletions table.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package gocassa

import (
"bytes"
"fmt"
"reflect"
"strconv"
"strings"

r "github.com/monzo/gocassa/reflect"
Expand Down Expand Up @@ -50,18 +47,6 @@ func newTableInfo(keyspace, name string, keys Keys, entity interface{}, fieldSou
return cinf
}

// Since we cant have Map -> [(k, v)] we settle for Map -> ([k], [v])
// #tuplelessLifeSucks
func keyValues(m map[string]interface{}) ([]string, []interface{}) {
keys := []string{}
values := []interface{}{}
for _, k := range sortedKeys(m) {
keys = append(keys, k)
values = append(values, m[k])
}
return keys, values
}

func toMap(i interface{}) (m map[string]interface{}, ok bool) {
switch v := i.(type) {
case map[string]interface{}:
Expand Down Expand Up @@ -144,36 +129,6 @@ func allFieldValuesAreNullable(fields map[string]interface{}) bool {
return true
}

// INSERT INTO Hollywood.NerdMovies (user_uuid, fan)
// VALUES ('cfd66ccc-d857-4e90-b1e5-df98a3d40cd6', 'johndoe')
//
// Gotcha: primkey must be first
func insertStatement(keySpaceName, cfName string, fields map[string]interface{}, opts Options) (string, []interface{}) {
fieldNames, vals := keyValues(fields)

placeHolders := make([]string, len(fieldNames))
lowerFieldNames := make([]string, len(fieldNames))
for i, v := range fieldNames {
placeHolders[i] = "?"
lowerFieldNames[i] = strings.ToLower(v)
}

buf := new(bytes.Buffer)
buf.WriteString(fmt.Sprintf("INSERT INTO %s.%s (%s) VALUES (%s)",
keySpaceName,
cfName,
strings.Join(lowerFieldNames, ", "),
strings.Join(placeHolders, ", ")))

// Apply options
if opts.TTL != 0 {
buf.WriteString(" USING TTL ? ")
vals = append(vals, strconv.FormatFloat(opts.TTL.Seconds(), 'f', 0, 64))
}

return buf.String(), vals
}

func (t t) Set(i interface{}) Op {
m, ok := toMap(i)
if !ok {
Expand Down

0 comments on commit 35e7d70

Please sign in to comment.