Code Monkey home page Code Monkey logo

yago's People

Contributors

cdevienne avatar faide avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

faide cdevienne

yago's Issues

Remove the need for reflect in All()

The Query.All() function is wrong:

  • it uses reflect to detect the target variable type and to populate it
  • it forces a full load of the dataset

We want an api that:

  • does not need reflect
  • allow iterative loading of the dataset

"db.Engine.Close() used as value"

Hey,

When updating to the latest version, I get the message in the title:

habba@zouzou-asus-laptop:~$ go get -u github.com/orus-io/yago
# github.com/orus-io/yago
Dev/go/src/github.com/orus-io/yago/db.go:93: db.Engine.Close() used as value

Seems to come from rev c904eaa.

Fix the install command in the README

Hi,

The "try it out" section of the README contains the command:

go install github.com/orus-io/cmd/yago

It should instead be:

go install github.com/orus-io/yago/cmd/yago

Can't set a foreign key with "SET NULL"

Hi,

I can declare a foreign key with the following yago instruction:

`yago:"fk=Account ONDELETE RESTRICT"`

But I can't use SET NULL: the generate program only writes a OnDelete("SET") next to the qb.ForeignKey instruction into the generated yago file, which is invalid.

Lint error

Hi,

With the following model def:

// Model of the database
type Model struct {
	Meta *yago.Metadata

	RoutingEntry RoutingEntryModel
}

// RoutingEntry is an entry of the routing table
//yago:routing_table
type RoutingEntry struct {
	Key   string `yago:"primary_key"`
	Value string `yago:"."`
}

// NewModel initialize a Model
func NewModel() *Model {
	meta := yago.NewMetadata()
	return &Model{
		Meta:         meta,
		RoutingEntry: NewRoutingEntryModel(meta),
	}
}

The following code is generated:

// Scan a struct
func (mapper RoutingEntryMapper) Scan(rows *sql.Rows, instance yago.MappedStruct) error {
	s, ok := instance.(*RoutingEntry)
	if !ok {
		panic(fmt.Sprintf(
			"Wrong struct type passed to the mapper. Expected &RoutingEntry{}, got %s",
			reflect.TypeOf(instance).Name(),
		))
	}
	if err := rows.Scan(
		&s.Key,
		&s.Value,
	); err != nil {
		return err
	}
	return nil
}

The latest github.com/golang/lint/golint complains:

model_yago.go:151:2: redundant if ...; err != nil check, just return error instead.

-> Should be simplified to:

// Scan a struct
func (mapper RoutingEntryMapper) Scan(rows *sql.Rows, instance yago.MappedStruct) error {
	s, ok := instance.(*RoutingEntry)
	if !ok {
		panic(fmt.Sprintf(
			"Wrong struct type passed to the mapper. Expected &RoutingEntry{}, got %s",
			reflect.TypeOf(instance).Name(),
		))
	}
	err := rows.Scan(
		&s.Key,
		&s.Value,
	)
	return err
}

Fix multi-column pkey

The multi-column primary-key support is broken.
When generating code, the result will not compile.

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.