title: postgres throws error: null value in column "id" violates not-null constraint even when value is actually not null
body: <p>I am building a rest api using grpc,but even though i have value populated i get the above error.
  The curl Post gets redirected to createAlbum method</p>
  <p>i did create a db and table manually in postgres</p>
  <p>my db name is album I login using psql album(no password given)</p>
  <p>then i created</p>
  <pre><code>create Table PHOTO(id INTEGER PRIMARY KEY, albumId INTEGER NOT NULL, title VARCHAR(255) NOT NULL, url VARCHAR(255) UNIQUE NOT NULL, thubmNailUrl VARCHAR(255) UNIQUE NOT NULL);
  </code></pre>
  <p>This is my main code</p>
  <pre><code>func main(){
  prosgretConname := fmt.Sprintf(&quot;dbname=%v user=%v sslmode=disable&quot;, &quot;album&quot;, &quot;s&quot;)
      log.Infof(&quot;conname is %s&quot;, prosgretConname)
      db, err := gorm.Open(&quot;postgres&quot;, prosgretConname)
      if err != nil {
          panic(&quot;Failed to connect to database!&quot;)
      }// connects correctly to db
  
      //db.Table(&quot;photo&quot;)
      defer db.Close()
      go startGRPC(db)
      go startHTTP()
      // Block forever
      var wg sync.WaitGroup
      wg.Add(1)
      wg.Wait()
  
  }
  func startGRPC(db *gorm.DB) {
      lis, err := net.Listen(&quot;tcp&quot;, &quot;localhost:5566&quot;)
      if err != nil {
          log.Fatalf(&quot;failed to listen: %v&quot;, err)
      }
      grpcServer := grpc.NewServer()
      srv := svc.NewAlbumServer(db)
      albumgpb.RegisterAlbumServiceServer(grpcServer, srv)
  ...
  }
  </code></pre>
  <p>now my newAlbumServer returns an instance of the db</p>
  <pre><code>type Album struct {
      title        string `json:&quot;title&quot;`
      albumid      int    `json:&quot;albumid&quot;`
      id           int    `json:&quot;id&quot; gorm:&quot;primary_key;not null&quot;`
      url          string `json:&quot;url&quot;`
      thumbnailurl string `json:&quot;thumbnailurl&quot;`
  }
  func (a *AlbumServiceServer) CreateAlbum(ctx context.Context, in *albumgpb.Albumreq) (*albumgpb.Albumreq, error) {
      tx := a.db.Begin()
  
      photo := Album{}
      photo.title = in.Album.Title
      photo.albumid = int(in.Album.AlbumId)
      photo.id = int(in.Album.Id)
      photo.url = in.Album.Url
      photo.thumbnailurl = in.Album.ThumbNailUrl
  
      log.Infof(&quot;%v&quot;, photo.id) // this prints 1
      log.Infof(&quot;the id is %v&quot;, int(in.Album.Id))// this prints 1 on server logs
      log.Infof(&quot;%+v\n&quot;, in) //this prints the entire request in the POST command
      //tx.Table(&quot;photo&quot;).
  
  err := tx.Table(&quot;public.photo&quot;).Create(&amp;photo).Error // fails in this line stating pq: null value in column &quot;id&quot; violates not-null constraint 
  
  if err != nil {
      log.Errorf(&quot;could not insert into db&quot;)
      tx.Rollback()
      return nil, err
  }
  
  tx.Commit()
  </code></pre>
  <p>....</p>
  <p>this is my curl request and response</p>
  <pre><code>curl -X POST &quot;http://localhost:8080/album&quot; -d '{&quot;id&quot;:1,&quot;albumId&quot;:2,&quot;title&quot;:&quot;bleh&quot;,&quot;url&quot;:&quot;sds&quot;,&quot;thumbNailUrl&quot;:&quot;123&quot;}'
  2020-07-17 14:34:54.641 IST [16074] ERROR:  null value in column &quot;id&quot; violates not-null constraint
  2020-07-17 14:34:54.641 IST [16074] DETAIL:  Failing row contains (null, null, null, null, null).
  2020-07-17 14:34:54.641 IST [16074] STATEMENT:  INSERT INTO &quot;public&quot;.&quot;photo&quot; DEFAULT VALUES RETURNING &quot;public&quot;.&quot;photo&quot;.*
  {&quot;error&quot;:&quot;pq: null value in column \&quot;id\&quot; violates not-null constraint&quot;,&quot;code&quot;:2,&quot;message&quot;:&quot;pq: null value in column \&quot;id\&quot; violates not-null constraint&quot;}
  </code></pre>
  <p>Any advice on why its failing or what wrong i am doing will really be helpull</p>