aodin / aspect Goto Github PK
View Code? Open in Web Editor NEWA relational database toolkit for Go (OBSOLETE)
Home Page: https://github.com/aodin/sol
License: MIT License
A relational database toolkit for Go (OBSOLETE)
Home Page: https://github.com/aodin/sol
License: MIT License
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:"-"`
}
You should be able to construct a postgres.Insert and use return multiple parameters such as:
stmt := postgres.Insert(
Companies.C["name"],
Companies.C["about"],
).Returning(
Companies.C["id"],
Companies.C["is_active"],
).Values(company)
db.QueryOne(stmt, &company)
I started digging in the source code and it was confusing to see Validate func multiple times for each "instance" type - EG, https://github.com/aodin/aspect/blob/master/types.go#L42.
Therefore, how do you feel about moving each type into a file within the types folder?
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
);
sql.Select()
outputs:
SELECT FROM
It should be impossible to select nothing - possibly a compiler error!
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
)
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
Example:
SELECT * FROM "table" WHERE "id" IN (SELECT "id" FROM "table");
If a type is not set to NotNull: true
, then a nil
value should be able to pass the type's Validate
method.
A database error should be returned from attempting to INSERT multiple unique values, not a panic:
panic: runtime error: invalid memory address or nil pointer dereference
Example:
CREATE TABLE "table" (
"column" INTEGER CHECK ("column" > 0)
)
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:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.