Giter Club home page Giter Club logo

cqlc's People

Contributors

0x6e6562 avatar aackerman avatar gitter-badger avatar nsd20463 avatar philipsoutham avatar pingginp avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

chungjin hars10

cqlc's Issues

[gen] Remove log.Fatal and return error in generated code

In code generated from schema, in some switch statement log.Fatal is used, should just return error

func Map{{$StructType}}(iter *gocql.Iter, callback func(t {{$StructType}}) (bool, error)) error {
        columns := iter.Columns()
        row := make([]interface{}, len(columns))

        for {
            t := {{$StructType}}{}

            for i := 0; i < len(columns); i++ {
                switch columns[i].Name {
                {{range $_, $col := $cf.Columns}}
                    case "{{$col.Name}}": row[i] = &t.{{snakeToCamel $col.Name}}
                {{end}}
                default:
                    log.Fatal("unhandled column: ", columns[i].Name)
                }
            }
    }

[dep] Make logrus optional by making it an interface

User should not be forced to use logrus for using the cqlc runtime, there are two ways

  • add a minimal logger interface
  • allow user to pass in a debug handler so they can do whatever they want on the generated query, log it, panic whatever...

[dep] Lock version of dependencies

Since the upstream has stopped for 3 years and I still have to use it ... just open issue directly in my fork.

Need to lock the version of dependencies, might just use glide ...

[gen] Remove go-bindata

Just write a go file to define the template .... no need to use bindata to ship some small text with binary ....

bindata: generator/binding_tmpl.go

input: test/.fixtures/collections/input.go test/collections.cql

generator/binding_tmpl.go: generator/tmpl/binding.tmpl
	go-bindata -pkg=generator -o=generator/binding_tmpl.go generator/tmpl

[runtime] Support set map value by key

Follow on relops#39

AppendSlice is the base point to follow

const (
	NoCollectionType CollectionType = iota
	ListType
	SetType
	MapType
)

func appendList(c *Context, col ListColumn, values interface{}) {
	b := ColumnBinding{Column: col, Value: values, Incremental: true, CollectionType: ListType, CollectionOperationType: Append}
	c.Bindings = append(c.Bindings, b)
}

func prependList(c *Context, col ListColumn, values interface{}) {
	b := ColumnBinding{Column: col, Value: values, Incremental: true, CollectionType: ListType, CollectionOperationType: Prepend}
	c.Bindings = append(c.Bindings, b)
}

func removeList(c *Context, col ListColumn, values interface{}) {
	b := ColumnBinding{Column: col, Value: values, Incremental: true, CollectionType: ListType, CollectionOperationType: RemoveByValue}
	c.Bindings = append(c.Bindings, b)
}

func renderUpdate(ctx *Context, buf *bytes.Buffer, counterTable bool) {
           // ....
              switch binding.CollectionType {
			case ListType:
				switch binding.CollectionOperationType {
				case Append:
					setFragments[i] = fmt.Sprintf("%s = %s + ?", col, col)
				case Prepend:
					setFragments[i] = fmt.Sprintf("%s = ? + %s", col, col)
				case RemoveByValue:
					setFragments[i] = fmt.Sprintf("%s = %s - ?", col, col)
				}
			default:
				setFragments[i] = fmt.Sprintf("%s = ?", col)
			}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.