Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json: way to omit fields #298

Closed
kevinburke1 opened this issue Jan 24, 2020 · 9 comments
Closed

json: way to omit fields #298

kevinburke1 opened this issue Jan 24, 2020 · 9 comments
Labels
📚 postgresql wontfix This will not be worked on

Comments

@kevinburke1
Copy link
Contributor

I have emit_json_tags set to true but it would be nice to have some way to omit specific tags. In particular, I would not like to expose auto_id, the serial incrementing integer field

@kyleconroy kyleconroy added 📚 postgresql enhancement New feature or request labels Jan 28, 2020
@kyleconroy
Copy link
Collaborator

Hmm, the configuration format is currently not set up to allow this type of fine-grained configuration. Any idea on how we could change it?

@kevinburke1
Copy link
Contributor Author

I mean probably the answer is just "don't use the same struct for JSON serialization that you use for the database."

@kevinburke1
Copy link
Contributor Author

(having thought about this for a few days)

@mightyguava
Copy link
Contributor

mightyguava commented Jan 29, 2020

I have also arrived at the same conclusion no less than 3 times in the past, after starting out with JSON on my (hand-written) database models and fighting the inflexibility 😂

@kyleconroy
Copy link
Collaborator

@kevinburkemeter Going to mark this as wontfix.

@kyleconroy kyleconroy added wontfix This will not be worked on and removed enhancement New feature or request labels Jan 29, 2020
@dimuls
Copy link

dimuls commented May 11, 2020

Maybe we can use comments for this:

create table myuser (
  id bigserial primary key,
  login text not null,
  password_hash bytea not null -- json:"-"
);

For id and login standard id and login json tags should be generated, for password_hash it should be -.
Need some way to hide sensitive fields in REST API. Now one should use wrapping structs with json:"-" specified for that type of fields.

@eazylaykzy
Copy link

@kyleconroy I was wondering if this will be given consideration, moreover with the comment from @dimuls .

@kwinso
Copy link

kwinso commented Jan 7, 2024

Was this implemented?

@lucaskbr
Copy link

lucaskbr commented Jan 30, 2024

open pr for the feature -> #3117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 postgresql wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

7 participants