Coder Social home page Coder Social logo

piotrkowalczuk / pqt Goto Github PK

View Code? Open in Web Editor NEW
68.0 4.0 8.0 2.78 MB

Postgres schema definition, sql/go, code generation package.

Home Page: https://godoc.org/github.com/piotrkowalczuk/pqt

License: MIT License

Go 99.95% Makefile 0.05%
postgresql golang code-generation data-access-layer entity sql orm

pqt's Introduction

pqt GoDoc go workflow

This package is a toolbox for Postgres driven applications. It provides multiple tools to help to work with Postgres efficiently. In comparison to other currently available libraries instead of pushing struct tags into anti-pattern or parsing SQL, it allows defining schema programmatically.

From a developer perspective, pqt is primarily a toolkit generator, not an ORM. It means it is focusing on bringing low-level building blocks. Generated DAL (Data Access Layer) is only a (desired) side effect, a proof that those components fit together well.

A developer gets full access to the internals. Building your own, type-safe logic takes minutes. As a result, transition in and out is easy. No fear that you will be stuck with an ORM that doesn't meet your requirements anymore.

Documentation

Example

The package itself does not provide any command line application that would generate output out of given input. Instead, it encourages to write local generation application next to the proper package. A good example of how such an application could be structured can be found in examples.

By default, the example is trying to connect to local test database on the default port. To run it simply call:

$ make gen // not necessary, since generated code is already part of the repo
$ make run

Plugins

pqtgo supports plugins over the interface.

Contribution

TODO

pqt's People

Contributors

ders avatar karthikraobr avatar piotrkowalczuk avatar yurykozyrev avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

pqt's Issues

table aliases

I would suggest to introduce table aliases for using them in query.

Problem
E.g.: if we use column like this

pqt.NewColumn("version", pqt.TypeIntegerBig(), pqt.WithNotNull(), pqt.WithDefault("version+1", pqt.EventUpdate)

it will generate the following code in SELECT ... ON CONFLICT ... DO UPDATE SET ...:

INSERT INTO tablename (value, version) VALUES ('data', 0) 
ON CONFLICT (id) DO UPDATE SET value='data', version=version+1
RETURNING data, version

which will cause an error column reference "version" is ambiguous

Suggestion
Add table alias so it produce the code like

INSERT INTO tablename AS alias ... alias.version=version+1

Extend find method with recursive join statement.

Right now, with schema like A 1-n B 1-n C. Joining from C to A through B is not possible. So expression like:

filter := &model.CFindExpr{
            Offset:  req.Offset,
            Limit:   req.Limit,
            OrderBy: []model.RowOrder{model.RowOrder{Name: "id"}},
            JoinB: &model.BJoin{
                Fetch: true,
                Kind:  model.JoinInner,
                JoinA: &model.AJoin{
                    Fetch: true,
                    Kind:  model.JoinInner,
                },
            },
        }

will not fetch object A.

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.