Git Product home page Git Product logo

aspect's People

Contributors

aodin avatar pgrunde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aspect's Issues

Ignore fields with db tags

Allow fields to be ignored using the db tag -, such as:

type user struct {
    ID       int64    `db:"id"`
    Name     string   `db:"name"`
    Password string   `db:"password"`
    Manager  *manager `db:"-"`
}

Foreign Keys to SERIAL types should have a way to specify INTEGER instead

Currently, the schema:

var Companies = sql.Table("companies",
    sql.Column("id", postgres.Serial{NotNull: true}),
    sql.PrimaryKey("id"),
)
var Contacts = sql.Table("contacts",
    sql.ForeignKey("company_id", Companies.C["id"]),
    sql.Column("value", sql.String{}),
)

Generates the following:

CREATE TABLE "companies" (
  "id" SERIAL NOT NULL,
  PRIMARY KEY ("id")
);
CREATE TABLE "contacts" (
  "company_id" SERIAL REFERENCES companies("id"),
  "value" VARCHAR
);

There should be a way to specify an INTEGER instead of SERIAL:

CREATE TABLE "contacts" (
  "company_id" INTEGER REFERENCES companies("id"),
  "value" VARCHAR
);

You can Select() nothing

sql.Select()

outputs:

SELECT  FROM 

It should be impossible to select nothing - possibly a compiler error!

Allow omitempty option for db tags

Given a schema such as:

type user struct {
    ID       int64  `db:"id,omitempty"`
    Name     string `db:"name"`
    Password string `db:"password"`
}

The statement should not insert the ID field if it has the default value (in this case 0)

INSERT statements with malformed struct tags

Attempting partial insert on a struct will malformed tags such as:

type User struct {
    ID        int64  `db:"id"`
    Email     string `db:"email`
    FirstName string `db:"first_name`
}

stmt := aspect.Insert(
        Users.C["email"],
        Users.C["first_name"],
)

Will result in a panic:

panic: reflect: call of reflect.Value.Interface on zero Value

Future development moved to github.com/aodin/sol

Future development on this project has been moved to https://github.com/aodin/sol

Sol breaks compatibility with Aspect, but will fix a number of major issues:

  • Simplified Connection and Transaction interfaces
  • Types sub-package with proper constructors
  • Column selector functions instead of map indexes
  • Dialect specific tables and columns
  • Improved error handling

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.