Git Product home page Git Product logo

sqlgen's Issues

Support enum

Since we're parsing the go package, we should be able to check the custom type enum values.

Support complex query

The current version of sqlgen is too simple, it unable to handle complex situation like WHERE, ORDER BY, LIMIT etc.

Don't generate for any code generated file.

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.

Support nested pointer for `Scan` and `Value`

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
}

Migration module

We should allow user to configure whether to generate the migration functionality, such as CREATE TABLE, ALTER TABLE, etc

Composite key

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

Strict mode on code generation

Strict mode should sound when:

- [ ] invalid tag with go type

  • invalid tag with go marshaler and unmarshaler (e.g binary)
  • duplicate primary key
  • duplicate column name
  • unmatched function footprint with sequel interfaces
  • validate custom column name

Add more tests

  • Binary uuid primary key
  • Auto increment pk
  • Embedded imported struct
  • Embedded local struct
  • Type definition struct
  • Custom marshaler and unmarshaler
  • Custom data type

Source map?

To debug and check what output files has been created

Golang 1.22 has infer type

Previous generated code has type declaration for every getter, but go1.22 has infer type, no longer need to declare type explicitly.

Provide UPSERT feature

Currently, we cannot UPSERT the record, it's better we generate the UPSERT code in db module

The latest Postgres generated code is incorrect

The latest updated code is a bug, it affected our github actions, migration and others. Following are the bugs :

  • VALUE column is not found
  • unsigned integer doesn't support 0, should be greater and equal to 0

Support file glob **

Allow codegen to respect glob value, such as ./**/*, *.go, **/model.go, */model.go

Support database name

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:

  • Database name is optional

INSERT INTO with multiple record can be further optimize

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;
}

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.