I am trying to create a generic function/module through which I can get postgre sql insert queries for all possible values of structs . I am thinking of using reflection for this purpose . But the problem comes when the struct has a serial/primary key . As we are not assigning any value to this field ourselves it will take default value as 0 and create corresponding query and it will defeat my purpose . This structure will also have tags associated with it . One possible solution which I can think of is assigning a special tag to the primary key field through which my code can skip to include this field in the query generation process . Please suggest any other solution to this problem if any comes to mind .
Aucun commentaire:
Enregistrer un commentaire