Git Product home page Git Product logo

sqlgen's Introduction

Who am I?

package main

import (
    "fmt"
)

var aboutMe = struct{
    Name                          string
    Overview                      string
    Email                         string
    LinkedIn                      string
    Medium                        string
    FavouriteProgrammingLanguages []string
    OpenSources                   []string
}{
    Name: "Lee Sian Loong",
    Overview: `A guy who are very passionate in Frontend Development, Architecture Design and Opensource.`,
    Email: "[email protected]",
    LinkedIn: "https://www.linkedin.com/in/sian-loong-7b4a3037",
    Medium: "https://medium.com/@sianloong90",
    FavouriteProgrammingLanguages: []string{"Go", "TypeScript", "Kotlin"},
    OpenSources: []string{
        "https://github.com/si3nloong/sqlike",
        "https://github.com/ReactiveX/RxGo",
        "https://github.com/si3nloong/webhook",
        "https://github.com/si3nloong/svelte-hook-form",
        "https://github.com/si3nloong/macos_tree_view",
        "https://github.com/wetix/responsive-ui",
    },
}

func main() {
    fmt.Println(aboutMe)
}

Technologies and Tools

Stats

Go         8 hrs 21 mins   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘   87.60 %
Smarty     53 mins         โ–ˆโ–ˆโ–’โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   09.27 %
YAML       13 mins         โ–“โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   02.36 %
XML        4 mins          โ–’โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   00.74 %
Other      0 secs          โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘   00.03 %

sqlgen's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar si3nloong avatar

Stargazers

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

Watchers

 avatar

sqlgen's Issues

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
}

Support complex query

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

Support file glob **

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

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

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

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

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.

Source map?

To debug and check what output files has been created

Support enum

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

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

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.

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

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

Provide UPSERT feature

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

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.