si3nloong / sqlgen Goto Github PK
View Code? Open in Web Editor NEWSQL code generator, no extra runtime cost! It's blazingly fast!!! ๐๐๐
License: MIT License
SQL code generator, no extra runtime cost! It's blazingly fast!!! ๐๐๐
License: MIT License
Since we're parsing the go package, we should be able to check the custom type enum values.
Example :
ts.go
type ts struct{
CreatedAt time.Time
}
user.go
type User struct{
ts
}
Currently, we didn't support mssql
driver. To support it, may refer to https://github.com/microsoft/go-mssqldb
The current version of sqlgen
is too simple, it unable to handle complex situation like WHERE, ORDER BY, LIMIT etc.
Currently, when we run the generate function, it will generate the codes even for the struct that sqlgen generated, but this is not the thing we want.
Please, don't generate codes for any code generated file or we should have an option to optin.
The current codegen doesn't map the multi pointers struct field, it will ignore instead.
type DblPtr struct {
ID uint64 `sql:",auto_increment"`
PtrInt64 *int64
L7PtrStr *******string
L3PtrUint ***uint
L5PtrInt8 *****int8
}
The current support for Postgres is quite buggy
Maybe we can have a InsertOneStmt
.
Add documentation and guide
We should allow user to configure whether to generate the migration functionality, such as CREATE TABLE, ALTER TABLE, etc
Composite key is a key which is the combination of more than one field or column of a given table. It may be a candidate key or primary key.
Sometime, it doesn't make sense for us to specify a PK, but we want to combine multiple column to become a primary key.
https://www.javatpoint.com/sql-composite-key
For example:
import (
"cloud.google.com/go/civil"
)
type B struct {
civil.DateTime
}
This will not work atm.
Question ask from ChinHan: If I customize the table name by defining my own func (User) TableName()
, would AlterTableStmt()
use that?
Right now, we automatic assign the marshaler and unmarshaler by default, should have a way to set custom marshaler and unmarshaler instead.
Strict mode should sound when:
- [ ] invalid tag with go type
binary
)sequel
interfacesCurrently, we cannot enforce the unsigned decimal schema.
It's now static, should provide unsafe option, remove existing column, add any new column
Generated columns doesn't follow the order of struct properties
To debug and check what output files has been created
Configure getter prefix name.
Previous generated code has type declaration for every getter, but go1.22 has infer type, no longer need to declare type explicitly.
Currently, we cannot UPSERT the record, it's better we generate the UPSERT code in db module
Support fixed size byte, rune
The latest updated code is a bug, it affected our github actions, migration and others. Following are the bugs :
VALUE
column is not foundAllow codegen to respect glob value, such as ./**/*, *.go, **/model.go, */model.go
Currently, we only include the Table name in the SQL statement, not included the database name. Sometime, we need to specific some table to specific database.
Minimum requirement:
Currently, the codegen didn't validate the name provided in tag, we need to validate it to prevent invalid value to become column name.
func insert_statement() (string, string, string) {
return ("insert into user values ", "(?,?,?),", "(?,?,?);"); // -- screw the multiple cols
}
func insert_data(u []Users) string {
// query building, for speed, figure out []bytes in advance to reduce alloc
// me lazy
sql, b, c := insert_statement()
for i := 0; i < len(u)-1; i++ {
sql+=b
}
return sql + c;
}
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.