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

DateVal is not processing properly on mutation #3200

Closed
sirkon opened this issue Mar 25, 2019 · 2 comments
Closed

DateVal is not processing properly on mutation #3200

sirkon opened this issue Mar 25, 2019 · 2 comments

Comments

@sirkon
Copy link

sirkon commented Mar 25, 2019

If you suspect this could be a bug, follow the template.

  • What version of Dgraph are you using?

v0.0.13

  • Have you tried reproducing the issue with latest release?

yeah, sure

  • What is the hardware spec (RAM, OS)?
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 94
model name	: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
…
MemTotal:       16326928 kB
MemFree:         1709668 kB
MemAvailable:    7785724 kB
…
  • Steps to reproduce the issue (command/config used to run Dgraph).

You may use this docker compose info. Then set up an index

And a program I used:

package main

import (
	"context"
	"github.com/dgraph-io/dgo"
	"github.com/dgraph-io/dgo/protos/api"
	"google.golang.org/grpc"
	"log"
	"time"
)

func main() {
	conn, err := grpc.Dial("localhost:9080", grpc.WithInsecure())
	if err != nil {
		log.Fatal(err)
	}

	dgraphClient := api.NewDgraphClient(conn)
	client := dgo.NewDgraphClient(dgraphClient)

	resp, err := client.NewTxn().Mutate(context.Background(), &api.Mutation{
		Set: []*api.NQuad{
			{
				Subject:   "_:tmp",
				Predicate: "release_date",
				ObjectValue: &api.Value{
					Val: &api.Value_DateVal{
						DateVal: time.Now().AppendFormat(nil, "2006-01-02"),
					},
				},
			},
		},
	})
	if err != nil {
		log.Fatalf("failed to insert: %s", err)
	}
	log.Printf("inserted %d items", len(resp.Uids))
}
  • Expected behaviour and actual result.

I should get successful mutation. Got rpc error: code = Unknown desc = parsing time "" as "2006": cannot parse "" as "2006" instead. I could use api.Value_StrVal instead and this works. Still, it is a bit strange date vale doesn't work for date mutations.

PS you could do much better with dates. Using bytes for date is one strange decision. There's oneof specifically for these kind of tasks.

@srfrog
Copy link
Contributor

srfrog commented Mar 25, 2019

Thanks for reporting this. This is a duplicate of #3166 which has a PR (#3169) with a fix already. I will close this one. Please refer to the older issue.

Related: #3166

@srfrog srfrog closed this as completed Mar 25, 2019
@srfrog
Copy link
Contributor

srfrog commented Mar 25, 2019

Also, we store all values as bytes. But for dates we are storing them as time vals. Null dates use zero-time values. This is a recent change that might not be in the latest release yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants