Coder Social home page Coder Social logo

Structure binding about pgx HOT 4 CLOSED

jackc avatar jackc commented on June 1, 2024
Structure binding

from pgx.

Comments (4)

jackc avatar jackc commented on June 1, 2024

Scan makes this easy enough to do by hand.

from pgx.

elumalai avatar elumalai commented on June 1, 2024

@jackc Scan works for simple structs. Code generation from sql definition won't work, since most of the queries are not that straight forward. Right now we are doing the scan manually. It is not really convenient if the table has more columns. Also restructuring the fields eats up lot of time if we introduce columns later.

Any possibilities to reconsider ?

from pgx.

jackc avatar jackc commented on June 1, 2024

I'm not sure if this belongs in the database driver layer or not. Seems like their are multiple approaches and perhaps it belongs in a library that sits above pgx.

I'm currently experimenting with using code generation to make CRUD easier (pgxdata - definitely not usable yet). That may become useful at some point.

I'm not a fan of using reflection for structure binding, so I don't see that landing in core pgx.

Any particular approach you were looking for?

from pgx.

elumalai avatar elumalai commented on June 1, 2024

I agree with you concern about reflection. We avoided reflection as much as possible in our application and scanning fields manually. But after some period of time, we felt majority of our code base is for scanning. Most of the database queries involves multiple tables, I am not sure about the code generation approach either.

from pgx.

Related Issues (20)

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.